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