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