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