Annotation of loncom/interface/lonwhatsnew.pm, revision 1.51
1.2 albertel 1: #
1.51 ! albertel 2: # $Id: lonwhatsnew.pm,v 1.50 2006/01/13 01:18:44 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.39 raeburn 55: &Apache::loncommon::get_unprocessed_cgi(
56: $ENV{'QUERY_STRING'},['command','refpage']);
1.1 raeburn 57:
1.36 raeburn 58: my $command = $env{'form.command'};
1.39 raeburn 59: my $refpage = $env{'form.refpage'};
1.1 raeburn 60:
1.44 albertel 61: my %checkallowed = ( coursenormalmail => 1,
62: coursecritmail => 1, );
63: foreach my $perm_check (['whn','whatsnew',1],
64: ['pch','coursediscussion',1],
65: ['mgr','handgrading',1],
66: ['vgr','abovethreshold',1],
67: ['opa','haserrors',1],
68: ['mdc','versionchanges',0],
69: ) {
70: my ($perm,$key,$check_section) = @{ $perm_check };
71: my $scope = $env{'request.course.id'};
72: if (!($checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope))) {
73: $scope .= '/'.$env{'request.course.sec'};
74: if ( $check_section ) {
75: $checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope);
76: }
77: if ($checkallowed{$key}) {
78: $checkallowed{$key.'_section'} = $env{'request.course.sec'};
79: }
80: }
81: }
1.43 albertel 82:
1.44 albertel 83: if ( ! $env{'request.course.fn'} || ! $checkallowed{'whatsnew'}) {
1.43 albertel 84: # Not in a course, or no whn priv in course
1.42 raeburn 85: $env{'user.error.msg'}="/adm/whatsnew::whn:0:0:Cannot display what's new page";
1.1 raeburn 86: return HTTP_NOT_ACCEPTABLE;
87: }
88:
1.44 albertel 89: &Apache::loncommon::content_type($r,'text/html');
90: $r->send_http_header;
1.36 raeburn 91:
92: $r->print(&display_header($command,\%checkallowed));
93:
1.7 raeburn 94: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.36 raeburn 95: &Apache::lonhtmlcommon::add_breadcrumb
96: ({href=>'/adm/whatsnew',
97: text=>"Display Action Items"});
1.44 albertel 98: if (($command eq 'chgthreshold') && $checkallowed{'abovethreshold'}) {
1.7 raeburn 99: &Apache::lonhtmlcommon::add_breadcrumb
1.39 raeburn 100: ({href=>'/adm/whatsnew?command=chgthreshold&refpage='.$refpage,
1.13 raeburn 101: text=>"Change thresholds"});
1.7 raeburn 102: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.49 albertel 103: (undef,"What's New?",#'Course_Action_Items_Thresholds'
104: ));
1.44 albertel 105: } elsif (($command eq 'chginterval') && $checkallowed{'versionchanges'} ) {
1.36 raeburn 106: &Apache::lonhtmlcommon::add_breadcrumb
1.39 raeburn 107: ({href=>'/adm/whatsnew?command=chginterval&refpage='.$refpage,
1.36 raeburn 108: text=>"Change interval"});
109: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.49 albertel 110: (undef,"What's New?",#'Course_Action_Items_Intervals'
111: ));
1.44 albertel 112: } elsif (($command eq 'chgdisc') && $checkallowed{'coursediscussion'}) {
1.39 raeburn 113: &Apache::lonhtmlcommon::add_breadcrumb
114: ({href=>'/adm/whatsnew?command=chgdisc&refpage='.$refpage,
115: text=>"Change discussion display"});
116: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.49 albertel 117: (undef,"What's New?",#'Course_Action_Items_Intervals'
118: ));
1.39 raeburn 119: } elsif ($command eq 'courseinit') {
120: &Apache::lonhtmlcommon::add_breadcrumb
121: ({href=>'/adm/whatsnew?command=courseinit&refpage='.$refpage,
122: text=>"Course initialization preference"});
123: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.49 albertel 124: (undef,"What's New?",#'Course_Action_Items_Initialization'
125: ));
1.7 raeburn 126: } else {
127: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.49 albertel 128: (undef,"What's New?",#'Course_Action_Items_Display'
129: ));
1.7 raeburn 130: }
1.39 raeburn 131: &display_main_box($r,$command,$refpage,\%checkallowed);
1.14 albertel 132: return OK;
1.1 raeburn 133: }
134:
135: #------------------------------
136: # display_main_box
137: #
138: # Display all the elements within the main box
139: #------------------------------
140:
141: sub display_main_box {
1.39 raeburn 142: my ($r,$command,$refpage,$checkallowed) = @_;
1.1 raeburn 143: my $domain=&Apache::loncommon::determinedomain();
1.40 raeburn 144: my $function = &Apache::loncommon::get_users_function();
145: my $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain);
1.7 raeburn 146: $r->print('<table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td width="100%">');
1.13 raeburn 147:
1.39 raeburn 148: my %threshold_titles = &Apache::lonlocal::texthash (
1.13 raeburn 149: av_attempts => 'Average number of attempts',
150: degdiff => 'Degree of difficulty',
151: numstudents => 'Total number of students with submissions',
152: );
1.36 raeburn 153:
1.39 raeburn 154: my %interval_titles = &Apache::lonlocal::texthash (
1.36 raeburn 155: -1 => 'since start of course',
156: 2592000 => 'since last month',
157: 604800 => 'since last week',
158: 86400 => 'since yesterday',
159: );
160:
1.39 raeburn 161: my %initpage = &Apache::lonlocal::texthash (
162: firstres => 'first resource in the course',
163: whatsnew => "what's new? page",
164: userpref => 'your general user preferences',
165: coursespecific => 'specific setting for this course',
166: );
1.15 raeburn 167: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
168: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
169:
1.44 albertel 170: if (($command eq 'chgthreshold')
171: && $checkallowed->{'abovethreshold'}) {
1.39 raeburn 172: &display_threshold_config($r,$refpage,$tabbg,\%threshold_titles,
1.36 raeburn 173: $cdom,$crs);
1.44 albertel 174: } elsif (($command eq 'chginterval')
175: && $checkallowed->{'versionchanges'}) {
1.39 raeburn 176: &display_interval_config($r,$refpage,\%interval_titles);
1.44 albertel 177: } elsif (($command eq 'chgdisc')
178: && $checkallowed->{'coursediscussion'}) {
1.39 raeburn 179: &display_discussion_config($r,$refpage);
180: } elsif ($command eq 'courseinit') {
181: &courseinit_config($r,$refpage,\%initpage);
1.1 raeburn 182: } else {
1.40 raeburn 183: &display_actions_box($r,$tabbg,$command,$refpage,\%threshold_titles,
1.39 raeburn 184: \%interval_titles,\%initpage,$cdom,$crs,$checkallowed);
1.1 raeburn 185: }
186: $r->print(<<END_OF_BLOCK);
187: </td>
188: </tr>
189: </table><br />
190: </body>
191: </html>
192: END_OF_BLOCK
193: }
194:
195: #-------------------------------
196: # display_header
197: #
198: # Display the header information and set
199: # up the HTML
200: #-------------------------------
201:
1.39 raeburn 202: sub display_header {
1.36 raeburn 203: my ($command,$checkallowed) = @_;
1.3 albertel 204: my $html=&Apache::lonxml::xmlbegin();
1.1 raeburn 205: my $bodytag=&Apache::loncommon::bodytag('Course Action Items');
1.36 raeburn 206: my $scripttag;
207: unless ($command eq 'chgthreshold' || $command eq 'chginterval') {
208: $scripttag = <<"END";
209: <script type="text/javascript">
210: function change_display(caller,change) {
211: caller.value = change;
212: document.visible.submit();
213: }
214:
215: function changeAll(change) {
216: END
217: foreach my $item (keys(%{$checkallowed})) {
1.44 albertel 218: if ($item =~ /_section$/) { next; }
1.39 raeburn 219: if ($$checkallowed{$item}) {
220: $scripttag.='document.visible.display_'.$item.'.value=change'.
221: "\n";
222: }
1.36 raeburn 223: }
224: $scripttag.='document.visible.submit();
225: }
226: </script>
227: ';
228: }
1.1 raeburn 229: return(<<ENDHEAD);
1.3 albertel 230: $html
1.1 raeburn 231: <head>
232: <title>Course Action Items</title>
1.36 raeburn 233: $scripttag
1.1 raeburn 234: </head>
235: $bodytag
236: ENDHEAD
237: }
238:
239: #-------------------------------
240: # display_actions_box
241: #
242: # Display the action items
243: #
244: #-------------------------------
245:
1.39 raeburn 246: sub display_actions_box {
1.40 raeburn 247: my ($r,$tabbg,$command,$refpage,$threshold_titles,$interval_titles,
248: $initpage,$cdom,$crs,$checkallowed) = @_;
1.1 raeburn 249: my $rowColor1 = "#ffffff";
250: my $rowColor2 = "#eeeeee";
251:
1.36 raeburn 252: my $udom = $env{'user.domain'};
253: my $uname = $env{'user.name'};
254: my $cid = $env{'request.course.id'};
255:
256: my %lt = &Apache::lonlocal::texthash(
257: 'yacc' => 'You are accessing an invalid course.',
258: 'gtfr' => 'Go to first resource',
1.39 raeburn 259: 'pgse' => 'Page set to be displayed after you have selected a role in this course?',
1.36 raeburn 260: 'hial' => 'Hide all',
261: 'shal' => 'Show all',
262: );
263:
1.1 raeburn 264: my %unread = ();
265: my %ungraded = ();
266: my %bombed = ();
1.11 raeburn 267: my %triggered = ();
1.33 raeburn 268: my %changed = ();
1.1 raeburn 269: my @newmsgs = ();
270: my @critmsgs = ();
271: my @newdiscussions = ();
272: my @tograde = ();
273: my @bombs = ();
1.11 raeburn 274: my @warnings = ();
1.33 raeburn 275: my $msgcount = 0;
276: my $critmsgcount = 0;
277:
1.16 raeburn 278: my %res_title = ();
1.33 raeburn 279: my %show = ();
280: my $needitems = 0;
281: my $boxcount = 0;
1.1 raeburn 282:
1.39 raeburn 283: my $result;
284: if ($command eq 'newcourseinit') {
285: $result = &store_courseinit_setting($uname,$udom,$cid,$initpage);
286: }
287:
1.13 raeburn 288: my %threshold = (
1.22 www 289: av_attempts => 2,
290: degdiff => 0.5,
291: numstudents => 2,
1.13 raeburn 292: );
1.39 raeburn 293: my %pagedesc = &Apache::lonlocal::texthash (
294: firstres => 'First resource',
1.40 raeburn 295: whatsnew => "What's New? page",
1.39 raeburn 296: userpref => 'user preference',
297: coursespecific => 'course only',
298: default => 'default',
299: );
300:
301: my ($initcontrol,$initdisp) = &curr_courseinit();
302: my $currinit = $pagedesc{$initdisp}.' ('.$pagedesc{$initcontrol}.')';
1.13 raeburn 303:
1.36 raeburn 304: unless ($cid) {
305: $r->print('<br /><b><center>'.$lt{'yacc'}.'</center></b><br /><br />');
1.1 raeburn 306: return;
307: }
1.33 raeburn 308:
1.39 raeburn 309: if ($refpage eq 'start') {
310: if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
1.36 raeburn 311: &GDBM_READER(),0640)) {
1.39 raeburn 312: my $furl=$bighash{'first_url'};
313: untie(%bighash);
314: $r->print('<font size="+1"><a href="'.$furl.'">'.$lt{'gtfr'}.
315: '</a></font><br />');
316: }
1.36 raeburn 317: }
1.39 raeburn 318: $r->print($lt{'pgse'}.' '.&mt('Currently: [_1]','<i>'.$currinit.'</i>').
1.49 albertel 319: ' <nobr> '.&mt('[_1] for just [_2]','<b>Change</b>',
1.39 raeburn 320: '<a href="/adm/whatsnew?command=courseinit&refpage='.$refpage.
321: '">this course</a>').' '.&mt('or for all [_1].',
322: '<a href="/adm/preferences?action=changecourseinit&refpage='.
323: $refpage.'">your courses</a>').'</nobr><br /><hr />');
1.36 raeburn 324:
325: if ($command eq 'reset') {
326: $result = &process_reset($cdom,$crs);
327: } elsif ($command eq 'update') {
1.39 raeburn 328: $result = &process_update($uname,$udom,$threshold_titles);
1.36 raeburn 329: } elsif ($command eq 'newinterval') {
330: $result = &store_interval_setting($uname,$udom,$cid,$interval_titles);
1.39 raeburn 331: } elsif ($command eq 'newdiscconf') {
332: $result = &store_discussion_setting($uname,$udom,$cid);
1.36 raeburn 333: }
334:
335: my $store_result=&store_display_settings($uname,$udom,$cid,$checkallowed);
336:
337: unless ($store_result eq 'ok') {
338: &Apache::lonnet::logthis('Error storing whatsnew settings: '.
339: $store_result.' for '.'user '.$uname.':'.$udom.' in course '.$cid);
340: $result .= &mt('Unable to store visibility settings due to [_1]',
341: $store_result);
342: }
343:
344: if ($result) {
345: $r->print($result.'<hr width="100%" />');
346: }
347: $r->rflush();
348:
1.33 raeburn 349:
1.36 raeburn 350: my %display_settings = &get_display_settings($uname,$udom,$cid);
351: my $timediff = $display_settings{$cid.':interval'};
352: unless (defined($timediff)) { $timediff = 604800; }
1.35 raeburn 353: my $now = time;
1.36 raeburn 354: my $interval = $$interval_titles{$timediff};
1.35 raeburn 355: if ($timediff == -1) {
356: $timediff = time;
357: }
358: my $starttime = $now - $timediff;
1.39 raeburn 359: my $countunread = $display_settings{$cid.':countunread'};
360: unless (defined($countunread)) {
361: $countunread = 'on';
362: }
1.33 raeburn 363:
364: my %headings = &Apache::lonlocal::texthash(
365: coursediscussion => 'Unread course discussion posts',
366: handgrading => 'Problems requiring handgrading',
367: haserrors => 'Problems with errors',
368: versionchanges => 'Resources in course with version changes '.$interval,
1.37 raeburn 369: coursenormalmail => 'New course messages',
1.33 raeburn 370: coursecritmail => 'New critical messages in course',
371: );
372:
1.36 raeburn 373: if ($$checkallowed{'abovethreshold'}) {
1.39 raeburn 374: &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs);
1.33 raeburn 375: }
376:
377: $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'};
378:
379: my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail');
380:
1.36 raeburn 381: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 382: if ($key =~ /_section$/) { next; }
1.33 raeburn 383: $show{$key} = 0;
1.36 raeburn 384: if ($$checkallowed{$key}) {
385: unless ($display_settings{$cid.':'.$key} eq 'hide') {
1.33 raeburn 386: $show{$key} = 1;
387: }
388: }
389: }
390:
391: foreach my $item (@actionorder) {
392: unless ($item eq 'coursenormalmail' || $item eq 'coursecritmail') {
393: if ($show{$item}) {
394: $needitems = 1;
395: last;
396: }
397: }
398: }
399:
400: if ($needitems) {
1.37 raeburn 401: &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,$rowColor1,$rowColor2,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread);
1.1 raeburn 402: }
1.33 raeburn 403: if ($show{'coursenormalmail'}) {
1.50 raeburn 404: $msgcount = &getnormalmail(\@newmsgs);
1.7 raeburn 405: }
1.33 raeburn 406: if ($show{'coursecritmail'}) {
1.50 raeburn 407: $critmsgcount = &getcritmail(\@critmsgs);
1.11 raeburn 408: }
409:
1.36 raeburn 410: $r->print(qq|<a href="javascript:changeAll('hide');">$lt{'hial'}</a>
411: <a href="javascript:changeAll('show');">$lt{'shal'}</a>
412: <form method="post" name="visible" action="/adm/whatsnew">\n|);
413: foreach my $item (keys(%{$checkallowed})) {
1.44 albertel 414: if ($item =~ /_section$/) { next; }
1.36 raeburn 415: if ($$checkallowed{$item}) {
416: $r->print('<input type="hidden" name="display_'.$item.'" />'."\n");
417: }
418: }
1.1 raeburn 419:
1.39 raeburn 420: $r->print('<input type="hidden" name="refpage" value="'.$refpage.'"></form><br /><table border="0" width="100%" cellpadding="2" cellspacing="4"><tr><td align="left" valign="top" width="45%">');
1.1 raeburn 421:
1.33 raeburn 422: my $displayed = 0;
1.40 raeburn 423: my $totalboxes = 0;
424: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 425: if ($key =~ /_section$/) { next; }
426: if ($key eq 'whatsnew' ) { next; } # whatsnew check creates no box
1.40 raeburn 427: if ($$checkallowed{$key}) {
428: $totalboxes ++;
429: }
430: }
1.33 raeburn 431: my $halfway = int($totalboxes/2) + $totalboxes%2;
432: foreach my $actionitem (@actionorder) {
1.36 raeburn 433: if ($$checkallowed{$actionitem}) {
1.33 raeburn 434: if ($displayed == $halfway) {
1.40 raeburn 435: $r->print('</td><td width="6%"> </td><td align="left" valign="top" width="47%">');
1.1 raeburn 436: }
1.39 raeburn 437: &display_launcher($r,$actionitem,$refpage,$checkallowed,$tabbg,$rowColor1,$rowColor2,\%show,\%headings,\%res_title,\@tograde,\%ungraded,\@bombs,\%bombed,\%changed,\@warnings,\%triggered,\@newdiscussions,\%unread,$msgcount,\@newmsgs,$critmsgcount,\@critmsgs,$interval,$countunread);
1.33 raeburn 438: $displayed ++;
1.1 raeburn 439: }
440: }
441: $r->print('
442: </table>
443: </td>
444: </tr>
1.33 raeburn 445: </table>
446: </td>
447: </tr>
448: </table>');
1.1 raeburn 449: }
450:
1.11 raeburn 451: #-------------------------------
1.36 raeburn 452: # display_threshold_config
1.11 raeburn 453: #
1.13 raeburn 454: # Display the threshold setting screen
1.11 raeburn 455: #
456: #-------------------------------
457:
1.36 raeburn 458: sub display_threshold_config {
1.39 raeburn 459: my ($r,$refpage,$tabbg,$threshold_titles,$cdom,$crs) = @_;
460: my $uname = $env{'user.name'};
461: my $udom = $env{'user.dom'};
462: my $cid = $env{'request.course.id'};
1.13 raeburn 463: my %threshold = ();
464: my $rowColor1 = "#ffffff";
465: my $rowColor2 = "#eeeeee";
466: my $rowColor;
467:
468: my @thresholditems = ("av_attempts","degdiff","numstudents");
1.39 raeburn 469: foreach my $item (@thresholditems) {
470: $threshold{$item} = '';
471: }
472: my %threshold_titles = &Apache::lonlocal::texthash(
1.13 raeburn 473: av_attempts => 'Average number of attempts',
474: degdiff => 'Degree of difficulty',
475: numstudents => 'Total number of students with submissions',
476: );
1.39 raeburn 477: &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs);
1.13 raeburn 478:
1.36 raeburn 479: $r->print('<br /><form name="thresholdform" method="post" action="/adm/whatsnew">
480: <table border="0" cellpadding="2" cellspacing="4">
481: <tr>
482: <td align="left" valign="top" width="45%">
1.13 raeburn 483: <table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
484: <tr>
485: <td>
486: <table border="0" cellpadding="1" cellspacing="1" bgcolor="#000000">
487: <tr>
488: <td bgcolor="#ffffff">
489: <table cellspacing="0" cellpadding="4" border="0">
490: <tr bgcolor="'.$tabbg.'">
491: <th>Threshold Name</th>
492: <th>Current value</th>
493: <th>Change?</th>
494: </tr>');
495: my $rowNum =0;
496: foreach my $type (@thresholditems) {
1.39 raeburn 497: my $parameter = $env{'request.course.id'}.':threshold_'.$type;
1.13 raeburn 498: # onchange is javascript to automatically check the 'Set' button.
499: my $onchange = 'onFocus="javascript:window.document.forms'.
500: "['thresholdform'].elements['".$parameter."_setparmval']".
501: '.checked=true;"';
502: if ($rowNum %2 == 1) {
503: $rowColor = $rowColor1;
504: } else {
505: $rowColor = $rowColor2;
506: }
507: $r->print('
508: <tr bgcolor="'.$rowColor.'">
509: <td>'.$threshold_titles{$type}.'</td>
510: <td>'.&Apache::lonhtmlcommon::textbox($parameter.'_value',
511: $threshold{$type},
512: 10,$onchange).'</td>
513: <td>'
514: .&Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
515: '</td>
516: </tr>');
517: $rowNum ++;
518: }
519: $r->print('</table></td></tr></table></td></tr></table>
520: <br /><input type="submit" name="threshold" value="Make changes" />
1.36 raeburn 521: <input type="hidden" name="command" value="update" />
1.39 raeburn 522: <input type="hidden" name="refpage" value="'.$refpage.'" />
1.13 raeburn 523: </form>');
1.11 raeburn 524: }
525:
1.36 raeburn 526: #-------------------------------
527: # display_interval_config
528: #
529: # Display the interval setting screen
530: #
531: #-------------------------------
532:
533: sub display_interval_config {
1.39 raeburn 534: my ($r,$refpage,$interval_titles) = @_;
535: my $current = &get_current($env{'user.name'},$env{'user.domain'},
536: $env{'request.course.id'},'interval');
1.36 raeburn 537: $r->print('<br />'.&mt('Choose the time window to use for display of version changes for resources in the course.'));
538: unless ($current eq '') {
1.39 raeburn 539: $r->print(' '.&mt('Current value is [_1]','<b>'.
540: $$interval_titles{$current}.'</b>.'));
1.36 raeburn 541: }
542: $r->print('<br /><br />
543: <form method="post" name="intervalswitch" action="/adm/whatsnew">
544: <input type="hidden" name="command" value="newinterval" />
1.39 raeburn 545: <input type="hidden" name="refpage" value="'.$refpage.'" />
1.36 raeburn 546: <select name="interval">
547: ');
548: foreach my $key (reverse sort ({$a cmp $b} (keys(%{$interval_titles})))) {
549: $r->print('<option value="'.$key.'">Version changes '.$$interval_titles{$key}.
550: '</option>'."\n");
551: }
552: $r->print('</select>
553: <input type="submit" name="display" value="'.
554: &mt('Change interval').'" /></form>');
555: return;
556: }
557:
1.39 raeburn 558: #----------------------------------------------
559: # display_discussion_config
560: #
561: # Display the discussion display setting screen
562: #
563: #----------------------------------------------
564:
565: sub display_discussion_config {
566: my ($r,$refpage) = @_;
567: my $current = &get_current($env{'user.name'},$env{'user.domain'},
568: $env{'request.course.id'},'countunread');
569: if ($current eq '') {
570: $current = 'on';
571: }
1.47 raeburn 572: my %opposite = (
573: 'on' => 'off',
574: 'off' => 'on',
575: );
576: $r->print('<script type="text/javascript">
577: function toggle_countunread(choice) {
578: if (choice == "unchanged") {
579: document.discussionswitch.command.value = "";
580: }
581: document.discussionswitch.submit();
582: }
583: </script>');
584: $r->print('<br />'.&mt('Choose whether or not to display a count of the number of new posts for each resource or bulletin board which has unread posts.').'<br />'.&mt('This can increase the time taken to gather data for the [_1] page by a few seconds.',"<i>What's New?</i>").' '.&mt('Currently set to [_1].','<b>'.$current.'</b>'));
1.39 raeburn 585: $r->print('<br /><br />
1.47 raeburn 586: <form method="post" name="discussionswitch" action="/adm/whatsnew">
1.39 raeburn 587: <input type="hidden" name="command" value="newdiscconf" />
588: <input type="hidden" name="refpage" value="'.$refpage.'" />
1.47 raeburn 589: <input type="hidden" name="countunread" value="'.$opposite{$current}.'" />
1.39 raeburn 590: ');
1.47 raeburn 591: $r->print('<br/>
592: <input type="button" name="display" value="'.
593: &mt('Change to [_1]',$opposite{$current}).'"
594: onclick="javascript:toggle_countunread('."'change'".')" />
595:  
596: <input type="button" name="nochange" value="'.
597: &mt("No change").'"
598: onclick="javascript:toggle_countunread('."'unchanged'".')" />
599: </form>');
1.39 raeburn 600: return;
601: }
602:
603: #---------------------------------------------------
604: # courseinit_config
605: #
606: # Set page displayed when course loads after
607: # selecting a role in the course from the roles page.
608: #
609: #---------------------------------------------------
610:
611: sub courseinit_config {
612: my ($r,$refpage,$initpage) = @_;
613: my ($control,$current) = &curr_courseinit();
614: my @chgstate = ('userpref','coursespecific');
615: my @chgentry = ('firstres','whatsnew');
616: my %lt = &Apache::lonlocal::texthash(
617: 'chwp' => 'Choose which page will be displayed when you enter this course after selecting a role.',
618: 'cuva' => 'Current value is determined by',
619: 'anis' => 'and is set to display',
620: 'padc' => 'Page display controlled by',
621: 'chce' => 'Choose course entry',
622: 'moce' => 'Modify course entry',
623: );
624: $r->print(<<"END");
625: <br />$lt{'chwp'}
626: <br />$lt{'cuva'}: <b>
627: $$initpage{$control}</b> $lt{'anis'} <b>
628: $$initpage{$current}</b>.<br /><br />
629: <form method="post" name="courseinitswitch" action="/adm/whatsnew">
630: <input type="hidden" name="command" value="newcourseinit" />
631: <input type="hidden" name="refpage" value="$refpage" />
632: $lt{'padc'}
633: END
634: foreach my $choice (@chgstate) {
1.45 albertel 635: $r->print('<nobr><label><input type="radio" name="courseinit_control" value="'.
636: $choice.'"/>'.$$initpage{$choice}.' </label></nobr>');
1.39 raeburn 637: }
638: $r->print('<br /><br />'.&mt('If').' '.$$initpage{'coursespecific'}.
639: '<br />'.$lt{'chce'}." \n");
640: foreach my $choice (@chgentry) {
1.45 albertel 641: $r->print('<nobr><label><input type="radio" name="courseinit_page" value="'.
642: $choice.'"/>'.$$initpage{$choice}.' </label></nobr>');
1.39 raeburn 643: }
644: $r->print('<br /><br /><input type="submit" name="display" value="'.
645: $lt{'moce'}.'" /></form>');
646: return;
647: }
648:
649: sub curr_courseinit {
650: my $current = &get_current($env{'user.name'},$env{'user.domain'},
651: $env{'request.course.id'},'courseinit');
652: my $control;
1.40 raeburn 653: if ($current) {
654: $control = 'coursespecific';
655: } else {
1.39 raeburn 656: $control = 'userpref';
1.40 raeburn 657: my %userenv = &Apache::lonnet::get('environment',
658: ['course_init_display']);
659: if (exists($userenv{'course_init_display'})) {
660: $current = $userenv{'course_init_display'};
661: }
662: unless ($current) {
1.39 raeburn 663: $current = 'whatsnew';
664: }
665: }
666: return ($control,$current);
667: }
668:
1.33 raeburn 669: sub display_launcher {
1.39 raeburn 670: my ($r,$action,$refpage,$checkallowed,$tabbg,$rowColor1,$rowColor2,$show,
1.33 raeburn 671: $headings,$res_title,$tograde,$ungraded,$bombs,$bombed,$changed,
672: $warnings,$triggered,$newdiscussions,$unread,$msgcount,$newmsgs,
1.37 raeburn 673: $critmsgcount,$critmsgs,$interval,$countunread) = @_;
1.33 raeburn 674:
675: if ($$checkallowed{$action}) {
1.39 raeburn 676: &start_box($r,$tabbg,$show,$headings,$action,$refpage);
1.33 raeburn 677: if ($$show{$action}) {
678: if ($action eq 'handgrading') { # UNGRADED ITEMS
679: &display_handgrade($r,$tograde,$rowColor1,$rowColor2,
680: $ungraded);
681: } elsif ($action eq 'haserrors') { # BOMBS
682: &display_haserrors($r,$bombs,$rowColor1,$rowColor2,$bombed,
683: $res_title);
684: } elsif ($action eq 'versionchanges') { # VERSION CHANGES
685: &display_versionchanges($r,$changed,$res_title,$rowColor1,
686: $rowColor2,$interval);
687:
688: } elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS
1.39 raeburn 689: &display_abovethreshold($r,$refpage,$warnings,$triggered,
690: $res_title,$rowColor1,$rowColor2);
1.33 raeburn 691: } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION
692: &display_coursediscussion($r,$newdiscussions,$unread,
1.37 raeburn 693: $countunread,$res_title,$rowColor1,$rowColor2);
1.33 raeburn 694: } elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES
695: &display_coursenormalmail($r,$msgcount,$newmsgs,$rowColor1,
696: $rowColor2);
697: } elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES
698: &display_coursecritmail($r,$critmsgcount,$critmsgs,$rowColor1,
699: $rowColor2);
700: }
701: }
702: &end_box($r);
703: }
704: return;
705: }
706:
1.1 raeburn 707: sub getitems {
1.33 raeburn 708: my ($unread,$ungraded,$bombed,$triggered,$changed,$newdiscussions,
709: $tograde,$bombs,$warnings,$rowColor1,$rowColor2,$threshold,$cdom,$crs,
1.37 raeburn 710: $res_title,$show,$starttime,$countunread) = @_;
1.1 raeburn 711: my $navmap = Apache::lonnavmaps::navmap->new();
1.26 albertel 712: # force retrieve Resource to seed the part id cache we'll need it later
1.37 raeburn 713: my @allres=$navmap->retrieveResources(undef,
714: sub {if ($_[0]->is_problem) { $_[0]->parts();} return 1;});
1.33 raeburn 715: my %resourcetracker;
1.37 raeburn 716: my $discussiontime;
1.33 raeburn 717:
718: # Resource version changes
719: if ($$show{'versionchanges'}) {
720: &checkversions($cdom,$crs,$navmap,$changed,$starttime);
721: }
722:
723: if ($$show{'abovethreshold'}) {
724: %resourcetracker = &Apache::lonnet::dump('nohist_resourcetracker',
725: $cdom,$crs);
726: }
1.1 raeburn 727:
1.11 raeburn 728: my $warningnum = 0;
1.1 raeburn 729: foreach my $resource (@allres) {
730: my $result = '';
731: my $applies = 0;
732: my $symb = $resource->symb();
1.33 raeburn 733: %{$$bombed{$symb}} = ();
1.1 raeburn 734: %{$$ungraded{$symb}} = ();
1.11 raeburn 735: %{$$triggered{$symb}} = ();
736: $$triggered{$symb}{numparts} = 0;
1.1 raeburn 737: my $title = $resource->compTitle();
1.16 raeburn 738: $$res_title{$symb} = $title;
1.8 albertel 739: my $ressymb = $resource->wrap_symb();
1.33 raeburn 740:
1.37 raeburn 741: # Check if there are unread discussion postings
1.33 raeburn 742: if ($$show{'coursediscussion'}) {
1.51 ! albertel 743: &check_discussions($resource,$symb,$ressymb,$title,
! 744: $newdiscussions,$unread,$countunread);
1.33 raeburn 745: }
1.1 raeburn 746:
747: # Check for ungraded problems
748: if ($resource->is_problem()) {
1.33 raeburn 749: if ($$show{'handgrading'}) {
750: &check_handgraded($resource,$symb,$title,$cdom,$crs,$ungraded,
751: $tograde);
752: }
1.1 raeburn 753: }
754:
755: # Check for bombs
1.33 raeburn 756: if ($$show{'haserrors'}) {
757: &check_bombed($resource,$symb,$title,$bombs,$bombed);
758: }
759:
760: # Maxtries and degree of difficulty for problem parts, unless handgradeable
761: if ($$show{'abovethreshold'}) {
762: &check_thresholds($resource,$symb,\%resourcetracker,$triggered,
763: $threshold,$warnings,$warningnum,$rowColor1,$rowColor2);
764: }
765:
766: }
767: }
768:
769: sub check_discussions {
1.51 ! albertel 770: my ($resource,$symb,$ressymb,$title,$newdiscussions,$unread,
! 771: $countunread) = @_;
! 772:
! 773: if (!$resource->hasDiscussion()) { return; }
1.37 raeburn 774:
1.51 ! albertel 775: %{$$unread{$ressymb}} = ();
! 776: $$unread{$ressymb}{'title'} = $title;
! 777: $$unread{$ressymb}{'symb'} = $symb;
! 778: push(@{$newdiscussions}, $ressymb);
! 779:
! 780: $$unread{$ressymb}{'lastpost'} = $resource->last_post_time();
! 781:
! 782: if ($countunread eq 'on') {
! 783: $$unread{$ressymb}{'unreadcount'} = $resource->unread_discussion();
1.33 raeburn 784: }
785: }
786:
787: sub check_handgraded {
788: my ($resource,$symb,$title,$cdom,$cnum,$ungraded,$tograde) = @_;
789: if ($resource->is_problem()) {
790: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
791: my $partlist=$resource->parts();
792: my $handgradeable;
793: foreach my $part (@$partlist) {
1.31 raeburn 794: if ($resource->handgrade($part) eq 'yes') {
1.33 raeburn 795: $handgradeable=1; last;
1.31 raeburn 796: }
1.33 raeburn 797: }
798: if ($handgradeable) {
1.35 raeburn 799: my @ungraded = &Apache::bridgetask::get_queue_symb_status(
1.33 raeburn 800: 'gradingqueue',$symb,$cdom,$cnum);
801: if (@ungraded > 0) {
802: $$ungraded{$symb}{count} = scalar(@ungraded);
803: $$ungraded{$symb}{title} = $title;
804: push(@{$tograde}, $symb);
1.11 raeburn 805: }
806: }
1.33 raeburn 807: }
808: }
809:
810: sub check_bombed {
811: my ($resource,$symb,$title,$bombs,$bombed) = @_;
812: if ($resource->getErrors()) {
813: my $errors = $resource->getErrors();
814: $errors =~ s/^,//;
815: my @bombs = split(/,/, $errors);
816: my $errorcount = scalar(@bombs);
817: my $errorlink = '<a href="/adm/email?display='.
818: &Apache::lonnet::escape($bombs[0]).'">'.
819: $title.'</a>';
820: $$bombed{$symb}{errorcount} = $errorcount;
821: $$bombed{$symb}{errorlink} = $errorlink;
822: push(@{$bombs}, $symb);
823: }
824: }
825:
826: sub check_thresholds {
827: my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings,
828: $warningnum,$rowColor1,$rowColor2) = @_;
829: # Compile maxtries and degree of difficulty for problem parts, unless handgradeable
830: my @parts = @{$resource->parts()};
831: my %stats;
832: my %lastreset = ();
833: my $warning = 0;
834: my $rowColor;
835: foreach my $part (@parts) {
836: if ($resource->handgrade($part) eq 'yes') {
837: next;
838: }
1.48 raeburn 839: if ($resource->is_survey($part)) {
840: next;
841: }
1.33 raeburn 842: %{$stats{$part}} = ();
843: my ($attempts,$users,$corrects,$degdiff,$av_attempts);
844: if (exists($$resourcetracker{$symb."\0".$part."\0attempts"})) {
845: $attempts = $$resourcetracker{$symb."\0".$part."\0attempts"};
846: }
847: if (exists($$resourcetracker{$symb."\0".$part."\0users"})) {
848: $users = $$resourcetracker{$symb."\0".$part."\0users"};
849: }
850: if (exists($$resourcetracker{$symb."\0".$part."\0correct"})) {
851: $corrects = $$resourcetracker{$symb."\0".$part."\0correct"};
852: }
853: if ($attempts > 0) {
854: $degdiff = 1 - ($corrects/$attempts);
855: $degdiff = sprintf("%.2f",$degdiff);
856: }
857: if ($users > 0) {
858: $av_attempts = $attempts/$users;
859: $av_attempts = sprintf("%.2f",$av_attempts);
860: }
861: if ((($degdiff ne '' && $degdiff >= $$threshold{'degdiff'}) || ($av_attempts ne '' && $av_attempts >= $$threshold{'av_attempts'})) && ($users >= $$threshold{'numstudents'})) {
862: $stats{$part}{degdiff} = $degdiff;
863: $stats{$part}{attempts} = $av_attempts;
864: $stats{$part}{users} = $users;
865: $lastreset{$part} = $$resourcetracker{$symb."\0".$part."\0resettime"};
866: if ($lastreset{$part}) {
867: $lastreset{$part} = &Apache::lonnavmaps::timeToHumanString($lastreset{$part});
1.11 raeburn 868: }
1.33 raeburn 869: $warning = 1;
870: }
871: }
872: if ($warning) {
1.35 raeburn 873: if ($warningnum %2 == 1) {
1.33 raeburn 874: $rowColor = $rowColor1;
875: } else {
876: $rowColor = $rowColor2;
877: }
878: $$triggered{$symb}{title} = $resource->title;
879: foreach my $part (@parts) {
880: if (exists($stats{$part}{users})) {
881: my $resetname = 'reset_'.&Apache::lonnet::escape($symb."\0".$part);
882: my $resettitle = 'title_'.&Apache::lonnet::escape($symb."\0".$part);
883: if ($$triggered{$symb}{numparts}) {
884: $$triggered{$symb}{text} .= '<tr bgcolor="'.$rowColor.'">'."\n";
885: }
886: if (@parts > 1) {
887: $$triggered{$symb}{text} .= '
888: <td align="right"><small>part - '.$part.'<small></td>';
889: } else {
1.11 raeburn 890: $$triggered{$symb}{text} .= '
1.33 raeburn 891: <td align="right"><small>single part</small></td>';
1.11 raeburn 892: }
1.33 raeburn 893: $$triggered{$symb}{text} .= '
894: <td align="right"><small>'.$stats{$part}{users}.'</small></td>
895: <td align="right"><small>'.$stats{$part}{attempts}.'</small></td>
896: <td align="right"><small>'.$stats{$part}{degdiff}.'</small></td>
897: <td align="right"><small>'.$lastreset{$part}.'</small></td>
898: <td align="right"><small><input type="checkbox" name="'.$resetname.'" /><input type="hidden" name="'.$resettitle.'" value="'.&Apache::lonnet::escape($$triggered{$symb}{title}).'" /></td>
899: </tr>';
900: $$triggered{$symb}{numparts} ++;
1.11 raeburn 901: }
902: }
1.33 raeburn 903: push(@{$warnings},$symb);
1.35 raeburn 904: $warningnum ++;
1.1 raeburn 905: }
906: }
907:
1.33 raeburn 908:
1.13 raeburn 909: sub get_curr_thresholds {
1.39 raeburn 910: my ($threshold,$uname,$udom,$cid,$cdom,$crs) = @_;
911: my %thresholdsettings = &Apache::lonnet::dump('nohist_whatsnew',$udom,
912: $uname,$cid.':threshold');
913: my $thresholdcount = 0;
914: my ($tmp) = %thresholdsettings;
1.40 raeburn 915: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 916: foreach my $item (keys %{$threshold}) {
917: if (exists($thresholdsettings{$cid.':threshold_'.$item})) {
918: $$threshold{$item} =
919: $thresholdsettings{$cid.':threshold_'.$item};
920: $thresholdcount ++;
921: }
922: }
1.13 raeburn 923: }
1.39 raeburn 924: if ($thresholdcount == 3) {
925: return;
1.13 raeburn 926: }
1.39 raeburn 927: my %coursesettings = &Apache::lonnet::dump('environment',
928: $cdom,$crs,'internal.threshold');
929: my ($temp) = %coursesettings;
1.40 raeburn 930: unless ($temp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 931: foreach my $item (keys %{$threshold}) {
932: unless (exists($thresholdsettings{$cid.':threshold_'.$item})) {
933: if (exists($coursesettings{'internal.threshold_'.$item})) {
934: $$threshold{$item} =
935: $coursesettings{'internal.threshold_'.$item};
936: }
937: }
938: }
1.13 raeburn 939: }
1.39 raeburn 940: return;
1.13 raeburn 941: }
942:
1.39 raeburn 943: sub get_current {
944: my ($uname,$udom,$cid,$caller) = @_;
945: my $currvalue;
946: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid.
947: ':'.$caller);
1.36 raeburn 948: my ($tmp) = %settings;
1.40 raeburn 949: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 950: $currvalue = $settings{$cid.':'.$caller};
1.36 raeburn 951: }
1.39 raeburn 952: return $currvalue;
1.36 raeburn 953: }
954:
1.13 raeburn 955: sub process_reset {
956: my ($dom,$crs) = @_;
1.39 raeburn 957: my $result = '<b>'.&mt('Counters reset for following problems (and parts):').
958: '</b><br />';
1.13 raeburn 959: my @agg_types = ('attempts','users','correct');
1.39 raeburn 960: my %agg_titles = &Apache::lonlocal::texthash (
1.13 raeburn 961: attempts => 'Number of submissions',
962: users => 'Students with submissions',
963: correct => 'Number of correct submissions',
964: );
965: my @resets = ();
966: my %titles = ();
1.17 albertel 967: foreach my $key (keys(%env)) {
1.13 raeburn 968: next if ($key !~ /^form\.reset_(.+)$/);
969: my $title = &Apache::lonnet::unescape($env{'form.title_'.$1});
970: my $reset_item = &Apache::lonnet::unescape($1);
971: my %curr_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
972: my %aggregates = ();
1.17 albertel 973: my ($symb,$part) = split(/\0/,$reset_item);
1.13 raeburn 974: foreach my $type (@agg_types) {
975: $aggregates{$reset_item."\0".$type} = 0;
976: }
1.17 albertel 977: $aggregates{$reset_item."\0".'resettime'} = time;
1.13 raeburn 978: my $putresult = &Apache::lonnet::put('nohist_resourcetracker',\%aggregates,
979: $dom,$crs);
980: if ($putresult eq 'ok') {
981: $result .= $title.' -part '.$part.': ';
982: my %new_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
983: foreach my $type (@agg_types) {
984: $result .= $agg_titles{$type}.' = '.$new_aggregates{$reset_item."\0".$type}.'; ';
985: }
986: $result =~ s/; $//;
987: $result .= '<br />';
988: } else {
1.14 albertel 989: $result = $title.' -part '.$part.': '.&mt('Unable to reset counters to zero due to [_1]',$putresult).'.<br />'."\n";
1.13 raeburn 990: }
991: }
992: return $result;
993: }
994:
995: sub process_update {
1.39 raeburn 996: my ($uname,$udom,$threshold_titles) = @_;
1.15 raeburn 997: my $setoutput = '<b>Changes to threshold(s) for problem tracking:</b><br />';
1.13 raeburn 998: foreach (keys %env) {
999: next if ($_!~/^form\.(.+)\_setparmval$/);
1000: my $name = $1;
1001: my $value = $env{'form.'.$name.'_value'};
1002: if ($name && defined($value)) {
1.39 raeburn 1003: my $put_result = &Apache::lonnet::put('nohist_whatsnew',
1004: {$name=>$value},$udom,$uname);
1.13 raeburn 1005:
1.39 raeburn 1006: my ($shortname) = ($name =~ /^\Q$env{'request.course.id'}\E:threshold_(.+)$/);
1.13 raeburn 1007: if ($put_result eq 'ok') {
1.14 albertel 1008: $setoutput.=&mt('Set threshold for [_1] to [_2]',
1009: '<b>'.$$threshold_titles{$shortname}.'</b>',
1010: '<b>'.$value.'</b>').'<br />';
1011: } else {
1012: $setoutput.=&mt('Unable to set threshold for [_1] to [_2] due to [_3].',
1013: '<b>'.$name.'</b>','<b>'.$value.'</b>',
1014: '<tt>'.$put_result.'</tt>').'<br />';
1.13 raeburn 1015: }
1016: }
1017: }
1018: return $setoutput;
1019: }
1020:
1.33 raeburn 1021: sub getnormalmail {
1022: my ($newmsgs) = @_;
1.1 raeburn 1023: # Check for unread mail in course
1024: my $msgcount = 0;
1.3 albertel 1025:
1.10 raeburn 1026: my @messages = sort(&Apache::lonnet::getkeys('nohist_email'));
1.3 albertel 1027: foreach my $message (@messages) {
1028: my $msgid=&Apache::lonnet::escape($message);
1.10 raeburn 1029: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1.1 raeburn 1030: &Apache::lonmsg::unpackmsgid($msgid);
1.10 raeburn 1031: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 1032: if (defined($sendtime) && $sendtime!~/error/) {
1033: my $numsendtime = $sendtime;
1034: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
1035: if ($status eq 'new') {
1.10 raeburn 1036: $msgcount ++;
1037: if ($shortsubj eq '') {
1038: $shortsubj = &mt('No subject');
1039: }
1040: $shortsubj = &Apache::lonnet::unescape($shortsubj);
1.1 raeburn 1041: push(@{$newmsgs}, {
1042: msgid => $msgid,
1043: sendtime => $sendtime,
1.10 raeburn 1044: shortsub => $shortsubj,
1.1 raeburn 1045: from => $fromname,
1046: fromdom => $fromdom
1047: });
1048: }
1049: }
1050: }
1051: }
1.33 raeburn 1052: return $msgcount;
1053: }
1.1 raeburn 1054:
1.33 raeburn 1055: sub getcritmail {
1056: my ($critmsgs) = @_;
1.1 raeburn 1057: # Check for critical messages in course
1058: my %what=&Apache::lonnet::dump('critical');
1059: my $result = '';
1060: my $critmsgcount = 0;
1.3 albertel 1061: foreach my $msgid (sort(keys(%what))) {
1.10 raeburn 1062: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1063: &Apache::lonmsg::unpackmsgid($msgid);
1064: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 1065: if (defined($sendtime) && $sendtime!~/error/) {
1066: my $numsendtime = $sendtime;
1067: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
1068: $critmsgcount ++;
1.10 raeburn 1069: if ($shortsubj eq '') {
1070: $shortsubj = &mt('No subject');
1071: }
1072: $shortsubj = &Apache::lonnet::unescape($shortsubj);
1.1 raeburn 1073: push(@{$critmsgs}, {
1074: msgid => $msgid,
1075: sendtime => $sendtime,
1.10 raeburn 1076: shortsub => $shortsubj,
1.1 raeburn 1077: from => $fromname,
1078: fromdom => $fromdom
1079: });
1080: }
1081: }
1082: }
1.33 raeburn 1083: return $critmsgcount;
1084: }
1085:
1086:
1087: sub checkversions {
1088: my ($cdom,$crs,$navmap,$changed,$starttime) = @_;
1089: my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs);
1090: my ($tmp) = keys(%changes);
1.40 raeburn 1091: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 1092: if (keys(%changes) > 0) {
1093: foreach my $key (sort(keys(%changes))) {
1094: if ($changes{$key} > $starttime) {
1095: my $version;
1096: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
1097: my $currentversion=&Apache::lonnet::getversion($key);
1098: my $revdate =
1099: &Apache::lonnet::metadata($root.'.'.$extension,
1100: 'lastrevisiondate');
1101: $revdate = &Apache::lonlocal::locallocaltime($revdate);
1102: my $linkurl=&Apache::lonnet::clutter($key);
1103: my $usedversion=$navmap->usedVersion('version_'.$linkurl);
1104: my @resources = $navmap->getResourceByUrl($linkurl,1);
1105: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1106: $version = $usedversion;
1107: } else {
1108: $version = $currentversion;
1109: }
1110: foreach my $res (@resources) {
1.35 raeburn 1111: if (ref($res) eq 'Apache::lonnavmaps::resource') {
1112: my $symb = $res->symb();
1113: %{$$changed{$symb}} = (
1.33 raeburn 1114: current => $currentversion,
1115: version => $version,
1116: revdate => $revdate,
1.35 raeburn 1117: );
1118: }
1.33 raeburn 1119: }
1120: }
1121: }
1122: }
1123: }
1124: return;
1125: }
1126:
1127: sub display_handgrade {
1128: my ($r,$tograde,$rowColor1,$rowColor2,$ungraded) = @_;
1129: my $rowColor;
1130: my %lt = &Apache::lonlocal::texthash(
1131: 'prna' => 'Problem Name',
1132: 'nmun' => 'Number ungraded',
1133: 'nopr' => 'No problems require handgrading',
1134: );
1135: if (@{$tograde} > 0) {
1136: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'prna'}.'</small></b></td><td align="right"><b><small>'.$lt{'nmun'}.'</small></b></td></tr>');
1137: my $rowNum = 0;
1138: foreach my $res (@{$tograde}) {
1139: if ($rowNum %2 == 1) {
1140: $rowColor = $rowColor1;
1141: } else {
1142: $rowColor = $rowColor2;
1143: }
1144: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
1145: my $linkurl=&Apache::lonnet::clutter($url);
1146: $linkurl .= '?symb='.&Apache::lonnet::escape($res);
1147:
1148: $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>');
1149: $rowNum ++;
1150: }
1151: } else {
1152: $r->print('<tr><td bgcolor="#ffffff"><br><center><i><b><small> '.$lt{'nopr'}.' </small><br><br></b></i></td></tr>');
1153: }
1154: }
1155:
1156: sub display_haserrors {
1157: my ($r,$bombs,$rowColor1,$rowColor2,$bombed,$res_title) = @_;
1158: my $bombnum = 0;
1159: my $rowColor;
1160: my %lt = &Apache::lonlocal::texthash(
1161: reso => 'Resource',
1162: nmer => 'Number of errors',
1163: noer => 'No problems with errors',
1164: );
1165: if (@{$bombs} > 0) {
1166: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'reso'}.'</small></b></td><td align="right"><b><small>'.$lt{'nmer'}.'</small></b></td></tr>');
1167: @{$bombs} = sort { &cmp_title($a,$b,$res_title) } @{$bombs};
1168: foreach my $bomb (@{$bombs}) {
1169: if ($bombnum %2 == 1) {
1170: $rowColor = $rowColor1;
1171: } else {
1172: $rowColor = $rowColor2;
1173: }
1174: $r->print('<tr bgcolor="'.$rowColor.'"><td><small>'.$$bombed{$bomb}{errorlink}.'</small></td><td align="right"><small>'.$$bombed{$bomb}{errorcount}.'</small></td></tr>');
1175: $bombnum ++;
1176: }
1177: } else {
1178: $r->print('<tr><td bgcolor="#ffffff"><br /><center><b><i><small>'.$lt{'noer'}.'</small></i></b></center><br /></td></tr>');
1179: }
1180: return;
1181: }
1182:
1183: sub display_abovethreshold {
1.39 raeburn 1184: my ($r,$refpage,$warnings,$triggered,$res_title,$rowColor1,$rowColor2) = @_;
1.33 raeburn 1185: my %lt = &Apache::lonlocal::texthash(
1186: reso => 'Resource',
1187: part => 'Part',
1188: nust => 'Num. students',
1189: avat => 'Av. Attempts',
1190: dedi => 'Deg. Diff',
1191: lare => 'Last Reset',
1192: reco => 'Reset Count?',
1193: rese => 'Reset counters to 0',
1194: nopr => 'No problems satisfy threshold criteria',
1195: );
1196: my $rowColor;
1197: my $warningnum = 0;
1198: if (@{$warnings} > 0) {
1199: @{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings};
1.36 raeburn 1200: $r->print('<form name="reset_tracking" method="post" action="/adm/whatsnew">'.
1.39 raeburn 1201: ' <input type="hidden" name="command" value="reset" />'."\n".
1202: ' <input type="hidden" name="refpage" value="'.$refpage.'" />'.
1203: "\n");
1.33 raeburn 1204: $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>');
1205: foreach my $res (@{$warnings}) {
1206: if ($warningnum %2 == 1) {
1207: $rowColor = $rowColor1;
1208: } else {
1209: $rowColor = $rowColor2;
1210: }
1211: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
1212: my $linkurl=&Apache::lonnet::clutter($url);
1213: my $rowspan;
1214: if ($$triggered{$res}{numparts} > 1) {
1215: $rowspan = 'rowspan="'.$$triggered{$res}{numparts}.'"';
1216: }
1217: $linkurl .= '?symb='.&Apache::lonnet::escape($res);
1218: $r->print('<tr bgcolor="'.$rowColor.'"><td '.$rowspan.'><a href="'.$linkurl.'"><small>'.$$triggered{$res}{title}.'</small></a></td>'.$$triggered{$res}{text});
1219: $warningnum ++;
1220: }
1.35 raeburn 1221: $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 1222: } else {
1223: $r->print('<tr><td bgcolor="#ffffff"><br /><center><b><i><small>'.$lt{'nopr'}.'</small></i></b></center><br /></td></tr>');
1224: }
1225: }
1226:
1227: sub display_versionchanges {
1228: my ($r,$changed,$res_title,$rowColor1,$rowColor2,$interval) = @_;
1229: my %lt = &Apache::lonlocal::texthash(
1230: 'reso' => 'Resource',
1231: 'revd' => 'Last revised',
1232: 'newv' => 'New version',
1233: 'veru' => 'Version used',
1234: 'noup' => 'No updated versions',
1235: );
1236: my $rowColor;
1237: if (keys(%{$changed}) > 0) {
1238: $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>');
1239:
1240:
1241: my @changes = sort { &cmp_title($a,$b,$res_title) } keys(%{$changed});
1242: my $changenum = 0;
1243: foreach my $item (@changes) {
1244: if ($changenum %2 == 1) {
1245: $rowColor = $rowColor1;
1246: } else {
1247: $rowColor = $rowColor2;
1248: }
1249: my ($map,$id,$url)=&Apache::lonnet::decode_symb($item);
1250: my $linkurl=&Apache::lonnet::clutter($url);
1251: $linkurl .= '?symb='.&Apache::lonnet::escape($item);
1252:
1253: $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>');
1254: $changenum ++;
1255: }
1256: } else {
1257: $r->print('<tr><td bgcolor="#ffffff"><br /><center><b><i><small>'.$lt{'noup'}.' '.$interval.'</small></i></b></center><br /></td></tr>');
1258: }
1259: return;
1260: }
1261:
1262: sub display_coursediscussion {
1.37 raeburn 1263: my ($r,$newdiscussions,$unread,$countunread,$res_title,$rowColor1,
1264: $rowColor2) = @_;
1.33 raeburn 1265: my %lt = &Apache::lonlocal::texthash(
1266: 'loca' => 'Location',
1267: 'type' => 'Type',
1268: 'numn' => 'Number of new posts',
1269: 'noun' => 'No unread posts in course discussions',
1.37 raeburn 1270: 'tmlp' => 'Time of last post',
1.33 raeburn 1271: );
1272: my $rowColor;
1273: if (@{$newdiscussions} > 0) {
1274: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'loca'}.
1275: '</small></b></td><td><b><small>'.$lt{'type'}.
1.37 raeburn 1276: '</small></b>');
1.39 raeburn 1277: if ($countunread eq 'on') {
1.37 raeburn 1278: $r->print('<td><b><small>'.$lt{'tmlp'}.'</small></b></td>'.
1279: '<td align="right"><b><small>'.$lt{'numn'}.
1280: '</small></b></td>');
1281: } else {
1282: $r->print('<td align="right"><b><small>'.$lt{'tmlp'}.
1283: '</small></b></td>');
1284: }
1285: $r->print("</tr>\n");
1.33 raeburn 1286: @{$newdiscussions} = sort { &cmp_title($a,$b,$res_title) }
1287: @{$newdiscussions};
1288: my $rowNum = 0;
1289: foreach my $ressymb (@{$newdiscussions}) {
1290: my $forum_title = $$unread{$ressymb}{'title'};
1291: my $type = 'Resource';
1292: my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
1293: if ($feedurl =~ /bulletinboard/) {
1294: $type = 'Bulletin Board';
1295: }
1.37 raeburn 1296: if ($rowNum %2 == 1) {
1297: $rowColor = $rowColor1;
1298: } else {
1299: $rowColor = $rowColor2;
1300: }
1301: my $lastpost = &Apache::lonnavmaps::timeToHumanString(
1302: $$unread{$ressymb}{'lastpost'});
1303: $r->print('<tr bgcolor="'.$rowColor.'"><td><small><a href="'.$feedurl.'?symb='.$$unread{$ressymb}{symb}.'">'.$forum_title.'</a> </td><td><small>'.$type.' </small></td>');
1.39 raeburn 1304: if ($countunread eq 'on') {
1.37 raeburn 1305: my $unreadnum = $$unread{$ressymb}{'unreadcount'};
1306: $r->print('<td><small>'.$lastpost.'<small></td><td align="right">'.
1307: '<small>',$unreadnum.' </small></td>');
1308: } else {
1309: $r->print('<td align="right"><small>'.$lastpost.'</small></td>');
1.33 raeburn 1310: }
1.37 raeburn 1311: $r->print("</tr>\n");
1312: $rowNum ++;
1.33 raeburn 1313: }
1314: } else {
1315: $r->print('<tr><td bgcolor="#ffffff"><br><center> <i><b><small>'.
1316: $lt{'noun'}.'</small></b></i><br><br></td></tr>');
1317: }
1318: }
1319:
1320: sub display_coursenormalmail {
1321: my ($r,$msgcount,$newmsgs,$rowColor1,$rowColor2) = @_;
1322: my $rowColor;
1323: if ($msgcount > 0) {
1324: $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>');
1325: my $rowNum = 0;
1326: my $mailcount = 1;
1327: foreach my $msg (@{$newmsgs}) {
1328: if ($rowNum %2 == 1) {
1329: $rowColor = $rowColor1;
1330: } else {
1331: $rowColor = $rowColor2;
1332: }
1333: $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>');
1334: $rowNum ++;
1335: $mailcount ++;
1336: }
1337: } else {
1338: $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>');
1339: }
1340: }
1341:
1342: sub display_coursecritmail {
1343: my ($r,$critmsgcount,$critmsgs,$rowColor1,$rowColor2) = @_;
1344: my $rowColor;
1345: if ($critmsgcount > 0) {
1346: $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>');
1347: my $rowNum = 0;
1348: my $mailcount = 1;
1349: foreach my $msg (@{$critmsgs}) {
1350: if ($rowNum %2 == 1) {
1351: $rowColor = $rowColor1;
1352: } else {
1353: $rowColor = $rowColor2;
1354: }
1355: $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>');
1356: $rowNum ++;
1357: $mailcount ++;
1358: }
1359: } else {
1360: $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>');
1361: }
1.1 raeburn 1362: }
1363:
1364: sub cmp_title {
1.16 raeburn 1365: my ($a,$b,$res_title) = @_;
1366: my ($atitle,$btitle) = (lc($$res_title{$a}),lc($$res_title{$b}));
1.1 raeburn 1367: $atitle=~s/^\s*//;
1368: $btitle=~s/^\s*//;
1369: return $atitle cmp $btitle;
1370: }
1371:
1.33 raeburn 1372: sub get_display_settings {
1.36 raeburn 1373: my ($uname,$udom,$cid) = @_;
1.33 raeburn 1374: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid);
1375: my ($tmp) = keys(%settings);
1.40 raeburn 1376: if ($tmp=~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 1377: %settings = ();
1.41 raeburn 1378: unless ($tmp =~ /^error: 2 /) {
1379: &Apache::lonnet::logthis('Error retrieving whatsnew settings: '.
1380: $tmp.' for '.$uname.':'.$udom.' for course: '.$cid);
1.33 raeburn 1381: }
1382: }
1383: return %settings;
1384: }
1385:
1.36 raeburn 1386: sub store_display_settings {
1387: my ($uname,$udom,$cid,$checkallowed) = @_;
1388: my %whatsnew_settings;
1389: my $result;
1390: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 1391: if ($key =~ /_section$/) { next; }
1.36 raeburn 1392: if (exists($env{'form.display_'.$key})) {
1393: unless ($env{'form.display_'.$key} eq '') {
1394: $whatsnew_settings{$cid.':'.$key} = $env{'form.display_'.$key};
1395: }
1396: }
1397: }
1398: if (keys(%whatsnew_settings)) {
1399: $result = &Apache::lonnet::put('nohist_whatsnew',\%whatsnew_settings,
1400: $udom,$uname);
1401: } else {
1402: $result = 'ok';
1403: }
1404: return $result;
1405: }
1406:
1407: sub store_interval_setting {
1408: my ($uname,$udom,$cid,$interval_titles) = @_;
1409: my %interval_settings = ();
1410: my $result;
1411: if (defined($env{'form.interval'})) {
1412: $interval_settings{$cid.':interval'} = $env{'form.interval'};
1413: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
1414: \%interval_settings,$udom,$uname);
1415: if ($outcome eq 'ok') {
1416: $result = &mt('Interval set to version changes [_1]',
1417: '<b>'.$$interval_titles{$env{'form.interval'}}.'</b><br />');
1418:
1419: } else {
1420: &Apache::lonnet::logthis('Error storing whatsnew interval setting'.
1421: ' '.$outcome.' for '.$uname.':'.$udom.' in course '.$cid);
1422: $result = &mt('Unable to set interval to [_1] due to [_2].',
1423: '<b>'.$$interval_titles{$env{'form.interval'}}.'</b>',
1424: '<tt>'.$outcome.'</tt>.<br />');
1425: }
1426: }
1427: return $result;
1428: }
1429:
1.39 raeburn 1430: sub store_discussion_setting {
1431: my ($uname,$udom,$cid) = @_;
1432: my %discussion_settings;
1433: my $result;
1434: if (defined($env{'form.countunread'})) {
1435: $discussion_settings{$cid.':countunread'} = $env{'form.countunread'};
1436: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
1437: \%discussion_settings,$udom,$uname);
1438: if ($outcome eq 'ok') {
1439: $result = &mt('Count unread posts in discussions display set to [_1]',
1440: '<b>'.$env{'form.countunread'}.'</b><br />');
1441:
1442: } else {
1443: &Apache::lonnet::logthis('Error storing whatsnew countunread setting'.
1444: ' '.$outcome.' for '.$uname.':'.$udom.' in course '.$cid);
1445: $result = &mt('Unable to set "number unread posts display" to [_1]'.
1446: ' due to [_2].',
1447: '<b>'.$env{'form.countunread'}.'</b>',
1448: '<tt>'.$outcome.'</tt>.<br />');
1449: }
1450: }
1451: return $result;
1452: }
1453:
1454: sub store_courseinit_setting {
1455: my ($uname,$udom,$cid,$initpage) = @_;
1456: my %courseinit_settings;
1457: my $page_control;
1458: my $result;
1459: if (defined($env{'form.courseinit_control'})) {
1460: if ($env{'form.courseinit_control'} eq 'userpref') {
1461: $courseinit_settings{$cid.':courseinit'} = '';
1462: $page_control = 'global preferences';
1463: } else {
1464: if (defined($env{'form.courseinit_page'})) {
1465: $courseinit_settings{$cid.':courseinit'} =
1466: $env{'form.courseinit_page'};
1467: $page_control = 'course specific setting';
1468: }
1469: }
1470: if ($page_control) {
1471: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
1472: \%courseinit_settings,$udom,$uname);
1473: if ($outcome eq 'ok') {
1474: if ($page_control eq 'global preferences') {
1475: $result = &mt('Page displayed after role selection in course now set by [_1]',"<b>user's global preferences</b>.");
1476: } else {
1477: $result = &mt('Page displayed after role selection in this course set to [_1]','<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>.');
1478: }
1479: } else {
1480: &Apache::lonnet::logthis('Error storing whatsnew courseinit '.
1481: 'setting: '.$outcome.' for '.$uname.
1482: ':'.$udom.' in course '.$cid);
1483: if ($page_control eq 'global preferences') {
1484: $result = &mt('Unable to set control of page display to [_1]'.
1485: ' due to [_2].',
1486: '<b>'.$page_control.'</b>',
1487: '<tt>'.$outcome.'</tt>.<br />');
1488: } else {
1489: $result = &mt('Unable to set page display, after role selection, for this course to [_1] due to [_2].',
1490: '<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>',
1491: '<tt>'.$outcome.'</tt>.<br />');
1492: }
1493: }
1494: }
1495: }
1496: return $result;
1497: }
1498:
1.33 raeburn 1499: sub start_box {
1.39 raeburn 1500: my ($r,$tabbg,$show,$heading,$caller,$refpage) = @_;
1.33 raeburn 1501: my %lt = &Apache::lonlocal::texthash(
1502: chth => 'Change thresholds?',
1503: chin => 'Change interval?',
1.39 raeburn 1504: chop => 'Change options?',
1.33 raeburn 1505: );
1506: my $showhide;
1507: if ($$show{$caller}) {
1.36 raeburn 1508: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1509: 'display_'.$caller.",'hide'".');">Hide</a></b>';
1.33 raeburn 1510:
1511: } else {
1.36 raeburn 1512: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1513: 'display_'.$caller.",'show'".');">Show</a></b>';
1.33 raeburn 1514: }
1515:
1516: $r->print('
1517: <table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000" width="100%">
1518: <tr>
1519: <td>
1520: <table border="0" cellpadding="1" cellspacing="1" bgcolor="#000000" width="100%">
1521: <tr>
1522: <td bgcolor="'.$tabbg.'">
1523: <table width="100%" border="0" cellspacing="0" cellpadding="0">
1524: <tr>
1525: <td><b>'.$$heading{$caller}.'</b></td>
1526: <td valign="top" align="right">'.$showhide.'</td>
1527: </tr>
1528: </table>
1529: </td>
1530: </tr>');
1531: if (($caller eq 'abovethreshold') && ($$show{$caller})) {
1.40 raeburn 1532: if ($$show{$caller}) {
1533: $r->print('
1.33 raeburn 1534: <tr>
1.39 raeburn 1535: <td bgcolor="'.$tabbg.'" align="right"><a href="/adm/whatsnew?command=chgthreshold&refpage='.$refpage.'"><b><small>'.$lt{'chth'}.'</small></b></a></td>
1.33 raeburn 1536: </tr>');
1.40 raeburn 1537: }
1.33 raeburn 1538: } elsif (($caller eq 'versionchanges') && ($$show{$caller})) {
1.40 raeburn 1539: if ($$show{$caller}) {
1540: $r->print('
1.33 raeburn 1541: <tr>
1.39 raeburn 1542: <td bgcolor="'.$tabbg.'" align="right"><a href="/adm/whatsnew?command=chginterval&refpage='.$refpage.'"><b><small>'.$lt{'chin'}.'</small></b></a></td>
1543: </tr>');
1.40 raeburn 1544: }
1.39 raeburn 1545: } elsif ($caller eq 'coursediscussion') {
1.40 raeburn 1546: if ($$show{$caller}) {
1547: $r->print('
1.39 raeburn 1548: <tr>
1549: <td bgcolor="'.$tabbg.'" align="right"><a href="/adm/whatsnew?command=chgdisc&refpage='.$refpage.'"><b><small>'.$lt{'chop'}.'</small></b></a></td>
1.33 raeburn 1550: </tr>');
1.40 raeburn 1551: }
1.33 raeburn 1552: }
1553: $r->print('
1554: <tr>
1555: <td bgcolor="#ffffff">
1556: <table cellpadding="2" cellspacing="0" border="0" width="100%">
1557: ');
1558: return;
1559: }
1560:
1561: sub end_box {
1562: my ($r) = shift;
1563: $r->print('
1564: </table>
1565: </td>
1566: </tr>
1567: </table>
1568: </td>
1569: </tr>
1570: </table><br />');
1571: return;
1572: }
1573:
1.7 raeburn 1574: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>