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