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