Annotation of loncom/interface/lonwhatsnew.pm, revision 1.127
1.2 albertel 1: #
1.127 ! raeburn 2: # $Id: lonwhatsnew.pm,v 1.126 2020/03/30 11:04:13 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' ||
1.127 ! raeburn 656: $item eq 'newroles' || $item eq 'oldroles' ||
! 657: $item eq 'crslogin' || $item eq 'sessions') {
1.33 raeburn 658: if ($show{$item}) {
659: $needitems = 1;
660: last;
661: }
662: }
663: }
664:
1.84 raeburn 665: my $itemserror;
1.33 raeburn 666: if ($needitems) {
1.119 raeburn 667: $itemserror = &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread,$checkallowed);
1.1 raeburn 668: }
1.114 raeburn 669: my $classlist;
1.126 raeburn 670: if ($show{'oldroles'} || $show{'newroles'} || $show{'crslogin'} || $show{'sessions'}) {
1.115 raeburn 671: $classlist = &Apache::loncoursedata::get_classlist();
1.114 raeburn 672: }
1.33 raeburn 673: if ($show{'coursenormalmail'}) {
1.50 raeburn 674: $msgcount = &getnormalmail(\@newmsgs);
1.7 raeburn 675: }
1.33 raeburn 676: if ($show{'coursecritmail'}) {
1.50 raeburn 677: $critmsgcount = &getcritmail(\@critmsgs);
1.11 raeburn 678: }
1.77 raeburn 679: if ($show{'oldroles'}) {
1.114 raeburn 680: $expirecount = &getexpired(\%expired,$expiredstart,'previous',$classlist);
1.77 raeburn 681: }
682: if ($show{'newroles'}) {
1.114 raeburn 683: $activecount = &getactivated(\%activated,$activatedstart,'active',$classlist);
1.77 raeburn 684: }
1.106 raeburn 685: if ($show{'crslogin'}) {
686: $logincount = &getloggedin($cdom,$crs,\%loggedin,$crsloginstart);
687: }
1.126 raeburn 688: if ($show{'sessions'}) {
689: $sessioncount = &getsessions($cdom,$crs,\%sessions,$timediff{'sessions'},$classlist);
690: }
1.36 raeburn 691: $r->print(qq|<a href="javascript:changeAll('hide');">$lt{'hial'}</a>
692: <a href="javascript:changeAll('show');">$lt{'shal'}</a>
693: <form method="post" name="visible" action="/adm/whatsnew">\n|);
694: foreach my $item (keys(%{$checkallowed})) {
1.44 albertel 695: if ($item =~ /_section$/) { next; }
1.36 raeburn 696: if ($$checkallowed{$item}) {
697: $r->print('<input type="hidden" name="display_'.$item.'" />'."\n");
698: }
699: }
1.1 raeburn 700:
1.106 raeburn 701: $r->print('<input type="hidden" name="refpage" value="'.$refpage.'" /><table class="LC_double_column"><tr><td class="LC_left_col">');
1.1 raeburn 702:
1.33 raeburn 703: my $displayed = 0;
1.40 raeburn 704: my $totalboxes = 0;
705: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 706: if ($key =~ /_section$/) { next; }
707: if ($key eq 'whatsnew' ) { next; } # whatsnew check creates no box
1.40 raeburn 708: if ($$checkallowed{$key}) {
709: $totalboxes ++;
710: }
711: }
1.121 raeburn 712: my $currcolumn = 'left';
1.77 raeburn 713: # my $halfway = int($totalboxes/2) + $totalboxes%2;
1.33 raeburn 714: foreach my $actionitem (@actionorder) {
1.121 raeburn 715: if ($checkallowed->{$actionitem}) {
716: if (($actioncolumn{$actionitem} eq 'right') && ($currcolumn eq 'left')) {
1.73 raeburn 717: $r->print('</td><td> </td><td class="LC_right_col" >');
1.121 raeburn 718: $currcolumn = 'right';
1.1 raeburn 719: }
1.126 raeburn 720: &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 721: $displayed ++;
1.1 raeburn 722: }
723: }
724: $r->print('
1.33 raeburn 725: </td>
726: </tr>
1.73 raeburn 727: </table>
1.106 raeburn 728: </form>
1.73 raeburn 729: ');
1.1 raeburn 730: }
731:
1.11 raeburn 732: #-------------------------------
1.36 raeburn 733: # display_threshold_config
1.11 raeburn 734: #
1.13 raeburn 735: # Display the threshold setting screen
1.11 raeburn 736: #
737: #-------------------------------
738:
1.36 raeburn 739: sub display_threshold_config {
1.69 raeburn 740: my ($r,$refpage,$threshold_titles,$cdom,$crs) = @_;
1.39 raeburn 741: my $uname = $env{'user.name'};
742: my $udom = $env{'user.dom'};
743: my $cid = $env{'request.course.id'};
1.13 raeburn 744: my %threshold = ();
745: my $rowColor1 = "#ffffff";
746: my $rowColor2 = "#eeeeee";
747: my $rowColor;
748:
749: my @thresholditems = ("av_attempts","degdiff","numstudents");
1.39 raeburn 750: my %threshold_titles = &Apache::lonlocal::texthash(
1.13 raeburn 751: av_attempts => 'Average number of attempts',
752: degdiff => 'Degree of difficulty',
753: numstudents => 'Total number of students with submissions',
754: );
1.39 raeburn 755: &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs);
1.13 raeburn 756:
1.68 raeburn 757: $r->print('<br /><form name="thresholdform" method="post" action="/adm/whatsnew">'.
758: &Apache::loncommon::start_data_table().
759: &Apache::loncommon::start_data_table_header_row().
1.70 raeburn 760: '<th>'.&mt('Threshold Name').'</th>'."\n".
761: '<th>'.&mt('Current value').'</th>'."\n".
762: '<th>'.&mt('Change?').'</th>'."\n".
1.68 raeburn 763: &Apache::loncommon::end_data_table_header_row());
1.13 raeburn 764: foreach my $type (@thresholditems) {
1.39 raeburn 765: my $parameter = $env{'request.course.id'}.':threshold_'.$type;
1.13 raeburn 766: # onchange is javascript to automatically check the 'Set' button.
1.113 bisitz 767: my $onchange = 'onfocus="javascript:window.document.forms'.
1.13 raeburn 768: "['thresholdform'].elements['".$parameter."_setparmval']".
769: '.checked=true;"';
1.68 raeburn 770: $r->print(&Apache::loncommon::start_data_table_row()."\n".
771: '<td>'.$threshold_titles{$type}.'</td>'."\n".
772: '<td>'.&Apache::lonhtmlcommon::textbox($parameter.'_value',
1.13 raeburn 773: $threshold{$type},
1.68 raeburn 774: 10,$onchange).'</td>'."\n".
775: '<td>'.
776: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
777: '</td>'."\n".
778: &Apache::loncommon::end_data_table_row());
1.13 raeburn 779: }
1.68 raeburn 780: $r->print(&Apache::loncommon::end_data_table()."\n".
1.87 schafran 781: '<br /><input type="submit" name="threshold" value="'.&mt('Save').'" />
1.36 raeburn 782: <input type="hidden" name="command" value="update" />
1.39 raeburn 783: <input type="hidden" name="refpage" value="'.$refpage.'" />
1.13 raeburn 784: </form>');
1.11 raeburn 785: }
786:
1.36 raeburn 787: #-------------------------------
788: # display_interval_config
789: #
790: # Display the interval setting screen
791: #
792: #-------------------------------
793:
794: sub display_interval_config {
1.77 raeburn 795: my ($r,$refpage,$interval_titles,$context) = @_;
796: my $setting = 'interval';
797: if ($context eq 'oldroles') {
798: $setting = 'oldroleinterval';
799: } elsif ($context eq 'newroles') {
800: $setting = 'newroleinterval';
1.126 raeburn 801: } elsif ($context eq 'sessions') {
802: $setting = 'sessionactivity';
1.77 raeburn 803: }
1.59 albertel 804: my $lctype = lc(&Apache::loncommon::course_type());
1.39 raeburn 805: my $current = &get_current($env{'user.name'},$env{'user.domain'},
1.77 raeburn 806: $env{'request.course.id'},$setting);
807: if ($context eq 'oldroles') {
808: $r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' expired.').'<br />');
809: } elsif ($context eq 'newroles') {
810: $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 811: } elsif ($context eq 'crslogin') {
812: $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 813: } elsif ($context eq 'sessions') {
814: $r->print('<br />'.&mt('Choose the time limit to use to display active user sessions in the '.$lctype.'.').'<br />');
1.77 raeburn 815: } else {
816: $r->print('<br />'.&mt('Choose the time window to use to display resources in the '.$lctype.' with version changes.').'<br />');
817: }
1.36 raeburn 818: unless ($current eq '') {
1.77 raeburn 819: if (ref($interval_titles->{$context}) eq 'HASH') {
820: $r->print(' '.&mt('Current value is "[_1]".','<b>'.
821: $interval_titles->{$context}->{$current}.'</b>').'<br />');
822: }
1.36 raeburn 823: }
1.77 raeburn 824: $r->print('<br />
1.36 raeburn 825: <form method="post" name="intervalswitch" action="/adm/whatsnew">
826: <input type="hidden" name="command" value="newinterval" />
1.77 raeburn 827: <input type="hidden" name="intervaltype" value="'.$context.'" />
828: <input type="hidden" name="refpage" value="'.$refpage.'" />'.
829: &mt('Display:').'
1.36 raeburn 830: <select name="interval">
1.78 bisitz 831: <option value="" selected="selected">'.&mt('Select').'</option>
1.36 raeburn 832: ');
1.77 raeburn 833: if (ref($interval_titles) eq 'HASH') {
834: if (ref($interval_titles->{$context}) eq 'HASH') {
1.126 raeburn 835: my @sorted;
836: if ($context eq 'sessions') {
837: @sorted = sort { $a <=> $b } (keys(%{$interval_titles->{$context}}));
838: push(@sorted,shift(@sorted));
839: } else {
840: @sorted = reverse sort ({$a cmp $b} (keys(%{$interval_titles->{$context}})));
841: }
842: foreach my $key (@sorted) {
1.78 bisitz 843: $r->print('<option value="'.$key.'">'.&mt($interval_titles->{$context}->{$key}).
1.77 raeburn 844: '</option>'."\n");
845: }
846: }
1.36 raeburn 847: }
848: $r->print('</select>
849: <input type="submit" name="display" value="'.
1.87 schafran 850: &mt('Save').'" /></form>');
1.36 raeburn 851: return;
852: }
853:
1.39 raeburn 854: #----------------------------------------------
855: # display_discussion_config
856: #
857: # Display the discussion display setting screen
858: #
859: #----------------------------------------------
860:
861: sub display_discussion_config {
862: my ($r,$refpage) = @_;
863: my $current = &get_current($env{'user.name'},$env{'user.domain'},
864: $env{'request.course.id'},'countunread');
865: if ($current eq '') {
866: $current = 'on';
867: }
1.47 raeburn 868: my %opposite = (
869: 'on' => 'off',
870: 'off' => 'on',
871: );
872: $r->print('<script type="text/javascript">
873: function toggle_countunread(choice) {
874: if (choice == "unchanged") {
875: document.discussionswitch.command.value = "";
876: }
877: document.discussionswitch.submit();
878: }
879: </script>');
1.81 bisitz 880: $r->print('<br />'
1.86 schafran 881: .&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 882: .'<br />'
1.90 hauer 883: .&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 884: .' '
1.116 bisitz 885: .&mt('Currently set to [_1].','<b>'.$current.'</b>')
1.81 bisitz 886: );
1.39 raeburn 887: $r->print('<br /><br />
1.47 raeburn 888: <form method="post" name="discussionswitch" action="/adm/whatsnew">
1.39 raeburn 889: <input type="hidden" name="command" value="newdiscconf" />
890: <input type="hidden" name="refpage" value="'.$refpage.'" />
1.47 raeburn 891: <input type="hidden" name="countunread" value="'.$opposite{$current}.'" />
1.39 raeburn 892: ');
1.47 raeburn 893: $r->print('<br/>
894: <input type="button" name="display" value="'.
1.74 bisitz 895: &mt('Change to [_1]',&mt($opposite{$current})).'"
1.83 raeburn 896: onclick="javascript:toggle_countunread('."'change'".')" />'.
897: (' ' x7).
898: '<input type="button" name="nochange" value="'.
1.47 raeburn 899: &mt("No change").'"
900: onclick="javascript:toggle_countunread('."'unchanged'".')" />
901: </form>');
1.39 raeburn 902: return;
903: }
904:
905: #---------------------------------------------------
906: # courseinit_config
907: #
908: # Set page displayed when course loads after
909: # selecting a role in the course from the roles page.
910: #
911: #---------------------------------------------------
912:
913: sub courseinit_config {
914: my ($r,$refpage,$initpage) = @_;
915: my ($control,$current) = &curr_courseinit();
916: my @chgstate = ('userpref','coursespecific');
917: my @chgentry = ('firstres','whatsnew');
1.59 albertel 918: my $lctype = lc(&Apache::loncommon::course_type());
1.39 raeburn 919: my %lt = &Apache::lonlocal::texthash(
1.56 raeburn 920: 'chwp' => "Choose which page will be displayed when you enter this $lctype after selecting a role.",
1.39 raeburn 921: 'cuva' => 'Current value is determined by',
922: 'anis' => 'and is set to display',
923: 'padc' => 'Page display controlled by',
1.56 raeburn 924: 'chce' => 'Choose '.$lctype.' entry',
1.89 schafran 925: 'moce' => 'Save',
1.39 raeburn 926: );
927: $r->print(<<"END");
928: <br />$lt{'chwp'}
929: <br />$lt{'cuva'}: <b>
930: $$initpage{$control}</b> $lt{'anis'} <b>
931: $$initpage{$current}</b>.<br /><br />
932: <form method="post" name="courseinitswitch" action="/adm/whatsnew">
933: <input type="hidden" name="command" value="newcourseinit" />
934: <input type="hidden" name="refpage" value="$refpage" />
1.56 raeburn 935: $lt{'padc'}:
1.39 raeburn 936: END
937: foreach my $choice (@chgstate) {
1.56 raeburn 938: my $chkstring;
939: if ($choice eq $control) {
940: $chkstring = ' checked="checked" ';
941: }
1.73 raeburn 942: $r->print('<span class="LC_nobreak"><label><input type="radio" name="courseinit_control" value="'.
1.56 raeburn 943: $choice.'"'.$chkstring.'/>'.$$initpage{$choice}.
1.73 raeburn 944: ' </label></span>');
1.39 raeburn 945: }
946: $r->print('<br /><br />'.&mt('If').' '.$$initpage{'coursespecific'}.
1.56 raeburn 947: ' - <br />'.$lt{'chce'}.": \n");
1.39 raeburn 948: foreach my $choice (@chgentry) {
1.56 raeburn 949: my $chkstring;
950: if (($choice eq $current) && ($control eq 'coursespecific')) {
951: $chkstring = ' checked="checked" ';
952: }
1.73 raeburn 953: $r->print('<span class="LC_nobreak"><label><input type="radio" name="courseinit_page" value="'.
1.56 raeburn 954: $choice.'"'.$chkstring.'/>'.$$initpage{$choice}.
1.73 raeburn 955: ' </label></span>');
1.39 raeburn 956: }
957: $r->print('<br /><br /><input type="submit" name="display" value="'.
958: $lt{'moce'}.'" /></form>');
959: return;
960: }
961:
962: sub curr_courseinit {
963: my $current = &get_current($env{'user.name'},$env{'user.domain'},
964: $env{'request.course.id'},'courseinit');
965: my $control;
1.40 raeburn 966: if ($current) {
967: $control = 'coursespecific';
968: } else {
1.39 raeburn 969: $control = 'userpref';
1.40 raeburn 970: my %userenv = &Apache::lonnet::get('environment',
971: ['course_init_display']);
972: if (exists($userenv{'course_init_display'})) {
973: $current = $userenv{'course_init_display'};
974: }
975: unless ($current) {
1.39 raeburn 976: $current = 'whatsnew';
977: }
978: }
979: return ($control,$current);
980: }
981:
1.33 raeburn 982: sub display_launcher {
1.69 raeburn 983: my ($r,$action,$refpage,$checkallowed,$show,$headings,$res_title,
1.68 raeburn 984: $tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered,
985: $newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs,
1.77 raeburn 986: $interval,$countunread,$expired,$expirecount,$activated,$activecount,
1.126 raeburn 987: $crstype,$itemserror,$loggedin,$logincount,$sessions,$sessioncount,
988: $classlist) = @_;
1.33 raeburn 989:
990: if ($$checkallowed{$action}) {
1.106 raeburn 991: &start_box($r,$show,$headings,$action,$refpage);
1.33 raeburn 992: if ($$show{$action}) {
993: if ($action eq 'handgrading') { # UNGRADED ITEMS
1.84 raeburn 994: &display_handgrade($r,$tograde,$ungraded,$itemserror);
1.33 raeburn 995: } elsif ($action eq 'haserrors') { # BOMBS
1.84 raeburn 996: &display_haserrors($r,$bombs,$bombed,$res_title,$itemserror);
1.33 raeburn 997: } elsif ($action eq 'versionchanges') { # VERSION CHANGES
1.84 raeburn 998: &display_versionchanges($r,$changed,$res_title,$interval->{'versions'},$itemserror);
1.33 raeburn 999: } elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS
1.39 raeburn 1000: &display_abovethreshold($r,$refpage,$warnings,$triggered,
1.119 raeburn 1001: $res_title,$itemserror,$checkallowed);
1.33 raeburn 1002: } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION
1003: &display_coursediscussion($r,$newdiscussions,$unread,
1.84 raeburn 1004: $countunread,$res_title,$itemserror);
1.33 raeburn 1005: } elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES
1.68 raeburn 1006: &display_coursenormalmail($r,$msgcount,$newmsgs);
1.33 raeburn 1007: } elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES
1.68 raeburn 1008: &display_coursecritmail($r,$critmsgcount,$critmsgs);
1.77 raeburn 1009: } elsif ($action eq 'newroles') { # ACTIVATED ROLES
1010: &display_rolechanges($r,$activecount,$activated,$interval->{'newroles'},
1.114 raeburn 1011: $crstype,$classlist);
1.77 raeburn 1012: } elsif ($action eq 'oldroles') { # EXPIRED ROLES
1013: &display_rolechanges($r,$expirecount,$expired,$interval->{'oldroles'},
1.114 raeburn 1014: $crstype,$classlist);
1.106 raeburn 1015: } elsif ($action eq 'crslogin') { #LAST LOGIN
1.126 raeburn 1016: &display_activity($r,'logins',$logincount,$loggedin,$interval->{'crslogin'},
1.114 raeburn 1017: $crstype,$classlist);
1.126 raeburn 1018: } elsif ($action eq 'sessions') { #ACTIVE SESSIONS
1019: &display_activity($r,'sessions',$sessioncount,$sessions,$interval->{'sessions'},
1020: $crstype,$classlist);
1.33 raeburn 1021: }
1022: }
1023: &end_box($r);
1024: }
1025: return;
1026: }
1027:
1.1 raeburn 1028: sub getitems {
1.33 raeburn 1029: my ($unread,$ungraded,$bombed,$triggered,$changed,$newdiscussions,
1.68 raeburn 1030: $tograde,$bombs,$warnings,$threshold,$cdom,$crs,$res_title,$show,
1.119 raeburn 1031: $starttime,$countunread,$checkallowed) = @_;
1.1 raeburn 1032: my $navmap = Apache::lonnavmaps::navmap->new();
1.84 raeburn 1033: if (!defined($navmap)) {
1034: 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>';
1035: return $itemserror;
1036: }
1.26 albertel 1037: # force retrieve Resource to seed the part id cache we'll need it later
1.37 raeburn 1038: my @allres=$navmap->retrieveResources(undef,
1039: sub {if ($_[0]->is_problem) { $_[0]->parts();} return 1;});
1.33 raeburn 1040: my %resourcetracker;
1.37 raeburn 1041: my $discussiontime;
1.33 raeburn 1042:
1043: # Resource version changes
1044: if ($$show{'versionchanges'}) {
1045: &checkversions($cdom,$crs,$navmap,$changed,$starttime);
1046: }
1047:
1048: if ($$show{'abovethreshold'}) {
1049: %resourcetracker = &Apache::lonnet::dump('nohist_resourcetracker',
1050: $cdom,$crs);
1051: }
1.1 raeburn 1052:
1053: foreach my $resource (@allres) {
1054: my $result = '';
1055: my $applies = 0;
1056: my $symb = $resource->symb();
1.33 raeburn 1057: %{$$bombed{$symb}} = ();
1.1 raeburn 1058: %{$$ungraded{$symb}} = ();
1.11 raeburn 1059: %{$$triggered{$symb}} = ();
1060: $$triggered{$symb}{numparts} = 0;
1.66 raeburn 1061: if ($resource->encrypted()) {
1062: $$triggered{$symb}{'enclink'} = $resource->link();
1063: $$triggered{$symb}{'encsymb'} = $resource->shown_symb();
1064: }
1.1 raeburn 1065: my $title = $resource->compTitle();
1.16 raeburn 1066: $$res_title{$symb} = $title;
1.8 albertel 1067: my $ressymb = $resource->wrap_symb();
1.33 raeburn 1068:
1.37 raeburn 1069: # Check if there are unread discussion postings
1.33 raeburn 1070: if ($$show{'coursediscussion'}) {
1.51 albertel 1071: &check_discussions($resource,$symb,$ressymb,$title,
1072: $newdiscussions,$unread,$countunread);
1.33 raeburn 1073: }
1.1 raeburn 1074:
1075: # Check for ungraded problems
1076: if ($resource->is_problem()) {
1.33 raeburn 1077: if ($$show{'handgrading'}) {
1078: &check_handgraded($resource,$symb,$title,$cdom,$crs,$ungraded,
1079: $tograde);
1080: }
1.1 raeburn 1081: }
1082:
1083: # Check for bombs
1.33 raeburn 1084: if ($$show{'haserrors'}) {
1085: &check_bombed($resource,$symb,$title,$bombs,$bombed);
1086: }
1087:
1088: # Maxtries and degree of difficulty for problem parts, unless handgradeable
1089: if ($$show{'abovethreshold'}) {
1.61 albertel 1090: &check_thresholds($resource,$symb,\%resourcetracker,
1.119 raeburn 1091: $triggered,$threshold,$warnings,
1092: $checkallowed);
1.33 raeburn 1093: }
1094: }
1.84 raeburn 1095: return;
1.33 raeburn 1096: }
1097:
1098: sub check_discussions {
1.51 albertel 1099: my ($resource,$symb,$ressymb,$title,$newdiscussions,$unread,
1100: $countunread) = @_;
1101:
1102: if (!$resource->hasDiscussion()) { return; }
1.37 raeburn 1103:
1.51 albertel 1104: %{$$unread{$ressymb}} = ();
1105: $$unread{$ressymb}{'title'} = $title;
1106: $$unread{$ressymb}{'symb'} = $symb;
1.66 raeburn 1107: if ($resource->encrypted()) {
1108: $$unread{$ressymb}{'enclink'} = $resource->link();
1109: $$unread{$ressymb}{'encsymb'} = $resource->shown_symb();
1110: }
1.51 albertel 1111: push(@{$newdiscussions}, $ressymb);
1112:
1113: $$unread{$ressymb}{'lastpost'} = $resource->last_post_time();
1114:
1115: if ($countunread eq 'on') {
1.67 raeburn 1116: $$unread{$ressymb}{'unreadcount'} =
1117: $resource->discussion_info('unread');
1.33 raeburn 1118: }
1119: }
1120:
1121: sub check_handgraded {
1122: my ($resource,$symb,$title,$cdom,$cnum,$ungraded,$tograde) = @_;
1123: if ($resource->is_problem()) {
1124: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
1125: my $partlist=$resource->parts();
1126: my $handgradeable;
1127: foreach my $part (@$partlist) {
1.31 raeburn 1128: if ($resource->handgrade($part) eq 'yes') {
1.33 raeburn 1129: $handgradeable=1; last;
1.31 raeburn 1130: }
1.33 raeburn 1131: }
1132: if ($handgradeable) {
1.35 raeburn 1133: my @ungraded = &Apache::bridgetask::get_queue_symb_status(
1.33 raeburn 1134: 'gradingqueue',$symb,$cdom,$cnum);
1135: if (@ungraded > 0) {
1136: $$ungraded{$symb}{count} = scalar(@ungraded);
1137: $$ungraded{$symb}{title} = $title;
1.66 raeburn 1138: if ($resource->encrypted()) {
1139: $$ungraded{$symb}{'enclink'} = $resource->link();
1140: $$ungraded{$symb}{'encsymb'} = $resource->shown_symb();
1141: }
1142: push(@{$tograde},$symb);
1.11 raeburn 1143: }
1144: }
1.33 raeburn 1145: }
1146: }
1147:
1148: sub check_bombed {
1149: my ($resource,$symb,$title,$bombs,$bombed) = @_;
1150: if ($resource->getErrors()) {
1151: my $errors = $resource->getErrors();
1152: $errors =~ s/^,//;
1153: my @bombs = split(/,/, $errors);
1154: my $errorcount = scalar(@bombs);
1155: my $errorlink = '<a href="/adm/email?display='.
1.55 www 1156: &escape($bombs[0]).'">'.
1.33 raeburn 1157: $title.'</a>';
1158: $$bombed{$symb}{errorcount} = $errorcount;
1159: $$bombed{$symb}{errorlink} = $errorlink;
1160: push(@{$bombs}, $symb);
1161: }
1162: }
1163:
1164: sub check_thresholds {
1.119 raeburn 1165: my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings,
1166: $checkallowed) = @_;
1.33 raeburn 1167: # Compile maxtries and degree of difficulty for problem parts, unless handgradeable
1168: my @parts = @{$resource->parts()};
1169: my %stats;
1170: my %lastreset = ();
1171: my $warning = 0;
1172: foreach my $part (@parts) {
1173: if ($resource->handgrade($part) eq 'yes') {
1174: next;
1175: }
1.101 raeburn 1176: if ($resource->is_anonsurvey($part)) {
1177: next;
1178: }
1.48 raeburn 1179: if ($resource->is_survey($part)) {
1180: next;
1181: }
1.33 raeburn 1182: %{$stats{$part}} = ();
1183: my ($attempts,$users,$corrects,$degdiff,$av_attempts);
1184: if (exists($$resourcetracker{$symb."\0".$part."\0attempts"})) {
1185: $attempts = $$resourcetracker{$symb."\0".$part."\0attempts"};
1186: }
1187: if (exists($$resourcetracker{$symb."\0".$part."\0users"})) {
1188: $users = $$resourcetracker{$symb."\0".$part."\0users"};
1189: }
1190: if (exists($$resourcetracker{$symb."\0".$part."\0correct"})) {
1191: $corrects = $$resourcetracker{$symb."\0".$part."\0correct"};
1192: }
1193: if ($attempts > 0) {
1194: $degdiff = 1 - ($corrects/$attempts);
1195: $degdiff = sprintf("%.2f",$degdiff);
1196: }
1197: if ($users > 0) {
1198: $av_attempts = $attempts/$users;
1199: $av_attempts = sprintf("%.2f",$av_attempts);
1200: }
1.105 www 1201: &Apache::lonnet::statslog($symb,$part,$users,$av_attempts,$degdiff);
1.33 raeburn 1202: if ((($degdiff ne '' && $degdiff >= $$threshold{'degdiff'}) || ($av_attempts ne '' && $av_attempts >= $$threshold{'av_attempts'})) && ($users >= $$threshold{'numstudents'})) {
1203: $stats{$part}{degdiff} = $degdiff;
1204: $stats{$part}{attempts} = $av_attempts;
1205: $stats{$part}{users} = $users;
1206: $lastreset{$part} = $$resourcetracker{$symb."\0".$part."\0resettime"};
1207: if ($lastreset{$part}) {
1208: $lastreset{$part} = &Apache::lonnavmaps::timeToHumanString($lastreset{$part});
1.11 raeburn 1209: }
1.33 raeburn 1210: $warning = 1;
1211: }
1212: }
1213: if ($warning) {
1214: $$triggered{$symb}{title} = $resource->title;
1.62 raeburn 1215: my $partcount = 0;
1216: @{$$triggered{$symb}{text}} = ();
1.33 raeburn 1217: foreach my $part (@parts) {
1218: if (exists($stats{$part}{users})) {
1.55 www 1219: my $resetname = 'reset_'.&escape($symb."\0".$part);
1220: my $resettitle = 'title_'.&escape($symb."\0".$part);
1.33 raeburn 1221: if (@parts > 1) {
1.62 raeburn 1222: $$triggered{$symb}{text}[$partcount] = '
1.74 bisitz 1223: <td>'.&mt('part - ').$part.'</td>';
1.33 raeburn 1224: } else {
1.62 raeburn 1225: $$triggered{$symb}{text}[$partcount] = '
1.74 bisitz 1226: <td>'.&mt('single part').'</td>';
1.11 raeburn 1227: }
1.62 raeburn 1228: $$triggered{$symb}{text}[$partcount] .= '
1.61 albertel 1229: <td>'.$stats{$part}{users}.'</td>
1230: <td>'.$stats{$part}{attempts}.'</td>
1231: <td>'.$stats{$part}{degdiff}.'</td>
1.119 raeburn 1232: <td>'.$lastreset{$part}.'</td>';
1.120 raeburn 1233: if ($checkallowed->{'resetcounters'}) {
1234: $$triggered{$symb}{text}[$partcount] .=
1.119 raeburn 1235: '<td><input type="checkbox" name="'.$resetname.'" />'.
1236: '<input type="hidden" name="'.$resettitle.'" value="'.&escape($$triggered{$symb}{title}).'" /></td>';
1237: }
1.62 raeburn 1238: $partcount ++;
1.11 raeburn 1239: }
1.62 raeburn 1240: $$triggered{$symb}{numparts} = $partcount;
1.11 raeburn 1241: }
1.33 raeburn 1242: push(@{$warnings},$symb);
1.1 raeburn 1243: }
1244: }
1245:
1.33 raeburn 1246:
1.13 raeburn 1247: sub get_curr_thresholds {
1.39 raeburn 1248: my ($threshold,$uname,$udom,$cid,$cdom,$crs) = @_;
1.64 banghart 1249: # set default values
1250: %$threshold = (av_attempts => 2,
1251: degdiff => 0.5,
1252: numstudents => 2
1253: );
1.39 raeburn 1254: my %thresholdsettings = &Apache::lonnet::dump('nohist_whatsnew',$udom,
1255: $uname,$cid.':threshold');
1256: my $thresholdcount = 0;
1257: my ($tmp) = %thresholdsettings;
1.40 raeburn 1258: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.117 raeburn 1259: foreach my $item (keys(%{$threshold})) {
1.39 raeburn 1260: if (exists($thresholdsettings{$cid.':threshold_'.$item})) {
1261: $$threshold{$item} =
1262: $thresholdsettings{$cid.':threshold_'.$item};
1263: $thresholdcount ++;
1264: }
1265: }
1.13 raeburn 1266: }
1.39 raeburn 1267: if ($thresholdcount == 3) {
1268: return;
1.13 raeburn 1269: }
1.39 raeburn 1270: my %coursesettings = &Apache::lonnet::dump('environment',
1271: $cdom,$crs,'internal.threshold');
1272: my ($temp) = %coursesettings;
1.40 raeburn 1273: unless ($temp =~ /^(con_lost|error|no_such_host)/i) {
1.117 raeburn 1274: foreach my $item (keys(%{$threshold})) {
1.39 raeburn 1275: unless (exists($thresholdsettings{$cid.':threshold_'.$item})) {
1276: if (exists($coursesettings{'internal.threshold_'.$item})) {
1277: $$threshold{$item} =
1278: $coursesettings{'internal.threshold_'.$item};
1279: }
1280: }
1281: }
1.13 raeburn 1282: }
1.39 raeburn 1283: return;
1.13 raeburn 1284: }
1285:
1.39 raeburn 1286: sub get_current {
1287: my ($uname,$udom,$cid,$caller) = @_;
1288: my $currvalue;
1289: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid.
1290: ':'.$caller);
1.36 raeburn 1291: my ($tmp) = %settings;
1.40 raeburn 1292: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 1293: $currvalue = $settings{$cid.':'.$caller};
1.36 raeburn 1294: }
1.39 raeburn 1295: return $currvalue;
1.36 raeburn 1296: }
1297:
1.13 raeburn 1298: sub process_reset {
1.119 raeburn 1299: my ($dom,$crs,$checkallowed) = @_;
1300: if (!$checkallowed->{'resetcounters'}) {
1.123 raeburn 1301: return '<b>'.&mt('You do not have the required privileges to reset counters').
1.120 raeburn 1302: '</b><br />';
1.119 raeburn 1303: }
1.39 raeburn 1304: my $result = '<b>'.&mt('Counters reset for following problems (and parts):').
1305: '</b><br />';
1.13 raeburn 1306: my @agg_types = ('attempts','users','correct');
1.39 raeburn 1307: my %agg_titles = &Apache::lonlocal::texthash (
1.13 raeburn 1308: attempts => 'Number of submissions',
1309: users => 'Students with submissions',
1310: correct => 'Number of correct submissions',
1311: );
1312: my @resets = ();
1313: my %titles = ();
1.17 albertel 1314: foreach my $key (keys(%env)) {
1.13 raeburn 1315: next if ($key !~ /^form\.reset_(.+)$/);
1.55 www 1316: my $title = &unescape($env{'form.title_'.$1});
1317: my $reset_item = &unescape($1);
1.13 raeburn 1318: my %curr_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
1319: my %aggregates = ();
1.17 albertel 1320: my ($symb,$part) = split(/\0/,$reset_item);
1.13 raeburn 1321: foreach my $type (@agg_types) {
1322: $aggregates{$reset_item."\0".$type} = 0;
1323: }
1.17 albertel 1324: $aggregates{$reset_item."\0".'resettime'} = time;
1.13 raeburn 1325: my $putresult = &Apache::lonnet::put('nohist_resourcetracker',\%aggregates,
1326: $dom,$crs);
1327: if ($putresult eq 'ok') {
1328: $result .= $title.' -part '.$part.': ';
1329: my %new_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
1330: foreach my $type (@agg_types) {
1331: $result .= $agg_titles{$type}.' = '.$new_aggregates{$reset_item."\0".$type}.'; ';
1332: }
1333: $result =~ s/; $//;
1334: $result .= '<br />';
1335: } else {
1.14 albertel 1336: $result = $title.' -part '.$part.': '.&mt('Unable to reset counters to zero due to [_1]',$putresult).'.<br />'."\n";
1.13 raeburn 1337: }
1338: }
1339: return $result;
1340: }
1341:
1342: sub process_update {
1.39 raeburn 1343: my ($uname,$udom,$threshold_titles) = @_;
1.99 wenzelju 1344: my $setoutput = '<b>'.&mt('Changes to threshold(s) for problem tracking:').'</b><br/><br />';
1.117 raeburn 1345: foreach my $key (keys(%env)) {
1346: my $name;
1347: if ($key =~/^form\.(.+)\_setparmval$/) {
1348: $name = $1;
1349: } else {
1350: next;
1351: }
1.13 raeburn 1352: my $value = $env{'form.'.$name.'_value'};
1.65 banghart 1353: if ($name && defined($value) && ($value ne '')) {
1.39 raeburn 1354: my $put_result = &Apache::lonnet::put('nohist_whatsnew',
1355: {$name=>$value},$udom,$uname);
1.13 raeburn 1356:
1.39 raeburn 1357: my ($shortname) = ($name =~ /^\Q$env{'request.course.id'}\E:threshold_(.+)$/);
1.13 raeburn 1358: if ($put_result eq 'ok') {
1.99 wenzelju 1359: $setoutput.= &Apache::lonhtmlcommon::confirm_success(&mt('Set threshold for [_1] to [_2]',
1.14 albertel 1360: '<b>'.$$threshold_titles{$shortname}.'</b>',
1.99 wenzelju 1361: '<b>'.$value.'</b>').'<br />');
1.14 albertel 1362: } else {
1.99 wenzelju 1363: $setoutput.= &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set threshold for [_1] to [_2] due to [_3].',
1.14 albertel 1364: '<b>'.$name.'</b>','<b>'.$value.'</b>',
1.99 wenzelju 1365: '<tt>'.$put_result.'</tt>').'<br />',1);
1.13 raeburn 1366: }
1367: }
1368: }
1.99 wenzelju 1369: return &Apache::loncommon::confirmwrapper($setoutput);
1.13 raeburn 1370: }
1371:
1.33 raeburn 1372: sub getnormalmail {
1373: my ($newmsgs) = @_;
1.118 raeburn 1374: # Check for unread messages in user's INBOX (which were sent in context of current course).
1.1 raeburn 1375: my $msgcount = 0;
1.118 raeburn 1376: my @messages = &Apache::lonnet::getkeys('nohist_email');
1377: return $msgcount if (!@messages);
1378: my %emailstatus = &Apache::lonnet::dump('email_status');
1379: foreach my $msgid (sort(@messages)) {
1380: if ((!$emailstatus{$msgid}) || ($emailstatus{$msgid} eq 'new')) {
1381: my $skipstatus;
1382: if ($emailstatus{$msgid} eq 'new') {
1383: $skipstatus = 1;
1384: }
1.124 raeburn 1385: my $esc_msgid = &escape($msgid);
1.118 raeburn 1386: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1.125 raeburn 1387: &Apache::lonmsg::unpackmsgid($esc_msgid,undef,$skipstatus,undef,
1.118 raeburn 1388: $env{'request.course.id'});
1389: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1390: if (defined($sendtime) && $sendtime!~/error/) {
1391: if (($emailstatus{$msgid} eq 'new') || ($status eq 'new')) {
1392: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
1393: $msgcount ++;
1394: if ($shortsubj eq '') {
1395: $shortsubj = &mt('No subject');
1396: }
1397: push(@{$newmsgs}, {
1.124 raeburn 1398: msgid => $esc_msgid,
1.118 raeburn 1399: sendtime => $sendtime,
1400: shortsub => $shortsubj,
1401: from => $fromname,
1402: fromdom => $fromdom
1403: });
1.10 raeburn 1404: }
1.1 raeburn 1405: }
1406: }
1407: }
1408: }
1.33 raeburn 1409: return $msgcount;
1410: }
1.1 raeburn 1411:
1.33 raeburn 1412: sub getcritmail {
1413: my ($critmsgs) = @_;
1.118 raeburn 1414: # Check for critical messages which were sent in context of current course.
1.1 raeburn 1415: my %what=&Apache::lonnet::dump('critical');
1416: my $result = '';
1417: my $critmsgcount = 0;
1.3 albertel 1418: foreach my $msgid (sort(keys(%what))) {
1.125 raeburn 1419: my $esc_msgid = &escape($msgid);
1.10 raeburn 1420: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1.125 raeburn 1421: &Apache::lonmsg::unpackmsgid($esc_msgid,undef,1,undef,
1.118 raeburn 1422: $env{'request.course.id'});
1.10 raeburn 1423: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 1424: if (defined($sendtime) && $sendtime!~/error/) {
1.93 droeschl 1425: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
1.1 raeburn 1426: $critmsgcount ++;
1.10 raeburn 1427: if ($shortsubj eq '') {
1428: $shortsubj = &mt('No subject');
1429: }
1.1 raeburn 1430: push(@{$critmsgs}, {
1.125 raeburn 1431: msgid => $esc_msgid,
1.1 raeburn 1432: sendtime => $sendtime,
1.10 raeburn 1433: shortsub => $shortsubj,
1.1 raeburn 1434: from => $fromname,
1435: fromdom => $fromdom
1436: });
1437: }
1438: }
1439: }
1.33 raeburn 1440: return $critmsgcount;
1441: }
1442:
1.77 raeburn 1443: sub getexpired {
1.114 raeburn 1444: my ($rolechgs,$rolechgtime,$status,$classlist) = @_;
1445: my $expirecount = &getrolechanges($rolechgs,$rolechgtime,$status,$classlist);
1.77 raeburn 1446: return $expirecount;
1447: }
1448:
1449: sub getactivated {
1.114 raeburn 1450: my ($rolechgs,$rolechgtime,$status,$classlist) = @_;
1.77 raeburn 1451: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1452: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1453: my $now = time();
1454: my $context = 'course';
1455: my ($permission,$allowed) =
1456: &Apache::lonuserutils::get_permission($context);
1457: my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
1458: my %changes=&Apache::lonnet::dump('nohist_rolelog',$cdom,$cnum);
1459: my (%stucounted,%advcounted);
1460: my $activatedcount = 0;
1461: if (keys(%changes) > 0) {
1.111 raeburn 1462: foreach my $chg (keys(%changes)) {
1.77 raeburn 1463: if (ref($changes{$chg}) eq 'HASH') {
1.112 raeburn 1464: next if ($changes{$chg}{'delflag'});
1.111 raeburn 1465: if ($rolechgtime > 0) {
1.112 raeburn 1466: next if ($changes{$chg}{'exe_time'} < $rolechgtime);
1.111 raeburn 1467: }
1468: if ($changes{$chg}{'exe_time'}) {
1469: my $timestamp = $changes{$chg}{'exe_time'};
1.77 raeburn 1470: if (ref($changes{$chg}{'logentry'}) eq 'HASH') {
1.112 raeburn 1471: my $end = $changes{$chg}{'logentry'}{'end'};
1472: next if ($end && $end <= $now);
1.77 raeburn 1473: my $start = $changes{$chg}{'logentry'}{'start'};
1.112 raeburn 1474: next if ($start >= $timestamp);
1.77 raeburn 1475: my $section = $changes{$chg}{'logentry'}{'section'};
1.112 raeburn 1476: if (($viewablesec ne '') && ($section ne '')) {
1477: next if ($viewablesec ne $section);
1478: }
1.77 raeburn 1479: my $role = $changes{$chg}{'logentry'}{'role'};
1480: my $uname = $changes{$chg}{'uname'};
1481: my $udom = $changes{$chg}{'udom'};
1482: if ($role eq 'st') {
1483: $stucounted{$uname.':'.$udom.':'.$section} = $start.':'.$end;
1484: } else {
1485: $advcounted{$uname.':'.$udom.':'.$role.':'.$section} = $start.':'.$end;
1486: }
1487: my %chginfo = (
1488: 'section' => $section,
1489: 'uname' => $uname,
1490: 'udom' => $udom,
1491: 'role' => $role,
1492: 'status' => $status,
1493: );
1494: $activatedcount ++;
1495: push (@{$rolechgs->{$timestamp}},\%chginfo);
1496: }
1497: }
1498: }
1499: }
1500: }
1.114 raeburn 1501: $activatedcount += &getrolechanges($rolechgs,$rolechgtime,$status,$classlist,\%stucounted,
1502: \%advcounted);
1.77 raeburn 1503: return $activatedcount;
1504: }
1505:
1506: sub getrolechanges {
1.114 raeburn 1507: my ($rolechgs,$rolechgtime,$status,$classlist,$stucountref,$advcountref) = @_;
1.77 raeburn 1508: my (%stucounted,%advcounted);
1509: if (ref($stucountref) eq 'HASH') {
1510: %stucounted = %{$stucountref};
1511: }
1512: if (ref($advcountref) eq 'HASH') {
1513: %advcounted = %{$advcountref};
1514: }
1515: my $withsec = 1;
1516: my $hidepriv = 1;
1517: my $context = 'course';
1518: my @statuses = ($status);
1519: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1520: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1521: my $now = time();
1522: my ($permission,$allowed) =
1523: &Apache::lonuserutils::get_permission($context);
1524: my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
1525: my $secidx = &Apache::loncoursedata::CL_SECTION();
1526: my $startidx = &Apache::loncoursedata::CL_START();
1527: my $endidx = &Apache::loncoursedata::CL_END();
1528: my $rolechgcount = 0;
1.114 raeburn 1529: if (ref($classlist) eq 'HASH') {
1530: foreach my $key (keys(%{$classlist})) {
1531: my ($userstatus,$eventtime);
1532: my $student = $classlist->{$key};
1533: if (ref($student) eq 'ARRAY') {
1534: my $start = $student->[$startidx];
1535: my $end = $student->[$endidx];
1536: my $sec = $student->[$secidx];
1537: my ($stuname,$studom) = split(/:/,$key);
1538: if ($status eq 'active') {
1539: if (exists($stucounted{$key.':'.$sec})) {
1540: next;
1541: }
1.77 raeburn 1542: }
1.114 raeburn 1543: if (($end == 0) || ($end > $start)) {
1544: if ($start <= $now) {
1545: if ($end && $end < $now) {
1546: if ($rolechgtime > 0) {
1547: if ($end > $rolechgtime) {
1548: $userstatus = 'previous';
1549: }
1550: } else {
1.77 raeburn 1551: $userstatus = 'previous';
1552: }
1553: } else {
1.114 raeburn 1554: if ($rolechgtime > 0) {
1555: if ($start >= $rolechgtime) {
1556: $userstatus = 'active';
1557: }
1558: } else {
1.77 raeburn 1559: $userstatus = 'active';
1560: }
1561: }
1562: }
1563: }
1.114 raeburn 1564: next if ($userstatus ne $status);
1565: if ($status eq 'active') {
1566: $eventtime = $start;
1567: } else {
1568: $eventtime = $end;
1569: }
1570: if (($viewablesec ne '') && ($sec ne '')) {
1571: next if ($viewablesec ne $sec);
1572: }
1573: my %chginfo = (
1574: 'section' => $sec,
1575: 'uname' => $stuname,
1576: 'udom' => $studom,
1577: 'role' => 'st',
1578: 'status' => $userstatus,
1579: );
1580: $rolechgcount ++;
1581: push(@{$rolechgs->{$eventtime}},\%chginfo);
1.77 raeburn 1582: }
1583: }
1584: }
1585: my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
1586: \@statuses,undef,undef,$withsec,$hidepriv);
1587: foreach my $item (keys(%advrolehash)) {
1588: my ($userstatus,$eventtime);
1589: my ($uname,$udom,$role,$section) = split(/:/,$item,-1);
1590: my ($start,$end) = split(/:/,$advrolehash{$item});
1591: if ($start eq '-1' && $end eq '-1') {
1592: next;
1593: } else {
1594: if ($status eq 'active') {
1595: if (exists($advcounted{$item})) {
1596: next;
1597: }
1598: }
1599: if (($end == 0) || ($end > $start)) {
1600: if ($start <= $now) {
1601: if ($end && $end < $now) {
1602: if ($rolechgtime > 0) {
1603: if ($end > $rolechgtime) {
1604: $userstatus = 'previous';
1605: }
1606: } else {
1607: $userstatus = 'previous';
1608: }
1609: } else {
1610: if ($rolechgtime > 0) {
1611: if ($start >= $rolechgtime) {
1612: $userstatus = 'active';
1613: }
1614: } else {
1615: $userstatus = 'active';
1616: }
1617: }
1618: }
1619: }
1620: next if ($userstatus ne $status);
1621: if ($status eq 'active') {
1622: $eventtime = $start;
1623: } else {
1624: $eventtime = $end;
1625: }
1626: }
1627: if (($viewablesec ne '') && ($section ne '')) {
1628: next if ($viewablesec ne $section);
1629: }
1630: my %chginfo = (
1631: 'section' => $section,
1632: 'uname' => $uname,
1633: 'udom' => $udom,
1634: 'role' => $role,
1635: 'status' => $userstatus,
1636: );
1637: $rolechgcount ++;
1638: push (@{$rolechgs->{$eventtime}},\%chginfo);
1639: }
1640: return $rolechgcount;
1641: }
1.33 raeburn 1642:
1.106 raeburn 1643: sub getloggedin {
1644: my ($cdom,$crs,$lastlogins,$starttime) = @_;
1645: my $context = 'course';
1646: my ($permission,$allowed) =
1647: &Apache::lonuserutils::get_permission($context);
1648: my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
1649: my %crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$crs);
1650: my $logincount = 0;
1651: my ($tmp) = keys(%crslogins);
1652: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1653: if (keys(%crslogins) > 0) {
1654: foreach my $key (keys(%crslogins)) {
1655: my ($uname,$udom,$section,$role) = split(/:/,$key);
1656: my $eventtime = $crslogins{$key};
1657: if ($eventtime > $starttime) {
1658: if (($viewablesec ne '') && ($section ne '')) {
1659: next if ($viewablesec ne $section);
1660: }
1661: my %chginfo = (
1662: 'section' => $section,
1663: 'uname' => $uname,
1664: 'udom' => $udom,
1665: 'role' => $role,
1666: );
1667: $logincount ++;
1668: push (@{$lastlogins->{$eventtime}},\%chginfo);
1669: }
1670: }
1671: }
1672: }
1673: return $logincount;
1674: }
1675:
1.126 raeburn 1676: sub getsessions {
1677: my ($cdom,$cnum,$sessions,$lastactive,$classlist) = @_;
1678: my $context = 'course';
1679: my ($permission,$allowed) =
1680: &Apache::lonuserutils::get_permission($context);
1681: my %crs_sessions = &Apache::lonnet::get_course_sessions($cnum,$cdom,$lastactive);
1682: my $sessioncount = 0;
1683: if (keys(%crs_sessions) > 0) {
1684: if (ref($classlist) eq 'HASH') {
1685: my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
1686: my $secidx = &Apache::loncoursedata::CL_SECTION();
1687: my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'_'.$cnum,1);
1688: my %personnel;
1689: foreach my $role (sort(keys(%coursepersonnel))) {
1690: my ($rolecode,$section);
1691: if ($role =~ /:/) {
1692: ($rolecode,$section) = split(/:/,$role);
1693: } else {
1694: $rolecode = $role;
1695: }
1696: if ($viewablesec ne '') {
1697: next if ($viewablesec ne $section);
1698: }
1699: foreach my $user (split(/\,/,$coursepersonnel{$role})) {
1700: push(@{$personnel{$user}{$rolecode}},$section);
1701: }
1702: }
1703: foreach my $key (keys(%crs_sessions)) {
1704: if (exists($classlist->{$key})) {
1705: my $student = $classlist->{$key};
1706: my $section = $student->[$secidx];
1707: my $lastaccess = $crs_sessions{$key};
1708: if ($viewablesec ne '') {
1709: next if ($viewablesec ne $section);
1710: }
1711: my ($stuname,$studom) = split(/:/,$key);
1712: my %info = (
1713: 'section' => $section,
1714: 'role' => 'st',
1715: 'uname' => $stuname,
1716: 'udom' => $studom,
1717: );
1718: $sessioncount ++;
1719: push(@{$sessions->{$lastaccess}},\%info);
1720: } elsif (exists($personnel{$key})) {
1721: my $lastaccess = $crs_sessions{$key};
1722: my ($uname,$udom) = split(/:/,$key);
1723: if (ref($personnel{$key}) eq 'HASH') {
1724: my ($showrole,$showsec);
1725: foreach my $possrole ('cc','co','in','ta','ep','ad','st') {
1726: if (exists($personnel{$key}{$possrole})) {
1727: $showrole = $possrole;
1728: $showsec = join(', ',@{$personnel{$key}{$possrole}});
1729: last;
1730: }
1731: }
1732: my %info = (
1733: 'section' => $showsec,
1734: 'role' => $showrole,
1735: 'uname' => $uname,
1736: 'udom' => $udom,
1737: );
1738: $sessioncount ++;
1739: push(@{$sessions->{$lastaccess}},\%info);
1740: }
1741: }
1742: }
1743: }
1744: }
1745: return $sessioncount;
1746: }
1747:
1.33 raeburn 1748: sub checkversions {
1749: my ($cdom,$crs,$navmap,$changed,$starttime) = @_;
1750: my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs);
1751: my ($tmp) = keys(%changes);
1.40 raeburn 1752: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 1753: if (keys(%changes) > 0) {
1754: foreach my $key (sort(keys(%changes))) {
1755: if ($changes{$key} > $starttime) {
1756: my $version;
1757: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
1758: my $currentversion=&Apache::lonnet::getversion($key);
1759: my $revdate =
1760: &Apache::lonnet::metadata($root.'.'.$extension,
1761: 'lastrevisiondate');
1762: $revdate = &Apache::lonlocal::locallocaltime($revdate);
1763: my $linkurl=&Apache::lonnet::clutter($key);
1.104 bisitz 1764: my $usedversion=$navmap->usedVersion($linkurl);
1.33 raeburn 1765: my @resources = $navmap->getResourceByUrl($linkurl,1);
1766: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1767: $version = $usedversion;
1768: } else {
1769: $version = $currentversion;
1770: }
1771: foreach my $res (@resources) {
1.35 raeburn 1772: if (ref($res) eq 'Apache::lonnavmaps::resource') {
1773: my $symb = $res->symb();
1774: %{$$changed{$symb}} = (
1.33 raeburn 1775: current => $currentversion,
1776: version => $version,
1777: revdate => $revdate,
1.35 raeburn 1778: );
1779: }
1.33 raeburn 1780: }
1781: }
1782: }
1783: }
1784: }
1785: return;
1786: }
1787:
1788: sub display_handgrade {
1.84 raeburn 1789: my ($r,$tograde,$ungraded,$itemserror) = @_;
1.33 raeburn 1790: my %lt = &Apache::lonlocal::texthash(
1791: 'prna' => 'Problem Name',
1792: 'nmun' => 'Number ungraded',
1793: 'nopr' => 'No problems require handgrading',
1794: );
1795: if (@{$tograde} > 0) {
1.68 raeburn 1796: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1797: $lt{'prna'}.'</td><td class="LC_right_item">'.
1798: $lt{'nmun'}.'</td></tr>');
1.33 raeburn 1799: my $rowNum = 0;
1800: foreach my $res (@{$tograde}) {
1.68 raeburn 1801: $rowNum ++;
1802: my $css_class = $rowNum%2?' class="LC_odd_row"':'';
1.102 www 1803: my $linkurl='/adm/grades';
1.66 raeburn 1804: if ($$ungraded{$res}{'enclink'}) {
1.102 www 1805: $linkurl.='?symb='.$$ungraded{$res}{'encsymb'};
1806: } else {
1807: $linkurl.='?symb='.&escape($res);
1808: }
1.110 raeburn 1809: $linkurl.='&command=ungraded';
1.68 raeburn 1810: $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 1811: }
1.84 raeburn 1812: } elsif ($itemserror) {
1813: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1814: } else {
1.68 raeburn 1815: $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
1.33 raeburn 1816: }
1817: }
1818:
1819: sub display_haserrors {
1.84 raeburn 1820: my ($r,$bombs,$bombed,$res_title,$itemserror) = @_;
1.33 raeburn 1821: my $bombnum = 0;
1822: my %lt = &Apache::lonlocal::texthash(
1823: reso => 'Resource',
1824: nmer => 'Number of errors',
1825: noer => 'No problems with errors',
1826: );
1827: if (@{$bombs} > 0) {
1.68 raeburn 1828: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1829: $lt{'reso'}.'</td><td class="LC_right_item">'.
1830: $lt{'nmer'}.'</td></tr>');
1.33 raeburn 1831: @{$bombs} = sort { &cmp_title($a,$b,$res_title) } @{$bombs};
1832: foreach my $bomb (@{$bombs}) {
1833: $bombnum ++;
1.68 raeburn 1834: my $css_class = $bombnum%2?' class="LC_odd_row"':'';
1835: $r->print('<tr'.$css_class.'><td>'.$$bombed{$bomb}{errorlink}.
1836: '</td><td class="LC_right_item">'.
1837: $$bombed{$bomb}{errorcount}.'</td></tr>');
1.33 raeburn 1838: }
1.84 raeburn 1839: } elsif ($itemserror) {
1840: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1841: } else {
1.68 raeburn 1842: $r->print('<tr class="LC_empty_row"><td>'.$lt{'noer'}.'</td></tr>');
1.33 raeburn 1843: }
1844: return;
1845: }
1846:
1847: sub display_abovethreshold {
1.119 raeburn 1848: my ($r,$refpage,$warnings,$triggered,$res_title,$itemserror,$checkallowed) = @_;
1.33 raeburn 1849: my %lt = &Apache::lonlocal::texthash(
1850: reso => 'Resource',
1851: part => 'Part',
1852: nust => 'Num. students',
1853: avat => 'Av. Attempts',
1854: dedi => 'Deg. Diff',
1855: lare => 'Last Reset',
1856: reco => 'Reset Count?',
1857: rese => 'Reset counters to 0',
1858: nopr => 'No problems satisfy threshold criteria',
1859: );
1860: if (@{$warnings} > 0) {
1861: @{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings};
1.61 albertel 1862: $r->print('<tr class="LC_info_row">'.
1.110 raeburn 1863: '<td class="LC_left_item">'.$lt{'reso'}.
1864: '<input type="hidden" name="command" value="" /></td>'.
1.61 albertel 1865: '<td>'.$lt{'part'}.'</td><td>'.$lt{'nust'}.'</td>'.
1866: '<td>'.$lt{'avat'}.'</td><td>'.$lt{'dedi'}.'</td>'.
1.119 raeburn 1867: '<td>'.$lt{'lare'}.'</td>');
1868: if ($checkallowed->{'resetcounters'}) {
1869: $r->print('<td class="LC_right_item">'.$lt{'reco'}.'</td>');
1870: }
1871: $r->print('</tr>');
1.61 albertel 1872: my $row;
1.33 raeburn 1873: foreach my $res (@{$warnings}) {
1.61 albertel 1874: $row++;
1.33 raeburn 1875: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
1876: my $linkurl=&Apache::lonnet::clutter($url);
1877: my $rowspan;
1878: if ($$triggered{$res}{numparts} > 1) {
1879: $rowspan = 'rowspan="'.$$triggered{$res}{numparts}.'"';
1880: }
1.55 www 1881: $linkurl .= '?symb='.&escape($res);
1.66 raeburn 1882: if ($$triggered{$res}{'enclink'}) {
1883: $linkurl =
1884: $$triggered{$res}{'enclink'}.'?symb='.$$triggered{$res}{'encsymb'};
1885: }
1.68 raeburn 1886: my $css_class = $row%2?' class="LC_odd_row"':'';
1887: $r->print('<tr'.$css_class.'>'.
1.61 albertel 1888: '<td class="LC_first_item" '.$rowspan.'><a href="'.$linkurl.'">'.
1.62 raeburn 1889: $$triggered{$res}{title}.'</a></td>');
1890: if (ref($$triggered{$res}{text}) eq 'ARRAY') {
1891: $r->print($$triggered{$res}{text}[0]);
1892: }
1893: $r->print('</tr>');
1894: if (ref($$triggered{$res}{text}) eq 'ARRAY') {
1895: if (@{$$triggered{$res}{text}} > 1) {
1896: for (my $i=1; $i<@{$$triggered{$res}{text}}; $i++) {
1.107 raeburn 1897: $r->print('<tr '.$css_class.'>'.
1.62 raeburn 1898: $$triggered{$res}{text}[$i].'</tr>');
1899: }
1900: }
1901: }
1.33 raeburn 1902: }
1.120 raeburn 1903: if ($checkallowed->{'resetcounters'}) {
1.119 raeburn 1904: $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>');
1905: }
1.84 raeburn 1906: } elsif ($itemserror) {
1907: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1908: } else {
1.63 albertel 1909: $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
1.33 raeburn 1910: }
1911: }
1912:
1913: sub display_versionchanges {
1.84 raeburn 1914: my ($r,$changed,$res_title,$interval,$itemserror) = @_;
1.33 raeburn 1915: my %lt = &Apache::lonlocal::texthash(
1916: 'reso' => 'Resource',
1917: 'revd' => 'Last revised',
1918: 'newv' => 'New version',
1919: 'veru' => 'Version used',
1920: );
1921: if (keys(%{$changed}) > 0) {
1.68 raeburn 1922: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1923: $lt{'reso'}.'</td><td>'.$lt{'revd'}.'</td><td>'.
1924: $lt{'newv'}.'</td><td class="LC_right_item">'.
1925: $lt{'veru'}.'</td></tr>');
1.33 raeburn 1926: my @changes = sort { &cmp_title($a,$b,$res_title) } keys(%{$changed});
1927: my $changenum = 0;
1928: foreach my $item (@changes) {
1.68 raeburn 1929: $changenum ++;
1930: my $css_class = $changenum%2?' class="LC_odd_row"':'';
1.33 raeburn 1931: my ($map,$id,$url)=&Apache::lonnet::decode_symb($item);
1932: my $linkurl=&Apache::lonnet::clutter($url);
1.55 www 1933: $linkurl .= '?symb='.&escape($item);
1.33 raeburn 1934:
1.68 raeburn 1935: $r->print('<tr'.$css_class.'><td><a href="'.$linkurl.'">'.
1936: $$res_title{$item}.'</a></td><td>'.
1937: $$changed{$item}{'revdate'}.'</td><td>'.
1938: $$changed{$item}{'current'}.'</td><td>'.
1939: $$changed{$item}{'version'}.'</td></tr>');
1.33 raeburn 1940: }
1.84 raeburn 1941: } elsif ($itemserror) {
1942: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1943: } else {
1.78 bisitz 1944: $r->print('<tr class="LC_empty_row"><td>'
1945: .&mt('No '.$interval).'</td></tr>');
1.33 raeburn 1946: }
1947: return;
1948: }
1.77 raeburn 1949:
1950: sub display_rolechanges {
1.114 raeburn 1951: my ($r,$chgcount,$changed,$interval,$crstype,$classlist) = @_;
1.77 raeburn 1952: my $now = time();
1953: my %lt = &Apache::lonlocal::texthash(
1954: 'user' => 'User',
1955: 'tich' => 'Time of change',
1956: 'role' => 'Role',
1957: 'sec' => 'Section',
1958: 'status' => 'Status',
1959: );
1960: if ($chgcount) {
1961: $r->print('<tr class="LC_info_row">'.
1962: '<td class="LC_left_item">'.$lt{'tich'}.'</td>'.
1963: '<td class="LC_left_item">'.$lt{'user'}.'</td>'.
1964: '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
1965: '<td class="LC_left_item">'.$lt{'sec'}.'</td>'.
1966: '<td class="LC_left_item">'.$lt{'status'}.'</td></tr>');
1967: if (ref($changed) eq 'HASH') {
1968: my @changes = sort { $b <=> $a } (keys(%{$changed}));
1969: my $changenum = 0;
1.114 raeburn 1970: my $fullnameidx = &Apache::loncoursedata::CL_FULLNAME();
1.77 raeburn 1971: foreach my $item (@changes) {
1972: if (ref($changed->{$item}) eq 'ARRAY') {
1973: foreach my $chg (@{$changed->{$item}}) {
1974: if (ref($chg) eq 'HASH') {
1975: my $section;
1976: my $role =
1977: &Apache::lonnet::plaintext($chg->{'role'},$crstype);
1978: my $status = &mt($chg->{'status'});
1979: if ($chg->{'section'} eq '') {
1980: $section = &mt('none');
1981: } else {
1982: $section = $chg->{'section'};
1983: }
1984: my $uname = $chg->{'uname'};
1985: my $udom = $chg->{'udom'};
1986: $changenum ++;
1987: my $css_class = $changenum%2?' class="LC_odd_row"':'';
1.114 raeburn 1988: my $fullname;
1989: if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') {
1990: $fullname = $classlist->{$uname.':'.$udom}->[$fullnameidx];
1991: } else {
1992: $fullname = &Apache::loncommon::plainname($uname,$udom,'lastname');
1993: }
1.77 raeburn 1994: my $link =
1.114 raeburn 1995: &Apache::loncommon::aboutmewrapper($fullname,$uname,$udom);
1.77 raeburn 1996: $r->print('<tr'.$css_class.'>'.
1.93 droeschl 1997: '<td>'.&Apache::lonlocal::locallocaltime($item).'</td>'.
1.77 raeburn 1998: '<td>'.$link.'</td>'.
1999: '<td>'.$role.'</td>'.
2000: '<td>'.$section.'</td>'.
2001: '<td>'.$status.'</td></tr>');
2002: }
2003: }
2004: }
2005: }
2006: }
2007: } else {
1.78 bisitz 2008: $r->print('<tr class="LC_empty_row"><td>'
2009: .&mt('There are no '.$interval).'</td></tr>');
1.77 raeburn 2010: }
2011: return;
2012: }
1.106 raeburn 2013:
1.126 raeburn 2014: sub display_activity {
2015: my ($r,$context,$count,$details,$interval,$crstype,$classlist) = @_;
1.114 raeburn 2016: return unless (ref($classlist) eq 'HASH');
1.106 raeburn 2017: my %lt = &Apache::lonlocal::texthash(
2018: 'user' => 'User',
2019: 'role' => 'Role',
2020: 'sec' => 'Section',
2021: 'number' => 'Total number of logins',
2022: );
1.126 raeburn 2023: my $prefix = 'login';
2024: if ($context eq 'sessions') {
2025: $lt{'number'} = &mt('Total number of active user sessions');
2026: $lt{'active'} = &mt('Last active');
2027: $prefix = 'session';
2028: }
2029: if ($count) {
1.106 raeburn 2030:
1.126 raeburn 2031: my $hdr = '<tr class="LC_info_row" style="display:none" id="'.$prefix.'titledet">'.
1.106 raeburn 2032: '<td class="LC_left_item">'.$lt{'user'}.'</td>'.
2033: '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
1.126 raeburn 2034: '<td class="LC_left_item">'.$lt{'sec'}.'</td>';
2035: if ($context eq 'sessions') {
2036: $hdr .= '<td class="LC_left_item">'.$lt{'active'}.'</td>';
2037: }
2038: $hdr .= '</tr>'."\n".
2039: '<tr class="LC_info_row" id="'.$prefix.'titlesum">'.
2040: '<td class="LC_left_item">'.$lt{'number'}.'</td>'.
2041: '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
2042: '<td class="LC_left_item">'.$lt{'sec'};
1.106 raeburn 2043: my (%bylastname,%counts);
1.126 raeburn 2044: if (ref($details) eq 'HASH') {
2045: my @items = sort { $b <=> $a } (keys(%{$details}));
2046: my $num = 0;
1.114 raeburn 2047: my $fullnameidx = &Apache::loncoursedata::CL_FULLNAME();
1.126 raeburn 2048: foreach my $item (@items) {
2049: if (ref($details->{$item}) eq 'ARRAY') {
2050: foreach my $user (@{$details->{$item}}) {
1.106 raeburn 2051: if (ref($user) eq 'HASH') {
2052: my $section;
2053: my $role =
2054: &Apache::lonnet::plaintext($user->{'role'},$crstype);
2055: if ($user->{'section'} eq '') {
2056: $section = &mt('none');
2057: } else {
2058: $section = $user->{'section'};
2059: }
2060: $counts{$user->{'role'}}{$section} ++;
2061: my $uname = $user->{'uname'};
2062: my $udom = $user->{'udom'};
1.114 raeburn 2063: my $fullname;
2064: if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') {
1.115 raeburn 2065: $fullname = $classlist->{$uname.':'.$udom}->[$fullnameidx];
1.114 raeburn 2066: } else {
2067: $fullname = &Apache::loncommon::plainname($uname,$udom,'lastname');
2068: }
1.106 raeburn 2069: my $link =
2070: &Apache::loncommon::aboutmewrapper($fullname,$uname,$udom);
1.126 raeburn 2071: my $entry = '<td>'.$link.'</td>'.
2072: '<td>'.$role.'</td>'.
2073: '<td>'.$section.'</td>';
2074: if ($context eq 'sessions') {
2075: $entry .= '<td>'.&Apache::lonlocal::locallocaltime($item).'</td>';
2076: }
2077: push(@{$bylastname{$fullname}},$entry);
1.106 raeburn 2078: }
2079: }
2080: }
2081: }
2082: my $table;
2083: foreach my $person (sort(keys(%bylastname))) {
2084: if (ref($bylastname{$person}) eq 'ARRAY') {
2085: foreach my $item (@{$bylastname{$person}}) {
1.126 raeburn 2086: $num ++;
2087: my $css_class = $num%2?' class="LC_odd_row"':'';
2088: $table .= '<tr'.$css_class.' style="display:none;" id="'.$prefix.'det_'.$num.'">'.$item.'</tr>';
1.106 raeburn 2089: }
2090: }
2091: }
2092: my $numrow = 0;
2093: foreach my $role (sort(keys(%counts))) {
2094: my $showrole = &Apache::lonnet::plaintext($role,$crstype);
2095: if (ref($counts{$role}) eq 'HASH') {
2096: foreach my $sec (sort { $b <=> $a } (keys(%{$counts{$role}}))) {
2097: $numrow ++;
2098: my $css_class = $numrow%2?' class="LC_odd_row"':'';
1.126 raeburn 2099: $table .= '<tr '.$css_class.' id="'.$prefix.'sum_'.$numrow.'">'.
1.106 raeburn 2100: '<td>'.$counts{$role}{$sec}.'</td>'.
2101: '<td>'.$showrole.'</td>'.
2102: '<td>'.$sec.'</td></tr>';
2103: }
2104: }
2105: }
1.126 raeburn 2106: $r->print($hdr.'<input type="hidden" name="'.$prefix.'count" value="'.$num.
2107: '" /><input type="hidden" name="'.$prefix.'row" value="'.$numrow.
1.106 raeburn 2108: '" /></td></tr>'.$table);
2109: }
2110: } else {
2111: $r->print('<tr class="LC_empty_row"><td>'.
2112: &mt('There are no '.$interval).
1.126 raeburn 2113: '<input type="hidden" name="'.$prefix.'count" value="'.$count.
1.106 raeburn 2114: '." /></td></tr>');
2115: }
2116: return;
2117: }
1.126 raeburn 2118:
1.33 raeburn 2119: sub display_coursediscussion {
1.84 raeburn 2120: my ($r,$newdiscussions,$unread,$countunread,$res_title,$itemserror) = @_;
1.59 albertel 2121: my $lctype = lc(&Apache::loncommon::course_type());
1.33 raeburn 2122: my %lt = &Apache::lonlocal::texthash(
2123: 'loca' => 'Location',
2124: 'type' => 'Type',
2125: 'numn' => 'Number of new posts',
1.56 raeburn 2126: 'noun' => 'No unread posts in '.$lctype.' discussions',
1.37 raeburn 2127: 'tmlp' => 'Time of last post',
1.33 raeburn 2128: );
2129: if (@{$newdiscussions} > 0) {
1.68 raeburn 2130: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
2131: $lt{'loca'}.'</td><td>'.
2132: $lt{'type'}.'</td>');
1.39 raeburn 2133: if ($countunread eq 'on') {
1.68 raeburn 2134: $r->print('<td>'.$lt{'tmlp'}.'</td>'.
2135: '<td class="LC_right_item">'.$lt{'numn'}.'</td>');
1.37 raeburn 2136: } else {
1.68 raeburn 2137: $r->print('<td class="LC_right_item">'.$lt{'tmlp'}.'</td>');
1.37 raeburn 2138: }
2139: $r->print("</tr>\n");
1.33 raeburn 2140: @{$newdiscussions} = sort { &cmp_title($a,$b,$res_title) }
2141: @{$newdiscussions};
2142: my $rowNum = 0;
2143: foreach my $ressymb (@{$newdiscussions}) {
1.68 raeburn 2144: $rowNum ++;
1.33 raeburn 2145: my $forum_title = $$unread{$ressymb}{'title'};
2146: my $type = 'Resource';
2147: my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
1.108 droeschl 2148: my $disclink = $feedurl.'?symb='. &escape($$unread{$ressymb}{symb});
1.33 raeburn 2149: if ($feedurl =~ /bulletinboard/) {
1.85 schafran 2150: $type = 'Discussion Board';
1.33 raeburn 2151: }
1.66 raeburn 2152: if ($$unread{$ressymb}{'enclink'}) {
2153: $disclink = $$unread{$ressymb}{'enclink'}.'?symb='.$$unread{$ressymb}{'encsymb'};
2154: }
1.68 raeburn 2155: my $css_class = $rowNum%2?' class="LC_odd_row"':'';
1.37 raeburn 2156: my $lastpost = &Apache::lonnavmaps::timeToHumanString(
2157: $$unread{$ressymb}{'lastpost'});
1.70 raeburn 2158: $r->print('<tr'.$css_class.'><td><a href="'.$disclink.'">'.$forum_title.'</a> </td><td>'.&mt($type).' </td>');
1.39 raeburn 2159: if ($countunread eq 'on') {
1.37 raeburn 2160: my $unreadnum = $$unread{$ressymb}{'unreadcount'};
1.68 raeburn 2161: $r->print('<td>'.$lastpost.'</td><td class="LC_right_item">'.
2162: $unreadnum.' </td>');
1.37 raeburn 2163: } else {
1.68 raeburn 2164: $r->print('<td class="LC_right_item">'.$lastpost.'</td>');
1.33 raeburn 2165: }
1.37 raeburn 2166: $r->print("</tr>\n");
1.33 raeburn 2167: }
1.84 raeburn 2168: } elsif ($itemserror) {
2169: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 2170: } else {
1.68 raeburn 2171: $r->print('<tr class="LC_empty_row"><td>'.$lt{'noun'}.'</td></tr>');
1.33 raeburn 2172: }
2173: }
2174:
2175: sub display_coursenormalmail {
1.68 raeburn 2176: my ($r,$msgcount,$newmsgs) = @_;
1.59 albertel 2177: my $lctype = lc(&Apache::loncommon::course_type());
1.33 raeburn 2178: if ($msgcount > 0) {
1.68 raeburn 2179: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
2180: &mt('Number').'</td><td>'.&mt('Subject').'</td><td>'.
2181: &mt('Sender').'</td><td class="LC_right_item">'.
2182: &mt('Date/Time').'</td></tr>');
2183: my $mailcount = 0;
1.33 raeburn 2184: foreach my $msg (@{$newmsgs}) {
2185: $mailcount ++;
1.68 raeburn 2186: my $css_class = $mailcount%2?' class="LC_odd_row"':'';
1.76 raeburn 2187: $r->print('<tr'.$css_class.'><td>'.$mailcount
2188: .'. </td><td><a href="/adm/email?display='
2189: .$msg->{'msgid'}.'">'
2190: .$msg->{'shortsub'}.'</a> </td><td> '
2191: .$msg->{'from'}.':'.$msg->{'fromdom'}.' </td><td>'
2192: .$msg->{'sendtime'}.'</td></tr>');
1.33 raeburn 2193: }
2194: } else {
1.68 raeburn 2195: $r->print('<tr class="LC_empty_row"><td>'.
2196: &mt('No new '.$lctype.' messages').'</td></tr>');
1.33 raeburn 2197: }
2198: }
2199:
2200: sub display_coursecritmail {
1.68 raeburn 2201: my ($r,$critmsgcount,$critmsgs) = @_;
1.59 albertel 2202: my $lctype = lc(&Apache::loncommon::course_type());
1.33 raeburn 2203: if ($critmsgcount > 0) {
1.68 raeburn 2204: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
2205: &mt('Number').'</td><td>'.&mt('Subject').'</td><td>'.
2206: &mt('Sender').'</td><td class="LC_right_item">'.
2207: &mt('Date/Time').'</td></tr>');
2208: my $mailcount = 0;
1.33 raeburn 2209: foreach my $msg (@{$critmsgs}) {
2210: $mailcount ++;
1.68 raeburn 2211: my $css_class = $mailcount%2?' class="LC_odd_row"':'';
2212: $r->print('<tr'.$css_class.'><td>'.$mailcount.
2213: '. </td><td><a href="/adm/email?folder=critical">'.
2214: $msg->{'shortsub'}.'</a> </td><td> '.
1.72 albertel 2215: $msg->{'from'}.':'.$msg->{'fromdom'}.' </td><td>'.
1.68 raeburn 2216: $msg->{'sendtime'}.'</td></tr>');
1.33 raeburn 2217: }
2218: } else {
1.68 raeburn 2219: $r->print('<tr class="LC_empty_row"><td>'.
2220: &mt('No unread critical messages in '.$lctype).
2221: '</td></tr>');
1.33 raeburn 2222: }
1.1 raeburn 2223: }
2224:
2225: sub cmp_title {
1.16 raeburn 2226: my ($a,$b,$res_title) = @_;
2227: my ($atitle,$btitle) = (lc($$res_title{$a}),lc($$res_title{$b}));
1.1 raeburn 2228: $atitle=~s/^\s*//;
2229: $btitle=~s/^\s*//;
2230: return $atitle cmp $btitle;
2231: }
2232:
1.33 raeburn 2233: sub get_display_settings {
1.36 raeburn 2234: my ($uname,$udom,$cid) = @_;
1.33 raeburn 2235: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid);
2236: my ($tmp) = keys(%settings);
1.40 raeburn 2237: if ($tmp=~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 2238: %settings = ();
1.41 raeburn 2239: unless ($tmp =~ /^error: 2 /) {
1.59 albertel 2240: my $lctype = lc(&Apache::loncommon::course_type());
1.41 raeburn 2241: &Apache::lonnet::logthis('Error retrieving whatsnew settings: '.
1.56 raeburn 2242: $tmp.' for '.$uname.':'.$udom.' for '.$lctype.': '.$cid);
1.33 raeburn 2243: }
2244: }
2245: return %settings;
2246: }
2247:
1.36 raeburn 2248: sub store_display_settings {
2249: my ($uname,$udom,$cid,$checkallowed) = @_;
2250: my %whatsnew_settings;
2251: my $result;
2252: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 2253: if ($key =~ /_section$/) { next; }
1.36 raeburn 2254: if (exists($env{'form.display_'.$key})) {
2255: unless ($env{'form.display_'.$key} eq '') {
2256: $whatsnew_settings{$cid.':'.$key} = $env{'form.display_'.$key};
2257: }
2258: }
2259: }
2260: if (keys(%whatsnew_settings)) {
2261: $result = &Apache::lonnet::put('nohist_whatsnew',\%whatsnew_settings,
2262: $udom,$uname);
2263: } else {
2264: $result = 'ok';
2265: }
2266: return $result;
2267: }
2268:
2269: sub store_interval_setting {
2270: my ($uname,$udom,$cid,$interval_titles) = @_;
2271: my %interval_settings = ();
2272: my $result;
1.77 raeburn 2273: my $context = $env{'form.intervaltype'};
2274: if ($env{'form.interval'} ne '') {
2275: if ($context eq 'oldroles') {
2276: $interval_settings{$cid.':oldroleinterval'} = $env{'form.interval'};
2277: } elsif ($context eq 'newroles') {
2278: $interval_settings{$cid.':newroleinterval'} = $env{'form.interval'};
1.106 raeburn 2279: } elsif ($context eq 'crslogin') {
2280: $interval_settings{$cid.':crslogininterval'} = $env{'form.interval'};
1.126 raeburn 2281: } elsif ($context eq 'sessions') {
2282: $interval_settings{$cid.':sessionactivity'} = $env{'form.interval'};
1.77 raeburn 2283: } else {
2284: $interval_settings{$cid.':interval'} = $env{'form.interval'};
2285: }
1.36 raeburn 2286: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
2287: \%interval_settings,$udom,$uname);
2288: if ($outcome eq 'ok') {
1.77 raeburn 2289: if (ref($interval_titles->{$context}) eq 'HASH') {
1.99 wenzelju 2290: $result = &Apache::lonhtmlcommon::confirm_success(&mt('New filter setting: [_1].','<b>'.
2291: $interval_titles->{$context}->{$env{'form.interval'}}.'</b>').'<br />');
1.77 raeburn 2292: }
1.36 raeburn 2293: } else {
1.59 albertel 2294: my $lctype = lc(&Apache::loncommon::course_type());
1.77 raeburn 2295: &Apache::lonnet::logthis('Error saving whatsnew '.$context.' interval setting'.
1.56 raeburn 2296: ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
1.99 wenzelju 2297: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set interval to [_1] due to [_2].',
1.77 raeburn 2298: '<b>'.$interval_titles->{$context}->{$env{'form.interval'}}.'</b>',
1.99 wenzelju 2299: '<tt>'.$outcome.'</tt>'),1);
1.36 raeburn 2300: }
2301: }
1.99 wenzelju 2302: return &Apache::loncommon::confirmwrapper($result);
1.36 raeburn 2303: }
2304:
1.39 raeburn 2305: sub store_discussion_setting {
2306: my ($uname,$udom,$cid) = @_;
2307: my %discussion_settings;
2308: my $result;
2309: if (defined($env{'form.countunread'})) {
2310: $discussion_settings{$cid.':countunread'} = $env{'form.countunread'};
2311: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
2312: \%discussion_settings,$udom,$uname);
2313: if ($outcome eq 'ok') {
1.99 wenzelju 2314: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Count unread posts in discussions display set to [_1]',
2315: '<b>'.&mt($env{'form.countunread'}).'</b>').'<br />');
1.39 raeburn 2316:
2317: } else {
1.59 albertel 2318: my $lctype = lc(&Apache::loncommon::course_type());
1.71 albertel 2319: &Apache::lonnet::logthis('Error saving whatsnew countunread setting'.
1.56 raeburn 2320: ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
1.99 wenzelju 2321: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set "number unread posts display" to [_1]'.
1.39 raeburn 2322: ' due to [_2].',
1.74 bisitz 2323: '<b>'.&mt($env{'form.countunread'}).'</b>',
1.99 wenzelju 2324: '<tt>'.$outcome.'</tt>'),1);
1.39 raeburn 2325: }
2326: }
1.99 wenzelju 2327: return &Apache::loncommon::confirmwrapper($result);
1.39 raeburn 2328: }
2329:
2330: sub store_courseinit_setting {
2331: my ($uname,$udom,$cid,$initpage) = @_;
2332: my %courseinit_settings;
2333: my $page_control;
2334: my $result;
2335: if (defined($env{'form.courseinit_control'})) {
2336: if ($env{'form.courseinit_control'} eq 'userpref') {
2337: $courseinit_settings{$cid.':courseinit'} = '';
2338: $page_control = 'global preferences';
2339: } else {
2340: if (defined($env{'form.courseinit_page'})) {
2341: $courseinit_settings{$cid.':courseinit'} =
2342: $env{'form.courseinit_page'};
2343: $page_control = 'course specific setting';
2344: }
2345: }
2346: if ($page_control) {
1.59 albertel 2347: my $lctype = lc(&Apache::loncommon::course_type());
1.39 raeburn 2348: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
2349: \%courseinit_settings,$udom,$uname);
2350: if ($outcome eq 'ok') {
2351: if ($page_control eq 'global preferences') {
1.99 wenzelju 2352: $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 2353: } else {
1.99 wenzelju 2354: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Page displayed after role selection in this '.$lctype.' set to [_1].'
2355: ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>'));
1.39 raeburn 2356: }
2357: } else {
1.71 albertel 2358: &Apache::lonnet::logthis('Error saving whatsnew courseinit '.
1.39 raeburn 2359: 'setting: '.$outcome.' for '.$uname.
1.56 raeburn 2360: ':'.$udom.' in '.$lctype.' '.$cid);
1.39 raeburn 2361: if ($page_control eq 'global preferences') {
1.99 wenzelju 2362: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set control of page display to [_1]'.
1.39 raeburn 2363: ' due to [_2].',
2364: '<b>'.$page_control.'</b>',
1.99 wenzelju 2365: '<tt>'.$outcome.'</tt>'),1);
1.39 raeburn 2366: } else {
1.99 wenzelju 2367: $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 2368: ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>'
1.99 wenzelju 2369: ,'<tt>'.$outcome.'</tt>'),1);
1.39 raeburn 2370: }
2371: }
2372: }
2373: }
1.99 wenzelju 2374: return &Apache::loncommon::confirmwrapper($result);
1.39 raeburn 2375: }
2376:
1.33 raeburn 2377: sub start_box {
1.69 raeburn 2378: my ($r,$show,$heading,$caller,$refpage) = @_;
1.33 raeburn 2379: my %lt = &Apache::lonlocal::texthash(
2380: chth => 'Change thresholds?',
2381: chin => 'Change interval?',
1.39 raeburn 2382: chop => 'Change options?',
1.33 raeburn 2383: );
1.68 raeburn 2384: my $showhide;
1.33 raeburn 2385: if ($$show{$caller}) {
1.36 raeburn 2386: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1.70 raeburn 2387: 'display_'.$caller.",'hide'".');">'.
2388: &mt('Hide').'</a></b>';
1.33 raeburn 2389:
2390: } else {
1.36 raeburn 2391: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1.70 raeburn 2392: 'display_'.$caller.",'show'".');">'.
2393: &mt('Show').'</a></b>';
1.33 raeburn 2394: }
2395:
2396: $r->print('
1.68 raeburn 2397: <table class="LC_nested_outer">
1.33 raeburn 2398: <tr>
1.73 raeburn 2399: <th class="LC_left_item">'.$$heading{$caller}.'</th>
1.68 raeburn 2400: <th class="LC_right_item">'.$showhide.'</th>
2401: </tr>');
1.33 raeburn 2402: if (($caller eq 'abovethreshold') && ($$show{$caller})) {
1.40 raeburn 2403: if ($$show{$caller}) {
2404: $r->print('
1.33 raeburn 2405: <tr>
1.98 raeburn 2406: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgthreshold&refpage='.$refpage.'">'.$lt{'chth'}.'</a></td>
1.33 raeburn 2407: </tr>');
1.40 raeburn 2408: }
1.33 raeburn 2409: } elsif (($caller eq 'versionchanges') && ($$show{$caller})) {
1.40 raeburn 2410: if ($$show{$caller}) {
2411: $r->print('
1.33 raeburn 2412: <tr>
1.98 raeburn 2413: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chginterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1.39 raeburn 2414: </tr>');
1.40 raeburn 2415: }
1.39 raeburn 2416: } elsif ($caller eq 'coursediscussion') {
1.40 raeburn 2417: if ($$show{$caller}) {
2418: $r->print('
1.39 raeburn 2419: <tr>
1.98 raeburn 2420: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgdisc&refpage='.$refpage.'">'.$lt{'chop'}.'</a></td>
1.33 raeburn 2421: </tr>');
1.40 raeburn 2422: }
1.77 raeburn 2423: } elsif (($caller eq 'newroles') && ($$show{$caller})) {
2424: if ($$show{$caller}) {
2425: $r->print('
2426: <tr>
1.98 raeburn 2427: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgnewroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1.77 raeburn 2428: </tr>');
2429: }
2430: } elsif (($caller eq 'oldroles') && ($$show{$caller})) {
2431: if ($$show{$caller}) {
2432: $r->print('
2433: <tr>
1.98 raeburn 2434: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1.77 raeburn 2435: </tr>');
2436: }
1.106 raeburn 2437: } elsif (($caller eq 'crslogin') && ($$show{$caller})) {
2438: if ($$show{$caller}) {
2439: $r->print('
2440: <tr>
1.126 raeburn 2441: <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>
2442: </tr>');
2443: }
2444: } elsif (($caller eq 'sessions') && ($$show{$caller})) {
2445: if ($$show{$caller}) {
2446: $r->print('
2447: <tr>
2448: <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 2449: </tr>');
2450: }
2451: }
1.61 albertel 2452: $r->print('
1.33 raeburn 2453: <tr>
1.68 raeburn 2454: <td colspan="2">
2455: <table class="LC_nested">
1.33 raeburn 2456: ');
2457: return;
2458: }
2459:
2460: sub end_box {
2461: my ($r) = shift;
2462: $r->print('
2463: </table>
2464: </td>
2465: </tr>
2466: </table><br />');
2467: return;
2468: }
2469:
1.7 raeburn 2470: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>