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