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