Annotation of loncom/interface/lonwhatsnew.pm, revision 1.48
1.2 albertel 1: #
1.48 ! raeburn 2: # $Id: lonwhatsnew.pm,v 1.47 2006/01/06 23:56:05 raeburn Exp $
1.2 albertel 3: #
4: # Copyright Michigan State University Board of Trustees
5: #
6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
7: #
8: # LON-CAPA is free software; you can redistribute it and/or modify
9: # it under the terms of the GNU General Public License as published by
10: # the Free Software Foundation; either version 2 of the License, or
11: # (at your option) any later version.
12: #
13: # LON-CAPA is distributed in the hope that it will be useful,
14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: # GNU General Public License for more details.
17: #
18: # You should have received a copy of the GNU General Public License
19: # along with LON-CAPA; if not, write to the Free Software
20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21: #
22: # /home/httpd/html/adm/gpl.txt
23: #
24: # http://www.lon-capa.org/
25: #
26:
27:
1.1 raeburn 28: package Apache::lonwhatsnew;
29:
30: use strict;
31: use lib qw(/home/httpd/lib/perl);
32: use Apache::lonnet;
1.3 albertel 33: use Apache::loncommon();
34: use Apache::lonhtmlcommon();
1.1 raeburn 35: use Apache::lonlocal;
1.3 albertel 36: use Apache::loncoursedata();
37: use Apache::lonnavmaps();
1.18 raeburn 38: use Apache::lonuserstate;
1.1 raeburn 39: use Apache::Constants qw(:common :http);
40: use Time::Local;
1.24 albertel 41: use GDBM_File;
1.1 raeburn 42:
43: #----------------------------
44: # handler
45: #
46: #----------------------------
47:
48: sub handler {
49: my $r = shift;
1.7 raeburn 50: if ($r->header_only) {
51: &Apache::loncommon::content_type($r,'text/html');
52: $r->send_http_header;
53: return OK;
54: }
1.39 raeburn 55: &Apache::loncommon::get_unprocessed_cgi(
56: $ENV{'QUERY_STRING'},['command','refpage']);
1.1 raeburn 57:
1.36 raeburn 58: my $command = $env{'form.command'};
1.39 raeburn 59: my $refpage = $env{'form.refpage'};
1.1 raeburn 60:
1.44 albertel 61: my %checkallowed = ( coursenormalmail => 1,
62: coursecritmail => 1, );
63: foreach my $perm_check (['whn','whatsnew',1],
64: ['pch','coursediscussion',1],
65: ['mgr','handgrading',1],
66: ['vgr','abovethreshold',1],
67: ['opa','haserrors',1],
68: ['mdc','versionchanges',0],
69: ) {
70: my ($perm,$key,$check_section) = @{ $perm_check };
71: my $scope = $env{'request.course.id'};
72: if (!($checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope))) {
73: $scope .= '/'.$env{'request.course.sec'};
74: if ( $check_section ) {
75: $checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope);
76: }
77: if ($checkallowed{$key}) {
78: $checkallowed{$key.'_section'} = $env{'request.course.sec'};
79: }
80: }
81: }
1.43 albertel 82:
1.44 albertel 83: if ( ! $env{'request.course.fn'} || ! $checkallowed{'whatsnew'}) {
1.43 albertel 84: # Not in a course, or no whn priv in course
1.42 raeburn 85: $env{'user.error.msg'}="/adm/whatsnew::whn:0:0:Cannot display what's new page";
1.1 raeburn 86: return HTTP_NOT_ACCEPTABLE;
87: }
88:
1.44 albertel 89: &Apache::loncommon::content_type($r,'text/html');
90: $r->send_http_header;
1.36 raeburn 91:
92: $r->print(&display_header($command,\%checkallowed));
93:
1.7 raeburn 94: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.36 raeburn 95: &Apache::lonhtmlcommon::add_breadcrumb
96: ({href=>'/adm/whatsnew',
97: text=>"Display Action Items"});
1.44 albertel 98: if (($command eq 'chgthreshold') && $checkallowed{'abovethreshold'}) {
1.7 raeburn 99: &Apache::lonhtmlcommon::add_breadcrumb
1.39 raeburn 100: ({href=>'/adm/whatsnew?command=chgthreshold&refpage='.$refpage,
1.13 raeburn 101: text=>"Change thresholds"});
1.7 raeburn 102: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.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.47 raeburn 567: my %opposite = (
568: 'on' => 'off',
569: 'off' => 'on',
570: );
571: $r->print('<script type="text/javascript">
572: function toggle_countunread(choice) {
573: if (choice == "unchanged") {
574: document.discussionswitch.command.value = "";
575: }
576: document.discussionswitch.submit();
577: }
578: </script>');
579: $r->print('<br />'.&mt('Choose whether or not to display a count of the number of new posts for each resource or bulletin board which has unread posts.').'<br />'.&mt('This can increase the time taken to gather data for the [_1] page by a few seconds.',"<i>What's New?</i>").' '.&mt('Currently set to [_1].','<b>'.$current.'</b>'));
1.39 raeburn 580: $r->print('<br /><br />
1.47 raeburn 581: <form method="post" name="discussionswitch" action="/adm/whatsnew">
1.39 raeburn 582: <input type="hidden" name="command" value="newdiscconf" />
583: <input type="hidden" name="refpage" value="'.$refpage.'" />
1.47 raeburn 584: <input type="hidden" name="countunread" value="'.$opposite{$current}.'" />
1.39 raeburn 585: ');
1.47 raeburn 586: $r->print('<br/>
587: <input type="button" name="display" value="'.
588: &mt('Change to [_1]',$opposite{$current}).'"
589: onclick="javascript:toggle_countunread('."'change'".')" />
590:  
591: <input type="button" name="nochange" value="'.
592: &mt("No change").'"
593: onclick="javascript:toggle_countunread('."'unchanged'".')" />
594: </form>');
1.39 raeburn 595: return;
596: }
597:
598: #---------------------------------------------------
599: # courseinit_config
600: #
601: # Set page displayed when course loads after
602: # selecting a role in the course from the roles page.
603: #
604: #---------------------------------------------------
605:
606: sub courseinit_config {
607: my ($r,$refpage,$initpage) = @_;
608: my ($control,$current) = &curr_courseinit();
609: my @chgstate = ('userpref','coursespecific');
610: my @chgentry = ('firstres','whatsnew');
611: my %lt = &Apache::lonlocal::texthash(
612: 'chwp' => 'Choose which page will be displayed when you enter this course after selecting a role.',
613: 'cuva' => 'Current value is determined by',
614: 'anis' => 'and is set to display',
615: 'padc' => 'Page display controlled by',
616: 'chce' => 'Choose course entry',
617: 'moce' => 'Modify course entry',
618: );
619: $r->print(<<"END");
620: <br />$lt{'chwp'}
621: <br />$lt{'cuva'}: <b>
622: $$initpage{$control}</b> $lt{'anis'} <b>
623: $$initpage{$current}</b>.<br /><br />
624: <form method="post" name="courseinitswitch" action="/adm/whatsnew">
625: <input type="hidden" name="command" value="newcourseinit" />
626: <input type="hidden" name="refpage" value="$refpage" />
627: $lt{'padc'}
628: END
629: foreach my $choice (@chgstate) {
1.45 albertel 630: $r->print('<nobr><label><input type="radio" name="courseinit_control" value="'.
631: $choice.'"/>'.$$initpage{$choice}.' </label></nobr>');
1.39 raeburn 632: }
633: $r->print('<br /><br />'.&mt('If').' '.$$initpage{'coursespecific'}.
634: '<br />'.$lt{'chce'}." \n");
635: foreach my $choice (@chgentry) {
1.45 albertel 636: $r->print('<nobr><label><input type="radio" name="courseinit_page" value="'.
637: $choice.'"/>'.$$initpage{$choice}.' </label></nobr>');
1.39 raeburn 638: }
639: $r->print('<br /><br /><input type="submit" name="display" value="'.
640: $lt{'moce'}.'" /></form>');
641: return;
642: }
643:
644: sub curr_courseinit {
645: my $current = &get_current($env{'user.name'},$env{'user.domain'},
646: $env{'request.course.id'},'courseinit');
647: my $control;
1.40 raeburn 648: if ($current) {
649: $control = 'coursespecific';
650: } else {
1.39 raeburn 651: $control = 'userpref';
1.40 raeburn 652: my %userenv = &Apache::lonnet::get('environment',
653: ['course_init_display']);
654: if (exists($userenv{'course_init_display'})) {
655: $current = $userenv{'course_init_display'};
656: }
657: unless ($current) {
1.39 raeburn 658: $current = 'whatsnew';
659: }
660: }
661: return ($control,$current);
662: }
663:
1.33 raeburn 664: sub display_launcher {
1.39 raeburn 665: my ($r,$action,$refpage,$checkallowed,$tabbg,$rowColor1,$rowColor2,$show,
1.33 raeburn 666: $headings,$res_title,$tograde,$ungraded,$bombs,$bombed,$changed,
667: $warnings,$triggered,$newdiscussions,$unread,$msgcount,$newmsgs,
1.37 raeburn 668: $critmsgcount,$critmsgs,$interval,$countunread) = @_;
1.33 raeburn 669:
670: if ($$checkallowed{$action}) {
1.39 raeburn 671: &start_box($r,$tabbg,$show,$headings,$action,$refpage);
1.33 raeburn 672: if ($$show{$action}) {
673: if ($action eq 'handgrading') { # UNGRADED ITEMS
674: &display_handgrade($r,$tograde,$rowColor1,$rowColor2,
675: $ungraded);
676: } elsif ($action eq 'haserrors') { # BOMBS
677: &display_haserrors($r,$bombs,$rowColor1,$rowColor2,$bombed,
678: $res_title);
679: } elsif ($action eq 'versionchanges') { # VERSION CHANGES
680: &display_versionchanges($r,$changed,$res_title,$rowColor1,
681: $rowColor2,$interval);
682:
683: } elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS
1.39 raeburn 684: &display_abovethreshold($r,$refpage,$warnings,$triggered,
685: $res_title,$rowColor1,$rowColor2);
1.33 raeburn 686: } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION
687: &display_coursediscussion($r,$newdiscussions,$unread,
1.37 raeburn 688: $countunread,$res_title,$rowColor1,$rowColor2);
1.33 raeburn 689: } elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES
690: &display_coursenormalmail($r,$msgcount,$newmsgs,$rowColor1,
691: $rowColor2);
692: } elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES
693: &display_coursecritmail($r,$critmsgcount,$critmsgs,$rowColor1,
694: $rowColor2);
695: }
696: }
697: &end_box($r);
698: }
699: return;
700: }
701:
1.1 raeburn 702: sub getitems {
1.33 raeburn 703: my ($unread,$ungraded,$bombed,$triggered,$changed,$newdiscussions,
704: $tograde,$bombs,$warnings,$rowColor1,$rowColor2,$threshold,$cdom,$crs,
1.37 raeburn 705: $res_title,$show,$starttime,$countunread) = @_;
1.1 raeburn 706: my $navmap = Apache::lonnavmaps::navmap->new();
1.26 albertel 707: # force retrieve Resource to seed the part id cache we'll need it later
1.37 raeburn 708: my @allres=$navmap->retrieveResources(undef,
709: sub {if ($_[0]->is_problem) { $_[0]->parts();} return 1;});
1.33 raeburn 710: my %lastreadtime;
711: my %resourcetracker;
1.37 raeburn 712: my $discussiontime;
1.33 raeburn 713:
714: # Resource version changes
715: if ($$show{'versionchanges'}) {
716: &checkversions($cdom,$crs,$navmap,$changed,$starttime);
717: }
718:
1.37 raeburn 719: if ($$show{'coursediscussion'}) {
1.33 raeburn 720: my %lastread = &Apache::lonnet::dump('nohist_'.
721: $env{'request.course.id'}.'_discuss',
722: $env{'user.domain'},$env{'user.name'},'lastread');
723: foreach my $key (keys(%lastread)) {
724: my $newkey = $key;
725: $newkey =~ s/_lastread$//;
726: $lastreadtime{$newkey} = $lastread{$key};
727: }
728: }
729:
730: if ($$show{'abovethreshold'}) {
731: %resourcetracker = &Apache::lonnet::dump('nohist_resourcetracker',
732: $cdom,$crs);
733: }
1.1 raeburn 734:
1.11 raeburn 735: my $warningnum = 0;
1.1 raeburn 736: foreach my $resource (@allres) {
737: my $result = '';
738: my $applies = 0;
739: my $symb = $resource->symb();
1.33 raeburn 740: %{$$bombed{$symb}} = ();
1.1 raeburn 741: %{$$ungraded{$symb}} = ();
1.11 raeburn 742: %{$$triggered{$symb}} = ();
743: $$triggered{$symb}{numparts} = 0;
1.1 raeburn 744: my $title = $resource->compTitle();
1.16 raeburn 745: $$res_title{$symb} = $title;
1.8 albertel 746: my $ressymb = $resource->wrap_symb();
1.33 raeburn 747:
1.37 raeburn 748: # Check if there are unread discussion postings
1.33 raeburn 749: if ($$show{'coursediscussion'}) {
750: &check_discussions($cdom,$crs,$resource,$symb,$ressymb,$title,
1.37 raeburn 751: $newdiscussions,$unread);
1.33 raeburn 752: }
1.1 raeburn 753:
754: # Check for ungraded problems
755: if ($resource->is_problem()) {
1.33 raeburn 756: if ($$show{'handgrading'}) {
757: &check_handgraded($resource,$symb,$title,$cdom,$crs,$ungraded,
758: $tograde);
759: }
1.1 raeburn 760: }
761:
762: # Check for bombs
1.33 raeburn 763: if ($$show{'haserrors'}) {
764: &check_bombed($resource,$symb,$title,$bombs,$bombed);
765: }
766:
767: # Maxtries and degree of difficulty for problem parts, unless handgradeable
768: if ($$show{'abovethreshold'}) {
769: &check_thresholds($resource,$symb,\%resourcetracker,$triggered,
770: $threshold,$warnings,$warningnum,$rowColor1,$rowColor2);
771: }
772:
773: }
1.37 raeburn 774: my $hasdiscussion = @{$newdiscussions};
775: if ($$show{'coursediscussion'} && $hasdiscussion) { # Get time of last post;
776: $discussiontime = $navmap->{DISCUSSION_TIME};
777: foreach my $ressymb (@{$newdiscussions}) {
778: $$unread{$ressymb}{'lastpost'} = $$discussiontime{$ressymb};
779: }
1.39 raeburn 780: if ($countunread eq 'on') { #Get count of unread postings for each resource
1.37 raeburn 781: my $discussiondata = $navmap->get_discussion_data();
782: foreach my $ressymb (@{$newdiscussions}) {
783: &get_discussions($cdom,$crs,$discussiondata,$ressymb,
784: $unread,\%lastreadtime);
785: }
786: }
787: }
1.33 raeburn 788: }
789:
790: sub check_discussions {
1.37 raeburn 791: my ($cdom,$crs,$resource,$symb,$ressymb,$title,$newdiscussions,
792: $unread) = @_;
1.33 raeburn 793: if ($resource->hasDiscussion()) {
794: %{$$unread{$ressymb}} = ();
795: $$unread{$ressymb}{'title'} = $title;
796: $$unread{$ressymb}{'symb'} = $symb;
1.37 raeburn 797: push(@{$newdiscussions}, $ressymb);
798: }
799: }
800:
801: sub get_discussions {
802: my ($cdom,$crs,$discussiondata,$ressymb,$unread,$lastreadtime) = @_;
803: my $prevread = 0;
804: my $unreadcount = 0;
805: if (defined($$lastreadtime{$ressymb})) {
806: $prevread = $$lastreadtime{$ressymb};
807: }
808: my $version = $$discussiondata{'version:'.$ressymb};
809: if ($version) {
810: my $hiddenflag = 0;
811: my $deletedflag = 0;
812: my ($hidden,$deleted);
813: for (my $id=$version; $id>0; $id--) {
814: my $vkeys=$$discussiondata{$id.':keys:'.$ressymb};
815: my @keys=split(/:/,$vkeys);
816: if (grep/^hidden$/,@keys) {
817: unless ($hiddenflag) {
818: $hidden = $$discussiondata{$id.':'.$ressymb.':hidden'};
819: $hiddenflag = 1;
820: }
1.38 raeburn 821: } elsif (grep/^deleted$/,@keys) {
1.37 raeburn 822: unless ($deletedflag) {
823: $deleted = $$discussiondata{$id.':'.$ressymb.':deleted'};
824: $deletedflag = 1;
825: }
1.39 raeburn 826: } else {
1.38 raeburn 827: unless (($hidden =~/\.$id\./) || ($deleted =~/\.$id\./)) {
828: if ($prevread <$$discussiondata{$id.':'.$ressymb.':timestamp'}) {
1.33 raeburn 829: $unreadcount ++;
1.37 raeburn 830: $$unread{$ressymb}{$unreadcount} = $id.': '.
831: $$discussiondata{$id.':'.$ressymb.':subject'};
1.33 raeburn 832: }
833: }
834: }
1.1 raeburn 835: }
1.37 raeburn 836: $$unread{$ressymb}{'unreadcount'} = $unreadcount;
1.33 raeburn 837: }
838: }
839:
1.37 raeburn 840:
1.33 raeburn 841: sub check_handgraded {
842: my ($resource,$symb,$title,$cdom,$cnum,$ungraded,$tograde) = @_;
843: if ($resource->is_problem()) {
844: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
845: my $partlist=$resource->parts();
846: my $handgradeable;
847: foreach my $part (@$partlist) {
1.31 raeburn 848: if ($resource->handgrade($part) eq 'yes') {
1.33 raeburn 849: $handgradeable=1; last;
1.31 raeburn 850: }
1.33 raeburn 851: }
852: if ($handgradeable) {
1.35 raeburn 853: my @ungraded = &Apache::bridgetask::get_queue_symb_status(
1.33 raeburn 854: 'gradingqueue',$symb,$cdom,$cnum);
855: if (@ungraded > 0) {
856: $$ungraded{$symb}{count} = scalar(@ungraded);
857: $$ungraded{$symb}{title} = $title;
858: push(@{$tograde}, $symb);
1.11 raeburn 859: }
860: }
1.33 raeburn 861: }
862: }
863:
864: sub check_bombed {
865: my ($resource,$symb,$title,$bombs,$bombed) = @_;
866: if ($resource->getErrors()) {
867: my $errors = $resource->getErrors();
868: $errors =~ s/^,//;
869: my @bombs = split(/,/, $errors);
870: my $errorcount = scalar(@bombs);
871: my $errorlink = '<a href="/adm/email?display='.
872: &Apache::lonnet::escape($bombs[0]).'">'.
873: $title.'</a>';
874: $$bombed{$symb}{errorcount} = $errorcount;
875: $$bombed{$symb}{errorlink} = $errorlink;
876: push(@{$bombs}, $symb);
877: }
878: }
879:
880: sub check_thresholds {
881: my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings,
882: $warningnum,$rowColor1,$rowColor2) = @_;
883: # Compile maxtries and degree of difficulty for problem parts, unless handgradeable
884: my @parts = @{$resource->parts()};
885: my %stats;
886: my %lastreset = ();
887: my $warning = 0;
888: my $rowColor;
889: foreach my $part (@parts) {
890: if ($resource->handgrade($part) eq 'yes') {
891: next;
892: }
1.48 ! raeburn 893: if ($resource->is_survey($part)) {
! 894: next;
! 895: }
1.33 raeburn 896: %{$stats{$part}} = ();
897: my ($attempts,$users,$corrects,$degdiff,$av_attempts);
898: if (exists($$resourcetracker{$symb."\0".$part."\0attempts"})) {
899: $attempts = $$resourcetracker{$symb."\0".$part."\0attempts"};
900: }
901: if (exists($$resourcetracker{$symb."\0".$part."\0users"})) {
902: $users = $$resourcetracker{$symb."\0".$part."\0users"};
903: }
904: if (exists($$resourcetracker{$symb."\0".$part."\0correct"})) {
905: $corrects = $$resourcetracker{$symb."\0".$part."\0correct"};
906: }
907: if ($attempts > 0) {
908: $degdiff = 1 - ($corrects/$attempts);
909: $degdiff = sprintf("%.2f",$degdiff);
910: }
911: if ($users > 0) {
912: $av_attempts = $attempts/$users;
913: $av_attempts = sprintf("%.2f",$av_attempts);
914: }
915: if ((($degdiff ne '' && $degdiff >= $$threshold{'degdiff'}) || ($av_attempts ne '' && $av_attempts >= $$threshold{'av_attempts'})) && ($users >= $$threshold{'numstudents'})) {
916: $stats{$part}{degdiff} = $degdiff;
917: $stats{$part}{attempts} = $av_attempts;
918: $stats{$part}{users} = $users;
919: $lastreset{$part} = $$resourcetracker{$symb."\0".$part."\0resettime"};
920: if ($lastreset{$part}) {
921: $lastreset{$part} = &Apache::lonnavmaps::timeToHumanString($lastreset{$part});
1.11 raeburn 922: }
1.33 raeburn 923: $warning = 1;
924: }
925: }
926: if ($warning) {
1.35 raeburn 927: if ($warningnum %2 == 1) {
1.33 raeburn 928: $rowColor = $rowColor1;
929: } else {
930: $rowColor = $rowColor2;
931: }
932: $$triggered{$symb}{title} = $resource->title;
933: foreach my $part (@parts) {
934: if (exists($stats{$part}{users})) {
935: my $resetname = 'reset_'.&Apache::lonnet::escape($symb."\0".$part);
936: my $resettitle = 'title_'.&Apache::lonnet::escape($symb."\0".$part);
937: if ($$triggered{$symb}{numparts}) {
938: $$triggered{$symb}{text} .= '<tr bgcolor="'.$rowColor.'">'."\n";
939: }
940: if (@parts > 1) {
941: $$triggered{$symb}{text} .= '
942: <td align="right"><small>part - '.$part.'<small></td>';
943: } else {
1.11 raeburn 944: $$triggered{$symb}{text} .= '
1.33 raeburn 945: <td align="right"><small>single part</small></td>';
1.11 raeburn 946: }
1.33 raeburn 947: $$triggered{$symb}{text} .= '
948: <td align="right"><small>'.$stats{$part}{users}.'</small></td>
949: <td align="right"><small>'.$stats{$part}{attempts}.'</small></td>
950: <td align="right"><small>'.$stats{$part}{degdiff}.'</small></td>
951: <td align="right"><small>'.$lastreset{$part}.'</small></td>
952: <td align="right"><small><input type="checkbox" name="'.$resetname.'" /><input type="hidden" name="'.$resettitle.'" value="'.&Apache::lonnet::escape($$triggered{$symb}{title}).'" /></td>
953: </tr>';
954: $$triggered{$symb}{numparts} ++;
1.11 raeburn 955: }
956: }
1.33 raeburn 957: push(@{$warnings},$symb);
1.35 raeburn 958: $warningnum ++;
1.1 raeburn 959: }
960: }
961:
1.33 raeburn 962:
1.13 raeburn 963: sub get_curr_thresholds {
1.39 raeburn 964: my ($threshold,$uname,$udom,$cid,$cdom,$crs) = @_;
965: my %thresholdsettings = &Apache::lonnet::dump('nohist_whatsnew',$udom,
966: $uname,$cid.':threshold');
967: my $thresholdcount = 0;
968: my ($tmp) = %thresholdsettings;
1.40 raeburn 969: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 970: foreach my $item (keys %{$threshold}) {
971: if (exists($thresholdsettings{$cid.':threshold_'.$item})) {
972: $$threshold{$item} =
973: $thresholdsettings{$cid.':threshold_'.$item};
974: $thresholdcount ++;
975: }
976: }
1.13 raeburn 977: }
1.39 raeburn 978: if ($thresholdcount == 3) {
979: return;
1.13 raeburn 980: }
1.39 raeburn 981: my %coursesettings = &Apache::lonnet::dump('environment',
982: $cdom,$crs,'internal.threshold');
983: my ($temp) = %coursesettings;
1.40 raeburn 984: unless ($temp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 985: foreach my $item (keys %{$threshold}) {
986: unless (exists($thresholdsettings{$cid.':threshold_'.$item})) {
987: if (exists($coursesettings{'internal.threshold_'.$item})) {
988: $$threshold{$item} =
989: $coursesettings{'internal.threshold_'.$item};
990: }
991: }
992: }
1.13 raeburn 993: }
1.39 raeburn 994: return;
1.13 raeburn 995: }
996:
1.39 raeburn 997: sub get_current {
998: my ($uname,$udom,$cid,$caller) = @_;
999: my $currvalue;
1000: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid.
1001: ':'.$caller);
1.36 raeburn 1002: my ($tmp) = %settings;
1.40 raeburn 1003: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 1004: $currvalue = $settings{$cid.':'.$caller};
1.36 raeburn 1005: }
1.39 raeburn 1006: return $currvalue;
1.36 raeburn 1007: }
1008:
1.13 raeburn 1009: sub process_reset {
1010: my ($dom,$crs) = @_;
1.39 raeburn 1011: my $result = '<b>'.&mt('Counters reset for following problems (and parts):').
1012: '</b><br />';
1.13 raeburn 1013: my @agg_types = ('attempts','users','correct');
1.39 raeburn 1014: my %agg_titles = &Apache::lonlocal::texthash (
1.13 raeburn 1015: attempts => 'Number of submissions',
1016: users => 'Students with submissions',
1017: correct => 'Number of correct submissions',
1018: );
1019: my @resets = ();
1020: my %titles = ();
1.17 albertel 1021: foreach my $key (keys(%env)) {
1.13 raeburn 1022: next if ($key !~ /^form\.reset_(.+)$/);
1023: my $title = &Apache::lonnet::unescape($env{'form.title_'.$1});
1024: my $reset_item = &Apache::lonnet::unescape($1);
1025: my %curr_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
1026: my %aggregates = ();
1.17 albertel 1027: my ($symb,$part) = split(/\0/,$reset_item);
1.13 raeburn 1028: foreach my $type (@agg_types) {
1029: $aggregates{$reset_item."\0".$type} = 0;
1030: }
1.17 albertel 1031: $aggregates{$reset_item."\0".'resettime'} = time;
1.13 raeburn 1032: my $putresult = &Apache::lonnet::put('nohist_resourcetracker',\%aggregates,
1033: $dom,$crs);
1034: if ($putresult eq 'ok') {
1035: $result .= $title.' -part '.$part.': ';
1036: my %new_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
1037: foreach my $type (@agg_types) {
1038: $result .= $agg_titles{$type}.' = '.$new_aggregates{$reset_item."\0".$type}.'; ';
1039: }
1040: $result =~ s/; $//;
1041: $result .= '<br />';
1042: } else {
1.14 albertel 1043: $result = $title.' -part '.$part.': '.&mt('Unable to reset counters to zero due to [_1]',$putresult).'.<br />'."\n";
1.13 raeburn 1044: }
1045: }
1046: return $result;
1047: }
1048:
1049: sub process_update {
1.39 raeburn 1050: my ($uname,$udom,$threshold_titles) = @_;
1.15 raeburn 1051: my $setoutput = '<b>Changes to threshold(s) for problem tracking:</b><br />';
1.13 raeburn 1052: foreach (keys %env) {
1053: next if ($_!~/^form\.(.+)\_setparmval$/);
1054: my $name = $1;
1055: my $value = $env{'form.'.$name.'_value'};
1056: if ($name && defined($value)) {
1.39 raeburn 1057: my $put_result = &Apache::lonnet::put('nohist_whatsnew',
1058: {$name=>$value},$udom,$uname);
1.13 raeburn 1059:
1.39 raeburn 1060: my ($shortname) = ($name =~ /^\Q$env{'request.course.id'}\E:threshold_(.+)$/);
1.13 raeburn 1061: if ($put_result eq 'ok') {
1.14 albertel 1062: $setoutput.=&mt('Set threshold for [_1] to [_2]',
1063: '<b>'.$$threshold_titles{$shortname}.'</b>',
1064: '<b>'.$value.'</b>').'<br />';
1065: } else {
1066: $setoutput.=&mt('Unable to set threshold for [_1] to [_2] due to [_3].',
1067: '<b>'.$name.'</b>','<b>'.$value.'</b>',
1068: '<tt>'.$put_result.'</tt>').'<br />';
1.13 raeburn 1069: }
1070: }
1071: }
1072: return $setoutput;
1073: }
1074:
1.33 raeburn 1075: sub getnormalmail {
1076: my ($newmsgs) = @_;
1.1 raeburn 1077: # Check for unread mail in course
1078: my $msgcount = 0;
1.3 albertel 1079:
1.10 raeburn 1080: my @messages = sort(&Apache::lonnet::getkeys('nohist_email'));
1.3 albertel 1081: foreach my $message (@messages) {
1082: my $msgid=&Apache::lonnet::escape($message);
1.10 raeburn 1083: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1.1 raeburn 1084: &Apache::lonmsg::unpackmsgid($msgid);
1.10 raeburn 1085: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 1086: if (defined($sendtime) && $sendtime!~/error/) {
1087: my $numsendtime = $sendtime;
1088: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
1089: if ($status eq 'new') {
1.10 raeburn 1090: $msgcount ++;
1091: if ($shortsubj eq '') {
1092: $shortsubj = &mt('No subject');
1093: }
1094: $shortsubj = &Apache::lonnet::unescape($shortsubj);
1.1 raeburn 1095: push(@{$newmsgs}, {
1096: msgid => $msgid,
1097: sendtime => $sendtime,
1.10 raeburn 1098: shortsub => $shortsubj,
1.1 raeburn 1099: from => $fromname,
1100: fromdom => $fromdom
1101: });
1102: }
1103: }
1104: }
1105: }
1.33 raeburn 1106: return $msgcount;
1107: }
1.1 raeburn 1108:
1.33 raeburn 1109: sub getcritmail {
1110: my ($critmsgs) = @_;
1.1 raeburn 1111: # Check for critical messages in course
1112: my %what=&Apache::lonnet::dump('critical');
1113: my $result = '';
1114: my $critmsgcount = 0;
1.3 albertel 1115: foreach my $msgid (sort(keys(%what))) {
1.10 raeburn 1116: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1117: &Apache::lonmsg::unpackmsgid($msgid);
1118: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 1119: if (defined($sendtime) && $sendtime!~/error/) {
1120: my $numsendtime = $sendtime;
1121: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
1122: $critmsgcount ++;
1.10 raeburn 1123: if ($shortsubj eq '') {
1124: $shortsubj = &mt('No subject');
1125: }
1126: $shortsubj = &Apache::lonnet::unescape($shortsubj);
1.1 raeburn 1127: push(@{$critmsgs}, {
1128: msgid => $msgid,
1129: sendtime => $sendtime,
1.10 raeburn 1130: shortsub => $shortsubj,
1.1 raeburn 1131: from => $fromname,
1132: fromdom => $fromdom
1133: });
1134: }
1135: }
1136: }
1.33 raeburn 1137: return $critmsgcount;
1138: }
1139:
1140:
1141: sub checkversions {
1142: my ($cdom,$crs,$navmap,$changed,$starttime) = @_;
1143: my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs);
1144: my ($tmp) = keys(%changes);
1.40 raeburn 1145: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 1146: if (keys(%changes) > 0) {
1147: foreach my $key (sort(keys(%changes))) {
1148: if ($changes{$key} > $starttime) {
1149: my $version;
1150: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
1151: my $currentversion=&Apache::lonnet::getversion($key);
1152: my $revdate =
1153: &Apache::lonnet::metadata($root.'.'.$extension,
1154: 'lastrevisiondate');
1155: $revdate = &Apache::lonlocal::locallocaltime($revdate);
1156: my $linkurl=&Apache::lonnet::clutter($key);
1157: my $usedversion=$navmap->usedVersion('version_'.$linkurl);
1158: my @resources = $navmap->getResourceByUrl($linkurl,1);
1159: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1160: $version = $usedversion;
1161: } else {
1162: $version = $currentversion;
1163: }
1164: foreach my $res (@resources) {
1.35 raeburn 1165: if (ref($res) eq 'Apache::lonnavmaps::resource') {
1166: my $symb = $res->symb();
1167: %{$$changed{$symb}} = (
1.33 raeburn 1168: current => $currentversion,
1169: version => $version,
1170: revdate => $revdate,
1.35 raeburn 1171: );
1172: }
1.33 raeburn 1173: }
1174: }
1175: }
1176: }
1177: }
1178: return;
1179: }
1180:
1181: sub display_handgrade {
1182: my ($r,$tograde,$rowColor1,$rowColor2,$ungraded) = @_;
1183: my $rowColor;
1184: my %lt = &Apache::lonlocal::texthash(
1185: 'prna' => 'Problem Name',
1186: 'nmun' => 'Number ungraded',
1187: 'nopr' => 'No problems require handgrading',
1188: );
1189: if (@{$tograde} > 0) {
1190: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'prna'}.'</small></b></td><td align="right"><b><small>'.$lt{'nmun'}.'</small></b></td></tr>');
1191: my $rowNum = 0;
1192: foreach my $res (@{$tograde}) {
1193: if ($rowNum %2 == 1) {
1194: $rowColor = $rowColor1;
1195: } else {
1196: $rowColor = $rowColor2;
1197: }
1198: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
1199: my $linkurl=&Apache::lonnet::clutter($url);
1200: $linkurl .= '?symb='.&Apache::lonnet::escape($res);
1201:
1202: $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>');
1203: $rowNum ++;
1204: }
1205: } else {
1206: $r->print('<tr><td bgcolor="#ffffff"><br><center><i><b><small> '.$lt{'nopr'}.' </small><br><br></b></i></td></tr>');
1207: }
1208: }
1209:
1210: sub display_haserrors {
1211: my ($r,$bombs,$rowColor1,$rowColor2,$bombed,$res_title) = @_;
1212: my $bombnum = 0;
1213: my $rowColor;
1214: my %lt = &Apache::lonlocal::texthash(
1215: reso => 'Resource',
1216: nmer => 'Number of errors',
1217: noer => 'No problems with errors',
1218: );
1219: if (@{$bombs} > 0) {
1220: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'reso'}.'</small></b></td><td align="right"><b><small>'.$lt{'nmer'}.'</small></b></td></tr>');
1221: @{$bombs} = sort { &cmp_title($a,$b,$res_title) } @{$bombs};
1222: foreach my $bomb (@{$bombs}) {
1223: if ($bombnum %2 == 1) {
1224: $rowColor = $rowColor1;
1225: } else {
1226: $rowColor = $rowColor2;
1227: }
1228: $r->print('<tr bgcolor="'.$rowColor.'"><td><small>'.$$bombed{$bomb}{errorlink}.'</small></td><td align="right"><small>'.$$bombed{$bomb}{errorcount}.'</small></td></tr>');
1229: $bombnum ++;
1230: }
1231: } else {
1232: $r->print('<tr><td bgcolor="#ffffff"><br /><center><b><i><small>'.$lt{'noer'}.'</small></i></b></center><br /></td></tr>');
1233: }
1234: return;
1235: }
1236:
1237: sub display_abovethreshold {
1.39 raeburn 1238: my ($r,$refpage,$warnings,$triggered,$res_title,$rowColor1,$rowColor2) = @_;
1.33 raeburn 1239: my %lt = &Apache::lonlocal::texthash(
1240: reso => 'Resource',
1241: part => 'Part',
1242: nust => 'Num. students',
1243: avat => 'Av. Attempts',
1244: dedi => 'Deg. Diff',
1245: lare => 'Last Reset',
1246: reco => 'Reset Count?',
1247: rese => 'Reset counters to 0',
1248: nopr => 'No problems satisfy threshold criteria',
1249: );
1250: my $rowColor;
1251: my $warningnum = 0;
1252: if (@{$warnings} > 0) {
1253: @{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings};
1.36 raeburn 1254: $r->print('<form name="reset_tracking" method="post" action="/adm/whatsnew">'.
1.39 raeburn 1255: ' <input type="hidden" name="command" value="reset" />'."\n".
1256: ' <input type="hidden" name="refpage" value="'.$refpage.'" />'.
1257: "\n");
1.33 raeburn 1258: $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>');
1259: foreach my $res (@{$warnings}) {
1260: if ($warningnum %2 == 1) {
1261: $rowColor = $rowColor1;
1262: } else {
1263: $rowColor = $rowColor2;
1264: }
1265: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
1266: my $linkurl=&Apache::lonnet::clutter($url);
1267: my $rowspan;
1268: if ($$triggered{$res}{numparts} > 1) {
1269: $rowspan = 'rowspan="'.$$triggered{$res}{numparts}.'"';
1270: }
1271: $linkurl .= '?symb='.&Apache::lonnet::escape($res);
1272: $r->print('<tr bgcolor="'.$rowColor.'"><td '.$rowspan.'><a href="'.$linkurl.'"><small>'.$$triggered{$res}{title}.'</small></a></td>'.$$triggered{$res}{text});
1273: $warningnum ++;
1274: }
1.35 raeburn 1275: $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 1276: } else {
1277: $r->print('<tr><td bgcolor="#ffffff"><br /><center><b><i><small>'.$lt{'nopr'}.'</small></i></b></center><br /></td></tr>');
1278: }
1279: }
1280:
1281: sub display_versionchanges {
1282: my ($r,$changed,$res_title,$rowColor1,$rowColor2,$interval) = @_;
1283: my %lt = &Apache::lonlocal::texthash(
1284: 'reso' => 'Resource',
1285: 'revd' => 'Last revised',
1286: 'newv' => 'New version',
1287: 'veru' => 'Version used',
1288: 'noup' => 'No updated versions',
1289: );
1290: my $rowColor;
1291: if (keys(%{$changed}) > 0) {
1292: $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>');
1293:
1294:
1295: my @changes = sort { &cmp_title($a,$b,$res_title) } keys(%{$changed});
1296: my $changenum = 0;
1297: foreach my $item (@changes) {
1298: if ($changenum %2 == 1) {
1299: $rowColor = $rowColor1;
1300: } else {
1301: $rowColor = $rowColor2;
1302: }
1303: my ($map,$id,$url)=&Apache::lonnet::decode_symb($item);
1304: my $linkurl=&Apache::lonnet::clutter($url);
1305: $linkurl .= '?symb='.&Apache::lonnet::escape($item);
1306:
1307: $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>');
1308: $changenum ++;
1309: }
1310: } else {
1311: $r->print('<tr><td bgcolor="#ffffff"><br /><center><b><i><small>'.$lt{'noup'}.' '.$interval.'</small></i></b></center><br /></td></tr>');
1312: }
1313: return;
1314: }
1315:
1316: sub display_coursediscussion {
1.37 raeburn 1317: my ($r,$newdiscussions,$unread,$countunread,$res_title,$rowColor1,
1318: $rowColor2) = @_;
1.33 raeburn 1319: my %lt = &Apache::lonlocal::texthash(
1320: 'loca' => 'Location',
1321: 'type' => 'Type',
1322: 'numn' => 'Number of new posts',
1323: 'noun' => 'No unread posts in course discussions',
1.37 raeburn 1324: 'tmlp' => 'Time of last post',
1.33 raeburn 1325: );
1326: my $rowColor;
1327: if (@{$newdiscussions} > 0) {
1328: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'loca'}.
1329: '</small></b></td><td><b><small>'.$lt{'type'}.
1.37 raeburn 1330: '</small></b>');
1.39 raeburn 1331: if ($countunread eq 'on') {
1.37 raeburn 1332: $r->print('<td><b><small>'.$lt{'tmlp'}.'</small></b></td>'.
1333: '<td align="right"><b><small>'.$lt{'numn'}.
1334: '</small></b></td>');
1335: } else {
1336: $r->print('<td align="right"><b><small>'.$lt{'tmlp'}.
1337: '</small></b></td>');
1338: }
1339: $r->print("</tr>\n");
1.33 raeburn 1340: @{$newdiscussions} = sort { &cmp_title($a,$b,$res_title) }
1341: @{$newdiscussions};
1342: my $rowNum = 0;
1343: foreach my $ressymb (@{$newdiscussions}) {
1344: my $forum_title = $$unread{$ressymb}{'title'};
1345: my $type = 'Resource';
1346: my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
1347: if ($feedurl =~ /bulletinboard/) {
1348: $type = 'Bulletin Board';
1349: }
1.37 raeburn 1350: if ($rowNum %2 == 1) {
1351: $rowColor = $rowColor1;
1352: } else {
1353: $rowColor = $rowColor2;
1354: }
1355: my $lastpost = &Apache::lonnavmaps::timeToHumanString(
1356: $$unread{$ressymb}{'lastpost'});
1357: $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 1358: if ($countunread eq 'on') {
1.37 raeburn 1359: my $unreadnum = $$unread{$ressymb}{'unreadcount'};
1360: $r->print('<td><small>'.$lastpost.'<small></td><td align="right">'.
1361: '<small>',$unreadnum.' </small></td>');
1362: } else {
1363: $r->print('<td align="right"><small>'.$lastpost.'</small></td>');
1.33 raeburn 1364: }
1.37 raeburn 1365: $r->print("</tr>\n");
1366: $rowNum ++;
1.33 raeburn 1367: }
1368: } else {
1369: $r->print('<tr><td bgcolor="#ffffff"><br><center> <i><b><small>'.
1370: $lt{'noun'}.'</small></b></i><br><br></td></tr>');
1371: }
1372: }
1373:
1374: sub display_coursenormalmail {
1375: my ($r,$msgcount,$newmsgs,$rowColor1,$rowColor2) = @_;
1376: my $rowColor;
1377: if ($msgcount > 0) {
1378: $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>');
1379: my $rowNum = 0;
1380: my $mailcount = 1;
1381: foreach my $msg (@{$newmsgs}) {
1382: if ($rowNum %2 == 1) {
1383: $rowColor = $rowColor1;
1384: } else {
1385: $rowColor = $rowColor2;
1386: }
1387: $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>');
1388: $rowNum ++;
1389: $mailcount ++;
1390: }
1391: } else {
1392: $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>');
1393: }
1394: }
1395:
1396: sub display_coursecritmail {
1397: my ($r,$critmsgcount,$critmsgs,$rowColor1,$rowColor2) = @_;
1398: my $rowColor;
1399: if ($critmsgcount > 0) {
1400: $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>');
1401: my $rowNum = 0;
1402: my $mailcount = 1;
1403: foreach my $msg (@{$critmsgs}) {
1404: if ($rowNum %2 == 1) {
1405: $rowColor = $rowColor1;
1406: } else {
1407: $rowColor = $rowColor2;
1408: }
1409: $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>');
1410: $rowNum ++;
1411: $mailcount ++;
1412: }
1413: } else {
1414: $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>');
1415: }
1.1 raeburn 1416: }
1417:
1418: sub cmp_title {
1.16 raeburn 1419: my ($a,$b,$res_title) = @_;
1420: my ($atitle,$btitle) = (lc($$res_title{$a}),lc($$res_title{$b}));
1.1 raeburn 1421: $atitle=~s/^\s*//;
1422: $btitle=~s/^\s*//;
1423: return $atitle cmp $btitle;
1424: }
1425:
1.33 raeburn 1426: sub get_display_settings {
1.36 raeburn 1427: my ($uname,$udom,$cid) = @_;
1.33 raeburn 1428: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid);
1429: my ($tmp) = keys(%settings);
1.40 raeburn 1430: if ($tmp=~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 1431: %settings = ();
1.41 raeburn 1432: unless ($tmp =~ /^error: 2 /) {
1433: &Apache::lonnet::logthis('Error retrieving whatsnew settings: '.
1434: $tmp.' for '.$uname.':'.$udom.' for course: '.$cid);
1.33 raeburn 1435: }
1436: }
1437: return %settings;
1438: }
1439:
1.36 raeburn 1440: sub store_display_settings {
1441: my ($uname,$udom,$cid,$checkallowed) = @_;
1442: my %whatsnew_settings;
1443: my $result;
1444: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 1445: if ($key =~ /_section$/) { next; }
1.36 raeburn 1446: if (exists($env{'form.display_'.$key})) {
1447: unless ($env{'form.display_'.$key} eq '') {
1448: $whatsnew_settings{$cid.':'.$key} = $env{'form.display_'.$key};
1449: }
1450: }
1451: }
1452: if (keys(%whatsnew_settings)) {
1453: $result = &Apache::lonnet::put('nohist_whatsnew',\%whatsnew_settings,
1454: $udom,$uname);
1455: } else {
1456: $result = 'ok';
1457: }
1458: return $result;
1459: }
1460:
1461: sub store_interval_setting {
1462: my ($uname,$udom,$cid,$interval_titles) = @_;
1463: my %interval_settings = ();
1464: my $result;
1465: if (defined($env{'form.interval'})) {
1466: $interval_settings{$cid.':interval'} = $env{'form.interval'};
1467: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
1468: \%interval_settings,$udom,$uname);
1469: if ($outcome eq 'ok') {
1470: $result = &mt('Interval set to version changes [_1]',
1471: '<b>'.$$interval_titles{$env{'form.interval'}}.'</b><br />');
1472:
1473: } else {
1474: &Apache::lonnet::logthis('Error storing whatsnew interval setting'.
1475: ' '.$outcome.' for '.$uname.':'.$udom.' in course '.$cid);
1476: $result = &mt('Unable to set interval to [_1] due to [_2].',
1477: '<b>'.$$interval_titles{$env{'form.interval'}}.'</b>',
1478: '<tt>'.$outcome.'</tt>.<br />');
1479: }
1480: }
1481: return $result;
1482: }
1483:
1.39 raeburn 1484: sub store_discussion_setting {
1485: my ($uname,$udom,$cid) = @_;
1486: my %discussion_settings;
1487: my $result;
1488: if (defined($env{'form.countunread'})) {
1489: $discussion_settings{$cid.':countunread'} = $env{'form.countunread'};
1490: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
1491: \%discussion_settings,$udom,$uname);
1492: if ($outcome eq 'ok') {
1493: $result = &mt('Count unread posts in discussions display set to [_1]',
1494: '<b>'.$env{'form.countunread'}.'</b><br />');
1495:
1496: } else {
1497: &Apache::lonnet::logthis('Error storing whatsnew countunread setting'.
1498: ' '.$outcome.' for '.$uname.':'.$udom.' in course '.$cid);
1499: $result = &mt('Unable to set "number unread posts display" to [_1]'.
1500: ' due to [_2].',
1501: '<b>'.$env{'form.countunread'}.'</b>',
1502: '<tt>'.$outcome.'</tt>.<br />');
1503: }
1504: }
1505: return $result;
1506: }
1507:
1508: sub store_courseinit_setting {
1509: my ($uname,$udom,$cid,$initpage) = @_;
1510: my %courseinit_settings;
1511: my $page_control;
1512: my $result;
1513: if (defined($env{'form.courseinit_control'})) {
1514: if ($env{'form.courseinit_control'} eq 'userpref') {
1515: $courseinit_settings{$cid.':courseinit'} = '';
1516: $page_control = 'global preferences';
1517: } else {
1518: if (defined($env{'form.courseinit_page'})) {
1519: $courseinit_settings{$cid.':courseinit'} =
1520: $env{'form.courseinit_page'};
1521: $page_control = 'course specific setting';
1522: }
1523: }
1524: if ($page_control) {
1525: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
1526: \%courseinit_settings,$udom,$uname);
1527: if ($outcome eq 'ok') {
1528: if ($page_control eq 'global preferences') {
1529: $result = &mt('Page displayed after role selection in course now set by [_1]',"<b>user's global preferences</b>.");
1530: } else {
1531: $result = &mt('Page displayed after role selection in this course set to [_1]','<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>.');
1532: }
1533: } else {
1534: &Apache::lonnet::logthis('Error storing whatsnew courseinit '.
1535: 'setting: '.$outcome.' for '.$uname.
1536: ':'.$udom.' in course '.$cid);
1537: if ($page_control eq 'global preferences') {
1538: $result = &mt('Unable to set control of page display to [_1]'.
1539: ' due to [_2].',
1540: '<b>'.$page_control.'</b>',
1541: '<tt>'.$outcome.'</tt>.<br />');
1542: } else {
1543: $result = &mt('Unable to set page display, after role selection, for this course to [_1] due to [_2].',
1544: '<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>',
1545: '<tt>'.$outcome.'</tt>.<br />');
1546: }
1547: }
1548: }
1549: }
1550: return $result;
1551: }
1552:
1.33 raeburn 1553: sub start_box {
1.39 raeburn 1554: my ($r,$tabbg,$show,$heading,$caller,$refpage) = @_;
1.33 raeburn 1555: my %lt = &Apache::lonlocal::texthash(
1556: chth => 'Change thresholds?',
1557: chin => 'Change interval?',
1.39 raeburn 1558: chop => 'Change options?',
1.33 raeburn 1559: );
1560: my $showhide;
1561: if ($$show{$caller}) {
1.36 raeburn 1562: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1563: 'display_'.$caller.",'hide'".');">Hide</a></b>';
1.33 raeburn 1564:
1565: } else {
1.36 raeburn 1566: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1567: 'display_'.$caller.",'show'".');">Show</a></b>';
1.33 raeburn 1568: }
1569:
1570: $r->print('
1571: <table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000" width="100%">
1572: <tr>
1573: <td>
1574: <table border="0" cellpadding="1" cellspacing="1" bgcolor="#000000" width="100%">
1575: <tr>
1576: <td bgcolor="'.$tabbg.'">
1577: <table width="100%" border="0" cellspacing="0" cellpadding="0">
1578: <tr>
1579: <td><b>'.$$heading{$caller}.'</b></td>
1580: <td valign="top" align="right">'.$showhide.'</td>
1581: </tr>
1582: </table>
1583: </td>
1584: </tr>');
1585: if (($caller eq 'abovethreshold') && ($$show{$caller})) {
1.40 raeburn 1586: if ($$show{$caller}) {
1587: $r->print('
1.33 raeburn 1588: <tr>
1.39 raeburn 1589: <td bgcolor="'.$tabbg.'" align="right"><a href="/adm/whatsnew?command=chgthreshold&refpage='.$refpage.'"><b><small>'.$lt{'chth'}.'</small></b></a></td>
1.33 raeburn 1590: </tr>');
1.40 raeburn 1591: }
1.33 raeburn 1592: } elsif (($caller eq 'versionchanges') && ($$show{$caller})) {
1.40 raeburn 1593: if ($$show{$caller}) {
1594: $r->print('
1.33 raeburn 1595: <tr>
1.39 raeburn 1596: <td bgcolor="'.$tabbg.'" align="right"><a href="/adm/whatsnew?command=chginterval&refpage='.$refpage.'"><b><small>'.$lt{'chin'}.'</small></b></a></td>
1597: </tr>');
1.40 raeburn 1598: }
1.39 raeburn 1599: } elsif ($caller eq 'coursediscussion') {
1.40 raeburn 1600: if ($$show{$caller}) {
1601: $r->print('
1.39 raeburn 1602: <tr>
1603: <td bgcolor="'.$tabbg.'" align="right"><a href="/adm/whatsnew?command=chgdisc&refpage='.$refpage.'"><b><small>'.$lt{'chop'}.'</small></b></a></td>
1.33 raeburn 1604: </tr>');
1.40 raeburn 1605: }
1.33 raeburn 1606: }
1607: $r->print('
1608: <tr>
1609: <td bgcolor="#ffffff">
1610: <table cellpadding="2" cellspacing="0" border="0" width="100%">
1611: ');
1612: return;
1613: }
1614:
1615: sub end_box {
1616: my ($r) = shift;
1617: $r->print('
1618: </table>
1619: </td>
1620: </tr>
1621: </table>
1622: </td>
1623: </tr>
1624: </table><br />');
1625: return;
1626: }
1627:
1.7 raeburn 1628: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>