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