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