Annotation of loncom/interface/lonwhatsnew.pm, revision 1.35
1.2 albertel 1: #
1.35 ! raeburn 2: # $Id: lonwhatsnew.pm,v 1.34 2005/12/05 16:42:26 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.1 raeburn 39: use Apache::Constants qw(:common :http);
40: use Time::Local;
1.24 albertel 41: use GDBM_File;
1.1 raeburn 42:
43: #----------------------------
44: # handler
45: #
46: #----------------------------
47:
48: sub handler {
49: my $r = shift;
1.7 raeburn 50: if ($r->header_only) {
51: &Apache::loncommon::content_type($r,'text/html');
52: $r->send_http_header;
53: return OK;
54: }
1.1 raeburn 55: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['command']);
56:
1.13 raeburn 57: my $command;
58: if ($env{'form.action'} eq 'reset') {
59: $command = 'reset';
60: } elsif ($env{'form.action'} eq 'update') {
61: $command = 'update';
62: } else {
63: $command = $env{'form.command'};
1.1 raeburn 64: }
65:
1.7 raeburn 66: &Apache::loncommon::content_type($r,'text/html');
67: $r->send_http_header;
1.33 raeburn 68: $r->print(&display_header($command));
69: if (! (($env{'request.course.fn'}) && (&Apache::lonnet::allowed('bre',$env{'request.course.id'})))) {
70: # Not in a course, or not allowed to view action items
71: $env{'user.error.msg'}="/adm/whatsnew:bre:0:0:Cannot display what's new screen";
1.1 raeburn 72: return HTTP_NOT_ACCEPTABLE;
73: }
74:
1.7 raeburn 75: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.33 raeburn 76: if (($command eq 'chgthreshold') && (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
1.7 raeburn 77: &Apache::lonhtmlcommon::add_breadcrumb
1.13 raeburn 78: ({href=>'/adm/whatsnew?command=threshold',
79: text=>"Change thresholds"});
1.7 raeburn 80: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.13 raeburn 81: (undef,'Course Action Items','Course_Action_Items_Thresholds'));
1.7 raeburn 82: } else {
83: &Apache::lonhtmlcommon::add_breadcrumb
1.13 raeburn 84: ({href=>'/adm/whatsnew',
1.7 raeburn 85: text=>"Display Action Items"});
86: $r->print(&Apache::lonhtmlcommon::breadcrumbs
87: (undef,'Course Action Items','Course_Action_Items_Display'));
88: }
1.1 raeburn 89: &display_main_box($r,$command);
1.14 albertel 90: return OK;
1.1 raeburn 91: }
92:
93: #------------------------------
94: # display_main_box
95: #
96: # Display all the elements within the main box
97: #------------------------------
98:
99: sub display_main_box {
100: my ($r,$command) = @_;
101: my $domain=&Apache::loncommon::determinedomain();
102: my $tabbg=&Apache::loncommon::designparm('coordinator.tabbg',$domain);
1.7 raeburn 103: $r->print('<table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td width="100%">');
1.13 raeburn 104:
105: my %threshold_titles = (
106: av_attempts => 'Average number of attempts',
107: degdiff => 'Degree of difficulty',
108: numstudents => 'Total number of students with submissions',
109: );
1.15 raeburn 110: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
111: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
112:
1.33 raeburn 113: if (($command eq 'chgthreshold') && (&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
1.15 raeburn 114: &display_config_box($r,$command,$tabbg,\%threshold_titles,$cdom,$crs);
1.1 raeburn 115: } else {
1.15 raeburn 116: &display_actions_box($r,$command,\%threshold_titles,$cdom,$crs);
1.1 raeburn 117: }
118: $r->print(<<END_OF_BLOCK);
119: </td>
120: </tr>
121: </table><br />
122: </body>
123: </html>
124: END_OF_BLOCK
125: }
126:
127: #-------------------------------
128: # display_header
129: #
130: # Display the header information and set
131: # up the HTML
132: #-------------------------------
133:
134: sub display_header{
1.3 albertel 135: my $html=&Apache::lonxml::xmlbegin();
1.1 raeburn 136: my $bodytag=&Apache::loncommon::bodytag('Course Action Items');
137: return(<<ENDHEAD);
1.3 albertel 138: $html
1.1 raeburn 139: <head>
140: <title>Course Action Items</title>
141: </head>
142: $bodytag
143: ENDHEAD
144: }
145:
146: #-------------------------------
147: # display_actions_box
148: #
149: # Display the action items
150: #
151: #-------------------------------
152:
153: sub display_actions_box() {
1.15 raeburn 154: my ($r,$command,$threshold_titles,$cdom,$crs) = @_;
1.1 raeburn 155:
156: my $rowColor1 = "#ffffff";
157: my $rowColor2 = "#eeeeee";
158:
159: my %unread = ();
160: my %ungraded = ();
161: my %bombed = ();
1.11 raeburn 162: my %triggered = ();
1.33 raeburn 163: my %changed = ();
1.1 raeburn 164: my @newmsgs = ();
165: my @critmsgs = ();
166: my @newdiscussions = ();
167: my @tograde = ();
168: my @bombs = ();
1.11 raeburn 169: my @warnings = ();
1.33 raeburn 170: my $msgcount = 0;
171: my $critmsgcount = 0;
172:
1.16 raeburn 173: my %res_title = ();
1.33 raeburn 174: my %show = ();
175: my $needitems = 0;
176: my $boxcount = 0;
1.1 raeburn 177:
178: my $domain=&Apache::loncommon::determinedomain();
179: my $function;
1.5 albertel 180: if ($env{'request.role'}=~/^(cc|in|ta|ep)/) {
1.1 raeburn 181: $function='coordinator';
182: }
1.5 albertel 183: if ($env{'request.role'}=~/^(su|dc|ad|li)/) {
1.1 raeburn 184: $function='admin';
185: }
186:
1.13 raeburn 187: my %threshold = (
1.22 www 188: av_attempts => 2,
189: degdiff => 0.5,
190: numstudents => 2,
1.13 raeburn 191: );
192:
1.1 raeburn 193: my $pgbg=&Apache::loncommon::designparm($function.'.pgbg',$domain);
194: my $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain);
195:
1.5 albertel 196: unless ($env{'request.course.id'}) {
1.18 raeburn 197: $r->print('<br /><b><center>You are accessing an invalid course.</center></b><br /><br />');
1.1 raeburn 198: return;
199: }
1.33 raeburn 200:
201: my %checkallowed = (
202: coursediscussion => &Apache::lonnet::allowed('pch',$env{'request.course.id'}),
203: handgrading => &Apache::lonnet::allowed('mgr',$env{'request.course.id'}),
204: abovethreshold => &Apache::lonnet::allowed('vgr',$env{'request.course.id'}),
205: haserrors => &Apache::lonnet::allowed('opa',$env{'request.course.id'}),
206: versionchanges => &Apache::lonnet::allowed('opa',$env{'request.course.id'}),
207: coursenormalmail => 1,
208: coursecritmail => 1,
209: );
210:
1.35 ! raeburn 211: my $timediff = 604800;
1.33 raeburn 212: my %display_settings = &get_display_settings();
1.35 ! raeburn 213: my $now = time;
1.33 raeburn 214: my %intervals = (
215: -1 => 'since start of course',
216: 2592000 => 'since last month',
217: 604800 => 'since last week',
218: 86400 => 'since yesterday',
219: );
1.35 ! raeburn 220: my $interval = $intervals{$timediff};
! 221: if ($timediff == -1) {
! 222: $timediff = time;
! 223: }
! 224: my $starttime = $now - $timediff;
1.33 raeburn 225:
226: my %headings = &Apache::lonlocal::texthash(
227: coursediscussion => 'Unread course discussion posts',
228: handgrading => 'Problems requiring handgrading',
229: haserrors => 'Problems with errors',
230: versionchanges => 'Resources in course with version changes '.$interval,
231: coursenormalmail => 'New course message',
232: coursecritmail => 'New critical messages in course',
233: );
234:
235: if ($checkallowed{'abovethreshold'}) {
236: &get_curr_thresholds(\%threshold,$cdom,$crs);
237: }
238:
239: $headings{'abovethreshold'} = &mt('Problems with av. attempts').' ≥ '.$threshold{'av_attempts'}.' '.&mt('or deg. difficulty').' ≥ '.$threshold{'degdiff'}.'<br /> '.&mt('and total number of students with submissions').' ≥ '.$threshold{'numstudents'};
240:
241: my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail');
242:
243: foreach my $key (keys(%checkallowed)) {
244: $show{$key} = 0;
245: if ($checkallowed{$key}) {
246: unless ($display_settings{$key} eq 'off') {
247: $show{$key} = 1;
248: }
249: }
250: }
251:
252: foreach my $item (@actionorder) {
253: unless ($item eq 'coursenormalmail' || $item eq 'coursecritmail') {
254: if ($show{$item}) {
255: $needitems = 1;
256: last;
257: }
258: }
259: }
260:
261:
1.24 albertel 262: if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
263: &GDBM_READER(),0640)) {
264: my $furl=$bighash{'first_url'};
265: $r->print('<font size="+1"><a href="'.$furl.'">Go to first resource</a></font><a href="/adm/preferences?action=changecourseinit"></font><br />Change your preferences</a> to suppress display of this screen when accessing courses as Course Coordinator in the future.<br /><hr />');
266: untie(%bighash);
267: }
1.18 raeburn 268:
1.13 raeburn 269: my $result;
270:
271: if ($command eq 'reset') {
272: $result = &process_reset($cdom,$crs);
273: } elsif ($command eq 'update') {
274: $result = &process_update($cdom,$crs,$threshold_titles);
275: }
276: if ($result) {
277: $r->print($result.'<hr width="100%" />');
278: }
1.27 albertel 279: $r->rflush();
1.13 raeburn 280:
1.33 raeburn 281: if ($needitems) {
282: &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,$rowColor1,$rowColor2,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime);
1.1 raeburn 283: }
1.33 raeburn 284: if ($show{'coursenormalmail'}) {
285: &getnormalmail(\@newmsgs);
1.7 raeburn 286: }
1.33 raeburn 287: if ($show{'coursecritmail'}) {
288: &getcritmail(\@critmsgs);
1.11 raeburn 289: }
290:
1.33 raeburn 291: $r->print(qq|<a href="javascript:changeAll('hide');">Hide All</a> <a href="javascript:changeAll('show');">Show All</a>|);
1.1 raeburn 292:
1.33 raeburn 293: $r->print('<br /><table border="0" width="100%" cellpadding="2" cellspacing="4"><tr><td align="left" valign="top" width="45%">');
1.1 raeburn 294:
1.33 raeburn 295: my $displayed = 0;
296: my $totalboxes = keys(%checkallowed);
297: my $halfway = int($totalboxes/2) + $totalboxes%2;
298: foreach my $actionitem (@actionorder) {
299: if ($checkallowed{$actionitem}) {
300: if ($displayed == $halfway) {
301: $r->print('</td><td width="5%"> </td><td align="left" valign="top" width-"50%">');
1.1 raeburn 302: }
1.33 raeburn 303: &display_launcher($r,$actionitem,\%checkallowed,$tabbg,$rowColor1,$rowColor2,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,$interval);
304: $displayed ++;
1.1 raeburn 305: }
306: }
307: $r->print('
308: </table>
309: </td>
310: </tr>
1.33 raeburn 311: </table>
312: </td>
313: </tr>
314: </table>');
1.1 raeburn 315: }
316:
1.11 raeburn 317: #-------------------------------
318: # display_config_box
319: #
1.13 raeburn 320: # Display the threshold setting screen
1.11 raeburn 321: #
322: #-------------------------------
323:
324: sub display_config_box() {
1.15 raeburn 325: my ($r,$command,$tabbg,$threshold_titles,$cdom,$crs) = @_;
1.13 raeburn 326: my %threshold = ();
327: my $rowColor1 = "#ffffff";
328: my $rowColor2 = "#eeeeee";
329: my $rowColor;
330:
331: my @thresholditems = ("av_attempts","degdiff","numstudents");
332: my %threshold_titles = (
333: av_attempts => 'Average number of attempts',
334: degdiff => 'Degree of difficulty',
335: numstudents => 'Total number of students with submissions',
336: );
1.15 raeburn 337: &get_curr_thresholds(\%threshold,$cdom,$crs);
1.13 raeburn 338:
339: $r->print('<br /><form name="thresholdform" method="post"><table border="0" cellpadding="2" cellspacing="4"><tr><td align="left" valign="top" width="45%">
340: <table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
341: <tr>
342: <td>
343: <table border="0" cellpadding="1" cellspacing="1" bgcolor="#000000">
344: <tr>
345: <td bgcolor="#ffffff">
346: <table cellspacing="0" cellpadding="4" border="0">
347: <tr bgcolor="'.$tabbg.'">
348: <th>Threshold Name</th>
349: <th>Current value</th>
350: <th>Change?</th>
351: </tr>');
352: my $rowNum =0;
353: foreach my $type (@thresholditems) {
354: my $parameter = 'internal.threshold_'.$type;
355: # onchange is javascript to automatically check the 'Set' button.
356: my $onchange = 'onFocus="javascript:window.document.forms'.
357: "['thresholdform'].elements['".$parameter."_setparmval']".
358: '.checked=true;"';
359: if ($rowNum %2 == 1) {
360: $rowColor = $rowColor1;
361: } else {
362: $rowColor = $rowColor2;
363: }
364: $r->print('
365: <tr bgcolor="'.$rowColor.'">
366: <td>'.$threshold_titles{$type}.'</td>
367: <td>'.&Apache::lonhtmlcommon::textbox($parameter.'_value',
368: $threshold{$type},
369: 10,$onchange).'</td>
370: <td>'
371: .&Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
372: '</td>
373: </tr>');
374: $rowNum ++;
375: }
376: $r->print('</table></td></tr></table></td></tr></table>
377: <br /><input type="submit" name="threshold" value="Make changes" />
378: <input type="hidden" name="action" value="update" />
379: </form>');
1.11 raeburn 380: }
381:
1.33 raeburn 382: sub display_launcher {
383: my ($r,$action,$checkallowed,$tabbg,$rowColor1,$rowColor2,$show,
384: $headings,$res_title,$tograde,$ungraded,$bombs,$bombed,$changed,
385: $warnings,$triggered,$newdiscussions,$unread,$msgcount,$newmsgs,
386: $critmsgcount,$critmsgs,$interval) = @_;
387:
388: if ($$checkallowed{$action}) {
389: &start_box($r,$tabbg,$show,$headings,$action);
390: if ($$show{$action}) {
391: if ($action eq 'handgrading') { # UNGRADED ITEMS
392: &display_handgrade($r,$tograde,$rowColor1,$rowColor2,
393: $ungraded);
394: } elsif ($action eq 'haserrors') { # BOMBS
395: &display_haserrors($r,$bombs,$rowColor1,$rowColor2,$bombed,
396: $res_title);
397: } elsif ($action eq 'versionchanges') { # VERSION CHANGES
398: &display_versionchanges($r,$changed,$res_title,$rowColor1,
399: $rowColor2,$interval);
400:
401: } elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS
402: &display_abovethreshold($r,$warnings,$triggered,$res_title,
403: $rowColor1,$rowColor2);
404: } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION
405: &display_coursediscussion($r,$newdiscussions,$unread,
406: $res_title);
407: } elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES
408: &display_coursenormalmail($r,$msgcount,$newmsgs,$rowColor1,
409: $rowColor2);
410: } elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES
411: &display_coursecritmail($r,$critmsgcount,$critmsgs,$rowColor1,
412: $rowColor2);
413: }
414: }
415: &end_box($r);
416: }
417: return;
418: }
419:
1.1 raeburn 420: sub getitems {
1.33 raeburn 421: my ($unread,$ungraded,$bombed,$triggered,$changed,$newdiscussions,
422: $tograde,$bombs,$warnings,$rowColor1,$rowColor2,$threshold,$cdom,$crs,
423: $res_title,$show,$starttime) = @_;
1.1 raeburn 424: my $navmap = Apache::lonnavmaps::navmap->new();
1.26 albertel 425: # force retrieve Resource to seed the part id cache we'll need it later
426: my @allres=$navmap->retrieveResources(undef,sub {if ($_[0]->is_problem) { $_[0]->parts();} return 1;});
1.33 raeburn 427: my %lastreadtime;
428: my %resourcetracker;
429:
430: # Resource version changes
431: if ($$show{'versionchanges'}) {
432: &checkversions($cdom,$crs,$navmap,$changed,$starttime);
433: }
434:
435: if ($$show{'coursediscussions'}) {
436: my %lastread = &Apache::lonnet::dump('nohist_'.
437: $env{'request.course.id'}.'_discuss',
438: $env{'user.domain'},$env{'user.name'},'lastread');
439: foreach my $key (keys(%lastread)) {
440: my $newkey = $key;
441: $newkey =~ s/_lastread$//;
442: $lastreadtime{$newkey} = $lastread{$key};
443: }
444: }
445:
446: if ($$show{'abovethreshold'}) {
447: %resourcetracker = &Apache::lonnet::dump('nohist_resourcetracker',
448: $cdom,$crs);
449: }
1.1 raeburn 450:
1.11 raeburn 451: my $warningnum = 0;
1.1 raeburn 452: foreach my $resource (@allres) {
453: my $result = '';
454: my $applies = 0;
455: my $symb = $resource->symb();
1.33 raeburn 456: %{$$bombed{$symb}} = ();
1.1 raeburn 457: %{$$ungraded{$symb}} = ();
1.11 raeburn 458: %{$$triggered{$symb}} = ();
459: $$triggered{$symb}{numparts} = 0;
1.1 raeburn 460: my $title = $resource->compTitle();
1.16 raeburn 461: $$res_title{$symb} = $title;
1.8 albertel 462: my $ressymb = $resource->wrap_symb();
1.33 raeburn 463:
1.1 raeburn 464: # Check for unread discussion postings
1.33 raeburn 465: if ($$show{'coursediscussion'}) {
466: &check_discussions($cdom,$crs,$resource,$symb,$ressymb,$title,
1.34 raeburn 467: $newdiscussions,$unread,\%lastreadtime);
1.33 raeburn 468: }
1.1 raeburn 469:
470: # Check for ungraded problems
471: if ($resource->is_problem()) {
1.33 raeburn 472: if ($$show{'handgrading'}) {
473: &check_handgraded($resource,$symb,$title,$cdom,$crs,$ungraded,
474: $tograde);
475: }
1.1 raeburn 476: }
477:
478: # Check for bombs
1.33 raeburn 479: if ($$show{'haserrors'}) {
480: &check_bombed($resource,$symb,$title,$bombs,$bombed);
481: }
482:
483: # Maxtries and degree of difficulty for problem parts, unless handgradeable
484: if ($$show{'abovethreshold'}) {
485: &check_thresholds($resource,$symb,\%resourcetracker,$triggered,
486: $threshold,$warnings,$warningnum,$rowColor1,$rowColor2);
487: }
488:
489: }
490: }
491:
492: sub check_discussions {
493: my ($cdom,$crs,$resource,$symb,$ressymb,$title,$newdiscussions,$unread,
494: $lastreadtime) = @_;
495: # Check for unread discussion postings
496: if ($resource->hasDiscussion()) {
497: my $prevread = 0;
498: my $unreadcount = 0;
499: %{$$unread{$ressymb}} = ();
500: $$unread{$ressymb}{'title'} = $title;
501: $$unread{$ressymb}{'symb'} = $symb;
502: if (defined($$lastreadtime{$ressymb})) {
503: $prevread = $$lastreadtime{$ressymb};
504: }
505: my %contrib = &Apache::lonnet::restore($ressymb,
506: $env{'request.course.id'},$cdom,$crs);
507: if ($contrib{'version'}) {
508: for (my $id=1;$id<=$contrib{'version'};$id++) {
509: unless (($contrib{'hidden'}=~/\.$id\./) ||
510: ($contrib{'deleted'}=~/\.$id\./)) {
511: if ($prevread <$contrib{$id.':timestamp'}) {
512: $$unread{$ressymb}{$unreadcount} = $id.': '.$contrib{$id.':subject'};
513: $unreadcount ++;
514: }
515: }
516: }
1.1 raeburn 517: }
1.33 raeburn 518: if ($unreadcount) { push(@{$newdiscussions}, $ressymb); }
519: }
520: }
521:
522: sub check_handgraded {
523: my ($resource,$symb,$title,$cdom,$cnum,$ungraded,$tograde) = @_;
524: if ($resource->is_problem()) {
525: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
526: my $partlist=$resource->parts();
527: my $handgradeable;
528: foreach my $part (@$partlist) {
1.31 raeburn 529: if ($resource->handgrade($part) eq 'yes') {
1.33 raeburn 530: $handgradeable=1; last;
1.31 raeburn 531: }
1.33 raeburn 532: }
533: if ($handgradeable) {
1.35 ! raeburn 534: my @ungraded = &Apache::bridgetask::get_queue_symb_status(
1.33 raeburn 535: 'gradingqueue',$symb,$cdom,$cnum);
536: if (@ungraded > 0) {
537: $$ungraded{$symb}{count} = scalar(@ungraded);
538: $$ungraded{$symb}{title} = $title;
539: push(@{$tograde}, $symb);
1.11 raeburn 540: }
541: }
1.33 raeburn 542: }
543: }
544:
545: sub check_bombed {
546: my ($resource,$symb,$title,$bombs,$bombed) = @_;
547: if ($resource->getErrors()) {
548: my $errors = $resource->getErrors();
549: $errors =~ s/^,//;
550: my @bombs = split(/,/, $errors);
551: my $errorcount = scalar(@bombs);
552: my $errorlink = '<a href="/adm/email?display='.
553: &Apache::lonnet::escape($bombs[0]).'">'.
554: $title.'</a>';
555: $$bombed{$symb}{errorcount} = $errorcount;
556: $$bombed{$symb}{errorlink} = $errorlink;
557: push(@{$bombs}, $symb);
558: }
559: }
560:
561: sub check_thresholds {
562: my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings,
563: $warningnum,$rowColor1,$rowColor2) = @_;
564: # Compile maxtries and degree of difficulty for problem parts, unless handgradeable
565: my @parts = @{$resource->parts()};
566: my %stats;
567: my %lastreset = ();
568: my $warning = 0;
569: my $rowColor;
570: foreach my $part (@parts) {
571: if ($resource->handgrade($part) eq 'yes') {
572: next;
573: }
574: %{$stats{$part}} = ();
575: my ($attempts,$users,$corrects,$degdiff,$av_attempts);
576: if (exists($$resourcetracker{$symb."\0".$part."\0attempts"})) {
577: $attempts = $$resourcetracker{$symb."\0".$part."\0attempts"};
578: }
579: if (exists($$resourcetracker{$symb."\0".$part."\0users"})) {
580: $users = $$resourcetracker{$symb."\0".$part."\0users"};
581: }
582: if (exists($$resourcetracker{$symb."\0".$part."\0correct"})) {
583: $corrects = $$resourcetracker{$symb."\0".$part."\0correct"};
584: }
585: if ($attempts > 0) {
586: $degdiff = 1 - ($corrects/$attempts);
587: $degdiff = sprintf("%.2f",$degdiff);
588: }
589: if ($users > 0) {
590: $av_attempts = $attempts/$users;
591: $av_attempts = sprintf("%.2f",$av_attempts);
592: }
593: if ((($degdiff ne '' && $degdiff >= $$threshold{'degdiff'}) || ($av_attempts ne '' && $av_attempts >= $$threshold{'av_attempts'})) && ($users >= $$threshold{'numstudents'})) {
594: $stats{$part}{degdiff} = $degdiff;
595: $stats{$part}{attempts} = $av_attempts;
596: $stats{$part}{users} = $users;
597: $lastreset{$part} = $$resourcetracker{$symb."\0".$part."\0resettime"};
598: if ($lastreset{$part}) {
599: $lastreset{$part} = &Apache::lonnavmaps::timeToHumanString($lastreset{$part});
1.11 raeburn 600: }
1.33 raeburn 601: $warning = 1;
602: }
603: }
604: if ($warning) {
1.35 ! raeburn 605: if ($warningnum %2 == 1) {
1.33 raeburn 606: $rowColor = $rowColor1;
607: } else {
608: $rowColor = $rowColor2;
609: }
610: $$triggered{$symb}{title} = $resource->title;
611: foreach my $part (@parts) {
612: if (exists($stats{$part}{users})) {
613: my $resetname = 'reset_'.&Apache::lonnet::escape($symb."\0".$part);
614: my $resettitle = 'title_'.&Apache::lonnet::escape($symb."\0".$part);
615: if ($$triggered{$symb}{numparts}) {
616: $$triggered{$symb}{text} .= '<tr bgcolor="'.$rowColor.'">'."\n";
617: }
618: if (@parts > 1) {
619: $$triggered{$symb}{text} .= '
620: <td align="right"><small>part - '.$part.'<small></td>';
621: } else {
1.11 raeburn 622: $$triggered{$symb}{text} .= '
1.33 raeburn 623: <td align="right"><small>single part</small></td>';
1.11 raeburn 624: }
1.33 raeburn 625: $$triggered{$symb}{text} .= '
626: <td align="right"><small>'.$stats{$part}{users}.'</small></td>
627: <td align="right"><small>'.$stats{$part}{attempts}.'</small></td>
628: <td align="right"><small>'.$stats{$part}{degdiff}.'</small></td>
629: <td align="right"><small>'.$lastreset{$part}.'</small></td>
630: <td align="right"><small><input type="checkbox" name="'.$resetname.'" /><input type="hidden" name="'.$resettitle.'" value="'.&Apache::lonnet::escape($$triggered{$symb}{title}).'" /></td>
631: </tr>';
632: $$triggered{$symb}{numparts} ++;
1.11 raeburn 633: }
634: }
1.33 raeburn 635: push(@{$warnings},$symb);
1.35 ! raeburn 636: $warningnum ++;
1.1 raeburn 637: }
638: }
639:
1.33 raeburn 640:
1.13 raeburn 641: sub get_curr_thresholds {
642: my ($threshold,$cdom,$crs) = @_;
643: my %coursesettings = &Apache::lonnet::dump('environment',
644: $cdom,$crs,'internal.threshold');
645: if (exists($coursesettings{'internal.threshold_av_attempts'})) {
646: $$threshold{'av_attempts'} = $coursesettings{'internal.threshold_av_attempts'};
647: }
648: if (exists($coursesettings{'internal.threshold_degdiff'})) {
649: $$threshold{'degdiff'} = $coursesettings{'internal.threshold_degdiff'};
650: }
651: if (exists($coursesettings{'internal.threshold_numstudents'})) {
652: $$threshold{'numstudents'} = $coursesettings{'internal.threshold_numstudents'};
653: }
654: }
655:
656: sub process_reset {
657: my ($dom,$crs) = @_;
658: my $result = '<b>Counters reset for following problems (and parts):</b><br />';
659: my @agg_types = ('attempts','users','correct');
660: my %agg_titles = (
661: attempts => 'Number of submissions',
662: users => 'Students with submissions',
663: correct => 'Number of correct submissions',
664: );
665: my @resets = ();
666: my %titles = ();
1.17 albertel 667: foreach my $key (keys(%env)) {
1.13 raeburn 668: next if ($key !~ /^form\.reset_(.+)$/);
669: my $title = &Apache::lonnet::unescape($env{'form.title_'.$1});
670: my $reset_item = &Apache::lonnet::unescape($1);
671: my %curr_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
672: my %aggregates = ();
1.17 albertel 673: my ($symb,$part) = split(/\0/,$reset_item);
1.13 raeburn 674: foreach my $type (@agg_types) {
675: $aggregates{$reset_item."\0".$type} = 0;
676: }
1.17 albertel 677: $aggregates{$reset_item."\0".'resettime'} = time;
1.13 raeburn 678: my $putresult = &Apache::lonnet::put('nohist_resourcetracker',\%aggregates,
679: $dom,$crs);
680: if ($putresult eq 'ok') {
681: $result .= $title.' -part '.$part.': ';
682: my %new_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
683: foreach my $type (@agg_types) {
684: $result .= $agg_titles{$type}.' = '.$new_aggregates{$reset_item."\0".$type}.'; ';
685: }
686: $result =~ s/; $//;
687: $result .= '<br />';
688: } else {
1.14 albertel 689: $result = $title.' -part '.$part.': '.&mt('Unable to reset counters to zero due to [_1]',$putresult).'.<br />'."\n";
1.13 raeburn 690: }
691: }
692: return $result;
693: }
694:
695: sub process_update {
696: my ($dom,$crs,$threshold_titles) = @_;
1.15 raeburn 697: my $setoutput = '<b>Changes to threshold(s) for problem tracking:</b><br />';
1.13 raeburn 698: foreach (keys %env) {
699: next if ($_!~/^form\.(.+)\_setparmval$/);
700: my $name = $1;
701: my $value = $env{'form.'.$name.'_value'};
702: if ($name && defined($value)) {
703: my $put_result = &Apache::lonnet::put('environment',
704: {$name=>$value},$dom,$crs);
705:
706: my ($shortname) = ($name =~ /^internal\.threshold_(.+)$/);
707: if ($put_result eq 'ok') {
1.14 albertel 708: $setoutput.=&mt('Set threshold for [_1] to [_2]',
709: '<b>'.$$threshold_titles{$shortname}.'</b>',
710: '<b>'.$value.'</b>').'<br />';
711: } else {
712: $setoutput.=&mt('Unable to set threshold for [_1] to [_2] due to [_3].',
713: '<b>'.$name.'</b>','<b>'.$value.'</b>',
714: '<tt>'.$put_result.'</tt>').'<br />';
1.13 raeburn 715: }
716: }
717: }
718: return $setoutput;
719: }
720:
1.33 raeburn 721: sub getnormalmail {
722: my ($newmsgs) = @_;
1.1 raeburn 723: # Check for unread mail in course
724: my $msgcount = 0;
1.3 albertel 725:
1.10 raeburn 726: my @messages = sort(&Apache::lonnet::getkeys('nohist_email'));
1.3 albertel 727: foreach my $message (@messages) {
728: my $msgid=&Apache::lonnet::escape($message);
1.10 raeburn 729: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1.1 raeburn 730: &Apache::lonmsg::unpackmsgid($msgid);
1.10 raeburn 731: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 732: if (defined($sendtime) && $sendtime!~/error/) {
733: my $numsendtime = $sendtime;
734: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
735: if ($status eq 'new') {
1.10 raeburn 736: $msgcount ++;
737: if ($shortsubj eq '') {
738: $shortsubj = &mt('No subject');
739: }
740: $shortsubj = &Apache::lonnet::unescape($shortsubj);
1.1 raeburn 741: push(@{$newmsgs}, {
742: msgid => $msgid,
743: sendtime => $sendtime,
1.10 raeburn 744: shortsub => $shortsubj,
1.1 raeburn 745: from => $fromname,
746: fromdom => $fromdom
747: });
748: }
749: }
750: }
751: }
1.33 raeburn 752: return $msgcount;
753: }
1.1 raeburn 754:
1.33 raeburn 755: sub getcritmail {
756: my ($critmsgs) = @_;
1.1 raeburn 757: # Check for critical messages in course
758: my %what=&Apache::lonnet::dump('critical');
759: my $result = '';
760: my $critmsgcount = 0;
1.3 albertel 761: foreach my $msgid (sort(keys(%what))) {
1.10 raeburn 762: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
763: &Apache::lonmsg::unpackmsgid($msgid);
764: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 765: if (defined($sendtime) && $sendtime!~/error/) {
766: my $numsendtime = $sendtime;
767: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
768: $critmsgcount ++;
1.10 raeburn 769: if ($shortsubj eq '') {
770: $shortsubj = &mt('No subject');
771: }
772: $shortsubj = &Apache::lonnet::unescape($shortsubj);
1.1 raeburn 773: push(@{$critmsgs}, {
774: msgid => $msgid,
775: sendtime => $sendtime,
1.10 raeburn 776: shortsub => $shortsubj,
1.1 raeburn 777: from => $fromname,
778: fromdom => $fromdom
779: });
780: }
781: }
782: }
1.33 raeburn 783: return $critmsgcount;
784: }
785:
786:
787: sub checkversions {
788: my ($cdom,$crs,$navmap,$changed,$starttime) = @_;
789: my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs);
790: my ($tmp) = keys(%changes);
791: if ($tmp =~/^error\:/) {
792: &Apache::lonnet::logthis('Error retrieving version update information: '.
793: $tmp.' for '.$cdom.'_'.$crs.' in whatsnew');
794: } else {
795: if (keys(%changes) > 0) {
796: foreach my $key (sort(keys(%changes))) {
797: if ($changes{$key} > $starttime) {
798: my $version;
799: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
800: my $currentversion=&Apache::lonnet::getversion($key);
801: my $revdate =
802: &Apache::lonnet::metadata($root.'.'.$extension,
803: 'lastrevisiondate');
804: $revdate = &Apache::lonlocal::locallocaltime($revdate);
805: my $linkurl=&Apache::lonnet::clutter($key);
806: my $usedversion=$navmap->usedVersion('version_'.$linkurl);
807: my @resources = $navmap->getResourceByUrl($linkurl,1);
808: if (($usedversion) && ($usedversion ne 'mostrecent')) {
809: $version = $usedversion;
810: } else {
811: $version = $currentversion;
812: }
813: foreach my $res (@resources) {
1.35 ! raeburn 814: if (ref($res) eq 'Apache::lonnavmaps::resource') {
! 815: my $symb = $res->symb();
! 816: %{$$changed{$symb}} = (
1.33 raeburn 817: current => $currentversion,
818: version => $version,
819: revdate => $revdate,
1.35 ! raeburn 820: );
! 821: }
1.33 raeburn 822: }
823: }
824: }
825: }
826: }
827: return;
828: }
829:
830: sub display_handgrade {
831: my ($r,$tograde,$rowColor1,$rowColor2,$ungraded) = @_;
832: my $rowColor;
833: my %lt = &Apache::lonlocal::texthash(
834: 'prna' => 'Problem Name',
835: 'nmun' => 'Number ungraded',
836: 'nopr' => 'No problems require handgrading',
837: );
838: if (@{$tograde} > 0) {
839: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'prna'}.'</small></b></td><td align="right"><b><small>'.$lt{'nmun'}.'</small></b></td></tr>');
840: my $rowNum = 0;
841: foreach my $res (@{$tograde}) {
842: if ($rowNum %2 == 1) {
843: $rowColor = $rowColor1;
844: } else {
845: $rowColor = $rowColor2;
846: }
847: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
848: my $linkurl=&Apache::lonnet::clutter($url);
849: $linkurl .= '?symb='.&Apache::lonnet::escape($res);
850:
851: $r->print('<tr bgcolor="'.$rowColor.'"><td><a href="'.$linkurl.'"><small>'.$$ungraded{$res}{title}.'</small></a></td><td align="right"><small>'.$$ungraded{$res}{count}.'</small></td></tr>');
852: $rowNum ++;
853: }
854: } else {
855: $r->print('<tr><td bgcolor="#ffffff"><br><center><i><b><small> '.$lt{'nopr'}.' </small><br><br></b></i></td></tr>');
856: }
857: }
858:
859: sub display_haserrors {
860: my ($r,$bombs,$rowColor1,$rowColor2,$bombed,$res_title) = @_;
861: my $bombnum = 0;
862: my $rowColor;
863: my %lt = &Apache::lonlocal::texthash(
864: reso => 'Resource',
865: nmer => 'Number of errors',
866: noer => 'No problems with errors',
867: );
868: if (@{$bombs} > 0) {
869: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'reso'}.'</small></b></td><td align="right"><b><small>'.$lt{'nmer'}.'</small></b></td></tr>');
870: @{$bombs} = sort { &cmp_title($a,$b,$res_title) } @{$bombs};
871: foreach my $bomb (@{$bombs}) {
872: if ($bombnum %2 == 1) {
873: $rowColor = $rowColor1;
874: } else {
875: $rowColor = $rowColor2;
876: }
877: $r->print('<tr bgcolor="'.$rowColor.'"><td><small>'.$$bombed{$bomb}{errorlink}.'</small></td><td align="right"><small>'.$$bombed{$bomb}{errorcount}.'</small></td></tr>');
878: $bombnum ++;
879: }
880: } else {
881: $r->print('<tr><td bgcolor="#ffffff"><br /><center><b><i><small>'.$lt{'noer'}.'</small></i></b></center><br /></td></tr>');
882: }
883: return;
884: }
885:
886: sub display_abovethreshold {
887: my ($r,$warnings,$triggered,$res_title,$rowColor1,$rowColor2) = @_;
888: my %lt = &Apache::lonlocal::texthash(
889: reso => 'Resource',
890: part => 'Part',
891: nust => 'Num. students',
892: avat => 'Av. Attempts',
893: dedi => 'Deg. Diff',
894: lare => 'Last Reset',
895: reco => 'Reset Count?',
896: rese => 'Reset counters to 0',
897: nopr => 'No problems satisfy threshold criteria',
898: );
899: my $rowColor;
900: my $warningnum = 0;
901: if (@{$warnings} > 0) {
902: @{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings};
903: $r->print('<form name="reset_tracking" method="post">'.
904: ' <input type="hidden" name="action" value="reset" />'."\n");
905: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'reso'}.'</small></b></td><td align="right"><b><small>'.$lt{'part'}.'</small></b></td><td align="right"><b><small>'.$lt{'nust'}.'</small></b></td><td align="right"><b><small>'.$lt{'avat'}.'</small></b></td><td align="right"><b><small>'.$lt{'dedi'}.'</small></b></td><td align="right"><b><small>'.$lt{'lare'}.'</small></b></td><td align="right"><b><small>'.$lt{'reco'}.'</small></b></td></tr>');
906: foreach my $res (@{$warnings}) {
907: if ($warningnum %2 == 1) {
908: $rowColor = $rowColor1;
909: } else {
910: $rowColor = $rowColor2;
911: }
912: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
913: my $linkurl=&Apache::lonnet::clutter($url);
914: my $rowspan;
915: if ($$triggered{$res}{numparts} > 1) {
916: $rowspan = 'rowspan="'.$$triggered{$res}{numparts}.'"';
917: }
918: $linkurl .= '?symb='.&Apache::lonnet::escape($res);
919: $r->print('<tr bgcolor="'.$rowColor.'"><td '.$rowspan.'><a href="'.$linkurl.'"><small>'.$$triggered{$res}{title}.'</small></a></td>'.$$triggered{$res}{text});
920: $warningnum ++;
921: }
1.35 ! raeburn 922: $r->print('<tr bgcolor="#cccccc"><td colspan="7" align="right"><br /><b><small><input type="submit" name="counters" value="'.$lt{'rese'}.'" /></form>');
1.33 raeburn 923: } else {
924: $r->print('<tr><td bgcolor="#ffffff"><br /><center><b><i><small>'.$lt{'nopr'}.'</small></i></b></center><br /></td></tr>');
925: }
926: }
927:
928: sub display_versionchanges {
929: my ($r,$changed,$res_title,$rowColor1,$rowColor2,$interval) = @_;
930: my %lt = &Apache::lonlocal::texthash(
931: 'reso' => 'Resource',
932: 'revd' => 'Last revised',
933: 'newv' => 'New version',
934: 'veru' => 'Version used',
935: 'noup' => 'No updated versions',
936: );
937: my $rowColor;
938: if (keys(%{$changed}) > 0) {
939: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'reso'}.'</small></b></td><td><b><small>'.$lt{'revd'}.'</small></b></td><td><b><small>'.$lt{'newv'}.'</small></b></td><td><b><small>'.$lt{'veru'}.'</small></b></td></tr>');
940:
941:
942: my @changes = sort { &cmp_title($a,$b,$res_title) } keys(%{$changed});
943: my $changenum = 0;
944: foreach my $item (@changes) {
945: if ($changenum %2 == 1) {
946: $rowColor = $rowColor1;
947: } else {
948: $rowColor = $rowColor2;
949: }
950: my ($map,$id,$url)=&Apache::lonnet::decode_symb($item);
951: my $linkurl=&Apache::lonnet::clutter($url);
952: $linkurl .= '?symb='.&Apache::lonnet::escape($item);
953:
954: $r->print('<tr bgcolor="'.$rowColor.'"><td><small><a href="'.$linkurl.'">'.$$res_title{$item}.'</a></small></td><td><small>'.$$changed{$item}{'revdate'}.'</small></td><td><small>'.$$changed{$item}{'current'}.'</small></td><td><small>'.$$changed{$item}{'version'}.'</small></td></tr>');
955: $changenum ++;
956: }
957: } else {
958: $r->print('<tr><td bgcolor="#ffffff"><br /><center><b><i><small>'.$lt{'noup'}.' '.$interval.'</small></i></b></center><br /></td></tr>');
959: }
960: return;
961: }
962:
963: sub display_coursediscussion {
964: my ($r,$newdiscussions,$unread,$res_title,$rowColor1,$rowColor2) = @_;
965: my %lt = &Apache::lonlocal::texthash(
966: 'loca' => 'Location',
967: 'type' => 'Type',
968: 'numn' => 'Number of new posts',
969: 'noun' => 'No unread posts in course discussions',
970: );
971: my $rowColor;
972: if (@{$newdiscussions} > 0) {
973: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'loca'}.
974: '</small></b></td><td><b><small>'.$lt{'type'}.
975: '</small></b><td align="right"><b><small>'.$lt{'numn'}.
976: '</small></b></td></tr>');
977: @{$newdiscussions} = sort { &cmp_title($a,$b,$res_title) }
978: @{$newdiscussions};
979: my $rowNum = 0;
980: foreach my $ressymb (@{$newdiscussions}) {
981: my $forum_title = $$unread{$ressymb}{'title'};
982: my $type = 'Resource';
983: my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
984: if ($feedurl =~ /bulletinboard/) {
985: $type = 'Bulletin Board';
986: }
987: my $unreadnum = keys(%{$$unread{$ressymb}});
988: $unreadnum = $unreadnum - 2;
989: if ($unreadnum > 0) {
990: if ($rowNum %2 == 1) {
991: $rowColor = $rowColor1;
992: } else {
993: $rowColor = $rowColor2;
994: }
995: $r->print('<tr bgcolor="'.$rowColor.'"><td><small><a href="'.$feedurl.'?symb='.$$unread{$ressymb}{symb}.'">'.$forum_title.'</a> </td><td><small>'.$type.'</small></td><td align="right">'.$unreadnum.' </td></tr>');
996: $rowNum ++;
997: }
998: }
999: } else {
1000: $r->print('<tr><td bgcolor="#ffffff"><br><center> <i><b><small>'.
1001: $lt{'noun'}.'</small></b></i><br><br></td></tr>');
1002: }
1003: }
1004:
1005: sub display_coursenormalmail {
1006: my ($r,$msgcount,$newmsgs,$rowColor1,$rowColor2) = @_;
1007: my $rowColor;
1008: if ($msgcount > 0) {
1009: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.&mt('Number').'</small></b></td><td><b><small>'.&mt('Subject').'</small></b></td><td><b><small>'.&mt('Sender').'</small></b></td><td><b><small>'.&mt('Date/Time').'</small></b></td></tr>');
1010: my $rowNum = 0;
1011: my $mailcount = 1;
1012: foreach my $msg (@{$newmsgs}) {
1013: if ($rowNum %2 == 1) {
1014: $rowColor = $rowColor1;
1015: } else {
1016: $rowColor = $rowColor2;
1017: }
1018: $r->print('<tr bgcolor="'.$rowColor.'"><td valign="top"><small>'.$mailcount.'. </small></td><td valign="top"><small><a href="/adm/communicate">'.$msg->{'shortsub'}.'</a> </small></td><td valign="top"><small> '.$msg->{'from'}.'@'.$msg->{'fromdom'}.' </small></td><td valign="top"><small>'.$msg->{'sendtime'}.'</small></td></tr>');
1019: $rowNum ++;
1020: $mailcount ++;
1021: }
1022: } else {
1023: $r->print('<tr><td bgcolor="#ffffff" width="100%"><center><br /><b><i><small>'.&mt('No new course messages').'</small></i></b><br /><br /></center></td></tr>');
1024: }
1025: }
1026:
1027: sub display_coursecritmail {
1028: my ($r,$critmsgcount,$critmsgs,$rowColor1,$rowColor2) = @_;
1029: my $rowColor;
1030: if ($critmsgcount > 0) {
1031: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.&mt('Number').'</small></b></td><td><b><small>'.&mt('Subject').'</small></b></td><td><b><small>'.&mt('Sender').'</small></b></td><td><b><small>'.&mt('Date/Time').'</small></b></td></tr>');
1032: my $rowNum = 0;
1033: my $mailcount = 1;
1034: foreach my $msg (@{$critmsgs}) {
1035: if ($rowNum %2 == 1) {
1036: $rowColor = $rowColor1;
1037: } else {
1038: $rowColor = $rowColor2;
1039: }
1040: $r->print('<tr bgcolor="'.$rowColor.'"><td valign="top"><small>'.$mailcount.'. <small></td><td valign="top"><small><a href="/adm/email?folder=critical">'.$msg->{'shortsub'}.'</a> </small></td><td valign="top"><small> '.$msg->{'from'}.'@'.$msg->{'fromdom'}.' </small></td><td valign="top"><small>'.$msg->{'sendtime'}.'</small></td></tr>');
1041: $rowNum ++;
1042: $mailcount ++;
1043: }
1044: } else {
1045: $r->print('<tr><td bgcolor="#ffffff" width="100%"><center><br /><b><i><small>'.&mt('No unread critical messages in course').'</small></i></b><br /><br /></center></td></tr>');
1046: }
1.1 raeburn 1047: }
1048:
1049: sub cmp_title {
1.16 raeburn 1050: my ($a,$b,$res_title) = @_;
1051: my ($atitle,$btitle) = (lc($$res_title{$a}),lc($$res_title{$b}));
1.1 raeburn 1052: $atitle=~s/^\s*//;
1053: $btitle=~s/^\s*//;
1054: return $atitle cmp $btitle;
1055: }
1056:
1.33 raeburn 1057: sub get_display_settings {
1058: my $udom = $env{'user.domain'};
1059: my $uname = $env{'user.name'};
1060: my $cid = $env{'request.course.id'};
1061: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid);
1062: my ($tmp) = keys(%settings);
1063: if ($tmp=~/^error:/) {
1064: %settings = ();
1065: unless ($tmp eq 'error: 2 tie(GDBM) Failed while attempting dump') {
1066: &logthis('Error retrieving whatsnew settings: '.$tmp.' for '.
1067: $uname.':'.$udom.' for course: '.$cid);
1068: }
1069: }
1070: return %settings;
1071: }
1072:
1073: sub start_box {
1074: my ($r,$tabbg,$show,$heading,$caller) = @_;
1075: my %lt = &Apache::lonlocal::texthash(
1076: chth => 'Change thresholds?',
1077: chin => 'Change interval?',
1078: );
1079: my $showhide;
1080: if ($$show{$caller}) {
1081: $showhide = '<b><a href="javascript:change_display('."'".$caller.
1082: "','hide'".');">Hide</a></b>';
1083:
1084: } else {
1085: $showhide = '<b><a href="javascript:change_display('."'".$caller.
1086: "','show'".');">Show</a></b>';
1087: }
1088:
1089: $r->print('
1090: <table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000" width="100%">
1091: <tr>
1092: <td>
1093: <table border="0" cellpadding="1" cellspacing="1" bgcolor="#000000" width="100%">
1094: <tr>
1095: <td bgcolor="'.$tabbg.'">
1096: <table width="100%" border="0" cellspacing="0" cellpadding="0">
1097: <tr>
1098: <td><b>'.$$heading{$caller}.'</b></td>
1099: <td valign="top" align="right">'.$showhide.'</td>
1100: </tr>
1101: </table>
1102: </td>
1103: </tr>');
1104: if (($caller eq 'abovethreshold') && ($$show{$caller})) {
1105: $r->print('
1106: <tr>
1107: <td bgcolor="'.$tabbg.'" align="right"><a href="/adm/whatsnew?command=chgthreshold"><b><small>'.$lt{'chth'}.'</small></b></a></td>
1108: </tr>');
1109: } elsif (($caller eq 'versionchanges') && ($$show{$caller})) {
1110: $r->print('
1111: <tr>
1112: <td bgcolor="'.$tabbg.'" align="right"><a href="/adm/whatsnew?command=chginterval"><b><small>'.$lt{'chin'}.'</small></b></a></td>
1113: </tr>');
1114: }
1115: $r->print('
1116: <tr>
1117: <td bgcolor="#ffffff">
1118: <table cellpadding="2" cellspacing="0" border="0" width="100%">
1119: ');
1120: return;
1121: }
1122:
1123: sub end_box {
1124: my ($r) = shift;
1125: $r->print('
1126: </table>
1127: </td>
1128: </tr>
1129: </table>
1130: </td>
1131: </tr>
1132: </table><br />');
1133: return;
1134: }
1135:
1.7 raeburn 1136: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>