Annotation of loncom/interface/lonwhatsnew.pm, revision 1.97
1.2 albertel 1: #
1.97 ! bisitz 2: # $Id: lonwhatsnew.pm,v 1.96 2009/10/30 16:31:39 bisitz 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.1 raeburn 45:
46: #----------------------------
47: # handler
48: #
49: #----------------------------
50:
51: sub handler {
52: my $r = shift;
1.7 raeburn 53: if ($r->header_only) {
54: &Apache::loncommon::content_type($r,'text/html');
55: $r->send_http_header;
56: return OK;
57: }
1.39 raeburn 58: &Apache::loncommon::get_unprocessed_cgi(
59: $ENV{'QUERY_STRING'},['command','refpage']);
1.1 raeburn 60:
1.36 raeburn 61: my $command = $env{'form.command'};
1.39 raeburn 62: my $refpage = $env{'form.refpage'};
1.1 raeburn 63:
1.44 albertel 64: my %checkallowed = ( coursenormalmail => 1,
65: coursecritmail => 1, );
66: foreach my $perm_check (['whn','whatsnew',1],
67: ['pch','coursediscussion',1],
68: ['mgr','handgrading',1],
69: ['vgr','abovethreshold',1],
70: ['opa','haserrors',1],
71: ['mdc','versionchanges',0],
1.77 raeburn 72: ['vcl','newroles',1],
73: ['vcl','oldroles',1],
1.44 albertel 74: ) {
75: my ($perm,$key,$check_section) = @{ $perm_check };
76: my $scope = $env{'request.course.id'};
77: if (!($checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope))) {
78: $scope .= '/'.$env{'request.course.sec'};
79: if ( $check_section ) {
80: $checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope);
81: }
82: if ($checkallowed{$key}) {
83: $checkallowed{$key.'_section'} = $env{'request.course.sec'};
84: }
85: }
86: }
1.43 albertel 87:
1.44 albertel 88: if ( ! $env{'request.course.fn'} || ! $checkallowed{'whatsnew'}) {
1.43 albertel 89: # Not in a course, or no whn priv in course
1.42 raeburn 90: $env{'user.error.msg'}="/adm/whatsnew::whn:0:0:Cannot display what's new page";
1.1 raeburn 91: return HTTP_NOT_ACCEPTABLE;
92: }
93:
1.44 albertel 94: &Apache::loncommon::content_type($r,'text/html');
95: $r->send_http_header;
1.36 raeburn 96:
97: $r->print(&display_header($command,\%checkallowed));
98:
1.7 raeburn 99: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.36 raeburn 100: &Apache::lonhtmlcommon::add_breadcrumb
101: ({href=>'/adm/whatsnew',
1.90 hauer 102: text=>"What's New?"});
1.44 albertel 103: if (($command eq 'chgthreshold') && $checkallowed{'abovethreshold'}) {
1.7 raeburn 104: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 105: ({href=>'/adm/whatsnew?command=chgthreshold&refpage='.$refpage,
1.13 raeburn 106: text=>"Change thresholds"});
1.7 raeburn 107: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 108: ("What's New?",#'Course_Action_Items_Thresholds'
1.49 albertel 109: ));
1.44 albertel 110: } elsif (($command eq 'chginterval') && $checkallowed{'versionchanges'} ) {
1.36 raeburn 111: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 112: ({href=>'/adm/whatsnew?command=chginterval&refpage='.$refpage,
1.36 raeburn 113: text=>"Change interval"});
114: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 115: ("What's New?",#'Course_Action_Items_Intervals'
1.49 albertel 116: ));
1.44 albertel 117: } elsif (($command eq 'chgdisc') && $checkallowed{'coursediscussion'}) {
1.39 raeburn 118: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 119: ({href=>'/adm/whatsnew?command=chgdisc&refpage='.$refpage,
1.39 raeburn 120: text=>"Change discussion display"});
121: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 122: ("What's New?",#'Course_Action_Items_Intervals'
1.49 albertel 123: ));
1.39 raeburn 124: } elsif ($command eq 'courseinit') {
125: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 126: ({href=>'/adm/whatsnew?command=courseinit&refpage='.$refpage,
1.39 raeburn 127: text=>"Course initialization preference"});
128: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 129: ("What's New?",#'Course_Action_Items_Initialization'
1.49 albertel 130: ));
1.77 raeburn 131: } elsif ($command eq 'chgoldroleinterval' && $checkallowed{'oldroles'}) {
132: &Apache::lonhtmlcommon::add_breadcrumb
133: ({href=>'/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage,
134: text=>"Change interval"});
135: $r->print(&Apache::lonhtmlcommon::breadcrumbs
136: ("What's New?",#'Course_Action_Items_Intervals'
137: ));
138: } elsif ($command eq 'chgnewroleinterval' && $checkallowed{'newroles'}) {
139: &Apache::lonhtmlcommon::add_breadcrumb
140: ({href=>'/adm/whatsnew?command=chgnewroleinterval&refpage='.$refpage,
141: text=>"Change interval"});
142: $r->print(&Apache::lonhtmlcommon::breadcrumbs
143: ("What's New?",#'Course_Action_Items_Intervals'
144: ));
1.7 raeburn 145: } else {
146: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 147: ("What's New?",#'Course_Action_Items_Display'
1.49 albertel 148: ));
1.7 raeburn 149: }
1.39 raeburn 150: &display_main_box($r,$command,$refpage,\%checkallowed);
1.14 albertel 151: return OK;
1.1 raeburn 152: }
153:
154: #------------------------------
155: # display_main_box
156: #
157: # Display all the elements within the main box
158: #------------------------------
159:
160: sub display_main_box {
1.39 raeburn 161: my ($r,$command,$refpage,$checkallowed) = @_;
1.1 raeburn 162: my $domain=&Apache::loncommon::determinedomain();
1.40 raeburn 163: my $function = &Apache::loncommon::get_users_function();
1.59 albertel 164: my $lctype = lc(&Apache::loncommon::course_type());
1.7 raeburn 165: $r->print('<table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td width="100%">');
1.13 raeburn 166:
1.39 raeburn 167: my %threshold_titles = &Apache::lonlocal::texthash (
1.13 raeburn 168: av_attempts => 'Average number of attempts',
169: degdiff => 'Degree of difficulty',
170: numstudents => 'Total number of students with submissions',
171: );
1.78 bisitz 172: my %versions = (
1.77 raeburn 173: -1 => "version changes since start of $lctype",
174: 2592000 => 'version changes since last month',
175: 604800 => 'version changes since last week',
176: 86400 => 'version changes since yesterday',
177: );
1.78 bisitz 178: my %newroles = (
1.77 raeburn 179: -1 => "roles which have become active since start of $lctype",
180: 2592000 => 'roles which have become active since last month',
181: 604800 => 'roles which have become active since last week',
182: 86400 => 'roles which have become active since yesterday',
183: );
1.78 bisitz 184: my %oldroles = (
1.77 raeburn 185: -1 => "roles which expired since start of $lctype",
186: 2592000 => 'roles which expired since last month',
187: 604800 => 'roles which expired since last week',
188: 86400 => 'roles which expired since yesterday',
189: );
190: my %interval_titles = (
191: versions => \%versions,
192: newroles => \%newroles,
193: oldroles => \%oldroles,
1.36 raeburn 194: );
1.39 raeburn 195: my %initpage = &Apache::lonlocal::texthash (
1.56 raeburn 196: firstres => "first resource in the $lctype",
1.88 hauer 197: whatsnew => "What's New Page",
1.39 raeburn 198: userpref => 'your general user preferences',
1.56 raeburn 199: coursespecific => "specific setting for this $lctype",
1.39 raeburn 200: );
1.15 raeburn 201: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
202: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
203:
1.44 albertel 204: if (($command eq 'chgthreshold')
205: && $checkallowed->{'abovethreshold'}) {
1.69 raeburn 206: &display_threshold_config($r,$refpage,\%threshold_titles,
1.36 raeburn 207: $cdom,$crs);
1.44 albertel 208: } elsif (($command eq 'chginterval')
209: && $checkallowed->{'versionchanges'}) {
1.77 raeburn 210: &display_interval_config($r,$refpage,\%interval_titles,'versions');
1.44 albertel 211: } elsif (($command eq 'chgdisc')
212: && $checkallowed->{'coursediscussion'}) {
1.39 raeburn 213: &display_discussion_config($r,$refpage);
214: } elsif ($command eq 'courseinit') {
215: &courseinit_config($r,$refpage,\%initpage);
1.77 raeburn 216: } elsif (($command eq 'chgnewroleinterval')
217: && $checkallowed->{'newroles'}) {
218: &display_interval_config($r,$refpage,\%interval_titles,'newroles');
219: } elsif (($command eq 'chgoldroleinterval')
220: && $checkallowed->{'oldroles'}) {
221: &display_interval_config($r,$refpage,\%interval_titles,'oldroles');
1.1 raeburn 222: } else {
1.69 raeburn 223: &display_actions_box($r,$command,$refpage,\%threshold_titles,
1.39 raeburn 224: \%interval_titles,\%initpage,$cdom,$crs,$checkallowed);
1.1 raeburn 225: }
1.52 albertel 226: my $end_page = &Apache::loncommon::end_page();
1.1 raeburn 227: $r->print(<<END_OF_BLOCK);
228: </td>
229: </tr>
230: </table><br />
1.52 albertel 231: $end_page
1.1 raeburn 232: END_OF_BLOCK
233: }
234:
235: #-------------------------------
236: # display_header
237: #
238: # Display the header information and set
239: # up the HTML
240: #-------------------------------
241:
1.39 raeburn 242: sub display_header {
1.36 raeburn 243: my ($command,$checkallowed) = @_;
1.52 albertel 244:
1.36 raeburn 245: my $scripttag;
1.77 raeburn 246: unless ($command eq 'chgthreshold' || $command eq 'chginterval' ||
247: $command eq 'chgoldroleinterval' || $command eq 'chgnewroleinterval') {
1.36 raeburn 248: $scripttag = <<"END";
249: <script type="text/javascript">
250: function change_display(caller,change) {
251: caller.value = change;
1.77 raeburn 252: document.visible.submit();
1.36 raeburn 253: }
254:
255: function changeAll(change) {
256: END
257: foreach my $item (keys(%{$checkallowed})) {
1.44 albertel 258: if ($item =~ /_section$/) { next; }
1.39 raeburn 259: if ($$checkallowed{$item}) {
260: $scripttag.='document.visible.display_'.$item.'.value=change'.
261: "\n";
262: }
1.36 raeburn 263: }
264: $scripttag.='document.visible.submit();
265: }
266: </script>
267: ';
268: }
1.58 albertel 269: my $course_type=&Apache::loncommon::course_type();
1.90 hauer 270: return &Apache::loncommon::start_page("What's New?",
1.58 albertel 271: $scripttag);
1.1 raeburn 272: }
273:
274: #-------------------------------
275: # display_actions_box
276: #
277: # Display the action items
278: #
279: #-------------------------------
280:
1.39 raeburn 281: sub display_actions_box {
1.69 raeburn 282: my ($r,$command,$refpage,$threshold_titles,$interval_titles,$initpage,
283: $cdom,$crs,$checkallowed) = @_;
1.36 raeburn 284: my $udom = $env{'user.domain'};
285: my $uname = $env{'user.name'};
286: my $cid = $env{'request.course.id'};
1.59 albertel 287: my $crstype = &Apache::loncommon::course_type();
1.56 raeburn 288: my $lctype = lc($crstype);
289: my %stulabel = (
290: 'Course' => 'students',
1.95 raeburn 291: 'Community' => 'members',
1.56 raeburn 292: );
1.36 raeburn 293: my %lt = &Apache::lonlocal::texthash(
1.60 raeburn 294: 'yacc' => 'You are accessing an invalid course',
1.36 raeburn 295: 'gtfr' => 'Go to first resource',
296: 'hial' => 'Hide all',
297: 'shal' => 'Show all',
298: );
299:
1.1 raeburn 300: my %unread = ();
301: my %ungraded = ();
302: my %bombed = ();
1.11 raeburn 303: my %triggered = ();
1.33 raeburn 304: my %changed = ();
1.1 raeburn 305: my @newmsgs = ();
306: my @critmsgs = ();
307: my @newdiscussions = ();
308: my @tograde = ();
309: my @bombs = ();
1.11 raeburn 310: my @warnings = ();
1.33 raeburn 311: my $msgcount = 0;
312: my $critmsgcount = 0;
1.77 raeburn 313: my $expirecount;
314: my %expired;
315: my $activecount;
316: my %activated;
1.16 raeburn 317: my %res_title = ();
1.33 raeburn 318: my %show = ();
319: my $needitems = 0;
320: my $boxcount = 0;
1.1 raeburn 321:
1.39 raeburn 322: my $result;
323: if ($command eq 'newcourseinit') {
324: $result = &store_courseinit_setting($uname,$udom,$cid,$initpage);
325: }
326:
1.64 banghart 327: my %threshold = ();
1.39 raeburn 328: my %pagedesc = &Apache::lonlocal::texthash (
329: firstres => 'First resource',
1.88 hauer 330: whatsnew => "What's New Page",
1.39 raeburn 331: userpref => 'user preference',
1.56 raeburn 332: coursespecific => $lctype.' only',
1.39 raeburn 333: default => 'default',
334: );
335:
336: my ($initcontrol,$initdisp) = &curr_courseinit();
337: my $currinit = $pagedesc{$initdisp}.' ('.$pagedesc{$initcontrol}.')';
1.13 raeburn 338:
1.36 raeburn 339: unless ($cid) {
1.73 raeburn 340: $r->print('<p><span style="text-align: center; font-weight: bold;">'.$lt{'yacc'}.'</span></p>');
1.1 raeburn 341: return;
342: }
1.33 raeburn 343:
1.97 ! bisitz 344: my $header = '';
1.39 raeburn 345: if ($refpage eq 'start') {
346: if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
1.36 raeburn 347: &GDBM_READER(),0640)) {
1.39 raeburn 348: my $furl=$bighash{'first_url'};
349: untie(%bighash);
1.97 ! bisitz 350: $header .= '<b><a href="'.$furl.'">'.$lt{'gtfr'}.
! 351: '</a></b><br />';
1.39 raeburn 352: }
1.36 raeburn 353: }
1.97 ! bisitz 354: $header .= &mt('Page set to be displayed after you have selected a role in this '.$lctype).'.'
1.74 bisitz 355: .' <span class="LC_nobreak">'
1.78 bisitz 356: .&mt('Currently: [_1].','<i>'.$currinit.'</i>')
357: .' '
1.96 bisitz 358: .&mt('[_1]Change[_2] for just [_3]this '.$lctype.'[_4] or for [_5]all your courses/communities[_6].'
1.81 bisitz 359: ,'<b>'
360: ,'</b>'
1.74 bisitz 361: ,'<a href="/adm/whatsnew?command=courseinit&refpage='.$refpage.'">'
1.96 bisitz 362: ,'</a>'
1.81 bisitz 363: ,'<a href="/adm/preferences?action=changecourseinit&refpage='.$refpage.'">'
364: ,'</a>')
1.97 ! bisitz 365: .' </span>';
! 366:
! 367: $r->print(&Apache::loncommon::head_subbox($header));
1.56 raeburn 368:
1.36 raeburn 369: if ($command eq 'reset') {
370: $result = &process_reset($cdom,$crs);
371: } elsif ($command eq 'update') {
1.39 raeburn 372: $result = &process_update($uname,$udom,$threshold_titles);
1.36 raeburn 373: } elsif ($command eq 'newinterval') {
374: $result = &store_interval_setting($uname,$udom,$cid,$interval_titles);
1.39 raeburn 375: } elsif ($command eq 'newdiscconf') {
376: $result = &store_discussion_setting($uname,$udom,$cid);
1.36 raeburn 377: }
378:
379: my $store_result=&store_display_settings($uname,$udom,$cid,$checkallowed);
380:
381: unless ($store_result eq 'ok') {
1.71 albertel 382: &Apache::lonnet::logthis('Error saving whatsnew settings: '.
1.56 raeburn 383: $store_result.' for '.'user '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
1.97 ! bisitz 384: $result .= '<span class="LC_error">'
! 385: .&mt('Unable to save visibility settings due to [_1]',
! 386: $store_result)
! 387: .'</span>';
1.36 raeburn 388: }
389:
390: if ($result) {
1.94 bisitz 391: $r->print($result.'<hr />');
1.36 raeburn 392: }
393: $r->rflush();
394:
1.77 raeburn 395: my (%timediff,%interval);
396: my %display_settings = &get_display_settings($uname,$udom,$cid);
397: $timediff{'versions'} = $display_settings{$cid.':interval'};
398: unless (defined($timediff{'versions'})) { $timediff{'versions'} = 604800; }
399: $interval{'versions'} = $interval_titles->{'versions'}->{$timediff{'versions'}};
400:
401: my %headings = &Apache::lonlocal::texthash(
402: coursediscussion => 'Unread '.$lctype.' discussion posts',
403: handgrading => 'Problems requiring handgrading',
404: haserrors => 'Problems with errors',
405: coursenormalmail => 'New '.$lctype.' messages',
406: coursecritmail => 'New critical messages in '.$lctype,
407: );
408:
409: if ($timediff{'versions'} == -1) {
1.78 bisitz 410: $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since start of '.$lctype);
1.77 raeburn 411: } elsif ($timediff{'versions'} == 2592000) {
1.78 bisitz 412: $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since last month');
1.77 raeburn 413: } elsif ($timediff{'versions'} == 604800) {
1.78 bisitz 414: $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since last week');
1.77 raeburn 415: } elsif ($timediff{'versions'} == 86400) {
1.78 bisitz 416: $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since yesterday');
1.77 raeburn 417: }
418:
419: $timediff{'oldroles'} = $display_settings{$cid.':oldroleinterval'};
420: unless (defined($timediff{'oldroles'})) { $timediff{'oldroles'} = 604800; }
421: $interval{'oldroles'} = $interval_titles->{'oldroles'}->{$timediff{'oldroles'}};
422:
423: if ($timediff{'oldroles'} == -1) {
1.78 bisitz 424: $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since start of '.$lctype);
1.77 raeburn 425: } elsif ($timediff{'oldroles'} == 2592000) {
1.78 bisitz 426: $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since last month');
1.77 raeburn 427: } elsif ($timediff{'oldroles'} == 604800) {
1.78 bisitz 428: $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since last week');
1.77 raeburn 429: } elsif ($timediff{'oldroles'} == 86400) {
1.78 bisitz 430: $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since yesterday');
1.77 raeburn 431: }
432:
433: $timediff{'newroles'} = $display_settings{$cid.':newroleinterval'};
434: unless (defined($timediff{'newroles'})) { $timediff{'newroles'} = 604800; }
435: $interval{'newroles'} = $interval_titles->{'newroles'}->{$timediff{'newroles'}};
436:
437: if ($timediff{'newroles'} == -1) {
1.78 bisitz 438: $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since start of '.$lctype);
1.77 raeburn 439: } elsif ($timediff{'newroles'} == 2592000) {
1.78 bisitz 440: $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since last month');
1.77 raeburn 441: } elsif ($timediff{'newroles'} == 604800) {
1.78 bisitz 442: $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since last week');
1.77 raeburn 443: } elsif ($timediff{'newroles'} == 86400) {
1.78 bisitz 444: $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since yesterday');
1.77 raeburn 445: }
1.33 raeburn 446:
1.35 raeburn 447: my $now = time;
1.77 raeburn 448: if ($timediff{'versions'} == -1) {
449: $timediff{'versions'} = time;
450: }
451: my $starttime = $now - $timediff{'versions'};
452:
453: if ($timediff{'newroles'} == -1) {
454: $timediff{'newroles'} = time;
455: }
456: my $activatedstart = $now - $timediff{'newroles'};
457:
458: if ($timediff{'oldroles'} == -1) {
459: $timediff{'oldroles'} = time;
460: }
461: my $expiredstart = $now - $timediff{'oldroles'};
462:
1.39 raeburn 463: my $countunread = $display_settings{$cid.':countunread'};
464: unless (defined($countunread)) {
465: $countunread = 'on';
466: }
1.36 raeburn 467: if ($$checkallowed{'abovethreshold'}) {
1.39 raeburn 468: &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs);
1.33 raeburn 469: }
470:
1.59 albertel 471: $headings{'abovethreshold'} =
1.80 raeburn 472: &mt('(Problems with av. attempts ≥ [_1] or deg. difficulty ≥ [_2]) [_3] and total number of '.$stulabel{$crstype}.' with submissions ≥ [_4]',
1.59 albertel 473: $threshold{'av_attempts'},$threshold{'degdiff'},
1.80 raeburn 474: '<br />',$threshold{'numstudents'});
1.33 raeburn 475:
1.77 raeburn 476: my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail','newroles','oldroles');
1.33 raeburn 477:
1.36 raeburn 478: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 479: if ($key =~ /_section$/) { next; }
1.33 raeburn 480: $show{$key} = 0;
1.36 raeburn 481: if ($$checkallowed{$key}) {
482: unless ($display_settings{$cid.':'.$key} eq 'hide') {
1.33 raeburn 483: $show{$key} = 1;
484: }
485: }
486: }
487:
488: foreach my $item (@actionorder) {
1.77 raeburn 489: unless ($item eq 'coursenormalmail' || $item eq 'coursecritmail' ||
490: $item eq 'newroles' || $item eq 'oldroles') {
1.33 raeburn 491: if ($show{$item}) {
492: $needitems = 1;
493: last;
494: }
495: }
496: }
497:
1.84 raeburn 498: my $itemserror;
1.33 raeburn 499: if ($needitems) {
1.84 raeburn 500: $itemserror = &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread);
1.1 raeburn 501: }
1.33 raeburn 502: if ($show{'coursenormalmail'}) {
1.50 raeburn 503: $msgcount = &getnormalmail(\@newmsgs);
1.7 raeburn 504: }
1.33 raeburn 505: if ($show{'coursecritmail'}) {
1.50 raeburn 506: $critmsgcount = &getcritmail(\@critmsgs);
1.11 raeburn 507: }
1.77 raeburn 508: if ($show{'oldroles'}) {
509: $expirecount = &getexpired(\%expired,$expiredstart,'previous');
510: }
511: if ($show{'newroles'}) {
512: $activecount = &getactivated(\%activated,$activatedstart,'active');
513: }
1.36 raeburn 514: $r->print(qq|<a href="javascript:changeAll('hide');">$lt{'hial'}</a>
515: <a href="javascript:changeAll('show');">$lt{'shal'}</a>
516: <form method="post" name="visible" action="/adm/whatsnew">\n|);
517: foreach my $item (keys(%{$checkallowed})) {
1.44 albertel 518: if ($item =~ /_section$/) { next; }
1.36 raeburn 519: if ($$checkallowed{$item}) {
520: $r->print('<input type="hidden" name="display_'.$item.'" />'."\n");
521: }
522: }
1.1 raeburn 523:
1.73 raeburn 524: $r->print('<input type="hidden" name="refpage" value="'.$refpage.'" /></form><table class="LC_double_column"><tr><td class="LC_left_col">');
1.1 raeburn 525:
1.33 raeburn 526: my $displayed = 0;
1.40 raeburn 527: my $totalboxes = 0;
528: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 529: if ($key =~ /_section$/) { next; }
530: if ($key eq 'whatsnew' ) { next; } # whatsnew check creates no box
1.40 raeburn 531: if ($$checkallowed{$key}) {
532: $totalboxes ++;
533: }
534: }
1.77 raeburn 535: my $halfway = 4;
536: # my $halfway = int($totalboxes/2) + $totalboxes%2;
1.33 raeburn 537: foreach my $actionitem (@actionorder) {
1.36 raeburn 538: if ($$checkallowed{$actionitem}) {
1.33 raeburn 539: if ($displayed == $halfway) {
1.73 raeburn 540: $r->print('</td><td> </td><td class="LC_right_col" >');
1.1 raeburn 541: }
1.84 raeburn 542: &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);
1.33 raeburn 543: $displayed ++;
1.1 raeburn 544: }
545: }
546: $r->print('
1.33 raeburn 547: </td>
548: </tr>
1.73 raeburn 549: </table>
550: ');
1.1 raeburn 551: }
552:
1.11 raeburn 553: #-------------------------------
1.36 raeburn 554: # display_threshold_config
1.11 raeburn 555: #
1.13 raeburn 556: # Display the threshold setting screen
1.11 raeburn 557: #
558: #-------------------------------
559:
1.36 raeburn 560: sub display_threshold_config {
1.69 raeburn 561: my ($r,$refpage,$threshold_titles,$cdom,$crs) = @_;
1.39 raeburn 562: my $uname = $env{'user.name'};
563: my $udom = $env{'user.dom'};
564: my $cid = $env{'request.course.id'};
1.13 raeburn 565: my %threshold = ();
566: my $rowColor1 = "#ffffff";
567: my $rowColor2 = "#eeeeee";
568: my $rowColor;
569:
570: my @thresholditems = ("av_attempts","degdiff","numstudents");
1.39 raeburn 571: my %threshold_titles = &Apache::lonlocal::texthash(
1.13 raeburn 572: av_attempts => 'Average number of attempts',
573: degdiff => 'Degree of difficulty',
574: numstudents => 'Total number of students with submissions',
575: );
1.39 raeburn 576: &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs);
1.13 raeburn 577:
1.68 raeburn 578: $r->print('<br /><form name="thresholdform" method="post" action="/adm/whatsnew">'.
579: &Apache::loncommon::start_data_table().
580: &Apache::loncommon::start_data_table_header_row().
1.70 raeburn 581: '<th>'.&mt('Threshold Name').'</th>'."\n".
582: '<th>'.&mt('Current value').'</th>'."\n".
583: '<th>'.&mt('Change?').'</th>'."\n".
1.68 raeburn 584: &Apache::loncommon::end_data_table_header_row());
1.13 raeburn 585: foreach my $type (@thresholditems) {
1.39 raeburn 586: my $parameter = $env{'request.course.id'}.':threshold_'.$type;
1.13 raeburn 587: # onchange is javascript to automatically check the 'Set' button.
588: my $onchange = 'onFocus="javascript:window.document.forms'.
589: "['thresholdform'].elements['".$parameter."_setparmval']".
590: '.checked=true;"';
1.68 raeburn 591: $r->print(&Apache::loncommon::start_data_table_row()."\n".
592: '<td>'.$threshold_titles{$type}.'</td>'."\n".
593: '<td>'.&Apache::lonhtmlcommon::textbox($parameter.'_value',
1.13 raeburn 594: $threshold{$type},
1.68 raeburn 595: 10,$onchange).'</td>'."\n".
596: '<td>'.
597: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
598: '</td>'."\n".
599: &Apache::loncommon::end_data_table_row());
1.13 raeburn 600: }
1.68 raeburn 601: $r->print(&Apache::loncommon::end_data_table()."\n".
1.87 schafran 602: '<br /><input type="submit" name="threshold" value="'.&mt('Save').'" />
1.36 raeburn 603: <input type="hidden" name="command" value="update" />
1.39 raeburn 604: <input type="hidden" name="refpage" value="'.$refpage.'" />
1.13 raeburn 605: </form>');
1.11 raeburn 606: }
607:
1.36 raeburn 608: #-------------------------------
609: # display_interval_config
610: #
611: # Display the interval setting screen
612: #
613: #-------------------------------
614:
615: sub display_interval_config {
1.77 raeburn 616: my ($r,$refpage,$interval_titles,$context) = @_;
617: my $setting = 'interval';
618: if ($context eq 'oldroles') {
619: $setting = 'oldroleinterval';
620: } elsif ($context eq 'newroles') {
621: $setting = 'newroleinterval';
622: }
1.59 albertel 623: my $lctype = lc(&Apache::loncommon::course_type());
1.39 raeburn 624: my $current = &get_current($env{'user.name'},$env{'user.domain'},
1.77 raeburn 625: $env{'request.course.id'},$setting);
626: if ($context eq 'oldroles') {
627: $r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' expired.').'<br />');
628: } elsif ($context eq 'newroles') {
629: $r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' became available.').'<br />');
630: } else {
631: $r->print('<br />'.&mt('Choose the time window to use to display resources in the '.$lctype.' with version changes.').'<br />');
632: }
1.36 raeburn 633: unless ($current eq '') {
1.77 raeburn 634: if (ref($interval_titles->{$context}) eq 'HASH') {
635: $r->print(' '.&mt('Current value is "[_1]".','<b>'.
636: $interval_titles->{$context}->{$current}.'</b>').'<br />');
637: }
1.36 raeburn 638: }
1.77 raeburn 639: $r->print('<br />
1.36 raeburn 640: <form method="post" name="intervalswitch" action="/adm/whatsnew">
641: <input type="hidden" name="command" value="newinterval" />
1.77 raeburn 642: <input type="hidden" name="intervaltype" value="'.$context.'" />
643: <input type="hidden" name="refpage" value="'.$refpage.'" />'.
644: &mt('Display:').'
1.36 raeburn 645: <select name="interval">
1.78 bisitz 646: <option value="" selected="selected">'.&mt('Select').'</option>
1.36 raeburn 647: ');
1.77 raeburn 648: if (ref($interval_titles) eq 'HASH') {
649: if (ref($interval_titles->{$context}) eq 'HASH') {
650: foreach my $key (reverse sort ({$a cmp $b} (keys(%{$interval_titles->{$context}})))) {
1.78 bisitz 651: $r->print('<option value="'.$key.'">'.&mt($interval_titles->{$context}->{$key}).
1.77 raeburn 652: '</option>'."\n");
653: }
654: }
1.36 raeburn 655: }
656: $r->print('</select>
657: <input type="submit" name="display" value="'.
1.87 schafran 658: &mt('Save').'" /></form>');
1.36 raeburn 659: return;
660: }
661:
1.39 raeburn 662: #----------------------------------------------
663: # display_discussion_config
664: #
665: # Display the discussion display setting screen
666: #
667: #----------------------------------------------
668:
669: sub display_discussion_config {
670: my ($r,$refpage) = @_;
671: my $current = &get_current($env{'user.name'},$env{'user.domain'},
672: $env{'request.course.id'},'countunread');
673: if ($current eq '') {
674: $current = 'on';
675: }
1.47 raeburn 676: my %opposite = (
677: 'on' => 'off',
678: 'off' => 'on',
679: );
680: $r->print('<script type="text/javascript">
681: function toggle_countunread(choice) {
682: if (choice == "unchanged") {
683: document.discussionswitch.command.value = "";
684: }
685: document.discussionswitch.submit();
686: }
687: </script>');
1.81 bisitz 688: $r->print('<br />'
1.86 schafran 689: .&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 690: .'<br />'
1.90 hauer 691: .&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 692: .' '
693: .&mt('Currently set to [_1].','<b>'.$current.'</b>.')
694: );
1.39 raeburn 695: $r->print('<br /><br />
1.47 raeburn 696: <form method="post" name="discussionswitch" action="/adm/whatsnew">
1.39 raeburn 697: <input type="hidden" name="command" value="newdiscconf" />
698: <input type="hidden" name="refpage" value="'.$refpage.'" />
1.47 raeburn 699: <input type="hidden" name="countunread" value="'.$opposite{$current}.'" />
1.39 raeburn 700: ');
1.47 raeburn 701: $r->print('<br/>
702: <input type="button" name="display" value="'.
1.74 bisitz 703: &mt('Change to [_1]',&mt($opposite{$current})).'"
1.83 raeburn 704: onclick="javascript:toggle_countunread('."'change'".')" />'.
705: (' ' x7).
706: '<input type="button" name="nochange" value="'.
1.47 raeburn 707: &mt("No change").'"
708: onclick="javascript:toggle_countunread('."'unchanged'".')" />
709: </form>');
1.39 raeburn 710: return;
711: }
712:
713: #---------------------------------------------------
714: # courseinit_config
715: #
716: # Set page displayed when course loads after
717: # selecting a role in the course from the roles page.
718: #
719: #---------------------------------------------------
720:
721: sub courseinit_config {
722: my ($r,$refpage,$initpage) = @_;
723: my ($control,$current) = &curr_courseinit();
724: my @chgstate = ('userpref','coursespecific');
725: my @chgentry = ('firstres','whatsnew');
1.59 albertel 726: my $lctype = lc(&Apache::loncommon::course_type());
1.39 raeburn 727: my %lt = &Apache::lonlocal::texthash(
1.56 raeburn 728: 'chwp' => "Choose which page will be displayed when you enter this $lctype after selecting a role.",
1.39 raeburn 729: 'cuva' => 'Current value is determined by',
730: 'anis' => 'and is set to display',
731: 'padc' => 'Page display controlled by',
1.56 raeburn 732: 'chce' => 'Choose '.$lctype.' entry',
1.89 schafran 733: 'moce' => 'Save',
1.39 raeburn 734: );
735: $r->print(<<"END");
736: <br />$lt{'chwp'}
737: <br />$lt{'cuva'}: <b>
738: $$initpage{$control}</b> $lt{'anis'} <b>
739: $$initpage{$current}</b>.<br /><br />
740: <form method="post" name="courseinitswitch" action="/adm/whatsnew">
741: <input type="hidden" name="command" value="newcourseinit" />
742: <input type="hidden" name="refpage" value="$refpage" />
1.56 raeburn 743: $lt{'padc'}:
1.39 raeburn 744: END
745: foreach my $choice (@chgstate) {
1.56 raeburn 746: my $chkstring;
747: if ($choice eq $control) {
748: $chkstring = ' checked="checked" ';
749: }
1.73 raeburn 750: $r->print('<span class="LC_nobreak"><label><input type="radio" name="courseinit_control" value="'.
1.56 raeburn 751: $choice.'"'.$chkstring.'/>'.$$initpage{$choice}.
1.73 raeburn 752: ' </label></span>');
1.39 raeburn 753: }
754: $r->print('<br /><br />'.&mt('If').' '.$$initpage{'coursespecific'}.
1.56 raeburn 755: ' - <br />'.$lt{'chce'}.": \n");
1.39 raeburn 756: foreach my $choice (@chgentry) {
1.56 raeburn 757: my $chkstring;
758: if (($choice eq $current) && ($control eq 'coursespecific')) {
759: $chkstring = ' checked="checked" ';
760: }
1.73 raeburn 761: $r->print('<span class="LC_nobreak"><label><input type="radio" name="courseinit_page" value="'.
1.56 raeburn 762: $choice.'"'.$chkstring.'/>'.$$initpage{$choice}.
1.73 raeburn 763: ' </label></span>');
1.39 raeburn 764: }
765: $r->print('<br /><br /><input type="submit" name="display" value="'.
766: $lt{'moce'}.'" /></form>');
767: return;
768: }
769:
770: sub curr_courseinit {
771: my $current = &get_current($env{'user.name'},$env{'user.domain'},
772: $env{'request.course.id'},'courseinit');
773: my $control;
1.40 raeburn 774: if ($current) {
775: $control = 'coursespecific';
776: } else {
1.39 raeburn 777: $control = 'userpref';
1.40 raeburn 778: my %userenv = &Apache::lonnet::get('environment',
779: ['course_init_display']);
780: if (exists($userenv{'course_init_display'})) {
781: $current = $userenv{'course_init_display'};
782: }
783: unless ($current) {
1.39 raeburn 784: $current = 'whatsnew';
785: }
786: }
787: return ($control,$current);
788: }
789:
1.33 raeburn 790: sub display_launcher {
1.69 raeburn 791: my ($r,$action,$refpage,$checkallowed,$show,$headings,$res_title,
1.68 raeburn 792: $tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered,
793: $newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs,
1.77 raeburn 794: $interval,$countunread,$expired,$expirecount,$activated,$activecount,
1.84 raeburn 795: $crstype,$itemserror) = @_;
1.33 raeburn 796:
797: if ($$checkallowed{$action}) {
1.69 raeburn 798: &start_box($r,$show,$headings,$action,$refpage,$action);
1.33 raeburn 799: if ($$show{$action}) {
800: if ($action eq 'handgrading') { # UNGRADED ITEMS
1.84 raeburn 801: &display_handgrade($r,$tograde,$ungraded,$itemserror);
1.33 raeburn 802: } elsif ($action eq 'haserrors') { # BOMBS
1.84 raeburn 803: &display_haserrors($r,$bombs,$bombed,$res_title,$itemserror);
1.33 raeburn 804: } elsif ($action eq 'versionchanges') { # VERSION CHANGES
1.84 raeburn 805: &display_versionchanges($r,$changed,$res_title,$interval->{'versions'},$itemserror);
1.33 raeburn 806: } elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS
1.39 raeburn 807: &display_abovethreshold($r,$refpage,$warnings,$triggered,
1.84 raeburn 808: $res_title,$itemserror);
1.33 raeburn 809: } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION
810: &display_coursediscussion($r,$newdiscussions,$unread,
1.84 raeburn 811: $countunread,$res_title,$itemserror);
1.33 raeburn 812: } elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES
1.68 raeburn 813: &display_coursenormalmail($r,$msgcount,$newmsgs);
1.33 raeburn 814: } elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES
1.68 raeburn 815: &display_coursecritmail($r,$critmsgcount,$critmsgs);
1.77 raeburn 816: } elsif ($action eq 'newroles') { # ACTIVATED ROLES
817: &display_rolechanges($r,$activecount,$activated,$interval->{'newroles'},
818: $crstype);
819: } elsif ($action eq 'oldroles') { # EXPIRED ROLES
820: &display_rolechanges($r,$expirecount,$expired,$interval->{'oldroles'},
821: $crstype);
1.33 raeburn 822: }
823: }
824: &end_box($r);
825: }
826: return;
827: }
828:
1.1 raeburn 829: sub getitems {
1.33 raeburn 830: my ($unread,$ungraded,$bombed,$triggered,$changed,$newdiscussions,
1.68 raeburn 831: $tograde,$bombs,$warnings,$threshold,$cdom,$crs,$res_title,$show,
832: $starttime,$countunread) = @_;
1.1 raeburn 833: my $navmap = Apache::lonnavmaps::navmap->new();
1.84 raeburn 834: if (!defined($navmap)) {
835: 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>';
836: return $itemserror;
837: }
1.26 albertel 838: # force retrieve Resource to seed the part id cache we'll need it later
1.37 raeburn 839: my @allres=$navmap->retrieveResources(undef,
840: sub {if ($_[0]->is_problem) { $_[0]->parts();} return 1;});
1.33 raeburn 841: my %resourcetracker;
1.37 raeburn 842: my $discussiontime;
1.33 raeburn 843:
844: # Resource version changes
845: if ($$show{'versionchanges'}) {
846: &checkversions($cdom,$crs,$navmap,$changed,$starttime);
847: }
848:
849: if ($$show{'abovethreshold'}) {
850: %resourcetracker = &Apache::lonnet::dump('nohist_resourcetracker',
851: $cdom,$crs);
852: }
1.1 raeburn 853:
854: foreach my $resource (@allres) {
855: my $result = '';
856: my $applies = 0;
857: my $symb = $resource->symb();
1.33 raeburn 858: %{$$bombed{$symb}} = ();
1.1 raeburn 859: %{$$ungraded{$symb}} = ();
1.11 raeburn 860: %{$$triggered{$symb}} = ();
861: $$triggered{$symb}{numparts} = 0;
1.66 raeburn 862: if ($resource->encrypted()) {
863: $$triggered{$symb}{'enclink'} = $resource->link();
864: $$triggered{$symb}{'encsymb'} = $resource->shown_symb();
865: }
1.1 raeburn 866: my $title = $resource->compTitle();
1.16 raeburn 867: $$res_title{$symb} = $title;
1.8 albertel 868: my $ressymb = $resource->wrap_symb();
1.33 raeburn 869:
1.37 raeburn 870: # Check if there are unread discussion postings
1.33 raeburn 871: if ($$show{'coursediscussion'}) {
1.51 albertel 872: &check_discussions($resource,$symb,$ressymb,$title,
873: $newdiscussions,$unread,$countunread);
1.33 raeburn 874: }
1.1 raeburn 875:
876: # Check for ungraded problems
877: if ($resource->is_problem()) {
1.33 raeburn 878: if ($$show{'handgrading'}) {
879: &check_handgraded($resource,$symb,$title,$cdom,$crs,$ungraded,
880: $tograde);
881: }
1.1 raeburn 882: }
883:
884: # Check for bombs
1.33 raeburn 885: if ($$show{'haserrors'}) {
886: &check_bombed($resource,$symb,$title,$bombs,$bombed);
887: }
888:
889: # Maxtries and degree of difficulty for problem parts, unless handgradeable
890: if ($$show{'abovethreshold'}) {
1.61 albertel 891: &check_thresholds($resource,$symb,\%resourcetracker,
892: $triggered,$threshold,$warnings);
1.33 raeburn 893: }
894:
895: }
1.84 raeburn 896: return;
1.33 raeburn 897: }
898:
899: sub check_discussions {
1.51 albertel 900: my ($resource,$symb,$ressymb,$title,$newdiscussions,$unread,
901: $countunread) = @_;
902:
903: if (!$resource->hasDiscussion()) { return; }
1.37 raeburn 904:
1.51 albertel 905: %{$$unread{$ressymb}} = ();
906: $$unread{$ressymb}{'title'} = $title;
907: $$unread{$ressymb}{'symb'} = $symb;
1.66 raeburn 908: if ($resource->encrypted()) {
909: $$unread{$ressymb}{'enclink'} = $resource->link();
910: $$unread{$ressymb}{'encsymb'} = $resource->shown_symb();
911: }
1.51 albertel 912: push(@{$newdiscussions}, $ressymb);
913:
914: $$unread{$ressymb}{'lastpost'} = $resource->last_post_time();
915:
916: if ($countunread eq 'on') {
1.67 raeburn 917: $$unread{$ressymb}{'unreadcount'} =
918: $resource->discussion_info('unread');
1.33 raeburn 919: }
920: }
921:
922: sub check_handgraded {
923: my ($resource,$symb,$title,$cdom,$cnum,$ungraded,$tograde) = @_;
924: if ($resource->is_problem()) {
925: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
926: my $partlist=$resource->parts();
927: my $handgradeable;
928: foreach my $part (@$partlist) {
1.31 raeburn 929: if ($resource->handgrade($part) eq 'yes') {
1.33 raeburn 930: $handgradeable=1; last;
1.31 raeburn 931: }
1.33 raeburn 932: }
933: if ($handgradeable) {
1.35 raeburn 934: my @ungraded = &Apache::bridgetask::get_queue_symb_status(
1.33 raeburn 935: 'gradingqueue',$symb,$cdom,$cnum);
936: if (@ungraded > 0) {
937: $$ungraded{$symb}{count} = scalar(@ungraded);
938: $$ungraded{$symb}{title} = $title;
1.66 raeburn 939: if ($resource->encrypted()) {
940: $$ungraded{$symb}{'enclink'} = $resource->link();
941: $$ungraded{$symb}{'encsymb'} = $resource->shown_symb();
942: }
943: push(@{$tograde},$symb);
1.11 raeburn 944: }
945: }
1.33 raeburn 946: }
947: }
948:
949: sub check_bombed {
950: my ($resource,$symb,$title,$bombs,$bombed) = @_;
951: if ($resource->getErrors()) {
952: my $errors = $resource->getErrors();
953: $errors =~ s/^,//;
954: my @bombs = split(/,/, $errors);
955: my $errorcount = scalar(@bombs);
956: my $errorlink = '<a href="/adm/email?display='.
1.55 www 957: &escape($bombs[0]).'">'.
1.33 raeburn 958: $title.'</a>';
959: $$bombed{$symb}{errorcount} = $errorcount;
960: $$bombed{$symb}{errorlink} = $errorlink;
961: push(@{$bombs}, $symb);
962: }
963: }
964:
965: sub check_thresholds {
1.61 albertel 966: my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings) = @_;
1.33 raeburn 967: # Compile maxtries and degree of difficulty for problem parts, unless handgradeable
968: my @parts = @{$resource->parts()};
969: my %stats;
970: my %lastreset = ();
971: my $warning = 0;
972: foreach my $part (@parts) {
973: if ($resource->handgrade($part) eq 'yes') {
974: next;
975: }
1.48 raeburn 976: if ($resource->is_survey($part)) {
977: next;
978: }
1.33 raeburn 979: %{$stats{$part}} = ();
980: my ($attempts,$users,$corrects,$degdiff,$av_attempts);
981: if (exists($$resourcetracker{$symb."\0".$part."\0attempts"})) {
982: $attempts = $$resourcetracker{$symb."\0".$part."\0attempts"};
983: }
984: if (exists($$resourcetracker{$symb."\0".$part."\0users"})) {
985: $users = $$resourcetracker{$symb."\0".$part."\0users"};
986: }
987: if (exists($$resourcetracker{$symb."\0".$part."\0correct"})) {
988: $corrects = $$resourcetracker{$symb."\0".$part."\0correct"};
989: }
990: if ($attempts > 0) {
991: $degdiff = 1 - ($corrects/$attempts);
992: $degdiff = sprintf("%.2f",$degdiff);
993: }
994: if ($users > 0) {
995: $av_attempts = $attempts/$users;
996: $av_attempts = sprintf("%.2f",$av_attempts);
997: }
998: if ((($degdiff ne '' && $degdiff >= $$threshold{'degdiff'}) || ($av_attempts ne '' && $av_attempts >= $$threshold{'av_attempts'})) && ($users >= $$threshold{'numstudents'})) {
999: $stats{$part}{degdiff} = $degdiff;
1000: $stats{$part}{attempts} = $av_attempts;
1001: $stats{$part}{users} = $users;
1002: $lastreset{$part} = $$resourcetracker{$symb."\0".$part."\0resettime"};
1003: if ($lastreset{$part}) {
1004: $lastreset{$part} = &Apache::lonnavmaps::timeToHumanString($lastreset{$part});
1.11 raeburn 1005: }
1.33 raeburn 1006: $warning = 1;
1007: }
1008: }
1009: if ($warning) {
1010: $$triggered{$symb}{title} = $resource->title;
1.62 raeburn 1011: my $partcount = 0;
1012: @{$$triggered{$symb}{text}} = ();
1.33 raeburn 1013: foreach my $part (@parts) {
1014: if (exists($stats{$part}{users})) {
1.55 www 1015: my $resetname = 'reset_'.&escape($symb."\0".$part);
1016: my $resettitle = 'title_'.&escape($symb."\0".$part);
1.33 raeburn 1017: if (@parts > 1) {
1.62 raeburn 1018: $$triggered{$symb}{text}[$partcount] = '
1.74 bisitz 1019: <td>'.&mt('part - ').$part.'</td>';
1.33 raeburn 1020: } else {
1.62 raeburn 1021: $$triggered{$symb}{text}[$partcount] = '
1.74 bisitz 1022: <td>'.&mt('single part').'</td>';
1.11 raeburn 1023: }
1.62 raeburn 1024: $$triggered{$symb}{text}[$partcount] .= '
1.61 albertel 1025: <td>'.$stats{$part}{users}.'</td>
1026: <td>'.$stats{$part}{attempts}.'</td>
1027: <td>'.$stats{$part}{degdiff}.'</td>
1028: <td>'.$lastreset{$part}.'</td>
1.62 raeburn 1029: <td><input type="checkbox" name="'.$resetname.'" /><input type="hidden" name="'.$resettitle.'" value="'.&escape($$triggered{$symb}{title}).'" /></td>';
1030: $partcount ++;
1.11 raeburn 1031: }
1.62 raeburn 1032: $$triggered{$symb}{numparts} = $partcount;
1.11 raeburn 1033: }
1.33 raeburn 1034: push(@{$warnings},$symb);
1.1 raeburn 1035: }
1036: }
1037:
1.33 raeburn 1038:
1.13 raeburn 1039: sub get_curr_thresholds {
1.39 raeburn 1040: my ($threshold,$uname,$udom,$cid,$cdom,$crs) = @_;
1.64 banghart 1041: # set default values
1042: %$threshold = (av_attempts => 2,
1043: degdiff => 0.5,
1044: numstudents => 2
1045: );
1.39 raeburn 1046: my %thresholdsettings = &Apache::lonnet::dump('nohist_whatsnew',$udom,
1047: $uname,$cid.':threshold');
1048: my $thresholdcount = 0;
1049: my ($tmp) = %thresholdsettings;
1.40 raeburn 1050: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 1051: foreach my $item (keys %{$threshold}) {
1052: if (exists($thresholdsettings{$cid.':threshold_'.$item})) {
1053: $$threshold{$item} =
1054: $thresholdsettings{$cid.':threshold_'.$item};
1055: $thresholdcount ++;
1056: }
1057: }
1.13 raeburn 1058: }
1.39 raeburn 1059: if ($thresholdcount == 3) {
1060: return;
1.13 raeburn 1061: }
1.39 raeburn 1062: my %coursesettings = &Apache::lonnet::dump('environment',
1063: $cdom,$crs,'internal.threshold');
1064: my ($temp) = %coursesettings;
1.40 raeburn 1065: unless ($temp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 1066: foreach my $item (keys %{$threshold}) {
1067: unless (exists($thresholdsettings{$cid.':threshold_'.$item})) {
1068: if (exists($coursesettings{'internal.threshold_'.$item})) {
1069: $$threshold{$item} =
1070: $coursesettings{'internal.threshold_'.$item};
1071: }
1072: }
1073: }
1.13 raeburn 1074: }
1.39 raeburn 1075: return;
1.13 raeburn 1076: }
1077:
1.39 raeburn 1078: sub get_current {
1079: my ($uname,$udom,$cid,$caller) = @_;
1080: my $currvalue;
1081: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid.
1082: ':'.$caller);
1.36 raeburn 1083: my ($tmp) = %settings;
1.40 raeburn 1084: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 1085: $currvalue = $settings{$cid.':'.$caller};
1.36 raeburn 1086: }
1.39 raeburn 1087: return $currvalue;
1.36 raeburn 1088: }
1089:
1.13 raeburn 1090: sub process_reset {
1091: my ($dom,$crs) = @_;
1.39 raeburn 1092: my $result = '<b>'.&mt('Counters reset for following problems (and parts):').
1093: '</b><br />';
1.13 raeburn 1094: my @agg_types = ('attempts','users','correct');
1.39 raeburn 1095: my %agg_titles = &Apache::lonlocal::texthash (
1.13 raeburn 1096: attempts => 'Number of submissions',
1097: users => 'Students with submissions',
1098: correct => 'Number of correct submissions',
1099: );
1100: my @resets = ();
1101: my %titles = ();
1.17 albertel 1102: foreach my $key (keys(%env)) {
1.13 raeburn 1103: next if ($key !~ /^form\.reset_(.+)$/);
1.55 www 1104: my $title = &unescape($env{'form.title_'.$1});
1105: my $reset_item = &unescape($1);
1.13 raeburn 1106: my %curr_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
1107: my %aggregates = ();
1.17 albertel 1108: my ($symb,$part) = split(/\0/,$reset_item);
1.13 raeburn 1109: foreach my $type (@agg_types) {
1110: $aggregates{$reset_item."\0".$type} = 0;
1111: }
1.17 albertel 1112: $aggregates{$reset_item."\0".'resettime'} = time;
1.13 raeburn 1113: my $putresult = &Apache::lonnet::put('nohist_resourcetracker',\%aggregates,
1114: $dom,$crs);
1115: if ($putresult eq 'ok') {
1116: $result .= $title.' -part '.$part.': ';
1117: my %new_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
1118: foreach my $type (@agg_types) {
1119: $result .= $agg_titles{$type}.' = '.$new_aggregates{$reset_item."\0".$type}.'; ';
1120: }
1121: $result =~ s/; $//;
1122: $result .= '<br />';
1123: } else {
1.14 albertel 1124: $result = $title.' -part '.$part.': '.&mt('Unable to reset counters to zero due to [_1]',$putresult).'.<br />'."\n";
1.13 raeburn 1125: }
1126: }
1127: return $result;
1128: }
1129:
1130: sub process_update {
1.39 raeburn 1131: my ($uname,$udom,$threshold_titles) = @_;
1.74 bisitz 1132: my $setoutput = '<b>'.&mt('Changes to threshold(s) for problem tracking:').'</b><br />';
1.13 raeburn 1133: foreach (keys %env) {
1134: next if ($_!~/^form\.(.+)\_setparmval$/);
1135: my $name = $1;
1136: my $value = $env{'form.'.$name.'_value'};
1.65 banghart 1137: if ($name && defined($value) && ($value ne '')) {
1.39 raeburn 1138: my $put_result = &Apache::lonnet::put('nohist_whatsnew',
1139: {$name=>$value},$udom,$uname);
1.13 raeburn 1140:
1.39 raeburn 1141: my ($shortname) = ($name =~ /^\Q$env{'request.course.id'}\E:threshold_(.+)$/);
1.13 raeburn 1142: if ($put_result eq 'ok') {
1.14 albertel 1143: $setoutput.=&mt('Set threshold for [_1] to [_2]',
1144: '<b>'.$$threshold_titles{$shortname}.'</b>',
1145: '<b>'.$value.'</b>').'<br />';
1146: } else {
1147: $setoutput.=&mt('Unable to set threshold for [_1] to [_2] due to [_3].',
1148: '<b>'.$name.'</b>','<b>'.$value.'</b>',
1149: '<tt>'.$put_result.'</tt>').'<br />';
1.13 raeburn 1150: }
1151: }
1152: }
1153: return $setoutput;
1154: }
1155:
1.33 raeburn 1156: sub getnormalmail {
1157: my ($newmsgs) = @_;
1.1 raeburn 1158: # Check for unread mail in course
1159: my $msgcount = 0;
1.3 albertel 1160:
1.10 raeburn 1161: my @messages = sort(&Apache::lonnet::getkeys('nohist_email'));
1.3 albertel 1162: foreach my $message (@messages) {
1.55 www 1163: my $msgid=&escape($message);
1.10 raeburn 1164: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1.1 raeburn 1165: &Apache::lonmsg::unpackmsgid($msgid);
1.10 raeburn 1166: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 1167: if (defined($sendtime) && $sendtime!~/error/) {
1168: my $numsendtime = $sendtime;
1.91 lueken 1169: if ($status eq 'new') {
1.93 droeschl 1170: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
1.91 lueken 1171: $msgcount ++;
1.10 raeburn 1172: if ($shortsubj eq '') {
1173: $shortsubj = &mt('No subject');
1174: }
1.1 raeburn 1175: push(@{$newmsgs}, {
1176: msgid => $msgid,
1177: sendtime => $sendtime,
1.10 raeburn 1178: shortsub => $shortsubj,
1.1 raeburn 1179: from => $fromname,
1180: fromdom => $fromdom
1181: });
1182: }
1183: }
1184: }
1185: }
1.33 raeburn 1186: return $msgcount;
1187: }
1.1 raeburn 1188:
1.33 raeburn 1189: sub getcritmail {
1190: my ($critmsgs) = @_;
1.1 raeburn 1191: # Check for critical messages in course
1192: my %what=&Apache::lonnet::dump('critical');
1193: my $result = '';
1194: my $critmsgcount = 0;
1.3 albertel 1195: foreach my $msgid (sort(keys(%what))) {
1.10 raeburn 1196: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1197: &Apache::lonmsg::unpackmsgid($msgid);
1198: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 1199: if (defined($sendtime) && $sendtime!~/error/) {
1200: my $numsendtime = $sendtime;
1.93 droeschl 1201: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
1.1 raeburn 1202: $critmsgcount ++;
1.10 raeburn 1203: if ($shortsubj eq '') {
1204: $shortsubj = &mt('No subject');
1205: }
1.1 raeburn 1206: push(@{$critmsgs}, {
1207: msgid => $msgid,
1208: sendtime => $sendtime,
1.10 raeburn 1209: shortsub => $shortsubj,
1.1 raeburn 1210: from => $fromname,
1211: fromdom => $fromdom
1212: });
1213: }
1214: }
1215: }
1.33 raeburn 1216: return $critmsgcount;
1217: }
1218:
1.77 raeburn 1219: sub getexpired {
1220: my ($rolechgs,$rolechgtime,$status) = @_;
1221: my $expirecount = &getrolechanges($rolechgs,$rolechgtime,$status);
1222: return $expirecount;
1223: }
1224:
1225: sub getactivated {
1226: my ($rolechgs,$rolechgtime,$status) = @_;
1227: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1228: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1229: my $now = time();
1230: my $context = 'course';
1231: my ($permission,$allowed) =
1232: &Apache::lonuserutils::get_permission($context);
1233: my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
1234: my %changes=&Apache::lonnet::dump('nohist_rolelog',$cdom,$cnum);
1235: my (%stucounted,%advcounted);
1236: my $activatedcount = 0;
1237: if (keys(%changes) > 0) {
1238: foreach my $chg (sort { $b <=> $a } (keys(%changes))) {
1239: if (ref($changes{$chg}) eq 'HASH') {
1240: my $timestamp = $changes{$chg}{'exe_time'};
1241: if ($timestamp) {
1.79 raeburn 1242: if ($rolechgtime > 0) {
1243: if ($timestamp < $rolechgtime) {
1.77 raeburn 1244: last;
1245: }
1246: }
1247: if (ref($changes{$chg}{'logentry'}) eq 'HASH') {
1248: next if ($changes{$chg}{'delflag'});
1249: my $start = $changes{$chg}{'logentry'}{'start'};
1250: my $end = $changes{$chg}{'logentry'}{'end'};
1251: my $section = $changes{$chg}{'logentry'}{'section'};
1252: my $role = $changes{$chg}{'logentry'}{'role'};
1253: my $uname = $changes{$chg}{'uname'};
1254: my $udom = $changes{$chg}{'udom'};
1255: next if ($end && $end <= $now);
1256: if (($viewablesec ne '') && ($section ne '')) {
1257: next if ($viewablesec ne $section);
1258: }
1259: next if ($start >= $timestamp);
1260: if ($role eq 'st') {
1261: $stucounted{$uname.':'.$udom.':'.$section} = $start.':'.$end;
1262: } else {
1263: $advcounted{$uname.':'.$udom.':'.$role.':'.$section} = $start.':'.$end;
1264: }
1265: my %chginfo = (
1266: 'section' => $section,
1267: 'uname' => $uname,
1268: 'udom' => $udom,
1269: 'role' => $role,
1270: 'status' => $status,
1271: );
1272: $activatedcount ++;
1273: push (@{$rolechgs->{$timestamp}},\%chginfo);
1274: }
1275: }
1276: }
1277: }
1278: }
1279: $activatedcount += &getrolechanges($rolechgs,$rolechgtime,$status,\%stucounted,\%advcounted);
1280: return $activatedcount;
1281: }
1282:
1283: sub getrolechanges {
1284: my ($rolechgs,$rolechgtime,$status,$stucountref,$advcountref) = @_;
1285: my (%stucounted,%advcounted);
1286: if (ref($stucountref) eq 'HASH') {
1287: %stucounted = %{$stucountref};
1288: }
1289: if (ref($advcountref) eq 'HASH') {
1290: %advcounted = %{$advcountref};
1291: }
1292: my $withsec = 1;
1293: my $hidepriv = 1;
1294: my $context = 'course';
1295: my @statuses = ($status);
1296: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1297: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1298: my $now = time();
1299: my ($permission,$allowed) =
1300: &Apache::lonuserutils::get_permission($context);
1301: my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
1302: my $classlist = &Apache::loncoursedata::get_classlist();
1303: my $secidx = &Apache::loncoursedata::CL_SECTION();
1304: my $startidx = &Apache::loncoursedata::CL_START();
1305: my $endidx = &Apache::loncoursedata::CL_END();
1306: my $rolechgcount = 0;
1307: foreach my $key (keys(%{$classlist})) {
1308: my ($userstatus,$eventtime);
1309: my $student = $classlist->{$key};
1310: if (ref($student) eq 'ARRAY') {
1311: my $start = $student->[$startidx];
1312: my $end = $student->[$endidx];
1313: my $sec = $student->[$secidx];
1314: my ($stuname,$studom) = split(/:/,$key);
1315: if ($status eq 'active') {
1316: if (exists($stucounted{$key.':'.$sec})) {
1317: next;
1318: }
1319: }
1320: if (($end == 0) || ($end > $start)) {
1321: if ($start <= $now) {
1322: if ($end && $end < $now) {
1323: if ($rolechgtime > 0) {
1324: if ($end > $rolechgtime) {
1325: $userstatus = 'previous';
1326: }
1327: } else {
1328: $userstatus = 'previous';
1329: }
1330: } else {
1331: if ($rolechgtime > 0) {
1332: if ($start >= $rolechgtime) {
1333: $userstatus = 'active';
1334: }
1335: } else {
1336: $userstatus = 'active';
1337: }
1338: }
1339: }
1340: }
1341: next if ($userstatus ne $status);
1342: if ($status eq 'active') {
1343: $eventtime = $start;
1344: } else {
1345: $eventtime = $end;
1346: }
1347: if (($viewablesec ne '') && ($sec ne '')) {
1348: next if ($viewablesec ne $sec);
1349: }
1350: my %chginfo = (
1351: 'section' => $sec,
1352: 'uname' => $stuname,
1353: 'udom' => $studom,
1354: 'role' => 'st',
1355: 'status' => $userstatus,
1356: );
1357: $rolechgcount ++;
1358: push (@{$rolechgs->{$eventtime}},\%chginfo);
1359: }
1360: }
1361: my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
1362: \@statuses,undef,undef,$withsec,$hidepriv);
1363: foreach my $item (keys(%advrolehash)) {
1364: my ($userstatus,$eventtime);
1365: my ($uname,$udom,$role,$section) = split(/:/,$item,-1);
1366: my ($start,$end) = split(/:/,$advrolehash{$item});
1367: if ($start eq '-1' && $end eq '-1') {
1368: next;
1369: } else {
1370: if ($status eq 'active') {
1371: if (exists($advcounted{$item})) {
1372: next;
1373: }
1374: }
1375: if (($end == 0) || ($end > $start)) {
1376: if ($start <= $now) {
1377: if ($end && $end < $now) {
1378: if ($rolechgtime > 0) {
1379: if ($end > $rolechgtime) {
1380: $userstatus = 'previous';
1381: }
1382: } else {
1383: $userstatus = 'previous';
1384: }
1385: } else {
1386: if ($rolechgtime > 0) {
1387: if ($start >= $rolechgtime) {
1388: $userstatus = 'active';
1389: }
1390: } else {
1391: $userstatus = 'active';
1392: }
1393: }
1394: }
1395: }
1396: next if ($userstatus ne $status);
1397: if ($status eq 'active') {
1398: $eventtime = $start;
1399: } else {
1400: $eventtime = $end;
1401: }
1402: }
1403: if (($viewablesec ne '') && ($section ne '')) {
1404: next if ($viewablesec ne $section);
1405: }
1406: my %chginfo = (
1407: 'section' => $section,
1408: 'uname' => $uname,
1409: 'udom' => $udom,
1410: 'role' => $role,
1411: 'status' => $userstatus,
1412: );
1413: $rolechgcount ++;
1414: push (@{$rolechgs->{$eventtime}},\%chginfo);
1415: }
1416: return $rolechgcount;
1417: }
1.33 raeburn 1418:
1419: sub checkversions {
1420: my ($cdom,$crs,$navmap,$changed,$starttime) = @_;
1421: my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs);
1422: my ($tmp) = keys(%changes);
1.40 raeburn 1423: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 1424: if (keys(%changes) > 0) {
1425: foreach my $key (sort(keys(%changes))) {
1426: if ($changes{$key} > $starttime) {
1427: my $version;
1428: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
1429: my $currentversion=&Apache::lonnet::getversion($key);
1430: my $revdate =
1431: &Apache::lonnet::metadata($root.'.'.$extension,
1432: 'lastrevisiondate');
1433: $revdate = &Apache::lonlocal::locallocaltime($revdate);
1434: my $linkurl=&Apache::lonnet::clutter($key);
1435: my $usedversion=$navmap->usedVersion('version_'.$linkurl);
1436: my @resources = $navmap->getResourceByUrl($linkurl,1);
1437: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1438: $version = $usedversion;
1439: } else {
1440: $version = $currentversion;
1441: }
1442: foreach my $res (@resources) {
1.35 raeburn 1443: if (ref($res) eq 'Apache::lonnavmaps::resource') {
1444: my $symb = $res->symb();
1445: %{$$changed{$symb}} = (
1.33 raeburn 1446: current => $currentversion,
1447: version => $version,
1448: revdate => $revdate,
1.35 raeburn 1449: );
1450: }
1.33 raeburn 1451: }
1452: }
1453: }
1454: }
1455: }
1456: return;
1457: }
1458:
1459: sub display_handgrade {
1.84 raeburn 1460: my ($r,$tograde,$ungraded,$itemserror) = @_;
1.33 raeburn 1461: my %lt = &Apache::lonlocal::texthash(
1462: 'prna' => 'Problem Name',
1463: 'nmun' => 'Number ungraded',
1464: 'nopr' => 'No problems require handgrading',
1465: );
1466: if (@{$tograde} > 0) {
1.68 raeburn 1467: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1468: $lt{'prna'}.'</td><td class="LC_right_item">'.
1469: $lt{'nmun'}.'</td></tr>');
1.33 raeburn 1470: my $rowNum = 0;
1471: foreach my $res (@{$tograde}) {
1.68 raeburn 1472: $rowNum ++;
1473: my $css_class = $rowNum%2?' class="LC_odd_row"':'';
1.33 raeburn 1474: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
1475: my $linkurl=&Apache::lonnet::clutter($url);
1.55 www 1476: $linkurl .= '?symb='.&escape($res);
1.66 raeburn 1477: if ($$ungraded{$res}{'enclink'}) {
1478: $linkurl =
1479: $$ungraded{$res}{'enclink'}.'?symb='.$$ungraded{$res}{'encsymb'};
1480: }
1.68 raeburn 1481: $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 1482: }
1.84 raeburn 1483: } elsif ($itemserror) {
1484: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1485: } else {
1.68 raeburn 1486: $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
1.33 raeburn 1487: }
1488: }
1489:
1490: sub display_haserrors {
1.84 raeburn 1491: my ($r,$bombs,$bombed,$res_title,$itemserror) = @_;
1.33 raeburn 1492: my $bombnum = 0;
1493: my %lt = &Apache::lonlocal::texthash(
1494: reso => 'Resource',
1495: nmer => 'Number of errors',
1496: noer => 'No problems with errors',
1497: );
1498: if (@{$bombs} > 0) {
1.68 raeburn 1499: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1500: $lt{'reso'}.'</td><td class="LC_right_item">'.
1501: $lt{'nmer'}.'</td></tr>');
1.33 raeburn 1502: @{$bombs} = sort { &cmp_title($a,$b,$res_title) } @{$bombs};
1503: foreach my $bomb (@{$bombs}) {
1504: $bombnum ++;
1.68 raeburn 1505: my $css_class = $bombnum%2?' class="LC_odd_row"':'';
1506: $r->print('<tr'.$css_class.'><td>'.$$bombed{$bomb}{errorlink}.
1507: '</td><td class="LC_right_item">'.
1508: $$bombed{$bomb}{errorcount}.'</td></tr>');
1.33 raeburn 1509: }
1.84 raeburn 1510: } elsif ($itemserror) {
1511: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1512: } else {
1.68 raeburn 1513: $r->print('<tr class="LC_empty_row"><td>'.$lt{'noer'}.'</td></tr>');
1.33 raeburn 1514: }
1515: return;
1516: }
1517:
1518: sub display_abovethreshold {
1.84 raeburn 1519: my ($r,$refpage,$warnings,$triggered,$res_title,$itemserror) = @_;
1.33 raeburn 1520: my %lt = &Apache::lonlocal::texthash(
1521: reso => 'Resource',
1522: part => 'Part',
1523: nust => 'Num. students',
1524: avat => 'Av. Attempts',
1525: dedi => 'Deg. Diff',
1526: lare => 'Last Reset',
1527: reco => 'Reset Count?',
1528: rese => 'Reset counters to 0',
1529: nopr => 'No problems satisfy threshold criteria',
1530: );
1531: if (@{$warnings} > 0) {
1532: @{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings};
1.36 raeburn 1533: $r->print('<form name="reset_tracking" method="post" action="/adm/whatsnew">'.
1.39 raeburn 1534: ' <input type="hidden" name="command" value="reset" />'."\n".
1535: ' <input type="hidden" name="refpage" value="'.$refpage.'" />'.
1536: "\n");
1.61 albertel 1537: $r->print('<tr class="LC_info_row">'.
1.68 raeburn 1538: '<td class="LC_left_item">'.$lt{'reso'}.'</td>'.
1.61 albertel 1539: '<td>'.$lt{'part'}.'</td><td>'.$lt{'nust'}.'</td>'.
1540: '<td>'.$lt{'avat'}.'</td><td>'.$lt{'dedi'}.'</td>'.
1.68 raeburn 1541: '<td>'.$lt{'lare'}.'</td><td class="LC_right_item">'.
1542: $lt{'reco'}.'</td></tr>');
1.61 albertel 1543: my $row;
1.33 raeburn 1544: foreach my $res (@{$warnings}) {
1.61 albertel 1545: $row++;
1.33 raeburn 1546: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
1547: my $linkurl=&Apache::lonnet::clutter($url);
1548: my $rowspan;
1549: if ($$triggered{$res}{numparts} > 1) {
1550: $rowspan = 'rowspan="'.$$triggered{$res}{numparts}.'"';
1551: }
1.55 www 1552: $linkurl .= '?symb='.&escape($res);
1.66 raeburn 1553: if ($$triggered{$res}{'enclink'}) {
1554: $linkurl =
1555: $$triggered{$res}{'enclink'}.'?symb='.$$triggered{$res}{'encsymb'};
1556: }
1.68 raeburn 1557: my $css_class = $row%2?' class="LC_odd_row"':'';
1558: $r->print('<tr'.$css_class.'>'.
1.61 albertel 1559: '<td class="LC_first_item" '.$rowspan.'><a href="'.$linkurl.'">'.
1.62 raeburn 1560: $$triggered{$res}{title}.'</a></td>');
1561: if (ref($$triggered{$res}{text}) eq 'ARRAY') {
1562: $r->print($$triggered{$res}{text}[0]);
1563: }
1564: $r->print('</tr>');
1565: if (ref($$triggered{$res}{text}) eq 'ARRAY') {
1566: if (@{$$triggered{$res}{text}} > 1) {
1567: for (my $i=1; $i<@{$$triggered{$res}{text}}; $i++) {
1568: $r->print('<tr class="'.$css_class.'">'.
1569: $$triggered{$res}{text}[$i].'</tr>');
1570: }
1571: }
1572: }
1.33 raeburn 1573: }
1.68 raeburn 1574: $r->print('<tr class="LC_info_row"><td colspan="7" class="LC_right_item"><br /><input type="submit" name="counters" value="'.$lt{'rese'}.'" /></td></tr></form>');
1.84 raeburn 1575: } elsif ($itemserror) {
1576: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1577: } else {
1.63 albertel 1578: $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
1.33 raeburn 1579: }
1580: }
1581:
1582: sub display_versionchanges {
1.84 raeburn 1583: my ($r,$changed,$res_title,$interval,$itemserror) = @_;
1.33 raeburn 1584: my %lt = &Apache::lonlocal::texthash(
1585: 'reso' => 'Resource',
1586: 'revd' => 'Last revised',
1587: 'newv' => 'New version',
1588: 'veru' => 'Version used',
1589: );
1590: if (keys(%{$changed}) > 0) {
1.68 raeburn 1591: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1592: $lt{'reso'}.'</td><td>'.$lt{'revd'}.'</td><td>'.
1593: $lt{'newv'}.'</td><td class="LC_right_item">'.
1594: $lt{'veru'}.'</td></tr>');
1.33 raeburn 1595: my @changes = sort { &cmp_title($a,$b,$res_title) } keys(%{$changed});
1596: my $changenum = 0;
1597: foreach my $item (@changes) {
1.68 raeburn 1598: $changenum ++;
1599: my $css_class = $changenum%2?' class="LC_odd_row"':'';
1.33 raeburn 1600: my ($map,$id,$url)=&Apache::lonnet::decode_symb($item);
1601: my $linkurl=&Apache::lonnet::clutter($url);
1.55 www 1602: $linkurl .= '?symb='.&escape($item);
1.33 raeburn 1603:
1.68 raeburn 1604: $r->print('<tr'.$css_class.'><td><a href="'.$linkurl.'">'.
1605: $$res_title{$item}.'</a></td><td>'.
1606: $$changed{$item}{'revdate'}.'</td><td>'.
1607: $$changed{$item}{'current'}.'</td><td>'.
1608: $$changed{$item}{'version'}.'</td></tr>');
1.33 raeburn 1609: }
1.84 raeburn 1610: } elsif ($itemserror) {
1611: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1612: } else {
1.78 bisitz 1613: $r->print('<tr class="LC_empty_row"><td>'
1614: .&mt('No '.$interval).'</td></tr>');
1.33 raeburn 1615: }
1616: return;
1617: }
1.77 raeburn 1618:
1619: sub display_rolechanges {
1620: my ($r,$chgcount,$changed,$interval,$crstype) = @_;
1621: my $now = time();
1622: my %lt = &Apache::lonlocal::texthash(
1623: 'user' => 'User',
1624: 'tich' => 'Time of change',
1625: 'role' => 'Role',
1626: 'sec' => 'Section',
1627: 'status' => 'Status',
1628: );
1629: if ($chgcount) {
1630: $r->print('<tr class="LC_info_row">'.
1631: '<td class="LC_left_item">'.$lt{'tich'}.'</td>'.
1632: '<td class="LC_left_item">'.$lt{'user'}.'</td>'.
1633: '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
1634: '<td class="LC_left_item">'.$lt{'sec'}.'</td>'.
1635: '<td class="LC_left_item">'.$lt{'status'}.'</td></tr>');
1636: if (ref($changed) eq 'HASH') {
1637: my @changes = sort { $b <=> $a } (keys(%{$changed}));
1638: my $changenum = 0;
1639: foreach my $item (@changes) {
1640: if (ref($changed->{$item}) eq 'ARRAY') {
1641: foreach my $chg (@{$changed->{$item}}) {
1642: if (ref($chg) eq 'HASH') {
1643: my $section;
1644: my $role =
1645: &Apache::lonnet::plaintext($chg->{'role'},$crstype);
1646: my $status = &mt($chg->{'status'});
1647: if ($chg->{'section'} eq '') {
1648: $section = &mt('none');
1649: } else {
1650: $section = $chg->{'section'};
1651: }
1652: my $uname = $chg->{'uname'};
1653: my $udom = $chg->{'udom'};
1654: $changenum ++;
1655: my $css_class = $changenum%2?' class="LC_odd_row"':'';
1656: my $link =
1657: &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom);
1658: $r->print('<tr'.$css_class.'>'.
1.93 droeschl 1659: '<td>'.&Apache::lonlocal::locallocaltime($item).'</td>'.
1.77 raeburn 1660: '<td>'.$link.'</td>'.
1661: '<td>'.$role.'</td>'.
1662: '<td>'.$section.'</td>'.
1663: '<td>'.$status.'</td></tr>');
1664: }
1665: }
1666: }
1667: }
1668: }
1669: } else {
1.78 bisitz 1670: $r->print('<tr class="LC_empty_row"><td>'
1671: .&mt('There are no '.$interval).'</td></tr>');
1.77 raeburn 1672: }
1673: return;
1674: }
1.33 raeburn 1675:
1676: sub display_coursediscussion {
1.84 raeburn 1677: my ($r,$newdiscussions,$unread,$countunread,$res_title,$itemserror) = @_;
1.59 albertel 1678: my $lctype = lc(&Apache::loncommon::course_type());
1.33 raeburn 1679: my %lt = &Apache::lonlocal::texthash(
1680: 'loca' => 'Location',
1681: 'type' => 'Type',
1682: 'numn' => 'Number of new posts',
1.56 raeburn 1683: 'noun' => 'No unread posts in '.$lctype.' discussions',
1.37 raeburn 1684: 'tmlp' => 'Time of last post',
1.33 raeburn 1685: );
1686: if (@{$newdiscussions} > 0) {
1.68 raeburn 1687: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1688: $lt{'loca'}.'</td><td>'.
1689: $lt{'type'}.'</td>');
1.39 raeburn 1690: if ($countunread eq 'on') {
1.68 raeburn 1691: $r->print('<td>'.$lt{'tmlp'}.'</td>'.
1692: '<td class="LC_right_item">'.$lt{'numn'}.'</td>');
1.37 raeburn 1693: } else {
1.68 raeburn 1694: $r->print('<td class="LC_right_item">'.$lt{'tmlp'}.'</td>');
1.37 raeburn 1695: }
1696: $r->print("</tr>\n");
1.33 raeburn 1697: @{$newdiscussions} = sort { &cmp_title($a,$b,$res_title) }
1698: @{$newdiscussions};
1699: my $rowNum = 0;
1700: foreach my $ressymb (@{$newdiscussions}) {
1.68 raeburn 1701: $rowNum ++;
1.33 raeburn 1702: my $forum_title = $$unread{$ressymb}{'title'};
1703: my $type = 'Resource';
1704: my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
1.66 raeburn 1705: my $disclink = $feedurl.'?symb='.$$unread{$ressymb}{symb};
1.33 raeburn 1706: if ($feedurl =~ /bulletinboard/) {
1.85 schafran 1707: $type = 'Discussion Board';
1.33 raeburn 1708: }
1.66 raeburn 1709: if ($$unread{$ressymb}{'enclink'}) {
1710: $disclink = $$unread{$ressymb}{'enclink'}.'?symb='.$$unread{$ressymb}{'encsymb'};
1711: }
1.68 raeburn 1712: my $css_class = $rowNum%2?' class="LC_odd_row"':'';
1.37 raeburn 1713: my $lastpost = &Apache::lonnavmaps::timeToHumanString(
1714: $$unread{$ressymb}{'lastpost'});
1.70 raeburn 1715: $r->print('<tr'.$css_class.'><td><a href="'.$disclink.'">'.$forum_title.'</a> </td><td>'.&mt($type).' </td>');
1.39 raeburn 1716: if ($countunread eq 'on') {
1.37 raeburn 1717: my $unreadnum = $$unread{$ressymb}{'unreadcount'};
1.68 raeburn 1718: $r->print('<td>'.$lastpost.'</td><td class="LC_right_item">'.
1719: $unreadnum.' </td>');
1.37 raeburn 1720: } else {
1.68 raeburn 1721: $r->print('<td class="LC_right_item">'.$lastpost.'</td>');
1.33 raeburn 1722: }
1.37 raeburn 1723: $r->print("</tr>\n");
1.33 raeburn 1724: }
1.84 raeburn 1725: } elsif ($itemserror) {
1726: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1727: } else {
1.68 raeburn 1728: $r->print('<tr class="LC_empty_row"><td>'.$lt{'noun'}.'</td></tr>');
1.33 raeburn 1729: }
1730: }
1731:
1732: sub display_coursenormalmail {
1.68 raeburn 1733: my ($r,$msgcount,$newmsgs) = @_;
1.59 albertel 1734: my $lctype = lc(&Apache::loncommon::course_type());
1.33 raeburn 1735: if ($msgcount > 0) {
1.68 raeburn 1736: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1737: &mt('Number').'</td><td>'.&mt('Subject').'</td><td>'.
1738: &mt('Sender').'</td><td class="LC_right_item">'.
1739: &mt('Date/Time').'</td></tr>');
1740: my $mailcount = 0;
1.33 raeburn 1741: foreach my $msg (@{$newmsgs}) {
1742: $mailcount ++;
1.68 raeburn 1743: my $css_class = $mailcount%2?' class="LC_odd_row"':'';
1.76 raeburn 1744: $r->print('<tr'.$css_class.'><td>'.$mailcount
1745: .'. </td><td><a href="/adm/email?display='
1746: .$msg->{'msgid'}.'">'
1747: .$msg->{'shortsub'}.'</a> </td><td> '
1748: .$msg->{'from'}.':'.$msg->{'fromdom'}.' </td><td>'
1749: .$msg->{'sendtime'}.'</td></tr>');
1.33 raeburn 1750: }
1751: } else {
1.68 raeburn 1752: $r->print('<tr class="LC_empty_row"><td>'.
1753: &mt('No new '.$lctype.' messages').'</td></tr>');
1.33 raeburn 1754: }
1755: }
1756:
1757: sub display_coursecritmail {
1.68 raeburn 1758: my ($r,$critmsgcount,$critmsgs) = @_;
1.59 albertel 1759: my $lctype = lc(&Apache::loncommon::course_type());
1.33 raeburn 1760: if ($critmsgcount > 0) {
1.68 raeburn 1761: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1762: &mt('Number').'</td><td>'.&mt('Subject').'</td><td>'.
1763: &mt('Sender').'</td><td class="LC_right_item">'.
1764: &mt('Date/Time').'</td></tr>');
1765: my $mailcount = 0;
1.33 raeburn 1766: foreach my $msg (@{$critmsgs}) {
1767: $mailcount ++;
1.68 raeburn 1768: my $css_class = $mailcount%2?' class="LC_odd_row"':'';
1769: $r->print('<tr'.$css_class.'><td>'.$mailcount.
1770: '. </td><td><a href="/adm/email?folder=critical">'.
1771: $msg->{'shortsub'}.'</a> </td><td> '.
1.72 albertel 1772: $msg->{'from'}.':'.$msg->{'fromdom'}.' </td><td>'.
1.68 raeburn 1773: $msg->{'sendtime'}.'</td></tr>');
1.33 raeburn 1774: }
1775: } else {
1.68 raeburn 1776: $r->print('<tr class="LC_empty_row"><td>'.
1777: &mt('No unread critical messages in '.$lctype).
1778: '</td></tr>');
1.33 raeburn 1779: }
1.1 raeburn 1780: }
1781:
1782: sub cmp_title {
1.16 raeburn 1783: my ($a,$b,$res_title) = @_;
1784: my ($atitle,$btitle) = (lc($$res_title{$a}),lc($$res_title{$b}));
1.1 raeburn 1785: $atitle=~s/^\s*//;
1786: $btitle=~s/^\s*//;
1787: return $atitle cmp $btitle;
1788: }
1789:
1.33 raeburn 1790: sub get_display_settings {
1.36 raeburn 1791: my ($uname,$udom,$cid) = @_;
1.33 raeburn 1792: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid);
1793: my ($tmp) = keys(%settings);
1.40 raeburn 1794: if ($tmp=~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 1795: %settings = ();
1.41 raeburn 1796: unless ($tmp =~ /^error: 2 /) {
1.59 albertel 1797: my $lctype = lc(&Apache::loncommon::course_type());
1.41 raeburn 1798: &Apache::lonnet::logthis('Error retrieving whatsnew settings: '.
1.56 raeburn 1799: $tmp.' for '.$uname.':'.$udom.' for '.$lctype.': '.$cid);
1.33 raeburn 1800: }
1801: }
1802: return %settings;
1803: }
1804:
1.36 raeburn 1805: sub store_display_settings {
1806: my ($uname,$udom,$cid,$checkallowed) = @_;
1807: my %whatsnew_settings;
1808: my $result;
1809: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 1810: if ($key =~ /_section$/) { next; }
1.36 raeburn 1811: if (exists($env{'form.display_'.$key})) {
1812: unless ($env{'form.display_'.$key} eq '') {
1813: $whatsnew_settings{$cid.':'.$key} = $env{'form.display_'.$key};
1814: }
1815: }
1816: }
1817: if (keys(%whatsnew_settings)) {
1818: $result = &Apache::lonnet::put('nohist_whatsnew',\%whatsnew_settings,
1819: $udom,$uname);
1820: } else {
1821: $result = 'ok';
1822: }
1823: return $result;
1824: }
1825:
1826: sub store_interval_setting {
1827: my ($uname,$udom,$cid,$interval_titles) = @_;
1828: my %interval_settings = ();
1829: my $result;
1.77 raeburn 1830: my $context = $env{'form.intervaltype'};
1831: if ($env{'form.interval'} ne '') {
1832: if ($context eq 'oldroles') {
1833: $interval_settings{$cid.':oldroleinterval'} = $env{'form.interval'};
1834: } elsif ($context eq 'newroles') {
1835: $interval_settings{$cid.':newroleinterval'} = $env{'form.interval'};
1836: } else {
1837: $interval_settings{$cid.':interval'} = $env{'form.interval'};
1838: }
1.36 raeburn 1839: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
1840: \%interval_settings,$udom,$uname);
1841: if ($outcome eq 'ok') {
1.77 raeburn 1842: if (ref($interval_titles->{$context}) eq 'HASH') {
1843: $result = &mt('New filter setting: [_1].','<b>'.
1844: $interval_titles->{$context}->{$env{'form.interval'}}.'</b>').'<br />';
1845: }
1.36 raeburn 1846: } else {
1.59 albertel 1847: my $lctype = lc(&Apache::loncommon::course_type());
1.77 raeburn 1848: &Apache::lonnet::logthis('Error saving whatsnew '.$context.' interval setting'.
1.56 raeburn 1849: ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
1.36 raeburn 1850: $result = &mt('Unable to set interval to [_1] due to [_2].',
1.77 raeburn 1851: '<b>'.$interval_titles->{$context}->{$env{'form.interval'}}.'</b>',
1.36 raeburn 1852: '<tt>'.$outcome.'</tt>.<br />');
1853: }
1854: }
1855: return $result;
1856: }
1857:
1.39 raeburn 1858: sub store_discussion_setting {
1859: my ($uname,$udom,$cid) = @_;
1860: my %discussion_settings;
1861: my $result;
1862: if (defined($env{'form.countunread'})) {
1863: $discussion_settings{$cid.':countunread'} = $env{'form.countunread'};
1864: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
1865: \%discussion_settings,$udom,$uname);
1866: if ($outcome eq 'ok') {
1867: $result = &mt('Count unread posts in discussions display set to [_1]',
1.74 bisitz 1868: '<b>'.&mt($env{'form.countunread'}).'</b>').'<br />';
1.39 raeburn 1869:
1870: } else {
1.59 albertel 1871: my $lctype = lc(&Apache::loncommon::course_type());
1.71 albertel 1872: &Apache::lonnet::logthis('Error saving whatsnew countunread setting'.
1.56 raeburn 1873: ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
1.39 raeburn 1874: $result = &mt('Unable to set "number unread posts display" to [_1]'.
1875: ' due to [_2].',
1.74 bisitz 1876: '<b>'.&mt($env{'form.countunread'}).'</b>',
1.39 raeburn 1877: '<tt>'.$outcome.'</tt>.<br />');
1878: }
1879: }
1880: return $result;
1881: }
1882:
1883: sub store_courseinit_setting {
1884: my ($uname,$udom,$cid,$initpage) = @_;
1885: my %courseinit_settings;
1886: my $page_control;
1887: my $result;
1888: if (defined($env{'form.courseinit_control'})) {
1889: if ($env{'form.courseinit_control'} eq 'userpref') {
1890: $courseinit_settings{$cid.':courseinit'} = '';
1891: $page_control = 'global preferences';
1892: } else {
1893: if (defined($env{'form.courseinit_page'})) {
1894: $courseinit_settings{$cid.':courseinit'} =
1895: $env{'form.courseinit_page'};
1896: $page_control = 'course specific setting';
1897: }
1898: }
1899: if ($page_control) {
1.59 albertel 1900: my $lctype = lc(&Apache::loncommon::course_type());
1.39 raeburn 1901: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
1902: \%courseinit_settings,$udom,$uname);
1903: if ($outcome eq 'ok') {
1904: if ($page_control eq 'global preferences') {
1.81 bisitz 1905: $result = &mt("Page displayed after role selection in $lctype now set by [_1]user's global preferences[_2].",'<b>','</b>');
1.39 raeburn 1906: } else {
1.81 bisitz 1907: $result = &mt('Page displayed after role selection in this '.$lctype.' set to [_1].'
1908: ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>');
1.39 raeburn 1909: }
1910: } else {
1.71 albertel 1911: &Apache::lonnet::logthis('Error saving whatsnew courseinit '.
1.39 raeburn 1912: 'setting: '.$outcome.' for '.$uname.
1.56 raeburn 1913: ':'.$udom.' in '.$lctype.' '.$cid);
1.39 raeburn 1914: if ($page_control eq 'global preferences') {
1915: $result = &mt('Unable to set control of page display to [_1]'.
1916: ' due to [_2].',
1917: '<b>'.$page_control.'</b>',
1918: '<tt>'.$outcome.'</tt>.<br />');
1919: } else {
1.81 bisitz 1920: $result = &mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].'
1921: ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>'
1922: ,'<tt>'.$outcome.'</tt>')
1923: .'<br />';
1.39 raeburn 1924: }
1925: }
1926: }
1927: }
1928: return $result;
1929: }
1930:
1.33 raeburn 1931: sub start_box {
1.69 raeburn 1932: my ($r,$show,$heading,$caller,$refpage) = @_;
1.33 raeburn 1933: my %lt = &Apache::lonlocal::texthash(
1934: chth => 'Change thresholds?',
1935: chin => 'Change interval?',
1.39 raeburn 1936: chop => 'Change options?',
1.33 raeburn 1937: );
1.68 raeburn 1938: my $showhide;
1.33 raeburn 1939: if ($$show{$caller}) {
1.36 raeburn 1940: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1.70 raeburn 1941: 'display_'.$caller.",'hide'".');">'.
1942: &mt('Hide').'</a></b>';
1.33 raeburn 1943:
1944: } else {
1.36 raeburn 1945: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1.70 raeburn 1946: 'display_'.$caller.",'show'".');">'.
1947: &mt('Show').'</a></b>';
1.33 raeburn 1948: }
1949:
1950: $r->print('
1.68 raeburn 1951: <table class="LC_nested_outer">
1.33 raeburn 1952: <tr>
1.73 raeburn 1953: <th class="LC_left_item">'.$$heading{$caller}.'</th>
1.68 raeburn 1954: <th class="LC_right_item">'.$showhide.'</th>
1955: </tr>');
1.33 raeburn 1956: if (($caller eq 'abovethreshold') && ($$show{$caller})) {
1.40 raeburn 1957: if ($$show{$caller}) {
1958: $r->print('
1.33 raeburn 1959: <tr>
1.68 raeburn 1960: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgthreshold&refpage='.$refpage.'">'.$lt{'chth'}.'</a></td>
1.33 raeburn 1961: </tr>');
1.40 raeburn 1962: }
1.33 raeburn 1963: } elsif (($caller eq 'versionchanges') && ($$show{$caller})) {
1.40 raeburn 1964: if ($$show{$caller}) {
1965: $r->print('
1.33 raeburn 1966: <tr>
1.68 raeburn 1967: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chginterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1.39 raeburn 1968: </tr>');
1.40 raeburn 1969: }
1.39 raeburn 1970: } elsif ($caller eq 'coursediscussion') {
1.40 raeburn 1971: if ($$show{$caller}) {
1972: $r->print('
1.39 raeburn 1973: <tr>
1.68 raeburn 1974: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgdisc&refpage='.$refpage.'">'.$lt{'chop'}.'</a></td>
1.33 raeburn 1975: </tr>');
1.40 raeburn 1976: }
1.77 raeburn 1977: } elsif (($caller eq 'newroles') && ($$show{$caller})) {
1978: if ($$show{$caller}) {
1979: $r->print('
1980: <tr>
1981: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgnewroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1982: </tr>');
1983: }
1984: } elsif (($caller eq 'oldroles') && ($$show{$caller})) {
1985: if ($$show{$caller}) {
1986: $r->print('
1987: <tr>
1988: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1989: </tr>');
1990: }
1.33 raeburn 1991: }
1.61 albertel 1992: $r->print('
1.33 raeburn 1993: <tr>
1.68 raeburn 1994: <td colspan="2">
1995: <table class="LC_nested">
1.33 raeburn 1996: ');
1997: return;
1998: }
1999:
2000: sub end_box {
2001: my ($r) = shift;
2002: $r->print('
2003: </table>
2004: </td>
2005: </tr>
2006: </table><br />');
2007: return;
2008: }
2009:
1.7 raeburn 2010: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>