Annotation of loncom/interface/lonwhatsnew.pm, revision 1.126
1.2 albertel 1: #
1.126 ! raeburn 2: # $Id: lonwhatsnew.pm,v 1.125 2017/09/13 23:35:07 raeburn Exp $
1.2 albertel 3: #
4: # Copyright Michigan State University Board of Trustees
5: #
6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
7: #
8: # LON-CAPA is free software; you can redistribute it and/or modify
9: # it under the terms of the GNU General Public License as published by
10: # the Free Software Foundation; either version 2 of the License, or
11: # (at your option) any later version.
12: #
13: # LON-CAPA is distributed in the hope that it will be useful,
14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: # GNU General Public License for more details.
17: #
18: # You should have received a copy of the GNU General Public License
19: # along with LON-CAPA; if not, write to the Free Software
20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21: #
22: # /home/httpd/html/adm/gpl.txt
23: #
24: # http://www.lon-capa.org/
25: #
26:
27:
1.1 raeburn 28: package Apache::lonwhatsnew;
29:
30: use strict;
31: use lib qw(/home/httpd/lib/perl);
32: use Apache::lonnet;
1.3 albertel 33: use Apache::loncommon();
34: use Apache::lonhtmlcommon();
1.1 raeburn 35: use Apache::lonlocal;
1.3 albertel 36: use Apache::loncoursedata();
37: use Apache::lonnavmaps();
1.18 raeburn 38: use Apache::lonuserstate;
1.77 raeburn 39: use Apache::lonuserutils;
1.1 raeburn 40: use Apache::Constants qw(:common :http);
41: use Time::Local;
1.24 albertel 42: use GDBM_File;
1.55 www 43: use lib '/home/httpd/lib/perl/';
44: use LONCAPA;
1.98 raeburn 45: use HTML::Entities;
1.1 raeburn 46:
47: #----------------------------
48: # handler
49: #
50: #----------------------------
51:
52: sub handler {
53: my $r = shift;
1.7 raeburn 54: if ($r->header_only) {
55: &Apache::loncommon::content_type($r,'text/html');
56: $r->send_http_header;
57: return OK;
58: }
1.39 raeburn 59: &Apache::loncommon::get_unprocessed_cgi(
60: $ENV{'QUERY_STRING'},['command','refpage']);
1.1 raeburn 61:
1.36 raeburn 62: my $command = $env{'form.command'};
1.39 raeburn 63: my $refpage = $env{'form.refpage'};
1.1 raeburn 64:
1.121 raeburn 65: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
66: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
67:
68: my ($isadhoc,%checkallowed);
69:
70: if ($env{'request.role'} =~ m{^(cc|co)/}) {
71: my $rolecode = $1;
72: if ($env{"environment.internal.$cdom.$crs.$env{'request.role'}.adhoc"}) {
73: $isadhoc = 1;
74: }
75: } elsif ($env{'request.role'} =~ m{^cr/$cdom/$cdom\-domainconfig/(\w+)\./}) {
76: my $rolename = $1;
77: if ($env{"environment.internal.$cdom.$crs.cr/$cdom/$cdom-domainconfig/$rolename.adhoc"}) {
78: $isadhoc = 1;
79: }
80: }
81: unless ($isadhoc) {
82: %checkallowed = ( coursenormalmail => 1,
83: coursecritmail => 1,);
84: }
1.44 albertel 85: foreach my $perm_check (['whn','whatsnew',1],
86: ['pch','coursediscussion',1],
87: ['mgr','handgrading',1],
88: ['vgr','abovethreshold',1],
1.121 raeburn 89: ['vgr','haserrors',1],
1.122 raeburn 90: ['whn','versionchanges',1],
1.77 raeburn 91: ['vcl','newroles',1],
92: ['vcl','oldroles',1],
1.106 raeburn 93: ['whn','crslogin',1],
1.126 ! raeburn 94: ['vcl','sessions',1],
1.119 raeburn 95: ['mgr','resetcounters',1],
1.44 albertel 96: ) {
97: my ($perm,$key,$check_section) = @{ $perm_check };
98: my $scope = $env{'request.course.id'};
99: if (!($checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope))) {
100: $scope .= '/'.$env{'request.course.sec'};
101: if ( $check_section ) {
102: $checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope);
103: }
104: if ($checkallowed{$key}) {
105: $checkallowed{$key.'_section'} = $env{'request.course.sec'};
106: }
107: }
108: }
1.43 albertel 109:
1.44 albertel 110: if ( ! $env{'request.course.fn'} || ! $checkallowed{'whatsnew'}) {
1.43 albertel 111: # Not in a course, or no whn priv in course
1.103 raeburn 112: $env{'user.error.msg'}="/adm/whatsnew:whn:0:0:Cannot display what's new page";
1.1 raeburn 113: return HTTP_NOT_ACCEPTABLE;
114: }
115:
1.44 albertel 116: &Apache::loncommon::content_type($r,'text/html');
117: $r->send_http_header;
1.36 raeburn 118:
119: $r->print(&display_header($command,\%checkallowed));
120:
1.7 raeburn 121: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.36 raeburn 122: &Apache::lonhtmlcommon::add_breadcrumb
123: ({href=>'/adm/whatsnew',
1.90 hauer 124: text=>"What's New?"});
1.44 albertel 125: if (($command eq 'chgthreshold') && $checkallowed{'abovethreshold'}) {
1.7 raeburn 126: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 127: ({href=>'/adm/whatsnew?command=chgthreshold&refpage='.$refpage,
1.13 raeburn 128: text=>"Change thresholds"});
1.7 raeburn 129: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 130: ("What's New?",#'Course_Action_Items_Thresholds'
1.49 albertel 131: ));
1.44 albertel 132: } elsif (($command eq 'chginterval') && $checkallowed{'versionchanges'} ) {
1.36 raeburn 133: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 134: ({href=>'/adm/whatsnew?command=chginterval&refpage='.$refpage,
1.36 raeburn 135: text=>"Change interval"});
136: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 137: ("What's New?",#'Course_Action_Items_Intervals'
1.49 albertel 138: ));
1.44 albertel 139: } elsif (($command eq 'chgdisc') && $checkallowed{'coursediscussion'}) {
1.39 raeburn 140: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 141: ({href=>'/adm/whatsnew?command=chgdisc&refpage='.$refpage,
1.39 raeburn 142: text=>"Change discussion display"});
143: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 144: ("What's New?",#'Course_Action_Items_Intervals'
1.49 albertel 145: ));
1.39 raeburn 146: } elsif ($command eq 'courseinit') {
147: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 148: ({href=>'/adm/whatsnew?command=courseinit&refpage='.$refpage,
1.39 raeburn 149: text=>"Course initialization preference"});
150: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 151: ("What's New?",#'Course_Action_Items_Initialization'
1.49 albertel 152: ));
1.77 raeburn 153: } elsif ($command eq 'chgoldroleinterval' && $checkallowed{'oldroles'}) {
154: &Apache::lonhtmlcommon::add_breadcrumb
155: ({href=>'/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage,
156: text=>"Change interval"});
157: $r->print(&Apache::lonhtmlcommon::breadcrumbs
158: ("What's New?",#'Course_Action_Items_Intervals'
159: ));
160: } elsif ($command eq 'chgnewroleinterval' && $checkallowed{'newroles'}) {
161: &Apache::lonhtmlcommon::add_breadcrumb
162: ({href=>'/adm/whatsnew?command=chgnewroleinterval&refpage='.$refpage,
163: text=>"Change interval"});
164: $r->print(&Apache::lonhtmlcommon::breadcrumbs
165: ("What's New?",#'Course_Action_Items_Intervals'
166: ));
1.106 raeburn 167: } elsif ($command eq 'chgcrslogininterval' && $checkallowed{'crslogin'}) {
168: &Apache::lonhtmlcommon::add_breadcrumb
169: ({href=>'/adm/whatsnew?command=chgcrslogininterval&refpage='.$refpage,
170: text=>"Change interval"});
171: $r->print(&Apache::lonhtmlcommon::breadcrumbs
172: ("What's New?",#'Course_Action_Items_Intervals'
173: ));
1.126 ! raeburn 174: } elsif ($command eq 'chgsessionlimit' && $checkallowed{'sessions'}) {
! 175: &Apache::lonhtmlcommon::add_breadcrumb
! 176: ({href=>'/adm/whatsnew?command=chgsessionlimit&refpage='.$refpage,
! 177: text=>"Change session range"});
! 178: $r->print(&Apache::lonhtmlcommon::breadcrumbs
! 179: ("What's New?",#'Course_Action_Items_Sessions'
! 180: ));
1.7 raeburn 181: } else {
182: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 183: ("What's New?",#'Course_Action_Items_Display'
1.49 albertel 184: ));
1.7 raeburn 185: }
1.121 raeburn 186: &display_main_box($r,$command,$refpage,\%checkallowed,$cdom,$crs);
1.14 albertel 187: return OK;
1.1 raeburn 188: }
189:
190: #------------------------------
191: # display_main_box
192: #
193: # Display all the elements within the main box
194: #------------------------------
195:
196: sub display_main_box {
1.121 raeburn 197: my ($r,$command,$refpage,$checkallowed,$cdom,$crs) = @_;
1.1 raeburn 198: my $domain=&Apache::loncommon::determinedomain();
1.40 raeburn 199: my $function = &Apache::loncommon::get_users_function();
1.59 albertel 200: my $lctype = lc(&Apache::loncommon::course_type());
1.7 raeburn 201: $r->print('<table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td width="100%">');
1.13 raeburn 202:
1.39 raeburn 203: my %threshold_titles = &Apache::lonlocal::texthash (
1.13 raeburn 204: av_attempts => 'Average number of attempts',
205: degdiff => 'Degree of difficulty',
206: numstudents => 'Total number of students with submissions',
207: );
1.78 bisitz 208: my %versions = (
1.77 raeburn 209: -1 => "version changes since start of $lctype",
210: 2592000 => 'version changes since last month',
211: 604800 => 'version changes since last week',
212: 86400 => 'version changes since yesterday',
213: );
1.78 bisitz 214: my %newroles = (
1.77 raeburn 215: -1 => "roles which have become active since start of $lctype",
216: 2592000 => 'roles which have become active since last month',
217: 604800 => 'roles which have become active since last week',
218: 86400 => 'roles which have become active since yesterday',
219: );
1.78 bisitz 220: my %oldroles = (
1.77 raeburn 221: -1 => "roles which expired since start of $lctype",
222: 2592000 => 'roles which expired since last month',
223: 604800 => 'roles which expired since last week',
224: 86400 => 'roles which expired since yesterday',
225: );
1.106 raeburn 226: my %crslogins = (
227: -1 => 'last logins for anyone who has ever logged in',
228: 2592000 => 'last logins for users in last 30 days',
229: 604800 => 'last logins for users in last 7 days',
230: 86400 => 'last logins for users in last 24 hours',
231: );
1.126 ! raeburn 232: my %sessions = (
! 233: 300 => 'course sessions active in the last 5 minutes',
! 234: 600 => 'course sessions active in the last 10 minutes',
! 235: 1800 => 'course sessions active in the last 30 minutes',
! 236: 7200 => 'course sessions active in the last 2 hours',
! 237: -7200 => 'course sessions with last activity more than 2 hours ago',
! 238: );
1.77 raeburn 239: my %interval_titles = (
240: versions => \%versions,
241: newroles => \%newroles,
242: oldroles => \%oldroles,
1.106 raeburn 243: crslogin => \%crslogins,
1.126 ! raeburn 244: sessions => \%sessions,
1.36 raeburn 245: );
1.39 raeburn 246: my %initpage = &Apache::lonlocal::texthash (
1.56 raeburn 247: firstres => "first resource in the $lctype",
1.88 hauer 248: whatsnew => "What's New Page",
1.39 raeburn 249: userpref => 'your general user preferences',
1.56 raeburn 250: coursespecific => "specific setting for this $lctype",
1.39 raeburn 251: );
1.15 raeburn 252:
1.44 albertel 253: if (($command eq 'chgthreshold')
254: && $checkallowed->{'abovethreshold'}) {
1.121 raeburn 255: &display_threshold_config($r,$refpage,\%threshold_titles,$cdom,$crs);
1.44 albertel 256: } elsif (($command eq 'chginterval')
257: && $checkallowed->{'versionchanges'}) {
1.77 raeburn 258: &display_interval_config($r,$refpage,\%interval_titles,'versions');
1.44 albertel 259: } elsif (($command eq 'chgdisc')
260: && $checkallowed->{'coursediscussion'}) {
1.39 raeburn 261: &display_discussion_config($r,$refpage);
262: } elsif ($command eq 'courseinit') {
263: &courseinit_config($r,$refpage,\%initpage);
1.77 raeburn 264: } elsif (($command eq 'chgnewroleinterval')
265: && $checkallowed->{'newroles'}) {
266: &display_interval_config($r,$refpage,\%interval_titles,'newroles');
267: } elsif (($command eq 'chgoldroleinterval')
268: && $checkallowed->{'oldroles'}) {
269: &display_interval_config($r,$refpage,\%interval_titles,'oldroles');
1.106 raeburn 270: } elsif (($command eq 'chgcrslogininterval')
271: && $checkallowed->{'crslogin'}) {
272: &display_interval_config($r,$refpage,\%interval_titles,'crslogin');
1.126 ! raeburn 273: } elsif (($command eq 'chgsessionlimit')
! 274: && $checkallowed->{'sessions'}) {
! 275: &display_interval_config($r,$refpage,\%interval_titles,'sessions');
1.1 raeburn 276: } else {
1.69 raeburn 277: &display_actions_box($r,$command,$refpage,\%threshold_titles,
1.39 raeburn 278: \%interval_titles,\%initpage,$cdom,$crs,$checkallowed);
1.1 raeburn 279: }
1.52 albertel 280: my $end_page = &Apache::loncommon::end_page();
1.1 raeburn 281: $r->print(<<END_OF_BLOCK);
282: </td>
283: </tr>
284: </table><br />
1.52 albertel 285: $end_page
1.1 raeburn 286: END_OF_BLOCK
287: }
288:
289: #-------------------------------
290: # display_header
291: #
292: # Display the header information and set
293: # up the HTML
294: #-------------------------------
295:
1.39 raeburn 296: sub display_header {
1.36 raeburn 297: my ($command,$checkallowed) = @_;
1.52 albertel 298:
1.36 raeburn 299: my $scripttag;
1.77 raeburn 300: unless ($command eq 'chgthreshold' || $command eq 'chginterval' ||
1.106 raeburn 301: $command eq 'chgoldroleinterval' ||
302: $command eq 'chgnewroleinterval' || $command eq 'chgcrslogininterval') {
1.36 raeburn 303: $scripttag = <<"END";
304: <script type="text/javascript">
1.106 raeburn 305: // <![CDATA[
1.36 raeburn 306: function change_display(caller,change) {
307: caller.value = change;
1.77 raeburn 308: document.visible.submit();
1.36 raeburn 309: }
310:
311: function changeAll(change) {
312: END
313: foreach my $item (keys(%{$checkallowed})) {
1.44 albertel 314: if ($item =~ /_section$/) { next; }
1.39 raeburn 315: if ($$checkallowed{$item}) {
316: $scripttag.='document.visible.display_'.$item.'.value=change'.
317: "\n";
318: }
1.36 raeburn 319: }
1.126 ! raeburn 320: $scripttag.=<<"ENDTOGG";
! 321: document.visible.submit();
1.36 raeburn 322: }
1.106 raeburn 323:
1.109 raeburn 324: function thresholdreset() {
325: document.visible.command.value="reset";
326: document.visible.submit();
327: }
328:
1.126 ! raeburn 329: function toggledetails(prefix) {
! 330: var total = document.visible[prefix+'count'].value;
! 331: var sumrow = document.visible[prefix+'row'].value;
1.106 raeburn 332: if (total == 0) {
333: return;
334: }
1.126 ! raeburn 335: var showdetails = 0;
! 336: for (var i=0; i<document.visible[prefix+'details'].length; i++) {
! 337: if (document.visible[prefix+'details'][i].checked) {
! 338: showdetails = document.visible[prefix+'details'][i].value;
1.106 raeburn 339: }
340: }
341: var detval = "none";
342: var sumval = "";
1.126 ! raeburn 343: if (showdetails == 1) {
1.106 raeburn 344: detval = "";
345: sumval = "none";
346: }
347: for (var j=0; j<total; j++) {
348: var counter = j+1;
1.126 ! raeburn 349: var itemid = prefix+"det_"+counter;
1.106 raeburn 350: personele = document.getElementById(itemid);
351: if (personele != null) {
352: personele.style.display = detval;
353: }
354: }
1.126 ! raeburn 355: var detheaderele = document.getElementById(prefix+"titledet");
1.106 raeburn 356: if (detheaderele != null) {
357: detheaderele.style.display = detval;
358: }
359: for (var k=0; k<sumrow; k++) {
360: var counter = k+1;
1.126 ! raeburn 361: var itemid = prefix+"sum_"+counter;
! 362: catele = document.getElementById(itemid);
! 363: if (catele != null) {
! 364: catele.style.display = sumval;
1.106 raeburn 365: }
366: }
1.126 ! raeburn 367: var sumheaderele = document.getElementById(prefix+"titlesum");
1.106 raeburn 368: if (sumheaderele != null) {
369: sumheaderele.style.display = sumval;
370: }
371: return;
372: }
373: // ]]>
1.36 raeburn 374: </script>
1.126 ! raeburn 375: ENDTOGG
1.36 raeburn 376: }
1.58 albertel 377: my $course_type=&Apache::loncommon::course_type();
1.90 hauer 378: return &Apache::loncommon::start_page("What's New?",
1.58 albertel 379: $scripttag);
1.1 raeburn 380: }
381:
382: #-------------------------------
383: # display_actions_box
384: #
385: # Display the action items
386: #
387: #-------------------------------
388:
1.39 raeburn 389: sub display_actions_box {
1.69 raeburn 390: my ($r,$command,$refpage,$threshold_titles,$interval_titles,$initpage,
391: $cdom,$crs,$checkallowed) = @_;
1.36 raeburn 392: my $udom = $env{'user.domain'};
393: my $uname = $env{'user.name'};
394: my $cid = $env{'request.course.id'};
1.59 albertel 395: my $crstype = &Apache::loncommon::course_type();
1.56 raeburn 396: my $lctype = lc($crstype);
397: my %stulabel = (
398: 'Course' => 'students',
1.95 raeburn 399: 'Community' => 'members',
1.56 raeburn 400: );
1.36 raeburn 401: my %lt = &Apache::lonlocal::texthash(
1.60 raeburn 402: 'yacc' => 'You are accessing an invalid course',
1.36 raeburn 403: 'gtfr' => 'Go to first resource',
404: 'hial' => 'Hide all',
405: 'shal' => 'Show all',
406: );
407:
1.1 raeburn 408: my %unread = ();
409: my %ungraded = ();
410: my %bombed = ();
1.11 raeburn 411: my %triggered = ();
1.33 raeburn 412: my %changed = ();
1.1 raeburn 413: my @newmsgs = ();
414: my @critmsgs = ();
415: my @newdiscussions = ();
416: my @tograde = ();
417: my @bombs = ();
1.11 raeburn 418: my @warnings = ();
1.33 raeburn 419: my $msgcount = 0;
420: my $critmsgcount = 0;
1.77 raeburn 421: my $expirecount;
422: my %expired;
423: my $activecount;
424: my %activated;
1.106 raeburn 425: my %loggedin;
426: my $logincount;
1.126 ! raeburn 427: my %sessions;
! 428: my $sessioncount;
1.16 raeburn 429: my %res_title = ();
1.33 raeburn 430: my %show = ();
431: my $needitems = 0;
432: my $boxcount = 0;
1.1 raeburn 433:
1.39 raeburn 434: my $result;
435: if ($command eq 'newcourseinit') {
436: $result = &store_courseinit_setting($uname,$udom,$cid,$initpage);
437: }
438:
1.64 banghart 439: my %threshold = ();
1.39 raeburn 440: my %pagedesc = &Apache::lonlocal::texthash (
441: firstres => 'First resource',
1.88 hauer 442: whatsnew => "What's New Page",
1.39 raeburn 443: userpref => 'user preference',
1.56 raeburn 444: coursespecific => $lctype.' only',
1.39 raeburn 445: default => 'default',
446: );
447:
448: my ($initcontrol,$initdisp) = &curr_courseinit();
449: my $currinit = $pagedesc{$initdisp}.' ('.$pagedesc{$initcontrol}.')';
1.13 raeburn 450:
1.36 raeburn 451: unless ($cid) {
1.73 raeburn 452: $r->print('<p><span style="text-align: center; font-weight: bold;">'.$lt{'yacc'}.'</span></p>');
1.1 raeburn 453: return;
454: }
1.33 raeburn 455:
1.97 bisitz 456: my $header = '';
1.39 raeburn 457: if ($refpage eq 'start') {
458: if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
1.36 raeburn 459: &GDBM_READER(),0640)) {
1.98 raeburn 460: my $furl=&HTML::Entities::encode($bighash{'first_url'},'"<>&');
1.39 raeburn 461: untie(%bighash);
1.97 bisitz 462: $header .= '<b><a href="'.$furl.'">'.$lt{'gtfr'}.
463: '</a></b><br />';
1.39 raeburn 464: }
1.36 raeburn 465: }
1.97 bisitz 466: $header .= &mt('Page set to be displayed after you have selected a role in this '.$lctype).'.'
1.74 bisitz 467: .' <span class="LC_nobreak">'
1.78 bisitz 468: .&mt('Currently: [_1].','<i>'.$currinit.'</i>')
469: .' '
1.96 bisitz 470: .&mt('[_1]Change[_2] for just [_3]this '.$lctype.'[_4] or for [_5]all your courses/communities[_6].'
1.81 bisitz 471: ,'<b>'
472: ,'</b>'
1.74 bisitz 473: ,'<a href="/adm/whatsnew?command=courseinit&refpage='.$refpage.'">'
1.96 bisitz 474: ,'</a>'
1.81 bisitz 475: ,'<a href="/adm/preferences?action=changecourseinit&refpage='.$refpage.'">'
476: ,'</a>')
1.97 bisitz 477: .' </span>';
478:
479: $r->print(&Apache::loncommon::head_subbox($header));
1.56 raeburn 480:
1.36 raeburn 481: if ($command eq 'reset') {
1.119 raeburn 482: $result = &process_reset($cdom,$crs,$checkallowed);
1.36 raeburn 483: } elsif ($command eq 'update') {
1.39 raeburn 484: $result = &process_update($uname,$udom,$threshold_titles);
1.36 raeburn 485: } elsif ($command eq 'newinterval') {
486: $result = &store_interval_setting($uname,$udom,$cid,$interval_titles);
1.39 raeburn 487: } elsif ($command eq 'newdiscconf') {
488: $result = &store_discussion_setting($uname,$udom,$cid);
1.36 raeburn 489: }
490:
491: my $store_result=&store_display_settings($uname,$udom,$cid,$checkallowed);
492:
493: unless ($store_result eq 'ok') {
1.71 albertel 494: &Apache::lonnet::logthis('Error saving whatsnew settings: '.
1.56 raeburn 495: $store_result.' for '.'user '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
1.97 bisitz 496: $result .= '<span class="LC_error">'
497: .&mt('Unable to save visibility settings due to [_1]',
498: $store_result)
499: .'</span>';
1.36 raeburn 500: }
501:
502: if ($result) {
1.94 bisitz 503: $r->print($result.'<hr />');
1.36 raeburn 504: }
505: $r->rflush();
506:
1.77 raeburn 507: my (%timediff,%interval);
508: my %display_settings = &get_display_settings($uname,$udom,$cid);
509: $timediff{'versions'} = $display_settings{$cid.':interval'};
510: unless (defined($timediff{'versions'})) { $timediff{'versions'} = 604800; }
511: $interval{'versions'} = $interval_titles->{'versions'}->{$timediff{'versions'}};
512:
513: my %headings = &Apache::lonlocal::texthash(
514: coursediscussion => 'Unread '.$lctype.' discussion posts',
515: handgrading => 'Problems requiring handgrading',
516: haserrors => 'Problems with errors',
517: coursenormalmail => 'New '.$lctype.' messages',
518: coursecritmail => 'New critical messages in '.$lctype,
519: );
520:
521: if ($timediff{'versions'} == -1) {
1.78 bisitz 522: $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since start of '.$lctype);
1.77 raeburn 523: } elsif ($timediff{'versions'} == 2592000) {
1.78 bisitz 524: $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since last month');
1.77 raeburn 525: } elsif ($timediff{'versions'} == 604800) {
1.78 bisitz 526: $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since last week');
1.77 raeburn 527: } elsif ($timediff{'versions'} == 86400) {
1.78 bisitz 528: $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since yesterday');
1.77 raeburn 529: }
530:
531: $timediff{'oldroles'} = $display_settings{$cid.':oldroleinterval'};
532: unless (defined($timediff{'oldroles'})) { $timediff{'oldroles'} = 604800; }
533: $interval{'oldroles'} = $interval_titles->{'oldroles'}->{$timediff{'oldroles'}};
534:
535: if ($timediff{'oldroles'} == -1) {
1.78 bisitz 536: $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since start of '.$lctype);
1.77 raeburn 537: } elsif ($timediff{'oldroles'} == 2592000) {
1.78 bisitz 538: $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since last month');
1.77 raeburn 539: } elsif ($timediff{'oldroles'} == 604800) {
1.78 bisitz 540: $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since last week');
1.77 raeburn 541: } elsif ($timediff{'oldroles'} == 86400) {
1.78 bisitz 542: $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since yesterday');
1.77 raeburn 543: }
544:
545: $timediff{'newroles'} = $display_settings{$cid.':newroleinterval'};
546: unless (defined($timediff{'newroles'})) { $timediff{'newroles'} = 604800; }
547: $interval{'newroles'} = $interval_titles->{'newroles'}->{$timediff{'newroles'}};
548:
549: if ($timediff{'newroles'} == -1) {
1.78 bisitz 550: $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since start of '.$lctype);
1.77 raeburn 551: } elsif ($timediff{'newroles'} == 2592000) {
1.78 bisitz 552: $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since last month');
1.77 raeburn 553: } elsif ($timediff{'newroles'} == 604800) {
1.78 bisitz 554: $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since last week');
1.77 raeburn 555: } elsif ($timediff{'newroles'} == 86400) {
1.78 bisitz 556: $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since yesterday');
1.77 raeburn 557: }
1.33 raeburn 558:
1.106 raeburn 559: $timediff{'crslogin'} = $display_settings{$cid.':crslogininterval'};
560: unless (defined($timediff{'crslogin'})) { $timediff{'crslogin'} = 604800; }
561: $interval{'crslogin'} = $interval_titles->{'crslogin'}->{$timediff{'crslogin'}};
562:
563: if ($timediff{'crslogin'} == -1) {
564: $headings{'crslogin'} = &mt('Last login for anyone who has ever logged in');
565: } elsif ($timediff{'crslogin'} == 2592000) {
566: $headings{'crslogin'} = &mt('Last login for users in last 30 days');
567: } elsif ($timediff{'crslogin'} == 604800) {
568: $headings{'crslogin'} = &mt('Last login for users in last 7 days');
569: } elsif ($timediff{'crslogin'} == 86400) {
570: $headings{'crslogin'} = &mt('Last login for users in last 24 hours');
571: }
572:
1.126 ! raeburn 573: $timediff{'sessions'} = $display_settings{$cid.':sessionactivity'};
! 574: unless (defined($timediff{'sessions'})) { $timediff{'sessions'} = 7200; }
! 575: $interval{'sessions'} = $interval_titles->{'sessions'}->{$timediff{'sessions'}};
! 576:
! 577: if ($timediff{'sessions'} == -7200) {
! 578: $headings{'sessions'} = &mt('Session with activity more than 2 hours ago');
! 579: } elsif ($timediff{'sessions'} == 7200) {
! 580: $headings{'sessions'} = &mt('Session with activity in last 2 hours');
! 581: } elsif ($timediff{'sessions'} == 1800) {
! 582: $headings{'sessions'} = &mt('Session with activity in last 30 minutes');
! 583: } elsif ($timediff{'sessions'} == 600) {
! 584: $headings{'sessions'} = &mt('Session with activity in last 10 minutes');
! 585: } elsif ($timediff{'sessions'} == 300) {
! 586: $headings{'sessions'} = &mt('Session with activity in last 5 minutes');
! 587: }
! 588:
1.111 raeburn 589: my ($now,$starttime,$activatedstart,$expiredstart,$crsloginstart);
590: $now = time;
591:
1.77 raeburn 592: if ($timediff{'versions'} == -1) {
1.111 raeburn 593: $starttime = 0;
594: } else {
595: $starttime = $now - $timediff{'versions'};
1.77 raeburn 596: }
597:
598: if ($timediff{'newroles'} == -1) {
1.111 raeburn 599: $activatedstart = 0;
600: } else {
601: $activatedstart = $now - $timediff{'newroles'};
1.77 raeburn 602: }
603:
604: if ($timediff{'oldroles'} == -1) {
1.111 raeburn 605: $expiredstart = 0;
606: } else {
607: $expiredstart = $now - $timediff{'oldroles'};
1.77 raeburn 608: }
609:
1.106 raeburn 610: if ($timediff{'crslogin'} == -1) {
1.111 raeburn 611: $crsloginstart = 0;
612: } else {
613: $crsloginstart = $now - $timediff{'crslogin'};
1.106 raeburn 614: }
615:
1.39 raeburn 616: my $countunread = $display_settings{$cid.':countunread'};
617: unless (defined($countunread)) {
618: $countunread = 'on';
619: }
1.36 raeburn 620: if ($$checkallowed{'abovethreshold'}) {
1.39 raeburn 621: &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs);
1.33 raeburn 622: }
623:
1.59 albertel 624: $headings{'abovethreshold'} =
1.80 raeburn 625: &mt('(Problems with av. attempts ≥ [_1] or deg. difficulty ≥ [_2]) [_3] and total number of '.$stulabel{$crstype}.' with submissions ≥ [_4]',
1.59 albertel 626: $threshold{'av_attempts'},$threshold{'degdiff'},
1.80 raeburn 627: '<br />',$threshold{'numstudents'});
1.33 raeburn 628:
1.126 ! raeburn 629: my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail','newroles','oldroles','crslogin','sessions');
1.121 raeburn 630: my %actioncolumn = (
631: handgrading => 'left',
632: haserrors => 'left',
633: abovethreshold => 'left',
634: versionchanges => 'left',
635: coursediscussion => 'right',
636: coursenormalmail => 'right',
637: coursecritmail => 'right',
638: newroles => 'right',
639: oldroles => 'right',
640: crslogin => 'right',
1.126 ! raeburn 641: sessions => 'right',
1.121 raeburn 642: );
1.33 raeburn 643:
1.36 raeburn 644: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 645: if ($key =~ /_section$/) { next; }
1.33 raeburn 646: $show{$key} = 0;
1.36 raeburn 647: if ($$checkallowed{$key}) {
648: unless ($display_settings{$cid.':'.$key} eq 'hide') {
1.33 raeburn 649: $show{$key} = 1;
650: }
651: }
652: }
653:
654: foreach my $item (@actionorder) {
1.77 raeburn 655: unless ($item eq 'coursenormalmail' || $item eq 'coursecritmail' ||
656: $item eq 'newroles' || $item eq 'oldroles') {
1.33 raeburn 657: if ($show{$item}) {
658: $needitems = 1;
659: last;
660: }
661: }
662: }
663:
1.84 raeburn 664: my $itemserror;
1.33 raeburn 665: if ($needitems) {
1.119 raeburn 666: $itemserror = &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread,$checkallowed);
1.1 raeburn 667: }
1.114 raeburn 668: my $classlist;
1.126 ! raeburn 669: if ($show{'oldroles'} || $show{'newroles'} || $show{'crslogin'} || $show{'sessions'}) {
1.115 raeburn 670: $classlist = &Apache::loncoursedata::get_classlist();
1.114 raeburn 671: }
1.33 raeburn 672: if ($show{'coursenormalmail'}) {
1.50 raeburn 673: $msgcount = &getnormalmail(\@newmsgs);
1.7 raeburn 674: }
1.33 raeburn 675: if ($show{'coursecritmail'}) {
1.50 raeburn 676: $critmsgcount = &getcritmail(\@critmsgs);
1.11 raeburn 677: }
1.77 raeburn 678: if ($show{'oldroles'}) {
1.114 raeburn 679: $expirecount = &getexpired(\%expired,$expiredstart,'previous',$classlist);
1.77 raeburn 680: }
681: if ($show{'newroles'}) {
1.114 raeburn 682: $activecount = &getactivated(\%activated,$activatedstart,'active',$classlist);
1.77 raeburn 683: }
1.106 raeburn 684: if ($show{'crslogin'}) {
685: $logincount = &getloggedin($cdom,$crs,\%loggedin,$crsloginstart);
686: }
1.126 ! raeburn 687: if ($show{'sessions'}) {
! 688: $sessioncount = &getsessions($cdom,$crs,\%sessions,$timediff{'sessions'},$classlist);
! 689: }
1.36 raeburn 690: $r->print(qq|<a href="javascript:changeAll('hide');">$lt{'hial'}</a>
691: <a href="javascript:changeAll('show');">$lt{'shal'}</a>
692: <form method="post" name="visible" action="/adm/whatsnew">\n|);
693: foreach my $item (keys(%{$checkallowed})) {
1.44 albertel 694: if ($item =~ /_section$/) { next; }
1.36 raeburn 695: if ($$checkallowed{$item}) {
696: $r->print('<input type="hidden" name="display_'.$item.'" />'."\n");
697: }
698: }
1.1 raeburn 699:
1.106 raeburn 700: $r->print('<input type="hidden" name="refpage" value="'.$refpage.'" /><table class="LC_double_column"><tr><td class="LC_left_col">');
1.1 raeburn 701:
1.33 raeburn 702: my $displayed = 0;
1.40 raeburn 703: my $totalboxes = 0;
704: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 705: if ($key =~ /_section$/) { next; }
706: if ($key eq 'whatsnew' ) { next; } # whatsnew check creates no box
1.40 raeburn 707: if ($$checkallowed{$key}) {
708: $totalboxes ++;
709: }
710: }
1.121 raeburn 711: my $currcolumn = 'left';
1.77 raeburn 712: # my $halfway = int($totalboxes/2) + $totalboxes%2;
1.33 raeburn 713: foreach my $actionitem (@actionorder) {
1.121 raeburn 714: if ($checkallowed->{$actionitem}) {
715: if (($actioncolumn{$actionitem} eq 'right') && ($currcolumn eq 'left')) {
1.73 raeburn 716: $r->print('</td><td> </td><td class="LC_right_col" >');
1.121 raeburn 717: $currcolumn = 'right';
1.1 raeburn 718: }
1.126 ! raeburn 719: &display_launcher($r,$actionitem,$refpage,$checkallowed,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,\%interval,$countunread,\%expired,$expirecount,\%activated,$activecount,$crstype,$itemserror,\%loggedin,$logincount,\%sessions,$sessioncount,$classlist);
1.33 raeburn 720: $displayed ++;
1.1 raeburn 721: }
722: }
723: $r->print('
1.33 raeburn 724: </td>
725: </tr>
1.73 raeburn 726: </table>
1.106 raeburn 727: </form>
1.73 raeburn 728: ');
1.1 raeburn 729: }
730:
1.11 raeburn 731: #-------------------------------
1.36 raeburn 732: # display_threshold_config
1.11 raeburn 733: #
1.13 raeburn 734: # Display the threshold setting screen
1.11 raeburn 735: #
736: #-------------------------------
737:
1.36 raeburn 738: sub display_threshold_config {
1.69 raeburn 739: my ($r,$refpage,$threshold_titles,$cdom,$crs) = @_;
1.39 raeburn 740: my $uname = $env{'user.name'};
741: my $udom = $env{'user.dom'};
742: my $cid = $env{'request.course.id'};
1.13 raeburn 743: my %threshold = ();
744: my $rowColor1 = "#ffffff";
745: my $rowColor2 = "#eeeeee";
746: my $rowColor;
747:
748: my @thresholditems = ("av_attempts","degdiff","numstudents");
1.39 raeburn 749: my %threshold_titles = &Apache::lonlocal::texthash(
1.13 raeburn 750: av_attempts => 'Average number of attempts',
751: degdiff => 'Degree of difficulty',
752: numstudents => 'Total number of students with submissions',
753: );
1.39 raeburn 754: &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs);
1.13 raeburn 755:
1.68 raeburn 756: $r->print('<br /><form name="thresholdform" method="post" action="/adm/whatsnew">'.
757: &Apache::loncommon::start_data_table().
758: &Apache::loncommon::start_data_table_header_row().
1.70 raeburn 759: '<th>'.&mt('Threshold Name').'</th>'."\n".
760: '<th>'.&mt('Current value').'</th>'."\n".
761: '<th>'.&mt('Change?').'</th>'."\n".
1.68 raeburn 762: &Apache::loncommon::end_data_table_header_row());
1.13 raeburn 763: foreach my $type (@thresholditems) {
1.39 raeburn 764: my $parameter = $env{'request.course.id'}.':threshold_'.$type;
1.13 raeburn 765: # onchange is javascript to automatically check the 'Set' button.
1.113 bisitz 766: my $onchange = 'onfocus="javascript:window.document.forms'.
1.13 raeburn 767: "['thresholdform'].elements['".$parameter."_setparmval']".
768: '.checked=true;"';
1.68 raeburn 769: $r->print(&Apache::loncommon::start_data_table_row()."\n".
770: '<td>'.$threshold_titles{$type}.'</td>'."\n".
771: '<td>'.&Apache::lonhtmlcommon::textbox($parameter.'_value',
1.13 raeburn 772: $threshold{$type},
1.68 raeburn 773: 10,$onchange).'</td>'."\n".
774: '<td>'.
775: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
776: '</td>'."\n".
777: &Apache::loncommon::end_data_table_row());
1.13 raeburn 778: }
1.68 raeburn 779: $r->print(&Apache::loncommon::end_data_table()."\n".
1.87 schafran 780: '<br /><input type="submit" name="threshold" value="'.&mt('Save').'" />
1.36 raeburn 781: <input type="hidden" name="command" value="update" />
1.39 raeburn 782: <input type="hidden" name="refpage" value="'.$refpage.'" />
1.13 raeburn 783: </form>');
1.11 raeburn 784: }
785:
1.36 raeburn 786: #-------------------------------
787: # display_interval_config
788: #
789: # Display the interval setting screen
790: #
791: #-------------------------------
792:
793: sub display_interval_config {
1.77 raeburn 794: my ($r,$refpage,$interval_titles,$context) = @_;
795: my $setting = 'interval';
796: if ($context eq 'oldroles') {
797: $setting = 'oldroleinterval';
798: } elsif ($context eq 'newroles') {
799: $setting = 'newroleinterval';
1.126 ! raeburn 800: } elsif ($context eq 'sessions') {
! 801: $setting = 'sessionactivity';
1.77 raeburn 802: }
1.59 albertel 803: my $lctype = lc(&Apache::loncommon::course_type());
1.39 raeburn 804: my $current = &get_current($env{'user.name'},$env{'user.domain'},
1.77 raeburn 805: $env{'request.course.id'},$setting);
806: if ($context eq 'oldroles') {
807: $r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' expired.').'<br />');
808: } elsif ($context eq 'newroles') {
809: $r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' became available.').'<br />');
1.106 raeburn 810: } elsif ($context eq 'crslogin') {
811: $r->print('<br />'.&mt('Choose the time window to use to display the last login by a user in the '.$lctype).'<br />');
1.126 ! raeburn 812: } elsif ($context eq 'sessions') {
! 813: $r->print('<br />'.&mt('Choose the time limit to use to display active user sessions in the '.$lctype.'.').'<br />');
1.77 raeburn 814: } else {
815: $r->print('<br />'.&mt('Choose the time window to use to display resources in the '.$lctype.' with version changes.').'<br />');
816: }
1.36 raeburn 817: unless ($current eq '') {
1.77 raeburn 818: if (ref($interval_titles->{$context}) eq 'HASH') {
819: $r->print(' '.&mt('Current value is "[_1]".','<b>'.
820: $interval_titles->{$context}->{$current}.'</b>').'<br />');
821: }
1.36 raeburn 822: }
1.77 raeburn 823: $r->print('<br />
1.36 raeburn 824: <form method="post" name="intervalswitch" action="/adm/whatsnew">
825: <input type="hidden" name="command" value="newinterval" />
1.77 raeburn 826: <input type="hidden" name="intervaltype" value="'.$context.'" />
827: <input type="hidden" name="refpage" value="'.$refpage.'" />'.
828: &mt('Display:').'
1.36 raeburn 829: <select name="interval">
1.78 bisitz 830: <option value="" selected="selected">'.&mt('Select').'</option>
1.36 raeburn 831: ');
1.77 raeburn 832: if (ref($interval_titles) eq 'HASH') {
833: if (ref($interval_titles->{$context}) eq 'HASH') {
1.126 ! raeburn 834: my @sorted;
! 835: if ($context eq 'sessions') {
! 836: @sorted = sort { $a <=> $b } (keys(%{$interval_titles->{$context}}));
! 837: push(@sorted,shift(@sorted));
! 838: } else {
! 839: @sorted = reverse sort ({$a cmp $b} (keys(%{$interval_titles->{$context}})));
! 840: }
! 841: foreach my $key (@sorted) {
1.78 bisitz 842: $r->print('<option value="'.$key.'">'.&mt($interval_titles->{$context}->{$key}).
1.77 raeburn 843: '</option>'."\n");
844: }
845: }
1.36 raeburn 846: }
847: $r->print('</select>
848: <input type="submit" name="display" value="'.
1.87 schafran 849: &mt('Save').'" /></form>');
1.36 raeburn 850: return;
851: }
852:
1.39 raeburn 853: #----------------------------------------------
854: # display_discussion_config
855: #
856: # Display the discussion display setting screen
857: #
858: #----------------------------------------------
859:
860: sub display_discussion_config {
861: my ($r,$refpage) = @_;
862: my $current = &get_current($env{'user.name'},$env{'user.domain'},
863: $env{'request.course.id'},'countunread');
864: if ($current eq '') {
865: $current = 'on';
866: }
1.47 raeburn 867: my %opposite = (
868: 'on' => 'off',
869: 'off' => 'on',
870: );
871: $r->print('<script type="text/javascript">
872: function toggle_countunread(choice) {
873: if (choice == "unchanged") {
874: document.discussionswitch.command.value = "";
875: }
876: document.discussionswitch.submit();
877: }
878: </script>');
1.81 bisitz 879: $r->print('<br />'
1.86 schafran 880: .&mt('Choose whether or not to display a count of the number of new posts for each resource or discussion board which has unread posts.')
1.81 bisitz 881: .'<br />'
1.90 hauer 882: .&mt("This can increase the time taken to gather data for the [_1]What's New Page[_2] by a few seconds.",'<i>','</i>')
1.81 bisitz 883: .' '
1.116 bisitz 884: .&mt('Currently set to [_1].','<b>'.$current.'</b>')
1.81 bisitz 885: );
1.39 raeburn 886: $r->print('<br /><br />
1.47 raeburn 887: <form method="post" name="discussionswitch" action="/adm/whatsnew">
1.39 raeburn 888: <input type="hidden" name="command" value="newdiscconf" />
889: <input type="hidden" name="refpage" value="'.$refpage.'" />
1.47 raeburn 890: <input type="hidden" name="countunread" value="'.$opposite{$current}.'" />
1.39 raeburn 891: ');
1.47 raeburn 892: $r->print('<br/>
893: <input type="button" name="display" value="'.
1.74 bisitz 894: &mt('Change to [_1]',&mt($opposite{$current})).'"
1.83 raeburn 895: onclick="javascript:toggle_countunread('."'change'".')" />'.
896: (' ' x7).
897: '<input type="button" name="nochange" value="'.
1.47 raeburn 898: &mt("No change").'"
899: onclick="javascript:toggle_countunread('."'unchanged'".')" />
900: </form>');
1.39 raeburn 901: return;
902: }
903:
904: #---------------------------------------------------
905: # courseinit_config
906: #
907: # Set page displayed when course loads after
908: # selecting a role in the course from the roles page.
909: #
910: #---------------------------------------------------
911:
912: sub courseinit_config {
913: my ($r,$refpage,$initpage) = @_;
914: my ($control,$current) = &curr_courseinit();
915: my @chgstate = ('userpref','coursespecific');
916: my @chgentry = ('firstres','whatsnew');
1.59 albertel 917: my $lctype = lc(&Apache::loncommon::course_type());
1.39 raeburn 918: my %lt = &Apache::lonlocal::texthash(
1.56 raeburn 919: 'chwp' => "Choose which page will be displayed when you enter this $lctype after selecting a role.",
1.39 raeburn 920: 'cuva' => 'Current value is determined by',
921: 'anis' => 'and is set to display',
922: 'padc' => 'Page display controlled by',
1.56 raeburn 923: 'chce' => 'Choose '.$lctype.' entry',
1.89 schafran 924: 'moce' => 'Save',
1.39 raeburn 925: );
926: $r->print(<<"END");
927: <br />$lt{'chwp'}
928: <br />$lt{'cuva'}: <b>
929: $$initpage{$control}</b> $lt{'anis'} <b>
930: $$initpage{$current}</b>.<br /><br />
931: <form method="post" name="courseinitswitch" action="/adm/whatsnew">
932: <input type="hidden" name="command" value="newcourseinit" />
933: <input type="hidden" name="refpage" value="$refpage" />
1.56 raeburn 934: $lt{'padc'}:
1.39 raeburn 935: END
936: foreach my $choice (@chgstate) {
1.56 raeburn 937: my $chkstring;
938: if ($choice eq $control) {
939: $chkstring = ' checked="checked" ';
940: }
1.73 raeburn 941: $r->print('<span class="LC_nobreak"><label><input type="radio" name="courseinit_control" value="'.
1.56 raeburn 942: $choice.'"'.$chkstring.'/>'.$$initpage{$choice}.
1.73 raeburn 943: ' </label></span>');
1.39 raeburn 944: }
945: $r->print('<br /><br />'.&mt('If').' '.$$initpage{'coursespecific'}.
1.56 raeburn 946: ' - <br />'.$lt{'chce'}.": \n");
1.39 raeburn 947: foreach my $choice (@chgentry) {
1.56 raeburn 948: my $chkstring;
949: if (($choice eq $current) && ($control eq 'coursespecific')) {
950: $chkstring = ' checked="checked" ';
951: }
1.73 raeburn 952: $r->print('<span class="LC_nobreak"><label><input type="radio" name="courseinit_page" value="'.
1.56 raeburn 953: $choice.'"'.$chkstring.'/>'.$$initpage{$choice}.
1.73 raeburn 954: ' </label></span>');
1.39 raeburn 955: }
956: $r->print('<br /><br /><input type="submit" name="display" value="'.
957: $lt{'moce'}.'" /></form>');
958: return;
959: }
960:
961: sub curr_courseinit {
962: my $current = &get_current($env{'user.name'},$env{'user.domain'},
963: $env{'request.course.id'},'courseinit');
964: my $control;
1.40 raeburn 965: if ($current) {
966: $control = 'coursespecific';
967: } else {
1.39 raeburn 968: $control = 'userpref';
1.40 raeburn 969: my %userenv = &Apache::lonnet::get('environment',
970: ['course_init_display']);
971: if (exists($userenv{'course_init_display'})) {
972: $current = $userenv{'course_init_display'};
973: }
974: unless ($current) {
1.39 raeburn 975: $current = 'whatsnew';
976: }
977: }
978: return ($control,$current);
979: }
980:
1.33 raeburn 981: sub display_launcher {
1.69 raeburn 982: my ($r,$action,$refpage,$checkallowed,$show,$headings,$res_title,
1.68 raeburn 983: $tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered,
984: $newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs,
1.77 raeburn 985: $interval,$countunread,$expired,$expirecount,$activated,$activecount,
1.126 ! raeburn 986: $crstype,$itemserror,$loggedin,$logincount,$sessions,$sessioncount,
! 987: $classlist) = @_;
1.33 raeburn 988:
989: if ($$checkallowed{$action}) {
1.106 raeburn 990: &start_box($r,$show,$headings,$action,$refpage);
1.33 raeburn 991: if ($$show{$action}) {
992: if ($action eq 'handgrading') { # UNGRADED ITEMS
1.84 raeburn 993: &display_handgrade($r,$tograde,$ungraded,$itemserror);
1.33 raeburn 994: } elsif ($action eq 'haserrors') { # BOMBS
1.84 raeburn 995: &display_haserrors($r,$bombs,$bombed,$res_title,$itemserror);
1.33 raeburn 996: } elsif ($action eq 'versionchanges') { # VERSION CHANGES
1.84 raeburn 997: &display_versionchanges($r,$changed,$res_title,$interval->{'versions'},$itemserror);
1.33 raeburn 998: } elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS
1.39 raeburn 999: &display_abovethreshold($r,$refpage,$warnings,$triggered,
1.119 raeburn 1000: $res_title,$itemserror,$checkallowed);
1.33 raeburn 1001: } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION
1002: &display_coursediscussion($r,$newdiscussions,$unread,
1.84 raeburn 1003: $countunread,$res_title,$itemserror);
1.33 raeburn 1004: } elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES
1.68 raeburn 1005: &display_coursenormalmail($r,$msgcount,$newmsgs);
1.33 raeburn 1006: } elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES
1.68 raeburn 1007: &display_coursecritmail($r,$critmsgcount,$critmsgs);
1.77 raeburn 1008: } elsif ($action eq 'newroles') { # ACTIVATED ROLES
1009: &display_rolechanges($r,$activecount,$activated,$interval->{'newroles'},
1.114 raeburn 1010: $crstype,$classlist);
1.77 raeburn 1011: } elsif ($action eq 'oldroles') { # EXPIRED ROLES
1012: &display_rolechanges($r,$expirecount,$expired,$interval->{'oldroles'},
1.114 raeburn 1013: $crstype,$classlist);
1.106 raeburn 1014: } elsif ($action eq 'crslogin') { #LAST LOGIN
1.126 ! raeburn 1015: &display_activity($r,'logins',$logincount,$loggedin,$interval->{'crslogin'},
1.114 raeburn 1016: $crstype,$classlist);
1.126 ! raeburn 1017: } elsif ($action eq 'sessions') { #ACTIVE SESSIONS
! 1018: &display_activity($r,'sessions',$sessioncount,$sessions,$interval->{'sessions'},
! 1019: $crstype,$classlist);
1.33 raeburn 1020: }
1021: }
1022: &end_box($r);
1023: }
1024: return;
1025: }
1026:
1.1 raeburn 1027: sub getitems {
1.33 raeburn 1028: my ($unread,$ungraded,$bombed,$triggered,$changed,$newdiscussions,
1.68 raeburn 1029: $tograde,$bombs,$warnings,$threshold,$cdom,$crs,$res_title,$show,
1.119 raeburn 1030: $starttime,$countunread,$checkallowed) = @_;
1.1 raeburn 1031: my $navmap = Apache::lonnavmaps::navmap->new();
1.84 raeburn 1032: if (!defined($navmap)) {
1033: my $itemserror = '<span class="LC_warning">'.&mt('An error occurred retrieving information about the course.').'<br />'.&mt('It is recommended that you [_1]re-select the course[_2].','<a href="/adm/roles">','</a>').'</span>';
1034: return $itemserror;
1035: }
1.26 albertel 1036: # force retrieve Resource to seed the part id cache we'll need it later
1.37 raeburn 1037: my @allres=$navmap->retrieveResources(undef,
1038: sub {if ($_[0]->is_problem) { $_[0]->parts();} return 1;});
1.33 raeburn 1039: my %resourcetracker;
1.37 raeburn 1040: my $discussiontime;
1.33 raeburn 1041:
1042: # Resource version changes
1043: if ($$show{'versionchanges'}) {
1044: &checkversions($cdom,$crs,$navmap,$changed,$starttime);
1045: }
1046:
1047: if ($$show{'abovethreshold'}) {
1048: %resourcetracker = &Apache::lonnet::dump('nohist_resourcetracker',
1049: $cdom,$crs);
1050: }
1.1 raeburn 1051:
1052: foreach my $resource (@allres) {
1053: my $result = '';
1054: my $applies = 0;
1055: my $symb = $resource->symb();
1.33 raeburn 1056: %{$$bombed{$symb}} = ();
1.1 raeburn 1057: %{$$ungraded{$symb}} = ();
1.11 raeburn 1058: %{$$triggered{$symb}} = ();
1059: $$triggered{$symb}{numparts} = 0;
1.66 raeburn 1060: if ($resource->encrypted()) {
1061: $$triggered{$symb}{'enclink'} = $resource->link();
1062: $$triggered{$symb}{'encsymb'} = $resource->shown_symb();
1063: }
1.1 raeburn 1064: my $title = $resource->compTitle();
1.16 raeburn 1065: $$res_title{$symb} = $title;
1.8 albertel 1066: my $ressymb = $resource->wrap_symb();
1.33 raeburn 1067:
1.37 raeburn 1068: # Check if there are unread discussion postings
1.33 raeburn 1069: if ($$show{'coursediscussion'}) {
1.51 albertel 1070: &check_discussions($resource,$symb,$ressymb,$title,
1071: $newdiscussions,$unread,$countunread);
1.33 raeburn 1072: }
1.1 raeburn 1073:
1074: # Check for ungraded problems
1075: if ($resource->is_problem()) {
1.33 raeburn 1076: if ($$show{'handgrading'}) {
1077: &check_handgraded($resource,$symb,$title,$cdom,$crs,$ungraded,
1078: $tograde);
1079: }
1.1 raeburn 1080: }
1081:
1082: # Check for bombs
1.33 raeburn 1083: if ($$show{'haserrors'}) {
1084: &check_bombed($resource,$symb,$title,$bombs,$bombed);
1085: }
1086:
1087: # Maxtries and degree of difficulty for problem parts, unless handgradeable
1088: if ($$show{'abovethreshold'}) {
1.61 albertel 1089: &check_thresholds($resource,$symb,\%resourcetracker,
1.119 raeburn 1090: $triggered,$threshold,$warnings,
1091: $checkallowed);
1.33 raeburn 1092: }
1093: }
1.84 raeburn 1094: return;
1.33 raeburn 1095: }
1096:
1097: sub check_discussions {
1.51 albertel 1098: my ($resource,$symb,$ressymb,$title,$newdiscussions,$unread,
1099: $countunread) = @_;
1100:
1101: if (!$resource->hasDiscussion()) { return; }
1.37 raeburn 1102:
1.51 albertel 1103: %{$$unread{$ressymb}} = ();
1104: $$unread{$ressymb}{'title'} = $title;
1105: $$unread{$ressymb}{'symb'} = $symb;
1.66 raeburn 1106: if ($resource->encrypted()) {
1107: $$unread{$ressymb}{'enclink'} = $resource->link();
1108: $$unread{$ressymb}{'encsymb'} = $resource->shown_symb();
1109: }
1.51 albertel 1110: push(@{$newdiscussions}, $ressymb);
1111:
1112: $$unread{$ressymb}{'lastpost'} = $resource->last_post_time();
1113:
1114: if ($countunread eq 'on') {
1.67 raeburn 1115: $$unread{$ressymb}{'unreadcount'} =
1116: $resource->discussion_info('unread');
1.33 raeburn 1117: }
1118: }
1119:
1120: sub check_handgraded {
1121: my ($resource,$symb,$title,$cdom,$cnum,$ungraded,$tograde) = @_;
1122: if ($resource->is_problem()) {
1123: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
1124: my $partlist=$resource->parts();
1125: my $handgradeable;
1126: foreach my $part (@$partlist) {
1.31 raeburn 1127: if ($resource->handgrade($part) eq 'yes') {
1.33 raeburn 1128: $handgradeable=1; last;
1.31 raeburn 1129: }
1.33 raeburn 1130: }
1131: if ($handgradeable) {
1.35 raeburn 1132: my @ungraded = &Apache::bridgetask::get_queue_symb_status(
1.33 raeburn 1133: 'gradingqueue',$symb,$cdom,$cnum);
1134: if (@ungraded > 0) {
1135: $$ungraded{$symb}{count} = scalar(@ungraded);
1136: $$ungraded{$symb}{title} = $title;
1.66 raeburn 1137: if ($resource->encrypted()) {
1138: $$ungraded{$symb}{'enclink'} = $resource->link();
1139: $$ungraded{$symb}{'encsymb'} = $resource->shown_symb();
1140: }
1141: push(@{$tograde},$symb);
1.11 raeburn 1142: }
1143: }
1.33 raeburn 1144: }
1145: }
1146:
1147: sub check_bombed {
1148: my ($resource,$symb,$title,$bombs,$bombed) = @_;
1149: if ($resource->getErrors()) {
1150: my $errors = $resource->getErrors();
1151: $errors =~ s/^,//;
1152: my @bombs = split(/,/, $errors);
1153: my $errorcount = scalar(@bombs);
1154: my $errorlink = '<a href="/adm/email?display='.
1.55 www 1155: &escape($bombs[0]).'">'.
1.33 raeburn 1156: $title.'</a>';
1157: $$bombed{$symb}{errorcount} = $errorcount;
1158: $$bombed{$symb}{errorlink} = $errorlink;
1159: push(@{$bombs}, $symb);
1160: }
1161: }
1162:
1163: sub check_thresholds {
1.119 raeburn 1164: my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings,
1165: $checkallowed) = @_;
1.33 raeburn 1166: # Compile maxtries and degree of difficulty for problem parts, unless handgradeable
1167: my @parts = @{$resource->parts()};
1168: my %stats;
1169: my %lastreset = ();
1170: my $warning = 0;
1171: foreach my $part (@parts) {
1172: if ($resource->handgrade($part) eq 'yes') {
1173: next;
1174: }
1.101 raeburn 1175: if ($resource->is_anonsurvey($part)) {
1176: next;
1177: }
1.48 raeburn 1178: if ($resource->is_survey($part)) {
1179: next;
1180: }
1.33 raeburn 1181: %{$stats{$part}} = ();
1182: my ($attempts,$users,$corrects,$degdiff,$av_attempts);
1183: if (exists($$resourcetracker{$symb."\0".$part."\0attempts"})) {
1184: $attempts = $$resourcetracker{$symb."\0".$part."\0attempts"};
1185: }
1186: if (exists($$resourcetracker{$symb."\0".$part."\0users"})) {
1187: $users = $$resourcetracker{$symb."\0".$part."\0users"};
1188: }
1189: if (exists($$resourcetracker{$symb."\0".$part."\0correct"})) {
1190: $corrects = $$resourcetracker{$symb."\0".$part."\0correct"};
1191: }
1192: if ($attempts > 0) {
1193: $degdiff = 1 - ($corrects/$attempts);
1194: $degdiff = sprintf("%.2f",$degdiff);
1195: }
1196: if ($users > 0) {
1197: $av_attempts = $attempts/$users;
1198: $av_attempts = sprintf("%.2f",$av_attempts);
1199: }
1.105 www 1200: &Apache::lonnet::statslog($symb,$part,$users,$av_attempts,$degdiff);
1.33 raeburn 1201: if ((($degdiff ne '' && $degdiff >= $$threshold{'degdiff'}) || ($av_attempts ne '' && $av_attempts >= $$threshold{'av_attempts'})) && ($users >= $$threshold{'numstudents'})) {
1202: $stats{$part}{degdiff} = $degdiff;
1203: $stats{$part}{attempts} = $av_attempts;
1204: $stats{$part}{users} = $users;
1205: $lastreset{$part} = $$resourcetracker{$symb."\0".$part."\0resettime"};
1206: if ($lastreset{$part}) {
1207: $lastreset{$part} = &Apache::lonnavmaps::timeToHumanString($lastreset{$part});
1.11 raeburn 1208: }
1.33 raeburn 1209: $warning = 1;
1210: }
1211: }
1212: if ($warning) {
1213: $$triggered{$symb}{title} = $resource->title;
1.62 raeburn 1214: my $partcount = 0;
1215: @{$$triggered{$symb}{text}} = ();
1.33 raeburn 1216: foreach my $part (@parts) {
1217: if (exists($stats{$part}{users})) {
1.55 www 1218: my $resetname = 'reset_'.&escape($symb."\0".$part);
1219: my $resettitle = 'title_'.&escape($symb."\0".$part);
1.33 raeburn 1220: if (@parts > 1) {
1.62 raeburn 1221: $$triggered{$symb}{text}[$partcount] = '
1.74 bisitz 1222: <td>'.&mt('part - ').$part.'</td>';
1.33 raeburn 1223: } else {
1.62 raeburn 1224: $$triggered{$symb}{text}[$partcount] = '
1.74 bisitz 1225: <td>'.&mt('single part').'</td>';
1.11 raeburn 1226: }
1.62 raeburn 1227: $$triggered{$symb}{text}[$partcount] .= '
1.61 albertel 1228: <td>'.$stats{$part}{users}.'</td>
1229: <td>'.$stats{$part}{attempts}.'</td>
1230: <td>'.$stats{$part}{degdiff}.'</td>
1.119 raeburn 1231: <td>'.$lastreset{$part}.'</td>';
1.120 raeburn 1232: if ($checkallowed->{'resetcounters'}) {
1233: $$triggered{$symb}{text}[$partcount] .=
1.119 raeburn 1234: '<td><input type="checkbox" name="'.$resetname.'" />'.
1235: '<input type="hidden" name="'.$resettitle.'" value="'.&escape($$triggered{$symb}{title}).'" /></td>';
1236: }
1.62 raeburn 1237: $partcount ++;
1.11 raeburn 1238: }
1.62 raeburn 1239: $$triggered{$symb}{numparts} = $partcount;
1.11 raeburn 1240: }
1.33 raeburn 1241: push(@{$warnings},$symb);
1.1 raeburn 1242: }
1243: }
1244:
1.33 raeburn 1245:
1.13 raeburn 1246: sub get_curr_thresholds {
1.39 raeburn 1247: my ($threshold,$uname,$udom,$cid,$cdom,$crs) = @_;
1.64 banghart 1248: # set default values
1249: %$threshold = (av_attempts => 2,
1250: degdiff => 0.5,
1251: numstudents => 2
1252: );
1.39 raeburn 1253: my %thresholdsettings = &Apache::lonnet::dump('nohist_whatsnew',$udom,
1254: $uname,$cid.':threshold');
1255: my $thresholdcount = 0;
1256: my ($tmp) = %thresholdsettings;
1.40 raeburn 1257: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.117 raeburn 1258: foreach my $item (keys(%{$threshold})) {
1.39 raeburn 1259: if (exists($thresholdsettings{$cid.':threshold_'.$item})) {
1260: $$threshold{$item} =
1261: $thresholdsettings{$cid.':threshold_'.$item};
1262: $thresholdcount ++;
1263: }
1264: }
1.13 raeburn 1265: }
1.39 raeburn 1266: if ($thresholdcount == 3) {
1267: return;
1.13 raeburn 1268: }
1.39 raeburn 1269: my %coursesettings = &Apache::lonnet::dump('environment',
1270: $cdom,$crs,'internal.threshold');
1271: my ($temp) = %coursesettings;
1.40 raeburn 1272: unless ($temp =~ /^(con_lost|error|no_such_host)/i) {
1.117 raeburn 1273: foreach my $item (keys(%{$threshold})) {
1.39 raeburn 1274: unless (exists($thresholdsettings{$cid.':threshold_'.$item})) {
1275: if (exists($coursesettings{'internal.threshold_'.$item})) {
1276: $$threshold{$item} =
1277: $coursesettings{'internal.threshold_'.$item};
1278: }
1279: }
1280: }
1.13 raeburn 1281: }
1.39 raeburn 1282: return;
1.13 raeburn 1283: }
1284:
1.39 raeburn 1285: sub get_current {
1286: my ($uname,$udom,$cid,$caller) = @_;
1287: my $currvalue;
1288: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid.
1289: ':'.$caller);
1.36 raeburn 1290: my ($tmp) = %settings;
1.40 raeburn 1291: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 1292: $currvalue = $settings{$cid.':'.$caller};
1.36 raeburn 1293: }
1.39 raeburn 1294: return $currvalue;
1.36 raeburn 1295: }
1296:
1.13 raeburn 1297: sub process_reset {
1.119 raeburn 1298: my ($dom,$crs,$checkallowed) = @_;
1299: if (!$checkallowed->{'resetcounters'}) {
1.123 raeburn 1300: return '<b>'.&mt('You do not have the required privileges to reset counters').
1.120 raeburn 1301: '</b><br />';
1.119 raeburn 1302: }
1.39 raeburn 1303: my $result = '<b>'.&mt('Counters reset for following problems (and parts):').
1304: '</b><br />';
1.13 raeburn 1305: my @agg_types = ('attempts','users','correct');
1.39 raeburn 1306: my %agg_titles = &Apache::lonlocal::texthash (
1.13 raeburn 1307: attempts => 'Number of submissions',
1308: users => 'Students with submissions',
1309: correct => 'Number of correct submissions',
1310: );
1311: my @resets = ();
1312: my %titles = ();
1.17 albertel 1313: foreach my $key (keys(%env)) {
1.13 raeburn 1314: next if ($key !~ /^form\.reset_(.+)$/);
1.55 www 1315: my $title = &unescape($env{'form.title_'.$1});
1316: my $reset_item = &unescape($1);
1.13 raeburn 1317: my %curr_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
1318: my %aggregates = ();
1.17 albertel 1319: my ($symb,$part) = split(/\0/,$reset_item);
1.13 raeburn 1320: foreach my $type (@agg_types) {
1321: $aggregates{$reset_item."\0".$type} = 0;
1322: }
1.17 albertel 1323: $aggregates{$reset_item."\0".'resettime'} = time;
1.13 raeburn 1324: my $putresult = &Apache::lonnet::put('nohist_resourcetracker',\%aggregates,
1325: $dom,$crs);
1326: if ($putresult eq 'ok') {
1327: $result .= $title.' -part '.$part.': ';
1328: my %new_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
1329: foreach my $type (@agg_types) {
1330: $result .= $agg_titles{$type}.' = '.$new_aggregates{$reset_item."\0".$type}.'; ';
1331: }
1332: $result =~ s/; $//;
1333: $result .= '<br />';
1334: } else {
1.14 albertel 1335: $result = $title.' -part '.$part.': '.&mt('Unable to reset counters to zero due to [_1]',$putresult).'.<br />'."\n";
1.13 raeburn 1336: }
1337: }
1338: return $result;
1339: }
1340:
1341: sub process_update {
1.39 raeburn 1342: my ($uname,$udom,$threshold_titles) = @_;
1.99 wenzelju 1343: my $setoutput = '<b>'.&mt('Changes to threshold(s) for problem tracking:').'</b><br/><br />';
1.117 raeburn 1344: foreach my $key (keys(%env)) {
1345: my $name;
1346: if ($key =~/^form\.(.+)\_setparmval$/) {
1347: $name = $1;
1348: } else {
1349: next;
1350: }
1.13 raeburn 1351: my $value = $env{'form.'.$name.'_value'};
1.65 banghart 1352: if ($name && defined($value) && ($value ne '')) {
1.39 raeburn 1353: my $put_result = &Apache::lonnet::put('nohist_whatsnew',
1354: {$name=>$value},$udom,$uname);
1.13 raeburn 1355:
1.39 raeburn 1356: my ($shortname) = ($name =~ /^\Q$env{'request.course.id'}\E:threshold_(.+)$/);
1.13 raeburn 1357: if ($put_result eq 'ok') {
1.99 wenzelju 1358: $setoutput.= &Apache::lonhtmlcommon::confirm_success(&mt('Set threshold for [_1] to [_2]',
1.14 albertel 1359: '<b>'.$$threshold_titles{$shortname}.'</b>',
1.99 wenzelju 1360: '<b>'.$value.'</b>').'<br />');
1.14 albertel 1361: } else {
1.99 wenzelju 1362: $setoutput.= &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set threshold for [_1] to [_2] due to [_3].',
1.14 albertel 1363: '<b>'.$name.'</b>','<b>'.$value.'</b>',
1.99 wenzelju 1364: '<tt>'.$put_result.'</tt>').'<br />',1);
1.13 raeburn 1365: }
1366: }
1367: }
1.99 wenzelju 1368: return &Apache::loncommon::confirmwrapper($setoutput);
1.13 raeburn 1369: }
1370:
1.33 raeburn 1371: sub getnormalmail {
1372: my ($newmsgs) = @_;
1.118 raeburn 1373: # Check for unread messages in user's INBOX (which were sent in context of current course).
1.1 raeburn 1374: my $msgcount = 0;
1.118 raeburn 1375: my @messages = &Apache::lonnet::getkeys('nohist_email');
1376: return $msgcount if (!@messages);
1377: my %emailstatus = &Apache::lonnet::dump('email_status');
1378: foreach my $msgid (sort(@messages)) {
1379: if ((!$emailstatus{$msgid}) || ($emailstatus{$msgid} eq 'new')) {
1380: my $skipstatus;
1381: if ($emailstatus{$msgid} eq 'new') {
1382: $skipstatus = 1;
1383: }
1.124 raeburn 1384: my $esc_msgid = &escape($msgid);
1.118 raeburn 1385: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1.125 raeburn 1386: &Apache::lonmsg::unpackmsgid($esc_msgid,undef,$skipstatus,undef,
1.118 raeburn 1387: $env{'request.course.id'});
1388: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1389: if (defined($sendtime) && $sendtime!~/error/) {
1390: if (($emailstatus{$msgid} eq 'new') || ($status eq 'new')) {
1391: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
1392: $msgcount ++;
1393: if ($shortsubj eq '') {
1394: $shortsubj = &mt('No subject');
1395: }
1396: push(@{$newmsgs}, {
1.124 raeburn 1397: msgid => $esc_msgid,
1.118 raeburn 1398: sendtime => $sendtime,
1399: shortsub => $shortsubj,
1400: from => $fromname,
1401: fromdom => $fromdom
1402: });
1.10 raeburn 1403: }
1.1 raeburn 1404: }
1405: }
1406: }
1407: }
1.33 raeburn 1408: return $msgcount;
1409: }
1.1 raeburn 1410:
1.33 raeburn 1411: sub getcritmail {
1412: my ($critmsgs) = @_;
1.118 raeburn 1413: # Check for critical messages which were sent in context of current course.
1.1 raeburn 1414: my %what=&Apache::lonnet::dump('critical');
1415: my $result = '';
1416: my $critmsgcount = 0;
1.3 albertel 1417: foreach my $msgid (sort(keys(%what))) {
1.125 raeburn 1418: my $esc_msgid = &escape($msgid);
1.10 raeburn 1419: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1.125 raeburn 1420: &Apache::lonmsg::unpackmsgid($esc_msgid,undef,1,undef,
1.118 raeburn 1421: $env{'request.course.id'});
1.10 raeburn 1422: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 1423: if (defined($sendtime) && $sendtime!~/error/) {
1.93 droeschl 1424: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
1.1 raeburn 1425: $critmsgcount ++;
1.10 raeburn 1426: if ($shortsubj eq '') {
1427: $shortsubj = &mt('No subject');
1428: }
1.1 raeburn 1429: push(@{$critmsgs}, {
1.125 raeburn 1430: msgid => $esc_msgid,
1.1 raeburn 1431: sendtime => $sendtime,
1.10 raeburn 1432: shortsub => $shortsubj,
1.1 raeburn 1433: from => $fromname,
1434: fromdom => $fromdom
1435: });
1436: }
1437: }
1438: }
1.33 raeburn 1439: return $critmsgcount;
1440: }
1441:
1.77 raeburn 1442: sub getexpired {
1.114 raeburn 1443: my ($rolechgs,$rolechgtime,$status,$classlist) = @_;
1444: my $expirecount = &getrolechanges($rolechgs,$rolechgtime,$status,$classlist);
1.77 raeburn 1445: return $expirecount;
1446: }
1447:
1448: sub getactivated {
1.114 raeburn 1449: my ($rolechgs,$rolechgtime,$status,$classlist) = @_;
1.77 raeburn 1450: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1451: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1452: my $now = time();
1453: my $context = 'course';
1454: my ($permission,$allowed) =
1455: &Apache::lonuserutils::get_permission($context);
1456: my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
1457: my %changes=&Apache::lonnet::dump('nohist_rolelog',$cdom,$cnum);
1458: my (%stucounted,%advcounted);
1459: my $activatedcount = 0;
1460: if (keys(%changes) > 0) {
1.111 raeburn 1461: foreach my $chg (keys(%changes)) {
1.77 raeburn 1462: if (ref($changes{$chg}) eq 'HASH') {
1.112 raeburn 1463: next if ($changes{$chg}{'delflag'});
1.111 raeburn 1464: if ($rolechgtime > 0) {
1.112 raeburn 1465: next if ($changes{$chg}{'exe_time'} < $rolechgtime);
1.111 raeburn 1466: }
1467: if ($changes{$chg}{'exe_time'}) {
1468: my $timestamp = $changes{$chg}{'exe_time'};
1.77 raeburn 1469: if (ref($changes{$chg}{'logentry'}) eq 'HASH') {
1.112 raeburn 1470: my $end = $changes{$chg}{'logentry'}{'end'};
1471: next if ($end && $end <= $now);
1.77 raeburn 1472: my $start = $changes{$chg}{'logentry'}{'start'};
1.112 raeburn 1473: next if ($start >= $timestamp);
1.77 raeburn 1474: my $section = $changes{$chg}{'logentry'}{'section'};
1.112 raeburn 1475: if (($viewablesec ne '') && ($section ne '')) {
1476: next if ($viewablesec ne $section);
1477: }
1.77 raeburn 1478: my $role = $changes{$chg}{'logentry'}{'role'};
1479: my $uname = $changes{$chg}{'uname'};
1480: my $udom = $changes{$chg}{'udom'};
1481: if ($role eq 'st') {
1482: $stucounted{$uname.':'.$udom.':'.$section} = $start.':'.$end;
1483: } else {
1484: $advcounted{$uname.':'.$udom.':'.$role.':'.$section} = $start.':'.$end;
1485: }
1486: my %chginfo = (
1487: 'section' => $section,
1488: 'uname' => $uname,
1489: 'udom' => $udom,
1490: 'role' => $role,
1491: 'status' => $status,
1492: );
1493: $activatedcount ++;
1494: push (@{$rolechgs->{$timestamp}},\%chginfo);
1495: }
1496: }
1497: }
1498: }
1499: }
1.114 raeburn 1500: $activatedcount += &getrolechanges($rolechgs,$rolechgtime,$status,$classlist,\%stucounted,
1501: \%advcounted);
1.77 raeburn 1502: return $activatedcount;
1503: }
1504:
1505: sub getrolechanges {
1.114 raeburn 1506: my ($rolechgs,$rolechgtime,$status,$classlist,$stucountref,$advcountref) = @_;
1.77 raeburn 1507: my (%stucounted,%advcounted);
1508: if (ref($stucountref) eq 'HASH') {
1509: %stucounted = %{$stucountref};
1510: }
1511: if (ref($advcountref) eq 'HASH') {
1512: %advcounted = %{$advcountref};
1513: }
1514: my $withsec = 1;
1515: my $hidepriv = 1;
1516: my $context = 'course';
1517: my @statuses = ($status);
1518: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1519: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1520: my $now = time();
1521: my ($permission,$allowed) =
1522: &Apache::lonuserutils::get_permission($context);
1523: my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
1524: my $secidx = &Apache::loncoursedata::CL_SECTION();
1525: my $startidx = &Apache::loncoursedata::CL_START();
1526: my $endidx = &Apache::loncoursedata::CL_END();
1527: my $rolechgcount = 0;
1.114 raeburn 1528: if (ref($classlist) eq 'HASH') {
1529: foreach my $key (keys(%{$classlist})) {
1530: my ($userstatus,$eventtime);
1531: my $student = $classlist->{$key};
1532: if (ref($student) eq 'ARRAY') {
1533: my $start = $student->[$startidx];
1534: my $end = $student->[$endidx];
1535: my $sec = $student->[$secidx];
1536: my ($stuname,$studom) = split(/:/,$key);
1537: if ($status eq 'active') {
1538: if (exists($stucounted{$key.':'.$sec})) {
1539: next;
1540: }
1.77 raeburn 1541: }
1.114 raeburn 1542: if (($end == 0) || ($end > $start)) {
1543: if ($start <= $now) {
1544: if ($end && $end < $now) {
1545: if ($rolechgtime > 0) {
1546: if ($end > $rolechgtime) {
1547: $userstatus = 'previous';
1548: }
1549: } else {
1.77 raeburn 1550: $userstatus = 'previous';
1551: }
1552: } else {
1.114 raeburn 1553: if ($rolechgtime > 0) {
1554: if ($start >= $rolechgtime) {
1555: $userstatus = 'active';
1556: }
1557: } else {
1.77 raeburn 1558: $userstatus = 'active';
1559: }
1560: }
1561: }
1562: }
1.114 raeburn 1563: next if ($userstatus ne $status);
1564: if ($status eq 'active') {
1565: $eventtime = $start;
1566: } else {
1567: $eventtime = $end;
1568: }
1569: if (($viewablesec ne '') && ($sec ne '')) {
1570: next if ($viewablesec ne $sec);
1571: }
1572: my %chginfo = (
1573: 'section' => $sec,
1574: 'uname' => $stuname,
1575: 'udom' => $studom,
1576: 'role' => 'st',
1577: 'status' => $userstatus,
1578: );
1579: $rolechgcount ++;
1580: push(@{$rolechgs->{$eventtime}},\%chginfo);
1.77 raeburn 1581: }
1582: }
1583: }
1584: my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
1585: \@statuses,undef,undef,$withsec,$hidepriv);
1586: foreach my $item (keys(%advrolehash)) {
1587: my ($userstatus,$eventtime);
1588: my ($uname,$udom,$role,$section) = split(/:/,$item,-1);
1589: my ($start,$end) = split(/:/,$advrolehash{$item});
1590: if ($start eq '-1' && $end eq '-1') {
1591: next;
1592: } else {
1593: if ($status eq 'active') {
1594: if (exists($advcounted{$item})) {
1595: next;
1596: }
1597: }
1598: if (($end == 0) || ($end > $start)) {
1599: if ($start <= $now) {
1600: if ($end && $end < $now) {
1601: if ($rolechgtime > 0) {
1602: if ($end > $rolechgtime) {
1603: $userstatus = 'previous';
1604: }
1605: } else {
1606: $userstatus = 'previous';
1607: }
1608: } else {
1609: if ($rolechgtime > 0) {
1610: if ($start >= $rolechgtime) {
1611: $userstatus = 'active';
1612: }
1613: } else {
1614: $userstatus = 'active';
1615: }
1616: }
1617: }
1618: }
1619: next if ($userstatus ne $status);
1620: if ($status eq 'active') {
1621: $eventtime = $start;
1622: } else {
1623: $eventtime = $end;
1624: }
1625: }
1626: if (($viewablesec ne '') && ($section ne '')) {
1627: next if ($viewablesec ne $section);
1628: }
1629: my %chginfo = (
1630: 'section' => $section,
1631: 'uname' => $uname,
1632: 'udom' => $udom,
1633: 'role' => $role,
1634: 'status' => $userstatus,
1635: );
1636: $rolechgcount ++;
1637: push (@{$rolechgs->{$eventtime}},\%chginfo);
1638: }
1639: return $rolechgcount;
1640: }
1.33 raeburn 1641:
1.106 raeburn 1642: sub getloggedin {
1643: my ($cdom,$crs,$lastlogins,$starttime) = @_;
1644: my $context = 'course';
1645: my ($permission,$allowed) =
1646: &Apache::lonuserutils::get_permission($context);
1647: my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
1648: my %crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$crs);
1649: my $logincount = 0;
1650: my ($tmp) = keys(%crslogins);
1651: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1652: if (keys(%crslogins) > 0) {
1653: foreach my $key (keys(%crslogins)) {
1654: my ($uname,$udom,$section,$role) = split(/:/,$key);
1655: my $eventtime = $crslogins{$key};
1656: if ($eventtime > $starttime) {
1657: if (($viewablesec ne '') && ($section ne '')) {
1658: next if ($viewablesec ne $section);
1659: }
1660: my %chginfo = (
1661: 'section' => $section,
1662: 'uname' => $uname,
1663: 'udom' => $udom,
1664: 'role' => $role,
1665: );
1666: $logincount ++;
1667: push (@{$lastlogins->{$eventtime}},\%chginfo);
1668: }
1669: }
1670: }
1671: }
1672: return $logincount;
1673: }
1674:
1.126 ! raeburn 1675: sub getsessions {
! 1676: my ($cdom,$cnum,$sessions,$lastactive,$classlist) = @_;
! 1677: my $context = 'course';
! 1678: my ($permission,$allowed) =
! 1679: &Apache::lonuserutils::get_permission($context);
! 1680: my %crs_sessions = &Apache::lonnet::get_course_sessions($cnum,$cdom,$lastactive);
! 1681: my $sessioncount = 0;
! 1682: if (keys(%crs_sessions) > 0) {
! 1683: if (ref($classlist) eq 'HASH') {
! 1684: my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
! 1685: my $secidx = &Apache::loncoursedata::CL_SECTION();
! 1686: my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'_'.$cnum,1);
! 1687: my %personnel;
! 1688: foreach my $role (sort(keys(%coursepersonnel))) {
! 1689: my ($rolecode,$section);
! 1690: if ($role =~ /:/) {
! 1691: ($rolecode,$section) = split(/:/,$role);
! 1692: } else {
! 1693: $rolecode = $role;
! 1694: }
! 1695: if ($viewablesec ne '') {
! 1696: next if ($viewablesec ne $section);
! 1697: }
! 1698: foreach my $user (split(/\,/,$coursepersonnel{$role})) {
! 1699: push(@{$personnel{$user}{$rolecode}},$section);
! 1700: }
! 1701: }
! 1702: foreach my $key (keys(%crs_sessions)) {
! 1703: if (exists($classlist->{$key})) {
! 1704: my $student = $classlist->{$key};
! 1705: my $section = $student->[$secidx];
! 1706: my $lastaccess = $crs_sessions{$key};
! 1707: if ($viewablesec ne '') {
! 1708: next if ($viewablesec ne $section);
! 1709: }
! 1710: my ($stuname,$studom) = split(/:/,$key);
! 1711: my %info = (
! 1712: 'section' => $section,
! 1713: 'role' => 'st',
! 1714: 'uname' => $stuname,
! 1715: 'udom' => $studom,
! 1716: );
! 1717: $sessioncount ++;
! 1718: push(@{$sessions->{$lastaccess}},\%info);
! 1719: } elsif (exists($personnel{$key})) {
! 1720: my $lastaccess = $crs_sessions{$key};
! 1721: my ($uname,$udom) = split(/:/,$key);
! 1722: if (ref($personnel{$key}) eq 'HASH') {
! 1723: my ($showrole,$showsec);
! 1724: foreach my $possrole ('cc','co','in','ta','ep','ad','st') {
! 1725: if (exists($personnel{$key}{$possrole})) {
! 1726: $showrole = $possrole;
! 1727: $showsec = join(', ',@{$personnel{$key}{$possrole}});
! 1728: last;
! 1729: }
! 1730: }
! 1731: my %info = (
! 1732: 'section' => $showsec,
! 1733: 'role' => $showrole,
! 1734: 'uname' => $uname,
! 1735: 'udom' => $udom,
! 1736: );
! 1737: $sessioncount ++;
! 1738: push(@{$sessions->{$lastaccess}},\%info);
! 1739: }
! 1740: }
! 1741: }
! 1742: }
! 1743: }
! 1744: return $sessioncount;
! 1745: }
! 1746:
1.33 raeburn 1747: sub checkversions {
1748: my ($cdom,$crs,$navmap,$changed,$starttime) = @_;
1749: my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs);
1750: my ($tmp) = keys(%changes);
1.40 raeburn 1751: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 1752: if (keys(%changes) > 0) {
1753: foreach my $key (sort(keys(%changes))) {
1754: if ($changes{$key} > $starttime) {
1755: my $version;
1756: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
1757: my $currentversion=&Apache::lonnet::getversion($key);
1758: my $revdate =
1759: &Apache::lonnet::metadata($root.'.'.$extension,
1760: 'lastrevisiondate');
1761: $revdate = &Apache::lonlocal::locallocaltime($revdate);
1762: my $linkurl=&Apache::lonnet::clutter($key);
1.104 bisitz 1763: my $usedversion=$navmap->usedVersion($linkurl);
1.33 raeburn 1764: my @resources = $navmap->getResourceByUrl($linkurl,1);
1765: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1766: $version = $usedversion;
1767: } else {
1768: $version = $currentversion;
1769: }
1770: foreach my $res (@resources) {
1.35 raeburn 1771: if (ref($res) eq 'Apache::lonnavmaps::resource') {
1772: my $symb = $res->symb();
1773: %{$$changed{$symb}} = (
1.33 raeburn 1774: current => $currentversion,
1775: version => $version,
1776: revdate => $revdate,
1.35 raeburn 1777: );
1778: }
1.33 raeburn 1779: }
1780: }
1781: }
1782: }
1783: }
1784: return;
1785: }
1786:
1787: sub display_handgrade {
1.84 raeburn 1788: my ($r,$tograde,$ungraded,$itemserror) = @_;
1.33 raeburn 1789: my %lt = &Apache::lonlocal::texthash(
1790: 'prna' => 'Problem Name',
1791: 'nmun' => 'Number ungraded',
1792: 'nopr' => 'No problems require handgrading',
1793: );
1794: if (@{$tograde} > 0) {
1.68 raeburn 1795: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1796: $lt{'prna'}.'</td><td class="LC_right_item">'.
1797: $lt{'nmun'}.'</td></tr>');
1.33 raeburn 1798: my $rowNum = 0;
1799: foreach my $res (@{$tograde}) {
1.68 raeburn 1800: $rowNum ++;
1801: my $css_class = $rowNum%2?' class="LC_odd_row"':'';
1.102 www 1802: my $linkurl='/adm/grades';
1.66 raeburn 1803: if ($$ungraded{$res}{'enclink'}) {
1.102 www 1804: $linkurl.='?symb='.$$ungraded{$res}{'encsymb'};
1805: } else {
1806: $linkurl.='?symb='.&escape($res);
1807: }
1.110 raeburn 1808: $linkurl.='&command=ungraded';
1.68 raeburn 1809: $r->print('<tr'.$css_class.'><td><a href="'.$linkurl.'">'.$$ungraded{$res}{title}.'</a></td><td class="LC_right_item">'.$$ungraded{$res}{count}.'</td></tr>');
1.33 raeburn 1810: }
1.84 raeburn 1811: } elsif ($itemserror) {
1812: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1813: } else {
1.68 raeburn 1814: $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
1.33 raeburn 1815: }
1816: }
1817:
1818: sub display_haserrors {
1.84 raeburn 1819: my ($r,$bombs,$bombed,$res_title,$itemserror) = @_;
1.33 raeburn 1820: my $bombnum = 0;
1821: my %lt = &Apache::lonlocal::texthash(
1822: reso => 'Resource',
1823: nmer => 'Number of errors',
1824: noer => 'No problems with errors',
1825: );
1826: if (@{$bombs} > 0) {
1.68 raeburn 1827: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1828: $lt{'reso'}.'</td><td class="LC_right_item">'.
1829: $lt{'nmer'}.'</td></tr>');
1.33 raeburn 1830: @{$bombs} = sort { &cmp_title($a,$b,$res_title) } @{$bombs};
1831: foreach my $bomb (@{$bombs}) {
1832: $bombnum ++;
1.68 raeburn 1833: my $css_class = $bombnum%2?' class="LC_odd_row"':'';
1834: $r->print('<tr'.$css_class.'><td>'.$$bombed{$bomb}{errorlink}.
1835: '</td><td class="LC_right_item">'.
1836: $$bombed{$bomb}{errorcount}.'</td></tr>');
1.33 raeburn 1837: }
1.84 raeburn 1838: } elsif ($itemserror) {
1839: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1840: } else {
1.68 raeburn 1841: $r->print('<tr class="LC_empty_row"><td>'.$lt{'noer'}.'</td></tr>');
1.33 raeburn 1842: }
1843: return;
1844: }
1845:
1846: sub display_abovethreshold {
1.119 raeburn 1847: my ($r,$refpage,$warnings,$triggered,$res_title,$itemserror,$checkallowed) = @_;
1.33 raeburn 1848: my %lt = &Apache::lonlocal::texthash(
1849: reso => 'Resource',
1850: part => 'Part',
1851: nust => 'Num. students',
1852: avat => 'Av. Attempts',
1853: dedi => 'Deg. Diff',
1854: lare => 'Last Reset',
1855: reco => 'Reset Count?',
1856: rese => 'Reset counters to 0',
1857: nopr => 'No problems satisfy threshold criteria',
1858: );
1859: if (@{$warnings} > 0) {
1860: @{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings};
1.61 albertel 1861: $r->print('<tr class="LC_info_row">'.
1.110 raeburn 1862: '<td class="LC_left_item">'.$lt{'reso'}.
1863: '<input type="hidden" name="command" value="" /></td>'.
1.61 albertel 1864: '<td>'.$lt{'part'}.'</td><td>'.$lt{'nust'}.'</td>'.
1865: '<td>'.$lt{'avat'}.'</td><td>'.$lt{'dedi'}.'</td>'.
1.119 raeburn 1866: '<td>'.$lt{'lare'}.'</td>');
1867: if ($checkallowed->{'resetcounters'}) {
1868: $r->print('<td class="LC_right_item">'.$lt{'reco'}.'</td>');
1869: }
1870: $r->print('</tr>');
1.61 albertel 1871: my $row;
1.33 raeburn 1872: foreach my $res (@{$warnings}) {
1.61 albertel 1873: $row++;
1.33 raeburn 1874: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
1875: my $linkurl=&Apache::lonnet::clutter($url);
1876: my $rowspan;
1877: if ($$triggered{$res}{numparts} > 1) {
1878: $rowspan = 'rowspan="'.$$triggered{$res}{numparts}.'"';
1879: }
1.55 www 1880: $linkurl .= '?symb='.&escape($res);
1.66 raeburn 1881: if ($$triggered{$res}{'enclink'}) {
1882: $linkurl =
1883: $$triggered{$res}{'enclink'}.'?symb='.$$triggered{$res}{'encsymb'};
1884: }
1.68 raeburn 1885: my $css_class = $row%2?' class="LC_odd_row"':'';
1886: $r->print('<tr'.$css_class.'>'.
1.61 albertel 1887: '<td class="LC_first_item" '.$rowspan.'><a href="'.$linkurl.'">'.
1.62 raeburn 1888: $$triggered{$res}{title}.'</a></td>');
1889: if (ref($$triggered{$res}{text}) eq 'ARRAY') {
1890: $r->print($$triggered{$res}{text}[0]);
1891: }
1892: $r->print('</tr>');
1893: if (ref($$triggered{$res}{text}) eq 'ARRAY') {
1894: if (@{$$triggered{$res}{text}} > 1) {
1895: for (my $i=1; $i<@{$$triggered{$res}{text}}; $i++) {
1.107 raeburn 1896: $r->print('<tr '.$css_class.'>'.
1.62 raeburn 1897: $$triggered{$res}{text}[$i].'</tr>');
1898: }
1899: }
1900: }
1.33 raeburn 1901: }
1.120 raeburn 1902: if ($checkallowed->{'resetcounters'}) {
1.119 raeburn 1903: $r->print('<tr class="LC_info_row"><td colspan="7" class="LC_right_item"><br /><input type="button" name="counters" value="'.$lt{'rese'}.'" onclick="javascript:thresholdreset();" /></td></tr>');
1904: }
1.84 raeburn 1905: } elsif ($itemserror) {
1906: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1907: } else {
1.63 albertel 1908: $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
1.33 raeburn 1909: }
1910: }
1911:
1912: sub display_versionchanges {
1.84 raeburn 1913: my ($r,$changed,$res_title,$interval,$itemserror) = @_;
1.33 raeburn 1914: my %lt = &Apache::lonlocal::texthash(
1915: 'reso' => 'Resource',
1916: 'revd' => 'Last revised',
1917: 'newv' => 'New version',
1918: 'veru' => 'Version used',
1919: );
1920: if (keys(%{$changed}) > 0) {
1.68 raeburn 1921: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1922: $lt{'reso'}.'</td><td>'.$lt{'revd'}.'</td><td>'.
1923: $lt{'newv'}.'</td><td class="LC_right_item">'.
1924: $lt{'veru'}.'</td></tr>');
1.33 raeburn 1925: my @changes = sort { &cmp_title($a,$b,$res_title) } keys(%{$changed});
1926: my $changenum = 0;
1927: foreach my $item (@changes) {
1.68 raeburn 1928: $changenum ++;
1929: my $css_class = $changenum%2?' class="LC_odd_row"':'';
1.33 raeburn 1930: my ($map,$id,$url)=&Apache::lonnet::decode_symb($item);
1931: my $linkurl=&Apache::lonnet::clutter($url);
1.55 www 1932: $linkurl .= '?symb='.&escape($item);
1.33 raeburn 1933:
1.68 raeburn 1934: $r->print('<tr'.$css_class.'><td><a href="'.$linkurl.'">'.
1935: $$res_title{$item}.'</a></td><td>'.
1936: $$changed{$item}{'revdate'}.'</td><td>'.
1937: $$changed{$item}{'current'}.'</td><td>'.
1938: $$changed{$item}{'version'}.'</td></tr>');
1.33 raeburn 1939: }
1.84 raeburn 1940: } elsif ($itemserror) {
1941: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1942: } else {
1.78 bisitz 1943: $r->print('<tr class="LC_empty_row"><td>'
1944: .&mt('No '.$interval).'</td></tr>');
1.33 raeburn 1945: }
1946: return;
1947: }
1.77 raeburn 1948:
1949: sub display_rolechanges {
1.114 raeburn 1950: my ($r,$chgcount,$changed,$interval,$crstype,$classlist) = @_;
1.77 raeburn 1951: my $now = time();
1952: my %lt = &Apache::lonlocal::texthash(
1953: 'user' => 'User',
1954: 'tich' => 'Time of change',
1955: 'role' => 'Role',
1956: 'sec' => 'Section',
1957: 'status' => 'Status',
1958: );
1959: if ($chgcount) {
1960: $r->print('<tr class="LC_info_row">'.
1961: '<td class="LC_left_item">'.$lt{'tich'}.'</td>'.
1962: '<td class="LC_left_item">'.$lt{'user'}.'</td>'.
1963: '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
1964: '<td class="LC_left_item">'.$lt{'sec'}.'</td>'.
1965: '<td class="LC_left_item">'.$lt{'status'}.'</td></tr>');
1966: if (ref($changed) eq 'HASH') {
1967: my @changes = sort { $b <=> $a } (keys(%{$changed}));
1968: my $changenum = 0;
1.114 raeburn 1969: my $fullnameidx = &Apache::loncoursedata::CL_FULLNAME();
1.77 raeburn 1970: foreach my $item (@changes) {
1971: if (ref($changed->{$item}) eq 'ARRAY') {
1972: foreach my $chg (@{$changed->{$item}}) {
1973: if (ref($chg) eq 'HASH') {
1974: my $section;
1975: my $role =
1976: &Apache::lonnet::plaintext($chg->{'role'},$crstype);
1977: my $status = &mt($chg->{'status'});
1978: if ($chg->{'section'} eq '') {
1979: $section = &mt('none');
1980: } else {
1981: $section = $chg->{'section'};
1982: }
1983: my $uname = $chg->{'uname'};
1984: my $udom = $chg->{'udom'};
1985: $changenum ++;
1986: my $css_class = $changenum%2?' class="LC_odd_row"':'';
1.114 raeburn 1987: my $fullname;
1988: if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') {
1989: $fullname = $classlist->{$uname.':'.$udom}->[$fullnameidx];
1990: } else {
1991: $fullname = &Apache::loncommon::plainname($uname,$udom,'lastname');
1992: }
1.77 raeburn 1993: my $link =
1.114 raeburn 1994: &Apache::loncommon::aboutmewrapper($fullname,$uname,$udom);
1.77 raeburn 1995: $r->print('<tr'.$css_class.'>'.
1.93 droeschl 1996: '<td>'.&Apache::lonlocal::locallocaltime($item).'</td>'.
1.77 raeburn 1997: '<td>'.$link.'</td>'.
1998: '<td>'.$role.'</td>'.
1999: '<td>'.$section.'</td>'.
2000: '<td>'.$status.'</td></tr>');
2001: }
2002: }
2003: }
2004: }
2005: }
2006: } else {
1.78 bisitz 2007: $r->print('<tr class="LC_empty_row"><td>'
2008: .&mt('There are no '.$interval).'</td></tr>');
1.77 raeburn 2009: }
2010: return;
2011: }
1.106 raeburn 2012:
1.126 ! raeburn 2013: sub display_activity {
! 2014: my ($r,$context,$count,$details,$interval,$crstype,$classlist) = @_;
1.114 raeburn 2015: return unless (ref($classlist) eq 'HASH');
1.106 raeburn 2016: my %lt = &Apache::lonlocal::texthash(
2017: 'user' => 'User',
2018: 'role' => 'Role',
2019: 'sec' => 'Section',
2020: 'number' => 'Total number of logins',
2021: );
1.126 ! raeburn 2022: my $prefix = 'login';
! 2023: if ($context eq 'sessions') {
! 2024: $lt{'number'} = &mt('Total number of active user sessions');
! 2025: $lt{'active'} = &mt('Last active');
! 2026: $prefix = 'session';
! 2027: }
! 2028: if ($count) {
1.106 raeburn 2029:
1.126 ! raeburn 2030: my $hdr = '<tr class="LC_info_row" style="display:none" id="'.$prefix.'titledet">'.
1.106 raeburn 2031: '<td class="LC_left_item">'.$lt{'user'}.'</td>'.
2032: '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
1.126 ! raeburn 2033: '<td class="LC_left_item">'.$lt{'sec'}.'</td>';
! 2034: if ($context eq 'sessions') {
! 2035: $hdr .= '<td class="LC_left_item">'.$lt{'active'}.'</td>';
! 2036: }
! 2037: $hdr .= '</tr>'."\n".
! 2038: '<tr class="LC_info_row" id="'.$prefix.'titlesum">'.
! 2039: '<td class="LC_left_item">'.$lt{'number'}.'</td>'.
! 2040: '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
! 2041: '<td class="LC_left_item">'.$lt{'sec'};
1.106 raeburn 2042: my (%bylastname,%counts);
1.126 ! raeburn 2043: if (ref($details) eq 'HASH') {
! 2044: my @items = sort { $b <=> $a } (keys(%{$details}));
! 2045: my $num = 0;
1.114 raeburn 2046: my $fullnameidx = &Apache::loncoursedata::CL_FULLNAME();
1.126 ! raeburn 2047: foreach my $item (@items) {
! 2048: if (ref($details->{$item}) eq 'ARRAY') {
! 2049: foreach my $user (@{$details->{$item}}) {
1.106 raeburn 2050: if (ref($user) eq 'HASH') {
2051: my $section;
2052: my $role =
2053: &Apache::lonnet::plaintext($user->{'role'},$crstype);
2054: if ($user->{'section'} eq '') {
2055: $section = &mt('none');
2056: } else {
2057: $section = $user->{'section'};
2058: }
2059: $counts{$user->{'role'}}{$section} ++;
2060: my $uname = $user->{'uname'};
2061: my $udom = $user->{'udom'};
1.114 raeburn 2062: my $fullname;
2063: if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') {
1.115 raeburn 2064: $fullname = $classlist->{$uname.':'.$udom}->[$fullnameidx];
1.114 raeburn 2065: } else {
2066: $fullname = &Apache::loncommon::plainname($uname,$udom,'lastname');
2067: }
1.106 raeburn 2068: my $link =
2069: &Apache::loncommon::aboutmewrapper($fullname,$uname,$udom);
1.126 ! raeburn 2070: my $entry = '<td>'.$link.'</td>'.
! 2071: '<td>'.$role.'</td>'.
! 2072: '<td>'.$section.'</td>';
! 2073: if ($context eq 'sessions') {
! 2074: $entry .= '<td>'.&Apache::lonlocal::locallocaltime($item).'</td>';
! 2075: }
! 2076: push(@{$bylastname{$fullname}},$entry);
1.106 raeburn 2077: }
2078: }
2079: }
2080: }
2081: my $table;
2082: foreach my $person (sort(keys(%bylastname))) {
2083: if (ref($bylastname{$person}) eq 'ARRAY') {
2084: foreach my $item (@{$bylastname{$person}}) {
1.126 ! raeburn 2085: $num ++;
! 2086: my $css_class = $num%2?' class="LC_odd_row"':'';
! 2087: $table .= '<tr'.$css_class.' style="display:none;" id="'.$prefix.'det_'.$num.'">'.$item.'</tr>';
1.106 raeburn 2088: }
2089: }
2090: }
2091: my $numrow = 0;
2092: foreach my $role (sort(keys(%counts))) {
2093: my $showrole = &Apache::lonnet::plaintext($role,$crstype);
2094: if (ref($counts{$role}) eq 'HASH') {
2095: foreach my $sec (sort { $b <=> $a } (keys(%{$counts{$role}}))) {
2096: $numrow ++;
2097: my $css_class = $numrow%2?' class="LC_odd_row"':'';
1.126 ! raeburn 2098: $table .= '<tr '.$css_class.' id="'.$prefix.'sum_'.$numrow.'">'.
1.106 raeburn 2099: '<td>'.$counts{$role}{$sec}.'</td>'.
2100: '<td>'.$showrole.'</td>'.
2101: '<td>'.$sec.'</td></tr>';
2102: }
2103: }
2104: }
1.126 ! raeburn 2105: $r->print($hdr.'<input type="hidden" name="'.$prefix.'count" value="'.$num.
! 2106: '" /><input type="hidden" name="'.$prefix.'row" value="'.$numrow.
1.106 raeburn 2107: '" /></td></tr>'.$table);
2108: }
2109: } else {
2110: $r->print('<tr class="LC_empty_row"><td>'.
2111: &mt('There are no '.$interval).
1.126 ! raeburn 2112: '<input type="hidden" name="'.$prefix.'count" value="'.$count.
1.106 raeburn 2113: '." /></td></tr>');
2114: }
2115: return;
2116: }
1.126 ! raeburn 2117:
1.33 raeburn 2118: sub display_coursediscussion {
1.84 raeburn 2119: my ($r,$newdiscussions,$unread,$countunread,$res_title,$itemserror) = @_;
1.59 albertel 2120: my $lctype = lc(&Apache::loncommon::course_type());
1.33 raeburn 2121: my %lt = &Apache::lonlocal::texthash(
2122: 'loca' => 'Location',
2123: 'type' => 'Type',
2124: 'numn' => 'Number of new posts',
1.56 raeburn 2125: 'noun' => 'No unread posts in '.$lctype.' discussions',
1.37 raeburn 2126: 'tmlp' => 'Time of last post',
1.33 raeburn 2127: );
2128: if (@{$newdiscussions} > 0) {
1.68 raeburn 2129: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
2130: $lt{'loca'}.'</td><td>'.
2131: $lt{'type'}.'</td>');
1.39 raeburn 2132: if ($countunread eq 'on') {
1.68 raeburn 2133: $r->print('<td>'.$lt{'tmlp'}.'</td>'.
2134: '<td class="LC_right_item">'.$lt{'numn'}.'</td>');
1.37 raeburn 2135: } else {
1.68 raeburn 2136: $r->print('<td class="LC_right_item">'.$lt{'tmlp'}.'</td>');
1.37 raeburn 2137: }
2138: $r->print("</tr>\n");
1.33 raeburn 2139: @{$newdiscussions} = sort { &cmp_title($a,$b,$res_title) }
2140: @{$newdiscussions};
2141: my $rowNum = 0;
2142: foreach my $ressymb (@{$newdiscussions}) {
1.68 raeburn 2143: $rowNum ++;
1.33 raeburn 2144: my $forum_title = $$unread{$ressymb}{'title'};
2145: my $type = 'Resource';
2146: my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
1.108 droeschl 2147: my $disclink = $feedurl.'?symb='. &escape($$unread{$ressymb}{symb});
1.33 raeburn 2148: if ($feedurl =~ /bulletinboard/) {
1.85 schafran 2149: $type = 'Discussion Board';
1.33 raeburn 2150: }
1.66 raeburn 2151: if ($$unread{$ressymb}{'enclink'}) {
2152: $disclink = $$unread{$ressymb}{'enclink'}.'?symb='.$$unread{$ressymb}{'encsymb'};
2153: }
1.68 raeburn 2154: my $css_class = $rowNum%2?' class="LC_odd_row"':'';
1.37 raeburn 2155: my $lastpost = &Apache::lonnavmaps::timeToHumanString(
2156: $$unread{$ressymb}{'lastpost'});
1.70 raeburn 2157: $r->print('<tr'.$css_class.'><td><a href="'.$disclink.'">'.$forum_title.'</a> </td><td>'.&mt($type).' </td>');
1.39 raeburn 2158: if ($countunread eq 'on') {
1.37 raeburn 2159: my $unreadnum = $$unread{$ressymb}{'unreadcount'};
1.68 raeburn 2160: $r->print('<td>'.$lastpost.'</td><td class="LC_right_item">'.
2161: $unreadnum.' </td>');
1.37 raeburn 2162: } else {
1.68 raeburn 2163: $r->print('<td class="LC_right_item">'.$lastpost.'</td>');
1.33 raeburn 2164: }
1.37 raeburn 2165: $r->print("</tr>\n");
1.33 raeburn 2166: }
1.84 raeburn 2167: } elsif ($itemserror) {
2168: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 2169: } else {
1.68 raeburn 2170: $r->print('<tr class="LC_empty_row"><td>'.$lt{'noun'}.'</td></tr>');
1.33 raeburn 2171: }
2172: }
2173:
2174: sub display_coursenormalmail {
1.68 raeburn 2175: my ($r,$msgcount,$newmsgs) = @_;
1.59 albertel 2176: my $lctype = lc(&Apache::loncommon::course_type());
1.33 raeburn 2177: if ($msgcount > 0) {
1.68 raeburn 2178: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
2179: &mt('Number').'</td><td>'.&mt('Subject').'</td><td>'.
2180: &mt('Sender').'</td><td class="LC_right_item">'.
2181: &mt('Date/Time').'</td></tr>');
2182: my $mailcount = 0;
1.33 raeburn 2183: foreach my $msg (@{$newmsgs}) {
2184: $mailcount ++;
1.68 raeburn 2185: my $css_class = $mailcount%2?' class="LC_odd_row"':'';
1.76 raeburn 2186: $r->print('<tr'.$css_class.'><td>'.$mailcount
2187: .'. </td><td><a href="/adm/email?display='
2188: .$msg->{'msgid'}.'">'
2189: .$msg->{'shortsub'}.'</a> </td><td> '
2190: .$msg->{'from'}.':'.$msg->{'fromdom'}.' </td><td>'
2191: .$msg->{'sendtime'}.'</td></tr>');
1.33 raeburn 2192: }
2193: } else {
1.68 raeburn 2194: $r->print('<tr class="LC_empty_row"><td>'.
2195: &mt('No new '.$lctype.' messages').'</td></tr>');
1.33 raeburn 2196: }
2197: }
2198:
2199: sub display_coursecritmail {
1.68 raeburn 2200: my ($r,$critmsgcount,$critmsgs) = @_;
1.59 albertel 2201: my $lctype = lc(&Apache::loncommon::course_type());
1.33 raeburn 2202: if ($critmsgcount > 0) {
1.68 raeburn 2203: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
2204: &mt('Number').'</td><td>'.&mt('Subject').'</td><td>'.
2205: &mt('Sender').'</td><td class="LC_right_item">'.
2206: &mt('Date/Time').'</td></tr>');
2207: my $mailcount = 0;
1.33 raeburn 2208: foreach my $msg (@{$critmsgs}) {
2209: $mailcount ++;
1.68 raeburn 2210: my $css_class = $mailcount%2?' class="LC_odd_row"':'';
2211: $r->print('<tr'.$css_class.'><td>'.$mailcount.
2212: '. </td><td><a href="/adm/email?folder=critical">'.
2213: $msg->{'shortsub'}.'</a> </td><td> '.
1.72 albertel 2214: $msg->{'from'}.':'.$msg->{'fromdom'}.' </td><td>'.
1.68 raeburn 2215: $msg->{'sendtime'}.'</td></tr>');
1.33 raeburn 2216: }
2217: } else {
1.68 raeburn 2218: $r->print('<tr class="LC_empty_row"><td>'.
2219: &mt('No unread critical messages in '.$lctype).
2220: '</td></tr>');
1.33 raeburn 2221: }
1.1 raeburn 2222: }
2223:
2224: sub cmp_title {
1.16 raeburn 2225: my ($a,$b,$res_title) = @_;
2226: my ($atitle,$btitle) = (lc($$res_title{$a}),lc($$res_title{$b}));
1.1 raeburn 2227: $atitle=~s/^\s*//;
2228: $btitle=~s/^\s*//;
2229: return $atitle cmp $btitle;
2230: }
2231:
1.33 raeburn 2232: sub get_display_settings {
1.36 raeburn 2233: my ($uname,$udom,$cid) = @_;
1.33 raeburn 2234: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid);
2235: my ($tmp) = keys(%settings);
1.40 raeburn 2236: if ($tmp=~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 2237: %settings = ();
1.41 raeburn 2238: unless ($tmp =~ /^error: 2 /) {
1.59 albertel 2239: my $lctype = lc(&Apache::loncommon::course_type());
1.41 raeburn 2240: &Apache::lonnet::logthis('Error retrieving whatsnew settings: '.
1.56 raeburn 2241: $tmp.' for '.$uname.':'.$udom.' for '.$lctype.': '.$cid);
1.33 raeburn 2242: }
2243: }
2244: return %settings;
2245: }
2246:
1.36 raeburn 2247: sub store_display_settings {
2248: my ($uname,$udom,$cid,$checkallowed) = @_;
2249: my %whatsnew_settings;
2250: my $result;
2251: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 2252: if ($key =~ /_section$/) { next; }
1.36 raeburn 2253: if (exists($env{'form.display_'.$key})) {
2254: unless ($env{'form.display_'.$key} eq '') {
2255: $whatsnew_settings{$cid.':'.$key} = $env{'form.display_'.$key};
2256: }
2257: }
2258: }
2259: if (keys(%whatsnew_settings)) {
2260: $result = &Apache::lonnet::put('nohist_whatsnew',\%whatsnew_settings,
2261: $udom,$uname);
2262: } else {
2263: $result = 'ok';
2264: }
2265: return $result;
2266: }
2267:
2268: sub store_interval_setting {
2269: my ($uname,$udom,$cid,$interval_titles) = @_;
2270: my %interval_settings = ();
2271: my $result;
1.77 raeburn 2272: my $context = $env{'form.intervaltype'};
2273: if ($env{'form.interval'} ne '') {
2274: if ($context eq 'oldroles') {
2275: $interval_settings{$cid.':oldroleinterval'} = $env{'form.interval'};
2276: } elsif ($context eq 'newroles') {
2277: $interval_settings{$cid.':newroleinterval'} = $env{'form.interval'};
1.106 raeburn 2278: } elsif ($context eq 'crslogin') {
2279: $interval_settings{$cid.':crslogininterval'} = $env{'form.interval'};
1.126 ! raeburn 2280: } elsif ($context eq 'sessions') {
! 2281: $interval_settings{$cid.':sessionactivity'} = $env{'form.interval'};
1.77 raeburn 2282: } else {
2283: $interval_settings{$cid.':interval'} = $env{'form.interval'};
2284: }
1.36 raeburn 2285: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
2286: \%interval_settings,$udom,$uname);
2287: if ($outcome eq 'ok') {
1.77 raeburn 2288: if (ref($interval_titles->{$context}) eq 'HASH') {
1.99 wenzelju 2289: $result = &Apache::lonhtmlcommon::confirm_success(&mt('New filter setting: [_1].','<b>'.
2290: $interval_titles->{$context}->{$env{'form.interval'}}.'</b>').'<br />');
1.77 raeburn 2291: }
1.36 raeburn 2292: } else {
1.59 albertel 2293: my $lctype = lc(&Apache::loncommon::course_type());
1.77 raeburn 2294: &Apache::lonnet::logthis('Error saving whatsnew '.$context.' interval setting'.
1.56 raeburn 2295: ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
1.99 wenzelju 2296: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set interval to [_1] due to [_2].',
1.77 raeburn 2297: '<b>'.$interval_titles->{$context}->{$env{'form.interval'}}.'</b>',
1.99 wenzelju 2298: '<tt>'.$outcome.'</tt>'),1);
1.36 raeburn 2299: }
2300: }
1.99 wenzelju 2301: return &Apache::loncommon::confirmwrapper($result);
1.36 raeburn 2302: }
2303:
1.39 raeburn 2304: sub store_discussion_setting {
2305: my ($uname,$udom,$cid) = @_;
2306: my %discussion_settings;
2307: my $result;
2308: if (defined($env{'form.countunread'})) {
2309: $discussion_settings{$cid.':countunread'} = $env{'form.countunread'};
2310: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
2311: \%discussion_settings,$udom,$uname);
2312: if ($outcome eq 'ok') {
1.99 wenzelju 2313: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Count unread posts in discussions display set to [_1]',
2314: '<b>'.&mt($env{'form.countunread'}).'</b>').'<br />');
1.39 raeburn 2315:
2316: } else {
1.59 albertel 2317: my $lctype = lc(&Apache::loncommon::course_type());
1.71 albertel 2318: &Apache::lonnet::logthis('Error saving whatsnew countunread setting'.
1.56 raeburn 2319: ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
1.99 wenzelju 2320: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set "number unread posts display" to [_1]'.
1.39 raeburn 2321: ' due to [_2].',
1.74 bisitz 2322: '<b>'.&mt($env{'form.countunread'}).'</b>',
1.99 wenzelju 2323: '<tt>'.$outcome.'</tt>'),1);
1.39 raeburn 2324: }
2325: }
1.99 wenzelju 2326: return &Apache::loncommon::confirmwrapper($result);
1.39 raeburn 2327: }
2328:
2329: sub store_courseinit_setting {
2330: my ($uname,$udom,$cid,$initpage) = @_;
2331: my %courseinit_settings;
2332: my $page_control;
2333: my $result;
2334: if (defined($env{'form.courseinit_control'})) {
2335: if ($env{'form.courseinit_control'} eq 'userpref') {
2336: $courseinit_settings{$cid.':courseinit'} = '';
2337: $page_control = 'global preferences';
2338: } else {
2339: if (defined($env{'form.courseinit_page'})) {
2340: $courseinit_settings{$cid.':courseinit'} =
2341: $env{'form.courseinit_page'};
2342: $page_control = 'course specific setting';
2343: }
2344: }
2345: if ($page_control) {
1.59 albertel 2346: my $lctype = lc(&Apache::loncommon::course_type());
1.39 raeburn 2347: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
2348: \%courseinit_settings,$udom,$uname);
2349: if ($outcome eq 'ok') {
2350: if ($page_control eq 'global preferences') {
1.99 wenzelju 2351: $result = &Apache::lonhtmlcommon::confirm_success(&mt("Page displayed after role selection in $lctype now set by [_1]user's global preferences[_2].",'<b>','</b>'));
1.39 raeburn 2352: } else {
1.99 wenzelju 2353: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Page displayed after role selection in this '.$lctype.' set to [_1].'
2354: ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>'));
1.39 raeburn 2355: }
2356: } else {
1.71 albertel 2357: &Apache::lonnet::logthis('Error saving whatsnew courseinit '.
1.39 raeburn 2358: 'setting: '.$outcome.' for '.$uname.
1.56 raeburn 2359: ':'.$udom.' in '.$lctype.' '.$cid);
1.39 raeburn 2360: if ($page_control eq 'global preferences') {
1.99 wenzelju 2361: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set control of page display to [_1]'.
1.39 raeburn 2362: ' due to [_2].',
2363: '<b>'.$page_control.'</b>',
1.99 wenzelju 2364: '<tt>'.$outcome.'</tt>'),1);
1.39 raeburn 2365: } else {
1.99 wenzelju 2366: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].'
1.81 bisitz 2367: ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>'
1.99 wenzelju 2368: ,'<tt>'.$outcome.'</tt>'),1);
1.39 raeburn 2369: }
2370: }
2371: }
2372: }
1.99 wenzelju 2373: return &Apache::loncommon::confirmwrapper($result);
1.39 raeburn 2374: }
2375:
1.33 raeburn 2376: sub start_box {
1.69 raeburn 2377: my ($r,$show,$heading,$caller,$refpage) = @_;
1.33 raeburn 2378: my %lt = &Apache::lonlocal::texthash(
2379: chth => 'Change thresholds?',
2380: chin => 'Change interval?',
1.39 raeburn 2381: chop => 'Change options?',
1.33 raeburn 2382: );
1.68 raeburn 2383: my $showhide;
1.33 raeburn 2384: if ($$show{$caller}) {
1.36 raeburn 2385: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1.70 raeburn 2386: 'display_'.$caller.",'hide'".');">'.
2387: &mt('Hide').'</a></b>';
1.33 raeburn 2388:
2389: } else {
1.36 raeburn 2390: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1.70 raeburn 2391: 'display_'.$caller.",'show'".');">'.
2392: &mt('Show').'</a></b>';
1.33 raeburn 2393: }
2394:
2395: $r->print('
1.68 raeburn 2396: <table class="LC_nested_outer">
1.33 raeburn 2397: <tr>
1.73 raeburn 2398: <th class="LC_left_item">'.$$heading{$caller}.'</th>
1.68 raeburn 2399: <th class="LC_right_item">'.$showhide.'</th>
2400: </tr>');
1.33 raeburn 2401: if (($caller eq 'abovethreshold') && ($$show{$caller})) {
1.40 raeburn 2402: if ($$show{$caller}) {
2403: $r->print('
1.33 raeburn 2404: <tr>
1.98 raeburn 2405: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgthreshold&refpage='.$refpage.'">'.$lt{'chth'}.'</a></td>
1.33 raeburn 2406: </tr>');
1.40 raeburn 2407: }
1.33 raeburn 2408: } elsif (($caller eq 'versionchanges') && ($$show{$caller})) {
1.40 raeburn 2409: if ($$show{$caller}) {
2410: $r->print('
1.33 raeburn 2411: <tr>
1.98 raeburn 2412: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chginterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1.39 raeburn 2413: </tr>');
1.40 raeburn 2414: }
1.39 raeburn 2415: } elsif ($caller eq 'coursediscussion') {
1.40 raeburn 2416: if ($$show{$caller}) {
2417: $r->print('
1.39 raeburn 2418: <tr>
1.98 raeburn 2419: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgdisc&refpage='.$refpage.'">'.$lt{'chop'}.'</a></td>
1.33 raeburn 2420: </tr>');
1.40 raeburn 2421: }
1.77 raeburn 2422: } elsif (($caller eq 'newroles') && ($$show{$caller})) {
2423: if ($$show{$caller}) {
2424: $r->print('
2425: <tr>
1.98 raeburn 2426: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgnewroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1.77 raeburn 2427: </tr>');
2428: }
2429: } elsif (($caller eq 'oldroles') && ($$show{$caller})) {
2430: if ($$show{$caller}) {
2431: $r->print('
2432: <tr>
1.98 raeburn 2433: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1.77 raeburn 2434: </tr>');
2435: }
1.106 raeburn 2436: } elsif (($caller eq 'crslogin') && ($$show{$caller})) {
2437: if ($$show{$caller}) {
2438: $r->print('
2439: <tr>
1.126 ! raeburn 2440: <td class="LC_subheader" align="left"><span class="LC_nobreak"><label><input type="radio" name="logindetails" value="0" checked="checked" onclick="javascript:toggledetails('."'login'".');" /> '.&mt('Summary').'</label><label><input type="radio" name="logindetails" value="1" onclick="javascript:toggledetails('."'login'".');" /> '.&mt('Details').'</label></span></td><td class="LC_subheader"><a href="/adm/whatsnew?command=chgcrslogininterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
! 2441: </tr>');
! 2442: }
! 2443: } elsif (($caller eq 'sessions') && ($$show{$caller})) {
! 2444: if ($$show{$caller}) {
! 2445: $r->print('
! 2446: <tr>
! 2447: <td class="LC_subheader" align="left"><span class="LC_nobreak"><label><input type="radio" name="sessiondetails" value="0" checked="checked" onclick="javascript:toggledetails('."'session'".');" /> '.&mt('Summary').'</label><label><input type="radio" name="sessiondetails" value="1" onclick="javascript:toggledetails('."'session'".');" /> '.&mt('Details').'</label></span></td><td class="LC_subheader"><a href="/adm/whatsnew?command=chgsessionlimit&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1.106 raeburn 2448: </tr>');
2449: }
2450: }
1.61 albertel 2451: $r->print('
1.33 raeburn 2452: <tr>
1.68 raeburn 2453: <td colspan="2">
2454: <table class="LC_nested">
1.33 raeburn 2455: ');
2456: return;
2457: }
2458:
2459: sub end_box {
2460: my ($r) = shift;
2461: $r->print('
2462: </table>
2463: </td>
2464: </tr>
2465: </table><br />');
2466: return;
2467: }
2468:
1.7 raeburn 2469: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>