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