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