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