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