Annotation of loncom/interface/lonwhatsnew.pm, revision 1.92
1.2 albertel 1: #
1.92 ! lueken 2: # $Id: lonwhatsnew.pm,v 1.91 2009/04/16 21:19:56 lueken Exp $
1.2 albertel 3: #
4: # Copyright Michigan State University Board of Trustees
5: #
6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
7: #
8: # LON-CAPA is free software; you can redistribute it and/or modify
9: # it under the terms of the GNU General Public License as published by
10: # the Free Software Foundation; either version 2 of the License, or
11: # (at your option) any later version.
12: #
13: # LON-CAPA is distributed in the hope that it will be useful,
14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: # GNU General Public License for more details.
17: #
18: # You should have received a copy of the GNU General Public License
19: # along with LON-CAPA; if not, write to the Free Software
20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21: #
22: # /home/httpd/html/adm/gpl.txt
23: #
24: # http://www.lon-capa.org/
25: #
26:
27:
1.1 raeburn 28: package Apache::lonwhatsnew;
29:
30: use strict;
31: use lib qw(/home/httpd/lib/perl);
32: use Apache::lonnet;
1.3 albertel 33: use Apache::loncommon();
34: use Apache::lonhtmlcommon();
1.1 raeburn 35: use Apache::lonlocal;
1.3 albertel 36: use Apache::loncoursedata();
37: use Apache::lonnavmaps();
1.18 raeburn 38: use Apache::lonuserstate;
1.77 raeburn 39: use Apache::lonuserutils;
1.1 raeburn 40: use Apache::Constants qw(:common :http);
41: use Time::Local;
1.24 albertel 42: use GDBM_File;
1.55 www 43: use lib '/home/httpd/lib/perl/';
44: use LONCAPA;
1.1 raeburn 45:
46: #----------------------------
47: # handler
48: #
49: #----------------------------
50:
51: sub handler {
52: my $r = shift;
1.7 raeburn 53: if ($r->header_only) {
54: &Apache::loncommon::content_type($r,'text/html');
55: $r->send_http_header;
56: return OK;
57: }
1.39 raeburn 58: &Apache::loncommon::get_unprocessed_cgi(
59: $ENV{'QUERY_STRING'},['command','refpage']);
1.1 raeburn 60:
1.36 raeburn 61: my $command = $env{'form.command'};
1.39 raeburn 62: my $refpage = $env{'form.refpage'};
1.1 raeburn 63:
1.44 albertel 64: my %checkallowed = ( coursenormalmail => 1,
65: coursecritmail => 1, );
66: foreach my $perm_check (['whn','whatsnew',1],
67: ['pch','coursediscussion',1],
68: ['mgr','handgrading',1],
69: ['vgr','abovethreshold',1],
70: ['opa','haserrors',1],
71: ['mdc','versionchanges',0],
1.77 raeburn 72: ['vcl','newroles',1],
73: ['vcl','oldroles',1],
1.44 albertel 74: ) {
75: my ($perm,$key,$check_section) = @{ $perm_check };
76: my $scope = $env{'request.course.id'};
77: if (!($checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope))) {
78: $scope .= '/'.$env{'request.course.sec'};
79: if ( $check_section ) {
80: $checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope);
81: }
82: if ($checkallowed{$key}) {
83: $checkallowed{$key.'_section'} = $env{'request.course.sec'};
84: }
85: }
86: }
1.43 albertel 87:
1.44 albertel 88: if ( ! $env{'request.course.fn'} || ! $checkallowed{'whatsnew'}) {
1.43 albertel 89: # Not in a course, or no whn priv in course
1.42 raeburn 90: $env{'user.error.msg'}="/adm/whatsnew::whn:0:0:Cannot display what's new page";
1.1 raeburn 91: return HTTP_NOT_ACCEPTABLE;
92: }
93:
1.44 albertel 94: &Apache::loncommon::content_type($r,'text/html');
95: $r->send_http_header;
1.36 raeburn 96:
97: $r->print(&display_header($command,\%checkallowed));
98:
1.7 raeburn 99: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.36 raeburn 100: &Apache::lonhtmlcommon::add_breadcrumb
101: ({href=>'/adm/whatsnew',
1.90 hauer 102: text=>"What's New?"});
1.44 albertel 103: if (($command eq 'chgthreshold') && $checkallowed{'abovethreshold'}) {
1.7 raeburn 104: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 105: ({href=>'/adm/whatsnew?command=chgthreshold&refpage='.$refpage,
1.13 raeburn 106: text=>"Change thresholds"});
1.7 raeburn 107: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 108: ("What's New?",#'Course_Action_Items_Thresholds'
1.49 albertel 109: ));
1.44 albertel 110: } elsif (($command eq 'chginterval') && $checkallowed{'versionchanges'} ) {
1.36 raeburn 111: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 112: ({href=>'/adm/whatsnew?command=chginterval&refpage='.$refpage,
1.36 raeburn 113: text=>"Change interval"});
114: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 115: ("What's New?",#'Course_Action_Items_Intervals'
1.49 albertel 116: ));
1.44 albertel 117: } elsif (($command eq 'chgdisc') && $checkallowed{'coursediscussion'}) {
1.39 raeburn 118: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 119: ({href=>'/adm/whatsnew?command=chgdisc&refpage='.$refpage,
1.39 raeburn 120: text=>"Change discussion display"});
121: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 122: ("What's New?",#'Course_Action_Items_Intervals'
1.49 albertel 123: ));
1.39 raeburn 124: } elsif ($command eq 'courseinit') {
125: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 126: ({href=>'/adm/whatsnew?command=courseinit&refpage='.$refpage,
1.39 raeburn 127: text=>"Course initialization preference"});
128: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 129: ("What's New?",#'Course_Action_Items_Initialization'
1.49 albertel 130: ));
1.77 raeburn 131: } elsif ($command eq 'chgoldroleinterval' && $checkallowed{'oldroles'}) {
132: &Apache::lonhtmlcommon::add_breadcrumb
133: ({href=>'/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage,
134: text=>"Change interval"});
135: $r->print(&Apache::lonhtmlcommon::breadcrumbs
136: ("What's New?",#'Course_Action_Items_Intervals'
137: ));
138: } elsif ($command eq 'chgnewroleinterval' && $checkallowed{'newroles'}) {
139: &Apache::lonhtmlcommon::add_breadcrumb
140: ({href=>'/adm/whatsnew?command=chgnewroleinterval&refpage='.$refpage,
141: text=>"Change interval"});
142: $r->print(&Apache::lonhtmlcommon::breadcrumbs
143: ("What's New?",#'Course_Action_Items_Intervals'
144: ));
1.7 raeburn 145: } else {
146: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 147: ("What's New?",#'Course_Action_Items_Display'
1.49 albertel 148: ));
1.7 raeburn 149: }
1.39 raeburn 150: &display_main_box($r,$command,$refpage,\%checkallowed);
1.14 albertel 151: return OK;
1.1 raeburn 152: }
153:
154: #------------------------------
155: # display_main_box
156: #
157: # Display all the elements within the main box
158: #------------------------------
159:
160: sub display_main_box {
1.39 raeburn 161: my ($r,$command,$refpage,$checkallowed) = @_;
1.1 raeburn 162: my $domain=&Apache::loncommon::determinedomain();
1.40 raeburn 163: my $function = &Apache::loncommon::get_users_function();
1.59 albertel 164: my $lctype = lc(&Apache::loncommon::course_type());
1.7 raeburn 165: $r->print('<table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td width="100%">');
1.13 raeburn 166:
1.39 raeburn 167: my %threshold_titles = &Apache::lonlocal::texthash (
1.13 raeburn 168: av_attempts => 'Average number of attempts',
169: degdiff => 'Degree of difficulty',
170: numstudents => 'Total number of students with submissions',
171: );
1.78 bisitz 172: my %versions = (
1.77 raeburn 173: -1 => "version changes since start of $lctype",
174: 2592000 => 'version changes since last month',
175: 604800 => 'version changes since last week',
176: 86400 => 'version changes since yesterday',
177: );
1.78 bisitz 178: my %newroles = (
1.77 raeburn 179: -1 => "roles which have become active since start of $lctype",
180: 2592000 => 'roles which have become active since last month',
181: 604800 => 'roles which have become active since last week',
182: 86400 => 'roles which have become active since yesterday',
183: );
1.78 bisitz 184: my %oldroles = (
1.77 raeburn 185: -1 => "roles which expired since start of $lctype",
186: 2592000 => 'roles which expired since last month',
187: 604800 => 'roles which expired since last week',
188: 86400 => 'roles which expired since yesterday',
189: );
190: my %interval_titles = (
191: versions => \%versions,
192: newroles => \%newroles,
193: oldroles => \%oldroles,
1.36 raeburn 194: );
1.39 raeburn 195: my %initpage = &Apache::lonlocal::texthash (
1.56 raeburn 196: firstres => "first resource in the $lctype",
1.88 hauer 197: whatsnew => "What's New Page",
1.39 raeburn 198: userpref => 'your general user preferences',
1.56 raeburn 199: coursespecific => "specific setting for this $lctype",
1.39 raeburn 200: );
1.15 raeburn 201: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
202: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
203:
1.44 albertel 204: if (($command eq 'chgthreshold')
205: && $checkallowed->{'abovethreshold'}) {
1.69 raeburn 206: &display_threshold_config($r,$refpage,\%threshold_titles,
1.36 raeburn 207: $cdom,$crs);
1.44 albertel 208: } elsif (($command eq 'chginterval')
209: && $checkallowed->{'versionchanges'}) {
1.77 raeburn 210: &display_interval_config($r,$refpage,\%interval_titles,'versions');
1.44 albertel 211: } elsif (($command eq 'chgdisc')
212: && $checkallowed->{'coursediscussion'}) {
1.39 raeburn 213: &display_discussion_config($r,$refpage);
214: } elsif ($command eq 'courseinit') {
215: &courseinit_config($r,$refpage,\%initpage);
1.77 raeburn 216: } elsif (($command eq 'chgnewroleinterval')
217: && $checkallowed->{'newroles'}) {
218: &display_interval_config($r,$refpage,\%interval_titles,'newroles');
219: } elsif (($command eq 'chgoldroleinterval')
220: && $checkallowed->{'oldroles'}) {
221: &display_interval_config($r,$refpage,\%interval_titles,'oldroles');
1.1 raeburn 222: } else {
1.69 raeburn 223: &display_actions_box($r,$command,$refpage,\%threshold_titles,
1.39 raeburn 224: \%interval_titles,\%initpage,$cdom,$crs,$checkallowed);
1.1 raeburn 225: }
1.52 albertel 226: my $end_page = &Apache::loncommon::end_page();
1.1 raeburn 227: $r->print(<<END_OF_BLOCK);
228: </td>
229: </tr>
230: </table><br />
1.52 albertel 231: $end_page
1.1 raeburn 232: END_OF_BLOCK
233: }
234:
235: #-------------------------------
236: # display_header
237: #
238: # Display the header information and set
239: # up the HTML
240: #-------------------------------
241:
1.39 raeburn 242: sub display_header {
1.36 raeburn 243: my ($command,$checkallowed) = @_;
1.52 albertel 244:
1.36 raeburn 245: my $scripttag;
1.77 raeburn 246: unless ($command eq 'chgthreshold' || $command eq 'chginterval' ||
247: $command eq 'chgoldroleinterval' || $command eq 'chgnewroleinterval') {
1.36 raeburn 248: $scripttag = <<"END";
249: <script type="text/javascript">
250: function change_display(caller,change) {
251: caller.value = change;
1.77 raeburn 252: document.visible.submit();
1.36 raeburn 253: }
254:
255: function changeAll(change) {
256: END
257: foreach my $item (keys(%{$checkallowed})) {
1.44 albertel 258: if ($item =~ /_section$/) { next; }
1.39 raeburn 259: if ($$checkallowed{$item}) {
260: $scripttag.='document.visible.display_'.$item.'.value=change'.
261: "\n";
262: }
1.36 raeburn 263: }
264: $scripttag.='document.visible.submit();
265: }
266: </script>
267: ';
268: }
1.58 albertel 269: my $course_type=&Apache::loncommon::course_type();
1.90 hauer 270: return &Apache::loncommon::start_page("What's New?",
1.58 albertel 271: $scripttag);
1.1 raeburn 272: }
273:
274: #-------------------------------
275: # display_actions_box
276: #
277: # Display the action items
278: #
279: #-------------------------------
280:
1.39 raeburn 281: sub display_actions_box {
1.69 raeburn 282: my ($r,$command,$refpage,$threshold_titles,$interval_titles,$initpage,
283: $cdom,$crs,$checkallowed) = @_;
1.36 raeburn 284: my $udom = $env{'user.domain'};
285: my $uname = $env{'user.name'};
286: my $cid = $env{'request.course.id'};
1.59 albertel 287: my $crstype = &Apache::loncommon::course_type();
1.56 raeburn 288: my $lctype = lc($crstype);
289: my %stulabel = (
290: 'Course' => 'students',
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.88 hauer 330: whatsnew => "What's New Page",
1.39 raeburn 331: userpref => 'user preference',
1.56 raeburn 332: coursespecific => $lctype.' only',
1.39 raeburn 333: default => 'default',
334: );
335:
336: my ($initcontrol,$initdisp) = &curr_courseinit();
337: my $currinit = $pagedesc{$initdisp}.' ('.$pagedesc{$initcontrol}.')';
1.13 raeburn 338:
1.36 raeburn 339: unless ($cid) {
1.73 raeburn 340: $r->print('<p><span style="text-align: center; font-weight: bold;">'.$lt{'yacc'}.'</span></p>');
1.1 raeburn 341: return;
342: }
1.33 raeburn 343:
1.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.87 schafran 597: '<br /><input type="submit" name="threshold" value="'.&mt('Save').'" />
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="'.
1.87 schafran 653: &mt('Save').'" /></form>');
1.36 raeburn 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 />'
1.90 hauer 686: .&mt("This can increase the time taken to gather data for the [_1]What's New Page[_2] by a few seconds.",'<i>','</i>')
1.81 bisitz 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',
1.89 schafran 728: 'moce' => 'Save',
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.92 ! lueken 1156: my $datetime;
! 1157:
1.10 raeburn 1158: my @messages = sort(&Apache::lonnet::getkeys('nohist_email'));
1.3 albertel 1159: foreach my $message (@messages) {
1.55 www 1160: my $msgid=&escape($message);
1.10 raeburn 1161: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1.1 raeburn 1162: &Apache::lonmsg::unpackmsgid($msgid);
1.10 raeburn 1163: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 1164: if (defined($sendtime) && $sendtime!~/error/) {
1165: my $numsendtime = $sendtime;
1.91 lueken 1166: if ($status eq 'new') {
1.92 ! lueken 1167: $sendtime = &Apache::lonlocal::locallocaltime($sendtime,'',\$datetime);
1.91 lueken 1168: $msgcount ++;
1.10 raeburn 1169: if ($shortsubj eq '') {
1170: $shortsubj = &mt('No subject');
1171: }
1.1 raeburn 1172: push(@{$newmsgs}, {
1173: msgid => $msgid,
1174: sendtime => $sendtime,
1.10 raeburn 1175: shortsub => $shortsubj,
1.1 raeburn 1176: from => $fromname,
1177: fromdom => $fromdom
1178: });
1179: }
1180: }
1181: }
1182: }
1.33 raeburn 1183: return $msgcount;
1184: }
1.1 raeburn 1185:
1.33 raeburn 1186: sub getcritmail {
1187: my ($critmsgs) = @_;
1.1 raeburn 1188: # Check for critical messages in course
1189: my %what=&Apache::lonnet::dump('critical');
1190: my $result = '';
1.92 ! lueken 1191: my $datetime;
1.1 raeburn 1192: my $critmsgcount = 0;
1.3 albertel 1193: foreach my $msgid (sort(keys(%what))) {
1.10 raeburn 1194: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1195: &Apache::lonmsg::unpackmsgid($msgid);
1196: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 1197: if (defined($sendtime) && $sendtime!~/error/) {
1198: my $numsendtime = $sendtime;
1.92 ! lueken 1199: $sendtime = &Apache::lonlocal::locallocaltime($sendtime,'',\$datetime);
1.1 raeburn 1200: $critmsgcount ++;
1.10 raeburn 1201: if ($shortsubj eq '') {
1202: $shortsubj = &mt('No subject');
1203: }
1.1 raeburn 1204: push(@{$critmsgs}, {
1205: msgid => $msgid,
1206: sendtime => $sendtime,
1.10 raeburn 1207: shortsub => $shortsubj,
1.1 raeburn 1208: from => $fromname,
1209: fromdom => $fromdom
1210: });
1211: }
1212: }
1213: }
1.33 raeburn 1214: return $critmsgcount;
1215: }
1216:
1.77 raeburn 1217: sub getexpired {
1218: my ($rolechgs,$rolechgtime,$status) = @_;
1219: my $expirecount = &getrolechanges($rolechgs,$rolechgtime,$status);
1220: return $expirecount;
1221: }
1222:
1223: sub getactivated {
1224: my ($rolechgs,$rolechgtime,$status) = @_;
1225: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1226: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1227: my $now = time();
1228: my $context = 'course';
1229: my ($permission,$allowed) =
1230: &Apache::lonuserutils::get_permission($context);
1231: my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
1232: my %changes=&Apache::lonnet::dump('nohist_rolelog',$cdom,$cnum);
1233: my (%stucounted,%advcounted);
1234: my $activatedcount = 0;
1235: if (keys(%changes) > 0) {
1236: foreach my $chg (sort { $b <=> $a } (keys(%changes))) {
1237: if (ref($changes{$chg}) eq 'HASH') {
1238: my $timestamp = $changes{$chg}{'exe_time'};
1239: if ($timestamp) {
1.79 raeburn 1240: if ($rolechgtime > 0) {
1241: if ($timestamp < $rolechgtime) {
1.77 raeburn 1242: last;
1243: }
1244: }
1245: if (ref($changes{$chg}{'logentry'}) eq 'HASH') {
1246: next if ($changes{$chg}{'delflag'});
1247: my $start = $changes{$chg}{'logentry'}{'start'};
1248: my $end = $changes{$chg}{'logentry'}{'end'};
1249: my $section = $changes{$chg}{'logentry'}{'section'};
1250: my $role = $changes{$chg}{'logentry'}{'role'};
1251: my $uname = $changes{$chg}{'uname'};
1252: my $udom = $changes{$chg}{'udom'};
1253: next if ($end && $end <= $now);
1254: if (($viewablesec ne '') && ($section ne '')) {
1255: next if ($viewablesec ne $section);
1256: }
1257: next if ($start >= $timestamp);
1258: if ($role eq 'st') {
1259: $stucounted{$uname.':'.$udom.':'.$section} = $start.':'.$end;
1260: } else {
1261: $advcounted{$uname.':'.$udom.':'.$role.':'.$section} = $start.':'.$end;
1262: }
1263: my %chginfo = (
1264: 'section' => $section,
1265: 'uname' => $uname,
1266: 'udom' => $udom,
1267: 'role' => $role,
1268: 'status' => $status,
1269: );
1270: $activatedcount ++;
1271: push (@{$rolechgs->{$timestamp}},\%chginfo);
1272: }
1273: }
1274: }
1275: }
1276: }
1277: $activatedcount += &getrolechanges($rolechgs,$rolechgtime,$status,\%stucounted,\%advcounted);
1278: return $activatedcount;
1279: }
1280:
1281: sub getrolechanges {
1282: my ($rolechgs,$rolechgtime,$status,$stucountref,$advcountref) = @_;
1283: my (%stucounted,%advcounted);
1284: if (ref($stucountref) eq 'HASH') {
1285: %stucounted = %{$stucountref};
1286: }
1287: if (ref($advcountref) eq 'HASH') {
1288: %advcounted = %{$advcountref};
1289: }
1290: my $withsec = 1;
1291: my $hidepriv = 1;
1292: my $context = 'course';
1293: my @statuses = ($status);
1294: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1295: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1296: my $now = time();
1297: my ($permission,$allowed) =
1298: &Apache::lonuserutils::get_permission($context);
1299: my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
1300: my $classlist = &Apache::loncoursedata::get_classlist();
1301: my $secidx = &Apache::loncoursedata::CL_SECTION();
1302: my $startidx = &Apache::loncoursedata::CL_START();
1303: my $endidx = &Apache::loncoursedata::CL_END();
1304: my $rolechgcount = 0;
1305: foreach my $key (keys(%{$classlist})) {
1306: my ($userstatus,$eventtime);
1307: my $student = $classlist->{$key};
1308: if (ref($student) eq 'ARRAY') {
1309: my $start = $student->[$startidx];
1310: my $end = $student->[$endidx];
1311: my $sec = $student->[$secidx];
1312: my ($stuname,$studom) = split(/:/,$key);
1313: if ($status eq 'active') {
1314: if (exists($stucounted{$key.':'.$sec})) {
1315: next;
1316: }
1317: }
1318: if (($end == 0) || ($end > $start)) {
1319: if ($start <= $now) {
1320: if ($end && $end < $now) {
1321: if ($rolechgtime > 0) {
1322: if ($end > $rolechgtime) {
1323: $userstatus = 'previous';
1324: }
1325: } else {
1326: $userstatus = 'previous';
1327: }
1328: } else {
1329: if ($rolechgtime > 0) {
1330: if ($start >= $rolechgtime) {
1331: $userstatus = 'active';
1332: }
1333: } else {
1334: $userstatus = 'active';
1335: }
1336: }
1337: }
1338: }
1339: next if ($userstatus ne $status);
1340: if ($status eq 'active') {
1341: $eventtime = $start;
1342: } else {
1343: $eventtime = $end;
1344: }
1345: if (($viewablesec ne '') && ($sec ne '')) {
1346: next if ($viewablesec ne $sec);
1347: }
1348: my %chginfo = (
1349: 'section' => $sec,
1350: 'uname' => $stuname,
1351: 'udom' => $studom,
1352: 'role' => 'st',
1353: 'status' => $userstatus,
1354: );
1355: $rolechgcount ++;
1356: push (@{$rolechgs->{$eventtime}},\%chginfo);
1357: }
1358: }
1359: my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
1360: \@statuses,undef,undef,$withsec,$hidepriv);
1361: foreach my $item (keys(%advrolehash)) {
1362: my ($userstatus,$eventtime);
1363: my ($uname,$udom,$role,$section) = split(/:/,$item,-1);
1364: my ($start,$end) = split(/:/,$advrolehash{$item});
1365: if ($start eq '-1' && $end eq '-1') {
1366: next;
1367: } else {
1368: if ($status eq 'active') {
1369: if (exists($advcounted{$item})) {
1370: next;
1371: }
1372: }
1373: if (($end == 0) || ($end > $start)) {
1374: if ($start <= $now) {
1375: if ($end && $end < $now) {
1376: if ($rolechgtime > 0) {
1377: if ($end > $rolechgtime) {
1378: $userstatus = 'previous';
1379: }
1380: } else {
1381: $userstatus = 'previous';
1382: }
1383: } else {
1384: if ($rolechgtime > 0) {
1385: if ($start >= $rolechgtime) {
1386: $userstatus = 'active';
1387: }
1388: } else {
1389: $userstatus = 'active';
1390: }
1391: }
1392: }
1393: }
1394: next if ($userstatus ne $status);
1395: if ($status eq 'active') {
1396: $eventtime = $start;
1397: } else {
1398: $eventtime = $end;
1399: }
1400: }
1401: if (($viewablesec ne '') && ($section ne '')) {
1402: next if ($viewablesec ne $section);
1403: }
1404: my %chginfo = (
1405: 'section' => $section,
1406: 'uname' => $uname,
1407: 'udom' => $udom,
1408: 'role' => $role,
1409: 'status' => $userstatus,
1410: );
1411: $rolechgcount ++;
1412: push (@{$rolechgs->{$eventtime}},\%chginfo);
1413: }
1414: return $rolechgcount;
1415: }
1.33 raeburn 1416:
1417: sub checkversions {
1418: my ($cdom,$crs,$navmap,$changed,$starttime) = @_;
1419: my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs);
1420: my ($tmp) = keys(%changes);
1.40 raeburn 1421: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 1422: if (keys(%changes) > 0) {
1423: foreach my $key (sort(keys(%changes))) {
1424: if ($changes{$key} > $starttime) {
1425: my $version;
1426: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
1427: my $currentversion=&Apache::lonnet::getversion($key);
1428: my $revdate =
1429: &Apache::lonnet::metadata($root.'.'.$extension,
1430: 'lastrevisiondate');
1431: $revdate = &Apache::lonlocal::locallocaltime($revdate);
1432: my $linkurl=&Apache::lonnet::clutter($key);
1433: my $usedversion=$navmap->usedVersion('version_'.$linkurl);
1434: my @resources = $navmap->getResourceByUrl($linkurl,1);
1435: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1436: $version = $usedversion;
1437: } else {
1438: $version = $currentversion;
1439: }
1440: foreach my $res (@resources) {
1.35 raeburn 1441: if (ref($res) eq 'Apache::lonnavmaps::resource') {
1442: my $symb = $res->symb();
1443: %{$$changed{$symb}} = (
1.33 raeburn 1444: current => $currentversion,
1445: version => $version,
1446: revdate => $revdate,
1.35 raeburn 1447: );
1448: }
1.33 raeburn 1449: }
1450: }
1451: }
1452: }
1453: }
1454: return;
1455: }
1456:
1457: sub display_handgrade {
1.84 raeburn 1458: my ($r,$tograde,$ungraded,$itemserror) = @_;
1.33 raeburn 1459: my %lt = &Apache::lonlocal::texthash(
1460: 'prna' => 'Problem Name',
1461: 'nmun' => 'Number ungraded',
1462: 'nopr' => 'No problems require handgrading',
1463: );
1464: if (@{$tograde} > 0) {
1.68 raeburn 1465: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1466: $lt{'prna'}.'</td><td class="LC_right_item">'.
1467: $lt{'nmun'}.'</td></tr>');
1.33 raeburn 1468: my $rowNum = 0;
1469: foreach my $res (@{$tograde}) {
1.68 raeburn 1470: $rowNum ++;
1471: my $css_class = $rowNum%2?' class="LC_odd_row"':'';
1.33 raeburn 1472: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
1473: my $linkurl=&Apache::lonnet::clutter($url);
1.55 www 1474: $linkurl .= '?symb='.&escape($res);
1.66 raeburn 1475: if ($$ungraded{$res}{'enclink'}) {
1476: $linkurl =
1477: $$ungraded{$res}{'enclink'}.'?symb='.$$ungraded{$res}{'encsymb'};
1478: }
1.68 raeburn 1479: $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 1480: }
1.84 raeburn 1481: } elsif ($itemserror) {
1482: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1483: } else {
1.68 raeburn 1484: $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
1.33 raeburn 1485: }
1486: }
1487:
1488: sub display_haserrors {
1.84 raeburn 1489: my ($r,$bombs,$bombed,$res_title,$itemserror) = @_;
1.33 raeburn 1490: my $bombnum = 0;
1491: my %lt = &Apache::lonlocal::texthash(
1492: reso => 'Resource',
1493: nmer => 'Number of errors',
1494: noer => 'No problems with errors',
1495: );
1496: if (@{$bombs} > 0) {
1.68 raeburn 1497: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1498: $lt{'reso'}.'</td><td class="LC_right_item">'.
1499: $lt{'nmer'}.'</td></tr>');
1.33 raeburn 1500: @{$bombs} = sort { &cmp_title($a,$b,$res_title) } @{$bombs};
1501: foreach my $bomb (@{$bombs}) {
1502: $bombnum ++;
1.68 raeburn 1503: my $css_class = $bombnum%2?' class="LC_odd_row"':'';
1504: $r->print('<tr'.$css_class.'><td>'.$$bombed{$bomb}{errorlink}.
1505: '</td><td class="LC_right_item">'.
1506: $$bombed{$bomb}{errorcount}.'</td></tr>');
1.33 raeburn 1507: }
1.84 raeburn 1508: } elsif ($itemserror) {
1509: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1510: } else {
1.68 raeburn 1511: $r->print('<tr class="LC_empty_row"><td>'.$lt{'noer'}.'</td></tr>');
1.33 raeburn 1512: }
1513: return;
1514: }
1515:
1516: sub display_abovethreshold {
1.84 raeburn 1517: my ($r,$refpage,$warnings,$triggered,$res_title,$itemserror) = @_;
1.33 raeburn 1518: my %lt = &Apache::lonlocal::texthash(
1519: reso => 'Resource',
1520: part => 'Part',
1521: nust => 'Num. students',
1522: avat => 'Av. Attempts',
1523: dedi => 'Deg. Diff',
1524: lare => 'Last Reset',
1525: reco => 'Reset Count?',
1526: rese => 'Reset counters to 0',
1527: nopr => 'No problems satisfy threshold criteria',
1528: );
1529: if (@{$warnings} > 0) {
1530: @{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings};
1.36 raeburn 1531: $r->print('<form name="reset_tracking" method="post" action="/adm/whatsnew">'.
1.39 raeburn 1532: ' <input type="hidden" name="command" value="reset" />'."\n".
1533: ' <input type="hidden" name="refpage" value="'.$refpage.'" />'.
1534: "\n");
1.61 albertel 1535: $r->print('<tr class="LC_info_row">'.
1.68 raeburn 1536: '<td class="LC_left_item">'.$lt{'reso'}.'</td>'.
1.61 albertel 1537: '<td>'.$lt{'part'}.'</td><td>'.$lt{'nust'}.'</td>'.
1538: '<td>'.$lt{'avat'}.'</td><td>'.$lt{'dedi'}.'</td>'.
1.68 raeburn 1539: '<td>'.$lt{'lare'}.'</td><td class="LC_right_item">'.
1540: $lt{'reco'}.'</td></tr>');
1.61 albertel 1541: my $row;
1.33 raeburn 1542: foreach my $res (@{$warnings}) {
1.61 albertel 1543: $row++;
1.33 raeburn 1544: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
1545: my $linkurl=&Apache::lonnet::clutter($url);
1546: my $rowspan;
1547: if ($$triggered{$res}{numparts} > 1) {
1548: $rowspan = 'rowspan="'.$$triggered{$res}{numparts}.'"';
1549: }
1.55 www 1550: $linkurl .= '?symb='.&escape($res);
1.66 raeburn 1551: if ($$triggered{$res}{'enclink'}) {
1552: $linkurl =
1553: $$triggered{$res}{'enclink'}.'?symb='.$$triggered{$res}{'encsymb'};
1554: }
1.68 raeburn 1555: my $css_class = $row%2?' class="LC_odd_row"':'';
1556: $r->print('<tr'.$css_class.'>'.
1.61 albertel 1557: '<td class="LC_first_item" '.$rowspan.'><a href="'.$linkurl.'">'.
1.62 raeburn 1558: $$triggered{$res}{title}.'</a></td>');
1559: if (ref($$triggered{$res}{text}) eq 'ARRAY') {
1560: $r->print($$triggered{$res}{text}[0]);
1561: }
1562: $r->print('</tr>');
1563: if (ref($$triggered{$res}{text}) eq 'ARRAY') {
1564: if (@{$$triggered{$res}{text}} > 1) {
1565: for (my $i=1; $i<@{$$triggered{$res}{text}}; $i++) {
1566: $r->print('<tr class="'.$css_class.'">'.
1567: $$triggered{$res}{text}[$i].'</tr>');
1568: }
1569: }
1570: }
1.33 raeburn 1571: }
1.68 raeburn 1572: $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 1573: } elsif ($itemserror) {
1574: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1575: } else {
1.63 albertel 1576: $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
1.33 raeburn 1577: }
1578: }
1579:
1580: sub display_versionchanges {
1.84 raeburn 1581: my ($r,$changed,$res_title,$interval,$itemserror) = @_;
1.33 raeburn 1582: my %lt = &Apache::lonlocal::texthash(
1583: 'reso' => 'Resource',
1584: 'revd' => 'Last revised',
1585: 'newv' => 'New version',
1586: 'veru' => 'Version used',
1587: );
1588: if (keys(%{$changed}) > 0) {
1.68 raeburn 1589: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1590: $lt{'reso'}.'</td><td>'.$lt{'revd'}.'</td><td>'.
1591: $lt{'newv'}.'</td><td class="LC_right_item">'.
1592: $lt{'veru'}.'</td></tr>');
1.33 raeburn 1593: my @changes = sort { &cmp_title($a,$b,$res_title) } keys(%{$changed});
1594: my $changenum = 0;
1595: foreach my $item (@changes) {
1.68 raeburn 1596: $changenum ++;
1597: my $css_class = $changenum%2?' class="LC_odd_row"':'';
1.33 raeburn 1598: my ($map,$id,$url)=&Apache::lonnet::decode_symb($item);
1599: my $linkurl=&Apache::lonnet::clutter($url);
1.55 www 1600: $linkurl .= '?symb='.&escape($item);
1.33 raeburn 1601:
1.68 raeburn 1602: $r->print('<tr'.$css_class.'><td><a href="'.$linkurl.'">'.
1603: $$res_title{$item}.'</a></td><td>'.
1604: $$changed{$item}{'revdate'}.'</td><td>'.
1605: $$changed{$item}{'current'}.'</td><td>'.
1606: $$changed{$item}{'version'}.'</td></tr>');
1.33 raeburn 1607: }
1.84 raeburn 1608: } elsif ($itemserror) {
1609: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1610: } else {
1.78 bisitz 1611: $r->print('<tr class="LC_empty_row"><td>'
1612: .&mt('No '.$interval).'</td></tr>');
1.33 raeburn 1613: }
1614: return;
1615: }
1.77 raeburn 1616:
1617: sub display_rolechanges {
1618: my ($r,$chgcount,$changed,$interval,$crstype) = @_;
1619: my $now = time();
1.92 ! lueken 1620: my $datetime;
1.77 raeburn 1621: my %lt = &Apache::lonlocal::texthash(
1622: 'user' => 'User',
1623: 'tich' => 'Time of change',
1624: 'role' => 'Role',
1625: 'sec' => 'Section',
1626: 'status' => 'Status',
1627: );
1628: if ($chgcount) {
1629: $r->print('<tr class="LC_info_row">'.
1630: '<td class="LC_left_item">'.$lt{'tich'}.'</td>'.
1631: '<td class="LC_left_item">'.$lt{'user'}.'</td>'.
1632: '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
1633: '<td class="LC_left_item">'.$lt{'sec'}.'</td>'.
1634: '<td class="LC_left_item">'.$lt{'status'}.'</td></tr>');
1635: if (ref($changed) eq 'HASH') {
1636: my @changes = sort { $b <=> $a } (keys(%{$changed}));
1637: my $changenum = 0;
1638: foreach my $item (@changes) {
1639: if (ref($changed->{$item}) eq 'ARRAY') {
1640: foreach my $chg (@{$changed->{$item}}) {
1641: if (ref($chg) eq 'HASH') {
1642: my $section;
1643: my $role =
1644: &Apache::lonnet::plaintext($chg->{'role'},$crstype);
1645: my $status = &mt($chg->{'status'});
1646: if ($chg->{'section'} eq '') {
1647: $section = &mt('none');
1648: } else {
1649: $section = $chg->{'section'};
1650: }
1651: my $uname = $chg->{'uname'};
1652: my $udom = $chg->{'udom'};
1653: $changenum ++;
1654: my $css_class = $changenum%2?' class="LC_odd_row"':'';
1655: my $link =
1656: &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom);
1657: $r->print('<tr'.$css_class.'>'.
1.92 ! lueken 1658: '<td>'.&Apache::lonlocal::locallocaltime($item,'',\$datetime).'</td>'.
1.77 raeburn 1659: '<td>'.$link.'</td>'.
1660: '<td>'.$role.'</td>'.
1661: '<td>'.$section.'</td>'.
1662: '<td>'.$status.'</td></tr>');
1663: }
1664: }
1665: }
1666: }
1667: }
1668: } else {
1.78 bisitz 1669: $r->print('<tr class="LC_empty_row"><td>'
1670: .&mt('There are no '.$interval).'</td></tr>');
1.77 raeburn 1671: }
1672: return;
1673: }
1.33 raeburn 1674:
1675: sub display_coursediscussion {
1.84 raeburn 1676: my ($r,$newdiscussions,$unread,$countunread,$res_title,$itemserror) = @_;
1.59 albertel 1677: my $lctype = lc(&Apache::loncommon::course_type());
1.33 raeburn 1678: my %lt = &Apache::lonlocal::texthash(
1679: 'loca' => 'Location',
1680: 'type' => 'Type',
1681: 'numn' => 'Number of new posts',
1.56 raeburn 1682: 'noun' => 'No unread posts in '.$lctype.' discussions',
1.37 raeburn 1683: 'tmlp' => 'Time of last post',
1.33 raeburn 1684: );
1685: if (@{$newdiscussions} > 0) {
1.68 raeburn 1686: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1687: $lt{'loca'}.'</td><td>'.
1688: $lt{'type'}.'</td>');
1.39 raeburn 1689: if ($countunread eq 'on') {
1.68 raeburn 1690: $r->print('<td>'.$lt{'tmlp'}.'</td>'.
1691: '<td class="LC_right_item">'.$lt{'numn'}.'</td>');
1.37 raeburn 1692: } else {
1.68 raeburn 1693: $r->print('<td class="LC_right_item">'.$lt{'tmlp'}.'</td>');
1.37 raeburn 1694: }
1695: $r->print("</tr>\n");
1.33 raeburn 1696: @{$newdiscussions} = sort { &cmp_title($a,$b,$res_title) }
1697: @{$newdiscussions};
1698: my $rowNum = 0;
1699: foreach my $ressymb (@{$newdiscussions}) {
1.68 raeburn 1700: $rowNum ++;
1.33 raeburn 1701: my $forum_title = $$unread{$ressymb}{'title'};
1702: my $type = 'Resource';
1703: my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
1.66 raeburn 1704: my $disclink = $feedurl.'?symb='.$$unread{$ressymb}{symb};
1.33 raeburn 1705: if ($feedurl =~ /bulletinboard/) {
1.85 schafran 1706: $type = 'Discussion Board';
1.33 raeburn 1707: }
1.66 raeburn 1708: if ($$unread{$ressymb}{'enclink'}) {
1709: $disclink = $$unread{$ressymb}{'enclink'}.'?symb='.$$unread{$ressymb}{'encsymb'};
1710: }
1.68 raeburn 1711: my $css_class = $rowNum%2?' class="LC_odd_row"':'';
1.37 raeburn 1712: my $lastpost = &Apache::lonnavmaps::timeToHumanString(
1713: $$unread{$ressymb}{'lastpost'});
1.70 raeburn 1714: $r->print('<tr'.$css_class.'><td><a href="'.$disclink.'">'.$forum_title.'</a> </td><td>'.&mt($type).' </td>');
1.39 raeburn 1715: if ($countunread eq 'on') {
1.37 raeburn 1716: my $unreadnum = $$unread{$ressymb}{'unreadcount'};
1.68 raeburn 1717: $r->print('<td>'.$lastpost.'</td><td class="LC_right_item">'.
1718: $unreadnum.' </td>');
1.37 raeburn 1719: } else {
1.68 raeburn 1720: $r->print('<td class="LC_right_item">'.$lastpost.'</td>');
1.33 raeburn 1721: }
1.37 raeburn 1722: $r->print("</tr>\n");
1.33 raeburn 1723: }
1.84 raeburn 1724: } elsif ($itemserror) {
1725: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1726: } else {
1.68 raeburn 1727: $r->print('<tr class="LC_empty_row"><td>'.$lt{'noun'}.'</td></tr>');
1.33 raeburn 1728: }
1729: }
1730:
1731: sub display_coursenormalmail {
1.68 raeburn 1732: my ($r,$msgcount,$newmsgs) = @_;
1.59 albertel 1733: my $lctype = lc(&Apache::loncommon::course_type());
1.33 raeburn 1734: if ($msgcount > 0) {
1.68 raeburn 1735: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1736: &mt('Number').'</td><td>'.&mt('Subject').'</td><td>'.
1737: &mt('Sender').'</td><td class="LC_right_item">'.
1738: &mt('Date/Time').'</td></tr>');
1739: my $mailcount = 0;
1.33 raeburn 1740: foreach my $msg (@{$newmsgs}) {
1741: $mailcount ++;
1.68 raeburn 1742: my $css_class = $mailcount%2?' class="LC_odd_row"':'';
1.76 raeburn 1743: $r->print('<tr'.$css_class.'><td>'.$mailcount
1744: .'. </td><td><a href="/adm/email?display='
1745: .$msg->{'msgid'}.'">'
1746: .$msg->{'shortsub'}.'</a> </td><td> '
1747: .$msg->{'from'}.':'.$msg->{'fromdom'}.' </td><td>'
1748: .$msg->{'sendtime'}.'</td></tr>');
1.33 raeburn 1749: }
1750: } else {
1.68 raeburn 1751: $r->print('<tr class="LC_empty_row"><td>'.
1752: &mt('No new '.$lctype.' messages').'</td></tr>');
1.33 raeburn 1753: }
1754: }
1755:
1756: sub display_coursecritmail {
1.68 raeburn 1757: my ($r,$critmsgcount,$critmsgs) = @_;
1.59 albertel 1758: my $lctype = lc(&Apache::loncommon::course_type());
1.33 raeburn 1759: if ($critmsgcount > 0) {
1.68 raeburn 1760: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1761: &mt('Number').'</td><td>'.&mt('Subject').'</td><td>'.
1762: &mt('Sender').'</td><td class="LC_right_item">'.
1763: &mt('Date/Time').'</td></tr>');
1764: my $mailcount = 0;
1.33 raeburn 1765: foreach my $msg (@{$critmsgs}) {
1766: $mailcount ++;
1.68 raeburn 1767: my $css_class = $mailcount%2?' class="LC_odd_row"':'';
1768: $r->print('<tr'.$css_class.'><td>'.$mailcount.
1769: '. </td><td><a href="/adm/email?folder=critical">'.
1770: $msg->{'shortsub'}.'</a> </td><td> '.
1.72 albertel 1771: $msg->{'from'}.':'.$msg->{'fromdom'}.' </td><td>'.
1.68 raeburn 1772: $msg->{'sendtime'}.'</td></tr>');
1.33 raeburn 1773: }
1774: } else {
1.68 raeburn 1775: $r->print('<tr class="LC_empty_row"><td>'.
1776: &mt('No unread critical messages in '.$lctype).
1777: '</td></tr>');
1.33 raeburn 1778: }
1.1 raeburn 1779: }
1780:
1781: sub cmp_title {
1.16 raeburn 1782: my ($a,$b,$res_title) = @_;
1783: my ($atitle,$btitle) = (lc($$res_title{$a}),lc($$res_title{$b}));
1.1 raeburn 1784: $atitle=~s/^\s*//;
1785: $btitle=~s/^\s*//;
1786: return $atitle cmp $btitle;
1787: }
1788:
1.33 raeburn 1789: sub get_display_settings {
1.36 raeburn 1790: my ($uname,$udom,$cid) = @_;
1.33 raeburn 1791: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid);
1792: my ($tmp) = keys(%settings);
1.40 raeburn 1793: if ($tmp=~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 1794: %settings = ();
1.41 raeburn 1795: unless ($tmp =~ /^error: 2 /) {
1.59 albertel 1796: my $lctype = lc(&Apache::loncommon::course_type());
1.41 raeburn 1797: &Apache::lonnet::logthis('Error retrieving whatsnew settings: '.
1.56 raeburn 1798: $tmp.' for '.$uname.':'.$udom.' for '.$lctype.': '.$cid);
1.33 raeburn 1799: }
1800: }
1801: return %settings;
1802: }
1803:
1.36 raeburn 1804: sub store_display_settings {
1805: my ($uname,$udom,$cid,$checkallowed) = @_;
1806: my %whatsnew_settings;
1807: my $result;
1808: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 1809: if ($key =~ /_section$/) { next; }
1.36 raeburn 1810: if (exists($env{'form.display_'.$key})) {
1811: unless ($env{'form.display_'.$key} eq '') {
1812: $whatsnew_settings{$cid.':'.$key} = $env{'form.display_'.$key};
1813: }
1814: }
1815: }
1816: if (keys(%whatsnew_settings)) {
1817: $result = &Apache::lonnet::put('nohist_whatsnew',\%whatsnew_settings,
1818: $udom,$uname);
1819: } else {
1820: $result = 'ok';
1821: }
1822: return $result;
1823: }
1824:
1825: sub store_interval_setting {
1826: my ($uname,$udom,$cid,$interval_titles) = @_;
1827: my %interval_settings = ();
1828: my $result;
1.77 raeburn 1829: my $context = $env{'form.intervaltype'};
1830: if ($env{'form.interval'} ne '') {
1831: if ($context eq 'oldroles') {
1832: $interval_settings{$cid.':oldroleinterval'} = $env{'form.interval'};
1833: } elsif ($context eq 'newroles') {
1834: $interval_settings{$cid.':newroleinterval'} = $env{'form.interval'};
1835: } else {
1836: $interval_settings{$cid.':interval'} = $env{'form.interval'};
1837: }
1.36 raeburn 1838: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
1839: \%interval_settings,$udom,$uname);
1840: if ($outcome eq 'ok') {
1.77 raeburn 1841: if (ref($interval_titles->{$context}) eq 'HASH') {
1842: $result = &mt('New filter setting: [_1].','<b>'.
1843: $interval_titles->{$context}->{$env{'form.interval'}}.'</b>').'<br />';
1844: }
1.36 raeburn 1845: } else {
1.59 albertel 1846: my $lctype = lc(&Apache::loncommon::course_type());
1.77 raeburn 1847: &Apache::lonnet::logthis('Error saving whatsnew '.$context.' interval setting'.
1.56 raeburn 1848: ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
1.36 raeburn 1849: $result = &mt('Unable to set interval to [_1] due to [_2].',
1.77 raeburn 1850: '<b>'.$interval_titles->{$context}->{$env{'form.interval'}}.'</b>',
1.36 raeburn 1851: '<tt>'.$outcome.'</tt>.<br />');
1852: }
1853: }
1854: return $result;
1855: }
1856:
1.39 raeburn 1857: sub store_discussion_setting {
1858: my ($uname,$udom,$cid) = @_;
1859: my %discussion_settings;
1860: my $result;
1861: if (defined($env{'form.countunread'})) {
1862: $discussion_settings{$cid.':countunread'} = $env{'form.countunread'};
1863: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
1864: \%discussion_settings,$udom,$uname);
1865: if ($outcome eq 'ok') {
1866: $result = &mt('Count unread posts in discussions display set to [_1]',
1.74 bisitz 1867: '<b>'.&mt($env{'form.countunread'}).'</b>').'<br />';
1.39 raeburn 1868:
1869: } else {
1.59 albertel 1870: my $lctype = lc(&Apache::loncommon::course_type());
1.71 albertel 1871: &Apache::lonnet::logthis('Error saving whatsnew countunread setting'.
1.56 raeburn 1872: ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
1.39 raeburn 1873: $result = &mt('Unable to set "number unread posts display" to [_1]'.
1874: ' due to [_2].',
1.74 bisitz 1875: '<b>'.&mt($env{'form.countunread'}).'</b>',
1.39 raeburn 1876: '<tt>'.$outcome.'</tt>.<br />');
1877: }
1878: }
1879: return $result;
1880: }
1881:
1882: sub store_courseinit_setting {
1883: my ($uname,$udom,$cid,$initpage) = @_;
1884: my %courseinit_settings;
1885: my $page_control;
1886: my $result;
1887: if (defined($env{'form.courseinit_control'})) {
1888: if ($env{'form.courseinit_control'} eq 'userpref') {
1889: $courseinit_settings{$cid.':courseinit'} = '';
1890: $page_control = 'global preferences';
1891: } else {
1892: if (defined($env{'form.courseinit_page'})) {
1893: $courseinit_settings{$cid.':courseinit'} =
1894: $env{'form.courseinit_page'};
1895: $page_control = 'course specific setting';
1896: }
1897: }
1898: if ($page_control) {
1.59 albertel 1899: my $lctype = lc(&Apache::loncommon::course_type());
1.39 raeburn 1900: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
1901: \%courseinit_settings,$udom,$uname);
1902: if ($outcome eq 'ok') {
1903: if ($page_control eq 'global preferences') {
1.81 bisitz 1904: $result = &mt("Page displayed after role selection in $lctype now set by [_1]user's global preferences[_2].",'<b>','</b>');
1.39 raeburn 1905: } else {
1.81 bisitz 1906: $result = &mt('Page displayed after role selection in this '.$lctype.' set to [_1].'
1907: ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>');
1.39 raeburn 1908: }
1909: } else {
1.71 albertel 1910: &Apache::lonnet::logthis('Error saving whatsnew courseinit '.
1.39 raeburn 1911: 'setting: '.$outcome.' for '.$uname.
1.56 raeburn 1912: ':'.$udom.' in '.$lctype.' '.$cid);
1.39 raeburn 1913: if ($page_control eq 'global preferences') {
1914: $result = &mt('Unable to set control of page display to [_1]'.
1915: ' due to [_2].',
1916: '<b>'.$page_control.'</b>',
1917: '<tt>'.$outcome.'</tt>.<br />');
1918: } else {
1.81 bisitz 1919: $result = &mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].'
1920: ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>'
1921: ,'<tt>'.$outcome.'</tt>')
1922: .'<br />';
1.39 raeburn 1923: }
1924: }
1925: }
1926: }
1927: return $result;
1928: }
1929:
1.33 raeburn 1930: sub start_box {
1.69 raeburn 1931: my ($r,$show,$heading,$caller,$refpage) = @_;
1.33 raeburn 1932: my %lt = &Apache::lonlocal::texthash(
1933: chth => 'Change thresholds?',
1934: chin => 'Change interval?',
1.39 raeburn 1935: chop => 'Change options?',
1.33 raeburn 1936: );
1.68 raeburn 1937: my $showhide;
1.33 raeburn 1938: if ($$show{$caller}) {
1.36 raeburn 1939: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1.70 raeburn 1940: 'display_'.$caller.",'hide'".');">'.
1941: &mt('Hide').'</a></b>';
1.33 raeburn 1942:
1943: } else {
1.36 raeburn 1944: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1.70 raeburn 1945: 'display_'.$caller.",'show'".');">'.
1946: &mt('Show').'</a></b>';
1.33 raeburn 1947: }
1948:
1949: $r->print('
1.68 raeburn 1950: <table class="LC_nested_outer">
1.33 raeburn 1951: <tr>
1.73 raeburn 1952: <th class="LC_left_item">'.$$heading{$caller}.'</th>
1.68 raeburn 1953: <th class="LC_right_item">'.$showhide.'</th>
1954: </tr>');
1.33 raeburn 1955: if (($caller eq 'abovethreshold') && ($$show{$caller})) {
1.40 raeburn 1956: if ($$show{$caller}) {
1957: $r->print('
1.33 raeburn 1958: <tr>
1.68 raeburn 1959: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgthreshold&refpage='.$refpage.'">'.$lt{'chth'}.'</a></td>
1.33 raeburn 1960: </tr>');
1.40 raeburn 1961: }
1.33 raeburn 1962: } elsif (($caller eq 'versionchanges') && ($$show{$caller})) {
1.40 raeburn 1963: if ($$show{$caller}) {
1964: $r->print('
1.33 raeburn 1965: <tr>
1.68 raeburn 1966: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chginterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1.39 raeburn 1967: </tr>');
1.40 raeburn 1968: }
1.39 raeburn 1969: } elsif ($caller eq 'coursediscussion') {
1.40 raeburn 1970: if ($$show{$caller}) {
1971: $r->print('
1.39 raeburn 1972: <tr>
1.68 raeburn 1973: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgdisc&refpage='.$refpage.'">'.$lt{'chop'}.'</a></td>
1.33 raeburn 1974: </tr>');
1.40 raeburn 1975: }
1.77 raeburn 1976: } elsif (($caller eq 'newroles') && ($$show{$caller})) {
1977: if ($$show{$caller}) {
1978: $r->print('
1979: <tr>
1980: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgnewroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1981: </tr>');
1982: }
1983: } elsif (($caller eq 'oldroles') && ($$show{$caller})) {
1984: if ($$show{$caller}) {
1985: $r->print('
1986: <tr>
1987: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1988: </tr>');
1989: }
1.33 raeburn 1990: }
1.61 albertel 1991: $r->print('
1.33 raeburn 1992: <tr>
1.68 raeburn 1993: <td colspan="2">
1994: <table class="LC_nested">
1.33 raeburn 1995: ');
1996: return;
1997: }
1998:
1999: sub end_box {
2000: my ($r) = shift;
2001: $r->print('
2002: </table>
2003: </td>
2004: </tr>
2005: </table><br />');
2006: return;
2007: }
2008:
1.7 raeburn 2009: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>