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