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