Annotation of loncom/interface/lonwhatsnew.pm, revision 1.56
1.2 albertel 1: #
1.56 ! raeburn 2: # $Id: lonwhatsnew.pm,v 1.55 2006/05/30 12:46:09 www 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'}) {
772: &check_thresholds($resource,$symb,\%resourcetracker,$triggered,
773: $threshold,$warnings,$warningnum,$rowColor1,$rowColor2);
774: }
775:
776: }
777: }
778:
779: sub check_discussions {
1.51 albertel 780: my ($resource,$symb,$ressymb,$title,$newdiscussions,$unread,
781: $countunread) = @_;
782:
783: if (!$resource->hasDiscussion()) { return; }
1.37 raeburn 784:
1.51 albertel 785: %{$$unread{$ressymb}} = ();
786: $$unread{$ressymb}{'title'} = $title;
787: $$unread{$ressymb}{'symb'} = $symb;
788: push(@{$newdiscussions}, $ressymb);
789:
790: $$unread{$ressymb}{'lastpost'} = $resource->last_post_time();
791:
792: if ($countunread eq 'on') {
793: $$unread{$ressymb}{'unreadcount'} = $resource->unread_discussion();
1.33 raeburn 794: }
795: }
796:
797: sub check_handgraded {
798: my ($resource,$symb,$title,$cdom,$cnum,$ungraded,$tograde) = @_;
799: if ($resource->is_problem()) {
800: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
801: my $partlist=$resource->parts();
802: my $handgradeable;
803: foreach my $part (@$partlist) {
1.31 raeburn 804: if ($resource->handgrade($part) eq 'yes') {
1.33 raeburn 805: $handgradeable=1; last;
1.31 raeburn 806: }
1.33 raeburn 807: }
808: if ($handgradeable) {
1.35 raeburn 809: my @ungraded = &Apache::bridgetask::get_queue_symb_status(
1.33 raeburn 810: 'gradingqueue',$symb,$cdom,$cnum);
811: if (@ungraded > 0) {
812: $$ungraded{$symb}{count} = scalar(@ungraded);
813: $$ungraded{$symb}{title} = $title;
814: push(@{$tograde}, $symb);
1.11 raeburn 815: }
816: }
1.33 raeburn 817: }
818: }
819:
820: sub check_bombed {
821: my ($resource,$symb,$title,$bombs,$bombed) = @_;
822: if ($resource->getErrors()) {
823: my $errors = $resource->getErrors();
824: $errors =~ s/^,//;
825: my @bombs = split(/,/, $errors);
826: my $errorcount = scalar(@bombs);
827: my $errorlink = '<a href="/adm/email?display='.
1.55 www 828: &escape($bombs[0]).'">'.
1.33 raeburn 829: $title.'</a>';
830: $$bombed{$symb}{errorcount} = $errorcount;
831: $$bombed{$symb}{errorlink} = $errorlink;
832: push(@{$bombs}, $symb);
833: }
834: }
835:
836: sub check_thresholds {
837: my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings,
838: $warningnum,$rowColor1,$rowColor2) = @_;
839: # Compile maxtries and degree of difficulty for problem parts, unless handgradeable
840: my @parts = @{$resource->parts()};
841: my %stats;
842: my %lastreset = ();
843: my $warning = 0;
844: my $rowColor;
845: foreach my $part (@parts) {
846: if ($resource->handgrade($part) eq 'yes') {
847: next;
848: }
1.48 raeburn 849: if ($resource->is_survey($part)) {
850: next;
851: }
1.33 raeburn 852: %{$stats{$part}} = ();
853: my ($attempts,$users,$corrects,$degdiff,$av_attempts);
854: if (exists($$resourcetracker{$symb."\0".$part."\0attempts"})) {
855: $attempts = $$resourcetracker{$symb."\0".$part."\0attempts"};
856: }
857: if (exists($$resourcetracker{$symb."\0".$part."\0users"})) {
858: $users = $$resourcetracker{$symb."\0".$part."\0users"};
859: }
860: if (exists($$resourcetracker{$symb."\0".$part."\0correct"})) {
861: $corrects = $$resourcetracker{$symb."\0".$part."\0correct"};
862: }
863: if ($attempts > 0) {
864: $degdiff = 1 - ($corrects/$attempts);
865: $degdiff = sprintf("%.2f",$degdiff);
866: }
867: if ($users > 0) {
868: $av_attempts = $attempts/$users;
869: $av_attempts = sprintf("%.2f",$av_attempts);
870: }
871: if ((($degdiff ne '' && $degdiff >= $$threshold{'degdiff'}) || ($av_attempts ne '' && $av_attempts >= $$threshold{'av_attempts'})) && ($users >= $$threshold{'numstudents'})) {
872: $stats{$part}{degdiff} = $degdiff;
873: $stats{$part}{attempts} = $av_attempts;
874: $stats{$part}{users} = $users;
875: $lastreset{$part} = $$resourcetracker{$symb."\0".$part."\0resettime"};
876: if ($lastreset{$part}) {
877: $lastreset{$part} = &Apache::lonnavmaps::timeToHumanString($lastreset{$part});
1.11 raeburn 878: }
1.33 raeburn 879: $warning = 1;
880: }
881: }
882: if ($warning) {
1.56 ! raeburn 883: if ($$warningnum %2 == 1) {
1.33 raeburn 884: $rowColor = $rowColor1;
885: } else {
886: $rowColor = $rowColor2;
887: }
1.56 ! raeburn 888: $$triggered{$symb}{rowColor} = $rowColor;
1.33 raeburn 889: $$triggered{$symb}{title} = $resource->title;
890: foreach my $part (@parts) {
891: if (exists($stats{$part}{users})) {
1.55 www 892: my $resetname = 'reset_'.&escape($symb."\0".$part);
893: my $resettitle = 'title_'.&escape($symb."\0".$part);
1.33 raeburn 894: if ($$triggered{$symb}{numparts}) {
895: $$triggered{$symb}{text} .= '<tr bgcolor="'.$rowColor.'">'."\n";
896: }
897: if (@parts > 1) {
898: $$triggered{$symb}{text} .= '
899: <td align="right"><small>part - '.$part.'<small></td>';
900: } else {
1.11 raeburn 901: $$triggered{$symb}{text} .= '
1.33 raeburn 902: <td align="right"><small>single part</small></td>';
1.11 raeburn 903: }
1.33 raeburn 904: $$triggered{$symb}{text} .= '
905: <td align="right"><small>'.$stats{$part}{users}.'</small></td>
906: <td align="right"><small>'.$stats{$part}{attempts}.'</small></td>
907: <td align="right"><small>'.$stats{$part}{degdiff}.'</small></td>
908: <td align="right"><small>'.$lastreset{$part}.'</small></td>
1.55 www 909: <td align="right"><small><input type="checkbox" name="'.$resetname.'" /><input type="hidden" name="'.$resettitle.'" value="'.&escape($$triggered{$symb}{title}).'" /></td>
1.33 raeburn 910: </tr>';
911: $$triggered{$symb}{numparts} ++;
1.11 raeburn 912: }
913: }
1.33 raeburn 914: push(@{$warnings},$symb);
1.56 ! raeburn 915: $$warningnum ++;
1.1 raeburn 916: }
917: }
918:
1.33 raeburn 919:
1.13 raeburn 920: sub get_curr_thresholds {
1.39 raeburn 921: my ($threshold,$uname,$udom,$cid,$cdom,$crs) = @_;
922: my %thresholdsettings = &Apache::lonnet::dump('nohist_whatsnew',$udom,
923: $uname,$cid.':threshold');
924: my $thresholdcount = 0;
925: my ($tmp) = %thresholdsettings;
1.40 raeburn 926: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 927: foreach my $item (keys %{$threshold}) {
928: if (exists($thresholdsettings{$cid.':threshold_'.$item})) {
929: $$threshold{$item} =
930: $thresholdsettings{$cid.':threshold_'.$item};
931: $thresholdcount ++;
932: }
933: }
1.13 raeburn 934: }
1.39 raeburn 935: if ($thresholdcount == 3) {
936: return;
1.13 raeburn 937: }
1.39 raeburn 938: my %coursesettings = &Apache::lonnet::dump('environment',
939: $cdom,$crs,'internal.threshold');
940: my ($temp) = %coursesettings;
1.40 raeburn 941: unless ($temp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 942: foreach my $item (keys %{$threshold}) {
943: unless (exists($thresholdsettings{$cid.':threshold_'.$item})) {
944: if (exists($coursesettings{'internal.threshold_'.$item})) {
945: $$threshold{$item} =
946: $coursesettings{'internal.threshold_'.$item};
947: }
948: }
949: }
1.13 raeburn 950: }
1.39 raeburn 951: return;
1.13 raeburn 952: }
953:
1.39 raeburn 954: sub get_current {
955: my ($uname,$udom,$cid,$caller) = @_;
956: my $currvalue;
957: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid.
958: ':'.$caller);
1.36 raeburn 959: my ($tmp) = %settings;
1.40 raeburn 960: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 961: $currvalue = $settings{$cid.':'.$caller};
1.36 raeburn 962: }
1.39 raeburn 963: return $currvalue;
1.36 raeburn 964: }
965:
1.13 raeburn 966: sub process_reset {
967: my ($dom,$crs) = @_;
1.39 raeburn 968: my $result = '<b>'.&mt('Counters reset for following problems (and parts):').
969: '</b><br />';
1.13 raeburn 970: my @agg_types = ('attempts','users','correct');
1.39 raeburn 971: my %agg_titles = &Apache::lonlocal::texthash (
1.13 raeburn 972: attempts => 'Number of submissions',
973: users => 'Students with submissions',
974: correct => 'Number of correct submissions',
975: );
976: my @resets = ();
977: my %titles = ();
1.17 albertel 978: foreach my $key (keys(%env)) {
1.13 raeburn 979: next if ($key !~ /^form\.reset_(.+)$/);
1.55 www 980: my $title = &unescape($env{'form.title_'.$1});
981: my $reset_item = &unescape($1);
1.13 raeburn 982: my %curr_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
983: my %aggregates = ();
1.17 albertel 984: my ($symb,$part) = split(/\0/,$reset_item);
1.13 raeburn 985: foreach my $type (@agg_types) {
986: $aggregates{$reset_item."\0".$type} = 0;
987: }
1.17 albertel 988: $aggregates{$reset_item."\0".'resettime'} = time;
1.13 raeburn 989: my $putresult = &Apache::lonnet::put('nohist_resourcetracker',\%aggregates,
990: $dom,$crs);
991: if ($putresult eq 'ok') {
992: $result .= $title.' -part '.$part.': ';
993: my %new_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
994: foreach my $type (@agg_types) {
995: $result .= $agg_titles{$type}.' = '.$new_aggregates{$reset_item."\0".$type}.'; ';
996: }
997: $result =~ s/; $//;
998: $result .= '<br />';
999: } else {
1.14 albertel 1000: $result = $title.' -part '.$part.': '.&mt('Unable to reset counters to zero due to [_1]',$putresult).'.<br />'."\n";
1.13 raeburn 1001: }
1002: }
1003: return $result;
1004: }
1005:
1006: sub process_update {
1.39 raeburn 1007: my ($uname,$udom,$threshold_titles) = @_;
1.15 raeburn 1008: my $setoutput = '<b>Changes to threshold(s) for problem tracking:</b><br />';
1.13 raeburn 1009: foreach (keys %env) {
1010: next if ($_!~/^form\.(.+)\_setparmval$/);
1011: my $name = $1;
1012: my $value = $env{'form.'.$name.'_value'};
1013: if ($name && defined($value)) {
1.39 raeburn 1014: my $put_result = &Apache::lonnet::put('nohist_whatsnew',
1015: {$name=>$value},$udom,$uname);
1.13 raeburn 1016:
1.39 raeburn 1017: my ($shortname) = ($name =~ /^\Q$env{'request.course.id'}\E:threshold_(.+)$/);
1.13 raeburn 1018: if ($put_result eq 'ok') {
1.14 albertel 1019: $setoutput.=&mt('Set threshold for [_1] to [_2]',
1020: '<b>'.$$threshold_titles{$shortname}.'</b>',
1021: '<b>'.$value.'</b>').'<br />';
1022: } else {
1023: $setoutput.=&mt('Unable to set threshold for [_1] to [_2] due to [_3].',
1024: '<b>'.$name.'</b>','<b>'.$value.'</b>',
1025: '<tt>'.$put_result.'</tt>').'<br />';
1.13 raeburn 1026: }
1027: }
1028: }
1029: return $setoutput;
1030: }
1031:
1.33 raeburn 1032: sub getnormalmail {
1033: my ($newmsgs) = @_;
1.1 raeburn 1034: # Check for unread mail in course
1035: my $msgcount = 0;
1.3 albertel 1036:
1.10 raeburn 1037: my @messages = sort(&Apache::lonnet::getkeys('nohist_email'));
1.3 albertel 1038: foreach my $message (@messages) {
1.55 www 1039: my $msgid=&escape($message);
1.10 raeburn 1040: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1.1 raeburn 1041: &Apache::lonmsg::unpackmsgid($msgid);
1.10 raeburn 1042: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 1043: if (defined($sendtime) && $sendtime!~/error/) {
1044: my $numsendtime = $sendtime;
1045: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
1046: if ($status eq 'new') {
1.10 raeburn 1047: $msgcount ++;
1048: if ($shortsubj eq '') {
1049: $shortsubj = &mt('No subject');
1050: }
1.1 raeburn 1051: push(@{$newmsgs}, {
1052: msgid => $msgid,
1053: sendtime => $sendtime,
1.10 raeburn 1054: shortsub => $shortsubj,
1.1 raeburn 1055: from => $fromname,
1056: fromdom => $fromdom
1057: });
1058: }
1059: }
1060: }
1061: }
1.33 raeburn 1062: return $msgcount;
1063: }
1.1 raeburn 1064:
1.33 raeburn 1065: sub getcritmail {
1066: my ($critmsgs) = @_;
1.1 raeburn 1067: # Check for critical messages in course
1068: my %what=&Apache::lonnet::dump('critical');
1069: my $result = '';
1070: my $critmsgcount = 0;
1.3 albertel 1071: foreach my $msgid (sort(keys(%what))) {
1.10 raeburn 1072: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1073: &Apache::lonmsg::unpackmsgid($msgid);
1074: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 1075: if (defined($sendtime) && $sendtime!~/error/) {
1076: my $numsendtime = $sendtime;
1077: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
1078: $critmsgcount ++;
1.10 raeburn 1079: if ($shortsubj eq '') {
1080: $shortsubj = &mt('No subject');
1081: }
1.1 raeburn 1082: push(@{$critmsgs}, {
1083: msgid => $msgid,
1084: sendtime => $sendtime,
1.10 raeburn 1085: shortsub => $shortsubj,
1.1 raeburn 1086: from => $fromname,
1087: fromdom => $fromdom
1088: });
1089: }
1090: }
1091: }
1.33 raeburn 1092: return $critmsgcount;
1093: }
1094:
1095:
1096: sub checkversions {
1097: my ($cdom,$crs,$navmap,$changed,$starttime) = @_;
1098: my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs);
1099: my ($tmp) = keys(%changes);
1.40 raeburn 1100: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 1101: if (keys(%changes) > 0) {
1102: foreach my $key (sort(keys(%changes))) {
1103: if ($changes{$key} > $starttime) {
1104: my $version;
1105: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
1106: my $currentversion=&Apache::lonnet::getversion($key);
1107: my $revdate =
1108: &Apache::lonnet::metadata($root.'.'.$extension,
1109: 'lastrevisiondate');
1110: $revdate = &Apache::lonlocal::locallocaltime($revdate);
1111: my $linkurl=&Apache::lonnet::clutter($key);
1112: my $usedversion=$navmap->usedVersion('version_'.$linkurl);
1113: my @resources = $navmap->getResourceByUrl($linkurl,1);
1114: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1115: $version = $usedversion;
1116: } else {
1117: $version = $currentversion;
1118: }
1119: foreach my $res (@resources) {
1.35 raeburn 1120: if (ref($res) eq 'Apache::lonnavmaps::resource') {
1121: my $symb = $res->symb();
1122: %{$$changed{$symb}} = (
1.33 raeburn 1123: current => $currentversion,
1124: version => $version,
1125: revdate => $revdate,
1.35 raeburn 1126: );
1127: }
1.33 raeburn 1128: }
1129: }
1130: }
1131: }
1132: }
1133: return;
1134: }
1135:
1136: sub display_handgrade {
1137: my ($r,$tograde,$rowColor1,$rowColor2,$ungraded) = @_;
1138: my $rowColor;
1139: my %lt = &Apache::lonlocal::texthash(
1140: 'prna' => 'Problem Name',
1141: 'nmun' => 'Number ungraded',
1142: 'nopr' => 'No problems require handgrading',
1143: );
1144: if (@{$tograde} > 0) {
1145: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'prna'}.'</small></b></td><td align="right"><b><small>'.$lt{'nmun'}.'</small></b></td></tr>');
1146: my $rowNum = 0;
1147: foreach my $res (@{$tograde}) {
1148: if ($rowNum %2 == 1) {
1149: $rowColor = $rowColor1;
1150: } else {
1151: $rowColor = $rowColor2;
1152: }
1153: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
1154: my $linkurl=&Apache::lonnet::clutter($url);
1.55 www 1155: $linkurl .= '?symb='.&escape($res);
1.33 raeburn 1156:
1157: $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>');
1158: $rowNum ++;
1159: }
1160: } else {
1161: $r->print('<tr><td bgcolor="#ffffff"><br><center><i><b><small> '.$lt{'nopr'}.' </small><br><br></b></i></td></tr>');
1162: }
1163: }
1164:
1165: sub display_haserrors {
1166: my ($r,$bombs,$rowColor1,$rowColor2,$bombed,$res_title) = @_;
1167: my $bombnum = 0;
1168: my $rowColor;
1169: my %lt = &Apache::lonlocal::texthash(
1170: reso => 'Resource',
1171: nmer => 'Number of errors',
1172: noer => 'No problems with errors',
1173: );
1174: if (@{$bombs} > 0) {
1175: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'reso'}.'</small></b></td><td align="right"><b><small>'.$lt{'nmer'}.'</small></b></td></tr>');
1176: @{$bombs} = sort { &cmp_title($a,$b,$res_title) } @{$bombs};
1177: foreach my $bomb (@{$bombs}) {
1178: if ($bombnum %2 == 1) {
1179: $rowColor = $rowColor1;
1180: } else {
1181: $rowColor = $rowColor2;
1182: }
1183: $r->print('<tr bgcolor="'.$rowColor.'"><td><small>'.$$bombed{$bomb}{errorlink}.'</small></td><td align="right"><small>'.$$bombed{$bomb}{errorcount}.'</small></td></tr>');
1184: $bombnum ++;
1185: }
1186: } else {
1187: $r->print('<tr><td bgcolor="#ffffff"><br /><center><b><i><small>'.$lt{'noer'}.'</small></i></b></center><br /></td></tr>');
1188: }
1189: return;
1190: }
1191:
1192: sub display_abovethreshold {
1.56 ! raeburn 1193: my ($r,$refpage,$warnings,$triggered,$res_title) = @_;
1.33 raeburn 1194: my %lt = &Apache::lonlocal::texthash(
1195: reso => 'Resource',
1196: part => 'Part',
1197: nust => 'Num. students',
1198: avat => 'Av. Attempts',
1199: dedi => 'Deg. Diff',
1200: lare => 'Last Reset',
1201: reco => 'Reset Count?',
1202: rese => 'Reset counters to 0',
1203: nopr => 'No problems satisfy threshold criteria',
1204: );
1205: if (@{$warnings} > 0) {
1206: @{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings};
1.36 raeburn 1207: $r->print('<form name="reset_tracking" method="post" action="/adm/whatsnew">'.
1.39 raeburn 1208: ' <input type="hidden" name="command" value="reset" />'."\n".
1209: ' <input type="hidden" name="refpage" value="'.$refpage.'" />'.
1210: "\n");
1.33 raeburn 1211: $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>');
1212: foreach my $res (@{$warnings}) {
1213: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
1214: my $linkurl=&Apache::lonnet::clutter($url);
1215: my $rowspan;
1216: if ($$triggered{$res}{numparts} > 1) {
1217: $rowspan = 'rowspan="'.$$triggered{$res}{numparts}.'"';
1218: }
1.55 www 1219: $linkurl .= '?symb='.&escape($res);
1.56 ! raeburn 1220: $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 1221: }
1.35 raeburn 1222: $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 1223: } else {
1224: $r->print('<tr><td bgcolor="#ffffff"><br /><center><b><i><small>'.$lt{'nopr'}.'</small></i></b></center><br /></td></tr>');
1225: }
1226: }
1227:
1228: sub display_versionchanges {
1229: my ($r,$changed,$res_title,$rowColor1,$rowColor2,$interval) = @_;
1230: my %lt = &Apache::lonlocal::texthash(
1231: 'reso' => 'Resource',
1232: 'revd' => 'Last revised',
1233: 'newv' => 'New version',
1234: 'veru' => 'Version used',
1235: 'noup' => 'No updated versions',
1236: );
1237: my $rowColor;
1238: if (keys(%{$changed}) > 0) {
1239: $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>');
1240:
1241:
1242: my @changes = sort { &cmp_title($a,$b,$res_title) } keys(%{$changed});
1243: my $changenum = 0;
1244: foreach my $item (@changes) {
1245: if ($changenum %2 == 1) {
1246: $rowColor = $rowColor1;
1247: } else {
1248: $rowColor = $rowColor2;
1249: }
1250: my ($map,$id,$url)=&Apache::lonnet::decode_symb($item);
1251: my $linkurl=&Apache::lonnet::clutter($url);
1.55 www 1252: $linkurl .= '?symb='.&escape($item);
1.33 raeburn 1253:
1254: $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>');
1255: $changenum ++;
1256: }
1257: } else {
1258: $r->print('<tr><td bgcolor="#ffffff"><br /><center><b><i><small>'.$lt{'noup'}.' '.$interval.'</small></i></b></center><br /></td></tr>');
1259: }
1260: return;
1261: }
1262:
1263: sub display_coursediscussion {
1.37 raeburn 1264: my ($r,$newdiscussions,$unread,$countunread,$res_title,$rowColor1,
1265: $rowColor2) = @_;
1.56 ! raeburn 1266: my $lctype = lc($env{'course.'.$env{'request.course.id'}.'.type'});
1.33 raeburn 1267: my %lt = &Apache::lonlocal::texthash(
1268: 'loca' => 'Location',
1269: 'type' => 'Type',
1270: 'numn' => 'Number of new posts',
1.56 ! raeburn 1271: 'noun' => 'No unread posts in '.$lctype.' discussions',
1.37 raeburn 1272: 'tmlp' => 'Time of last post',
1.33 raeburn 1273: );
1274: my $rowColor;
1275: if (@{$newdiscussions} > 0) {
1276: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.$lt{'loca'}.
1277: '</small></b></td><td><b><small>'.$lt{'type'}.
1.37 raeburn 1278: '</small></b>');
1.39 raeburn 1279: if ($countunread eq 'on') {
1.37 raeburn 1280: $r->print('<td><b><small>'.$lt{'tmlp'}.'</small></b></td>'.
1281: '<td align="right"><b><small>'.$lt{'numn'}.
1282: '</small></b></td>');
1283: } else {
1284: $r->print('<td align="right"><b><small>'.$lt{'tmlp'}.
1285: '</small></b></td>');
1286: }
1287: $r->print("</tr>\n");
1.33 raeburn 1288: @{$newdiscussions} = sort { &cmp_title($a,$b,$res_title) }
1289: @{$newdiscussions};
1290: my $rowNum = 0;
1291: foreach my $ressymb (@{$newdiscussions}) {
1292: my $forum_title = $$unread{$ressymb}{'title'};
1293: my $type = 'Resource';
1294: my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
1295: if ($feedurl =~ /bulletinboard/) {
1296: $type = 'Bulletin Board';
1297: }
1.37 raeburn 1298: if ($rowNum %2 == 1) {
1299: $rowColor = $rowColor1;
1300: } else {
1301: $rowColor = $rowColor2;
1302: }
1303: my $lastpost = &Apache::lonnavmaps::timeToHumanString(
1304: $$unread{$ressymb}{'lastpost'});
1305: $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 1306: if ($countunread eq 'on') {
1.37 raeburn 1307: my $unreadnum = $$unread{$ressymb}{'unreadcount'};
1308: $r->print('<td><small>'.$lastpost.'<small></td><td align="right">'.
1309: '<small>',$unreadnum.' </small></td>');
1310: } else {
1311: $r->print('<td align="right"><small>'.$lastpost.'</small></td>');
1.33 raeburn 1312: }
1.37 raeburn 1313: $r->print("</tr>\n");
1314: $rowNum ++;
1.33 raeburn 1315: }
1316: } else {
1317: $r->print('<tr><td bgcolor="#ffffff"><br><center> <i><b><small>'.
1318: $lt{'noun'}.'</small></b></i><br><br></td></tr>');
1319: }
1320: }
1321:
1322: sub display_coursenormalmail {
1323: my ($r,$msgcount,$newmsgs,$rowColor1,$rowColor2) = @_;
1324: my $rowColor;
1.56 ! raeburn 1325: my $lctype = lc($env{'course.'.$env{'request.course.id'}.'.type'});
1.33 raeburn 1326: if ($msgcount > 0) {
1327: $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>');
1328: my $rowNum = 0;
1329: my $mailcount = 1;
1330: foreach my $msg (@{$newmsgs}) {
1331: if ($rowNum %2 == 1) {
1332: $rowColor = $rowColor1;
1333: } else {
1334: $rowColor = $rowColor2;
1335: }
1336: $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>');
1337: $rowNum ++;
1338: $mailcount ++;
1339: }
1340: } else {
1.56 ! raeburn 1341: $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 1342: }
1343: }
1344:
1345: sub display_coursecritmail {
1346: my ($r,$critmsgcount,$critmsgs,$rowColor1,$rowColor2) = @_;
1347: my $rowColor;
1.56 ! raeburn 1348: my $lctype = lc($env{'course.'.$env{'request.course.id'}.'.type'});
1.33 raeburn 1349: if ($critmsgcount > 0) {
1350: $r->print('<tr bgcolor="#cccccc"><td><b><small>'.&mt('Number').'</small></b></td><td><b><small>'.&mt('Subject').'</small></b></td><td><b><small>'.&mt('Sender').'</small></b></td><td><b><small>'.&mt('Date/Time').'</small></b></td></tr>');
1351: my $rowNum = 0;
1352: my $mailcount = 1;
1353: foreach my $msg (@{$critmsgs}) {
1354: if ($rowNum %2 == 1) {
1355: $rowColor = $rowColor1;
1356: } else {
1357: $rowColor = $rowColor2;
1358: }
1359: $r->print('<tr bgcolor="'.$rowColor.'"><td valign="top"><small>'.$mailcount.'. <small></td><td valign="top"><small><a href="/adm/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>');
1360: $rowNum ++;
1361: $mailcount ++;
1362: }
1363: } else {
1.56 ! raeburn 1364: $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 1365: }
1.1 raeburn 1366: }
1367:
1368: sub cmp_title {
1.16 raeburn 1369: my ($a,$b,$res_title) = @_;
1370: my ($atitle,$btitle) = (lc($$res_title{$a}),lc($$res_title{$b}));
1.1 raeburn 1371: $atitle=~s/^\s*//;
1372: $btitle=~s/^\s*//;
1373: return $atitle cmp $btitle;
1374: }
1375:
1.33 raeburn 1376: sub get_display_settings {
1.36 raeburn 1377: my ($uname,$udom,$cid) = @_;
1.33 raeburn 1378: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid);
1379: my ($tmp) = keys(%settings);
1.40 raeburn 1380: if ($tmp=~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 1381: %settings = ();
1.41 raeburn 1382: unless ($tmp =~ /^error: 2 /) {
1.56 ! raeburn 1383: my $lctype = lc($env{'course.'.$env{'request.course.id'}.'.type'});
1.41 raeburn 1384: &Apache::lonnet::logthis('Error retrieving whatsnew settings: '.
1.56 ! raeburn 1385: $tmp.' for '.$uname.':'.$udom.' for '.$lctype.': '.$cid);
1.33 raeburn 1386: }
1387: }
1388: return %settings;
1389: }
1390:
1.36 raeburn 1391: sub store_display_settings {
1392: my ($uname,$udom,$cid,$checkallowed) = @_;
1393: my %whatsnew_settings;
1394: my $result;
1395: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 1396: if ($key =~ /_section$/) { next; }
1.36 raeburn 1397: if (exists($env{'form.display_'.$key})) {
1398: unless ($env{'form.display_'.$key} eq '') {
1399: $whatsnew_settings{$cid.':'.$key} = $env{'form.display_'.$key};
1400: }
1401: }
1402: }
1403: if (keys(%whatsnew_settings)) {
1404: $result = &Apache::lonnet::put('nohist_whatsnew',\%whatsnew_settings,
1405: $udom,$uname);
1406: } else {
1407: $result = 'ok';
1408: }
1409: return $result;
1410: }
1411:
1412: sub store_interval_setting {
1413: my ($uname,$udom,$cid,$interval_titles) = @_;
1414: my %interval_settings = ();
1415: my $result;
1416: if (defined($env{'form.interval'})) {
1417: $interval_settings{$cid.':interval'} = $env{'form.interval'};
1418: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
1419: \%interval_settings,$udom,$uname);
1420: if ($outcome eq 'ok') {
1421: $result = &mt('Interval set to version changes [_1]',
1422: '<b>'.$$interval_titles{$env{'form.interval'}}.'</b><br />');
1423:
1424: } else {
1.56 ! raeburn 1425: my $lctype = lc($env{'course.'.$env{'request.course.id'}.'.type'});
1.36 raeburn 1426: &Apache::lonnet::logthis('Error storing whatsnew interval setting'.
1.56 ! raeburn 1427: ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
1.36 raeburn 1428: $result = &mt('Unable to set interval to [_1] due to [_2].',
1429: '<b>'.$$interval_titles{$env{'form.interval'}}.'</b>',
1430: '<tt>'.$outcome.'</tt>.<br />');
1431: }
1432: }
1433: return $result;
1434: }
1435:
1.39 raeburn 1436: sub store_discussion_setting {
1437: my ($uname,$udom,$cid) = @_;
1438: my %discussion_settings;
1439: my $result;
1440: if (defined($env{'form.countunread'})) {
1441: $discussion_settings{$cid.':countunread'} = $env{'form.countunread'};
1442: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
1443: \%discussion_settings,$udom,$uname);
1444: if ($outcome eq 'ok') {
1445: $result = &mt('Count unread posts in discussions display set to [_1]',
1446: '<b>'.$env{'form.countunread'}.'</b><br />');
1447:
1448: } else {
1.56 ! raeburn 1449: my $lctype = lc($env{'course.'.$env{'request.course.id'}.'.type'});
1.39 raeburn 1450: &Apache::lonnet::logthis('Error storing whatsnew countunread setting'.
1.56 ! raeburn 1451: ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
1.39 raeburn 1452: $result = &mt('Unable to set "number unread posts display" to [_1]'.
1453: ' due to [_2].',
1454: '<b>'.$env{'form.countunread'}.'</b>',
1455: '<tt>'.$outcome.'</tt>.<br />');
1456: }
1457: }
1458: return $result;
1459: }
1460:
1461: sub store_courseinit_setting {
1462: my ($uname,$udom,$cid,$initpage) = @_;
1463: my %courseinit_settings;
1464: my $page_control;
1465: my $result;
1466: if (defined($env{'form.courseinit_control'})) {
1467: if ($env{'form.courseinit_control'} eq 'userpref') {
1468: $courseinit_settings{$cid.':courseinit'} = '';
1469: $page_control = 'global preferences';
1470: } else {
1471: if (defined($env{'form.courseinit_page'})) {
1472: $courseinit_settings{$cid.':courseinit'} =
1473: $env{'form.courseinit_page'};
1474: $page_control = 'course specific setting';
1475: }
1476: }
1477: if ($page_control) {
1.56 ! raeburn 1478: my $lctype = lc($env{'course.'.$env{'request.course.id'}.'.type'});
1.39 raeburn 1479: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
1480: \%courseinit_settings,$udom,$uname);
1481: if ($outcome eq 'ok') {
1482: if ($page_control eq 'global preferences') {
1.56 ! raeburn 1483: $result = &mt("Page displayed after role selection in [_1] now set by <b>user's global preferences</b>.",$lctype);
1.39 raeburn 1484: } else {
1.56 ! raeburn 1485: $result = &mt('Page displayed after role selection in this [_1] set to <b>[_2]</b>',$lctype,$$initpage{$env{'form.courseinit_page'}});
1.39 raeburn 1486: }
1487: } else {
1488: &Apache::lonnet::logthis('Error storing whatsnew courseinit '.
1489: 'setting: '.$outcome.' for '.$uname.
1.56 ! raeburn 1490: ':'.$udom.' in '.$lctype.' '.$cid);
1.39 raeburn 1491: if ($page_control eq 'global preferences') {
1492: $result = &mt('Unable to set control of page display to [_1]'.
1493: ' due to [_2].',
1494: '<b>'.$page_control.'</b>',
1495: '<tt>'.$outcome.'</tt>.<br />');
1496: } else {
1.56 ! raeburn 1497: $result = &mt('Unable to set page display, after role selection, for this [_1] to <b>[_2]</b> due to <tt>[_3]</tt>.<br />',$lctype,
! 1498: $$initpage{$env{'form.courseinit_page'}},$outcome);
1.39 raeburn 1499: }
1500: }
1501: }
1502: }
1503: return $result;
1504: }
1505:
1.33 raeburn 1506: sub start_box {
1.39 raeburn 1507: my ($r,$tabbg,$show,$heading,$caller,$refpage) = @_;
1.33 raeburn 1508: my %lt = &Apache::lonlocal::texthash(
1509: chth => 'Change thresholds?',
1510: chin => 'Change interval?',
1.39 raeburn 1511: chop => 'Change options?',
1.33 raeburn 1512: );
1513: my $showhide;
1514: if ($$show{$caller}) {
1.36 raeburn 1515: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1516: 'display_'.$caller.",'hide'".');">Hide</a></b>';
1.33 raeburn 1517:
1518: } else {
1.36 raeburn 1519: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1520: 'display_'.$caller.",'show'".');">Show</a></b>';
1.33 raeburn 1521: }
1522:
1523: $r->print('
1524: <table border="0" cellpadding="0" cellspacing="0" bgcolor="#000000" width="100%">
1525: <tr>
1526: <td>
1527: <table border="0" cellpadding="1" cellspacing="1" bgcolor="#000000" width="100%">
1528: <tr>
1529: <td bgcolor="'.$tabbg.'">
1530: <table width="100%" border="0" cellspacing="0" cellpadding="0">
1531: <tr>
1532: <td><b>'.$$heading{$caller}.'</b></td>
1533: <td valign="top" align="right">'.$showhide.'</td>
1534: </tr>
1535: </table>
1536: </td>
1537: </tr>');
1538: if (($caller eq 'abovethreshold') && ($$show{$caller})) {
1.40 raeburn 1539: if ($$show{$caller}) {
1540: $r->print('
1.33 raeburn 1541: <tr>
1.39 raeburn 1542: <td bgcolor="'.$tabbg.'" align="right"><a href="/adm/whatsnew?command=chgthreshold&refpage='.$refpage.'"><b><small>'.$lt{'chth'}.'</small></b></a></td>
1.33 raeburn 1543: </tr>');
1.40 raeburn 1544: }
1.33 raeburn 1545: } elsif (($caller eq 'versionchanges') && ($$show{$caller})) {
1.40 raeburn 1546: if ($$show{$caller}) {
1547: $r->print('
1.33 raeburn 1548: <tr>
1.39 raeburn 1549: <td bgcolor="'.$tabbg.'" align="right"><a href="/adm/whatsnew?command=chginterval&refpage='.$refpage.'"><b><small>'.$lt{'chin'}.'</small></b></a></td>
1550: </tr>');
1.40 raeburn 1551: }
1.39 raeburn 1552: } elsif ($caller eq 'coursediscussion') {
1.40 raeburn 1553: if ($$show{$caller}) {
1554: $r->print('
1.39 raeburn 1555: <tr>
1556: <td bgcolor="'.$tabbg.'" align="right"><a href="/adm/whatsnew?command=chgdisc&refpage='.$refpage.'"><b><small>'.$lt{'chop'}.'</small></b></a></td>
1.33 raeburn 1557: </tr>');
1.40 raeburn 1558: }
1.33 raeburn 1559: }
1560: $r->print('
1561: <tr>
1562: <td bgcolor="#ffffff">
1563: <table cellpadding="2" cellspacing="0" border="0" width="100%">
1564: ');
1565: return;
1566: }
1567:
1568: sub end_box {
1569: my ($r) = shift;
1570: $r->print('
1571: </table>
1572: </td>
1573: </tr>
1574: </table>
1575: </td>
1576: </tr>
1577: </table><br />');
1578: return;
1579: }
1580:
1.7 raeburn 1581: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>