Annotation of loncom/interface/lonwhatsnew.pm, revision 1.101.2.1.2.1
1.2 albertel 1: #
1.101.2.1.2.1! (raeburn 2:: # $Id: lonwhatsnew.pm,v 1.101.2.1 2011/05/12 16:53:02 raeburn Exp $
1.2 albertel 3: #
4: # Copyright Michigan State University Board of Trustees
5: #
6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
7: #
8: # LON-CAPA is free software; you can redistribute it and/or modify
9: # it under the terms of the GNU General Public License as published by
10: # the Free Software Foundation; either version 2 of the License, or
11: # (at your option) any later version.
12: #
13: # LON-CAPA is distributed in the hope that it will be useful,
14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: # GNU General Public License for more details.
17: #
18: # You should have received a copy of the GNU General Public License
19: # along with LON-CAPA; if not, write to the Free Software
20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21: #
22: # /home/httpd/html/adm/gpl.txt
23: #
24: # http://www.lon-capa.org/
25: #
26:
27:
1.1 raeburn 28: package Apache::lonwhatsnew;
29:
30: use strict;
31: use lib qw(/home/httpd/lib/perl);
32: use Apache::lonnet;
1.3 albertel 33: use Apache::loncommon();
34: use Apache::lonhtmlcommon();
1.1 raeburn 35: use Apache::lonlocal;
1.3 albertel 36: use Apache::loncoursedata();
37: use Apache::lonnavmaps();
1.18 raeburn 38: use Apache::lonuserstate;
1.77 raeburn 39: use Apache::lonuserutils;
1.1 raeburn 40: use Apache::Constants qw(:common :http);
41: use Time::Local;
1.24 albertel 42: use GDBM_File;
1.55 www 43: use lib '/home/httpd/lib/perl/';
44: use LONCAPA;
1.98 raeburn 45: use HTML::Entities;
1.1 raeburn 46:
47: #----------------------------
48: # handler
49: #
50: #----------------------------
51:
52: sub handler {
53: my $r = shift;
1.7 raeburn 54: if ($r->header_only) {
55: &Apache::loncommon::content_type($r,'text/html');
56: $r->send_http_header;
57: return OK;
58: }
1.39 raeburn 59: &Apache::loncommon::get_unprocessed_cgi(
60: $ENV{'QUERY_STRING'},['command','refpage']);
1.1 raeburn 61:
1.36 raeburn 62: my $command = $env{'form.command'};
1.39 raeburn 63: my $refpage = $env{'form.refpage'};
1.1 raeburn 64:
1.44 albertel 65: my %checkallowed = ( coursenormalmail => 1,
66: coursecritmail => 1, );
67: foreach my $perm_check (['whn','whatsnew',1],
68: ['pch','coursediscussion',1],
69: ['mgr','handgrading',1],
70: ['vgr','abovethreshold',1],
71: ['opa','haserrors',1],
72: ['mdc','versionchanges',0],
1.77 raeburn 73: ['vcl','newroles',1],
74: ['vcl','oldroles',1],
1.101.2.1.2.1! (raeburn 75:: ['whn','crslogin',1],
1.44 albertel 76: ) {
77: my ($perm,$key,$check_section) = @{ $perm_check };
78: my $scope = $env{'request.course.id'};
79: if (!($checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope))) {
80: $scope .= '/'.$env{'request.course.sec'};
81: if ( $check_section ) {
82: $checkallowed{$key} = &Apache::lonnet::allowed($perm,$scope);
83: }
84: if ($checkallowed{$key}) {
85: $checkallowed{$key.'_section'} = $env{'request.course.sec'};
86: }
87: }
88: }
1.43 albertel 89:
1.44 albertel 90: if ( ! $env{'request.course.fn'} || ! $checkallowed{'whatsnew'}) {
1.43 albertel 91: # Not in a course, or no whn priv in course
1.101.2.1 raeburn 92: $env{'user.error.msg'}="/adm/whatsnew:whn:0:0:Cannot display what's new page";
1.1 raeburn 93: return HTTP_NOT_ACCEPTABLE;
94: }
95:
1.44 albertel 96: &Apache::loncommon::content_type($r,'text/html');
97: $r->send_http_header;
1.36 raeburn 98:
99: $r->print(&display_header($command,\%checkallowed));
100:
1.7 raeburn 101: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.36 raeburn 102: &Apache::lonhtmlcommon::add_breadcrumb
103: ({href=>'/adm/whatsnew',
1.90 hauer 104: text=>"What's New?"});
1.44 albertel 105: if (($command eq 'chgthreshold') && $checkallowed{'abovethreshold'}) {
1.7 raeburn 106: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 107: ({href=>'/adm/whatsnew?command=chgthreshold&refpage='.$refpage,
1.13 raeburn 108: text=>"Change thresholds"});
1.7 raeburn 109: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 110: ("What's New?",#'Course_Action_Items_Thresholds'
1.49 albertel 111: ));
1.44 albertel 112: } elsif (($command eq 'chginterval') && $checkallowed{'versionchanges'} ) {
1.36 raeburn 113: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 114: ({href=>'/adm/whatsnew?command=chginterval&refpage='.$refpage,
1.36 raeburn 115: text=>"Change interval"});
116: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 117: ("What's New?",#'Course_Action_Items_Intervals'
1.49 albertel 118: ));
1.44 albertel 119: } elsif (($command eq 'chgdisc') && $checkallowed{'coursediscussion'}) {
1.39 raeburn 120: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 121: ({href=>'/adm/whatsnew?command=chgdisc&refpage='.$refpage,
1.39 raeburn 122: text=>"Change discussion display"});
123: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 124: ("What's New?",#'Course_Action_Items_Intervals'
1.49 albertel 125: ));
1.39 raeburn 126: } elsif ($command eq 'courseinit') {
127: &Apache::lonhtmlcommon::add_breadcrumb
1.73 raeburn 128: ({href=>'/adm/whatsnew?command=courseinit&refpage='.$refpage,
1.39 raeburn 129: text=>"Course initialization preference"});
130: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 131: ("What's New?",#'Course_Action_Items_Initialization'
1.49 albertel 132: ));
1.77 raeburn 133: } elsif ($command eq 'chgoldroleinterval' && $checkallowed{'oldroles'}) {
134: &Apache::lonhtmlcommon::add_breadcrumb
135: ({href=>'/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage,
136: text=>"Change interval"});
137: $r->print(&Apache::lonhtmlcommon::breadcrumbs
138: ("What's New?",#'Course_Action_Items_Intervals'
139: ));
140: } elsif ($command eq 'chgnewroleinterval' && $checkallowed{'newroles'}) {
141: &Apache::lonhtmlcommon::add_breadcrumb
142: ({href=>'/adm/whatsnew?command=chgnewroleinterval&refpage='.$refpage,
143: text=>"Change interval"});
144: $r->print(&Apache::lonhtmlcommon::breadcrumbs
145: ("What's New?",#'Course_Action_Items_Intervals'
146: ));
1.101.2.1.2.1! (raeburn 147:: } elsif ($command eq 'chgcrslogininterval' && $checkallowed{'crslogin'}) {
! 148:: &Apache::lonhtmlcommon::add_breadcrumb
! 149:: ({href=>'/adm/whatsnew?command=chgcrslogininterval&refpage='.$refpage,
! 150:: text=>"Change interval"});
! 151:: $r->print(&Apache::lonhtmlcommon::breadcrumbs
! 152:: ("What's New?",#'Course_Action_Items_Intervals'
! 153:: ));
1.7 raeburn 154: } else {
155: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.54 albertel 156: ("What's New?",#'Course_Action_Items_Display'
1.49 albertel 157: ));
1.7 raeburn 158: }
1.39 raeburn 159: &display_main_box($r,$command,$refpage,\%checkallowed);
1.14 albertel 160: return OK;
1.1 raeburn 161: }
162:
163: #------------------------------
164: # display_main_box
165: #
166: # Display all the elements within the main box
167: #------------------------------
168:
169: sub display_main_box {
1.39 raeburn 170: my ($r,$command,$refpage,$checkallowed) = @_;
1.1 raeburn 171: my $domain=&Apache::loncommon::determinedomain();
1.40 raeburn 172: my $function = &Apache::loncommon::get_users_function();
1.59 albertel 173: my $lctype = lc(&Apache::loncommon::course_type());
1.7 raeburn 174: $r->print('<table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td width="100%">');
1.13 raeburn 175:
1.39 raeburn 176: my %threshold_titles = &Apache::lonlocal::texthash (
1.13 raeburn 177: av_attempts => 'Average number of attempts',
178: degdiff => 'Degree of difficulty',
179: numstudents => 'Total number of students with submissions',
180: );
1.78 bisitz 181: my %versions = (
1.77 raeburn 182: -1 => "version changes since start of $lctype",
183: 2592000 => 'version changes since last month',
184: 604800 => 'version changes since last week',
185: 86400 => 'version changes since yesterday',
186: );
1.78 bisitz 187: my %newroles = (
1.77 raeburn 188: -1 => "roles which have become active since start of $lctype",
189: 2592000 => 'roles which have become active since last month',
190: 604800 => 'roles which have become active since last week',
191: 86400 => 'roles which have become active since yesterday',
192: );
1.78 bisitz 193: my %oldroles = (
1.77 raeburn 194: -1 => "roles which expired since start of $lctype",
195: 2592000 => 'roles which expired since last month',
196: 604800 => 'roles which expired since last week',
197: 86400 => 'roles which expired since yesterday',
198: );
1.101.2.1.2.1! (raeburn 199:: my %crslogins = (
! 200:: -1 => 'last logins for anyone who has ever logged in',
! 201:: 2592000 => 'last logins for users in last 30 days',
! 202:: 604800 => 'last logins for users in last 7 days',
! 203:: 86400 => 'last logins for users in last 24 hours',
! 204:: );
1.77 raeburn 205: my %interval_titles = (
206: versions => \%versions,
207: newroles => \%newroles,
208: oldroles => \%oldroles,
1.101.2.1.2.1! (raeburn 209:: crslogin => \%crslogins,
1.36 raeburn 210: );
1.39 raeburn 211: my %initpage = &Apache::lonlocal::texthash (
1.56 raeburn 212: firstres => "first resource in the $lctype",
1.88 hauer 213: whatsnew => "What's New Page",
1.39 raeburn 214: userpref => 'your general user preferences',
1.56 raeburn 215: coursespecific => "specific setting for this $lctype",
1.39 raeburn 216: );
1.15 raeburn 217: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
218: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
219:
1.44 albertel 220: if (($command eq 'chgthreshold')
221: && $checkallowed->{'abovethreshold'}) {
1.69 raeburn 222: &display_threshold_config($r,$refpage,\%threshold_titles,
1.36 raeburn 223: $cdom,$crs);
1.44 albertel 224: } elsif (($command eq 'chginterval')
225: && $checkallowed->{'versionchanges'}) {
1.77 raeburn 226: &display_interval_config($r,$refpage,\%interval_titles,'versions');
1.44 albertel 227: } elsif (($command eq 'chgdisc')
228: && $checkallowed->{'coursediscussion'}) {
1.39 raeburn 229: &display_discussion_config($r,$refpage);
230: } elsif ($command eq 'courseinit') {
231: &courseinit_config($r,$refpage,\%initpage);
1.77 raeburn 232: } elsif (($command eq 'chgnewroleinterval')
233: && $checkallowed->{'newroles'}) {
234: &display_interval_config($r,$refpage,\%interval_titles,'newroles');
235: } elsif (($command eq 'chgoldroleinterval')
236: && $checkallowed->{'oldroles'}) {
237: &display_interval_config($r,$refpage,\%interval_titles,'oldroles');
1.101.2.1.2.1! (raeburn 238:: } elsif (($command eq 'chgcrslogininterval')
! 239:: && $checkallowed->{'crslogin'}) {
! 240:: &display_interval_config($r,$refpage,\%interval_titles,'crslogin');
1.1 raeburn 241: } else {
1.69 raeburn 242: &display_actions_box($r,$command,$refpage,\%threshold_titles,
1.39 raeburn 243: \%interval_titles,\%initpage,$cdom,$crs,$checkallowed);
1.1 raeburn 244: }
1.52 albertel 245: my $end_page = &Apache::loncommon::end_page();
1.1 raeburn 246: $r->print(<<END_OF_BLOCK);
247: </td>
248: </tr>
249: </table><br />
1.52 albertel 250: $end_page
1.1 raeburn 251: END_OF_BLOCK
252: }
253:
254: #-------------------------------
255: # display_header
256: #
257: # Display the header information and set
258: # up the HTML
259: #-------------------------------
260:
1.39 raeburn 261: sub display_header {
1.36 raeburn 262: my ($command,$checkallowed) = @_;
1.52 albertel 263:
1.36 raeburn 264: my $scripttag;
1.77 raeburn 265: unless ($command eq 'chgthreshold' || $command eq 'chginterval' ||
1.101.2.1.2.1! (raeburn 266:: $command eq 'chgoldroleinterval' ||
! 267:: $command eq 'chgnewroleinterval' || $command eq 'chgcrslogininterval') {
1.36 raeburn 268: $scripttag = <<"END";
269: <script type="text/javascript">
1.101.2.1.2.1! (raeburn 270:: // <![CDATA[
1.36 raeburn 271: function change_display(caller,change) {
272: caller.value = change;
1.77 raeburn 273: document.visible.submit();
1.36 raeburn 274: }
275:
276: function changeAll(change) {
277: END
278: foreach my $item (keys(%{$checkallowed})) {
1.44 albertel 279: if ($item =~ /_section$/) { next; }
1.39 raeburn 280: if ($$checkallowed{$item}) {
281: $scripttag.='document.visible.display_'.$item.'.value=change'.
282: "\n";
283: }
1.36 raeburn 284: }
285: $scripttag.='document.visible.submit();
286: }
1.101.2.1.2.1! (raeburn 287::
! 288:: function togglelogins() {
! 289:: var total = document.visible.logincount.value;
! 290:: var sumrow = document.visible.loginrow.value;
! 291:: if (total == 0) {
! 292:: return;
! 293:: }
! 294:: var showlogindetails = 0;
! 295:: for (var i=0; i<document.visible.logindetails.length; i++) {
! 296:: if (document.visible.logindetails[i].checked) {
! 297:: showlogindetails = document.visible.logindetails[i].value;
! 298:: }
! 299:: }
! 300:: var detval = "none";
! 301:: var sumval = "";
! 302:: if (showlogindetails == 1) {
! 303:: detval = "";
! 304:: sumval = "none";
! 305:: }
! 306:: for (var j=0; j<total; j++) {
! 307:: var counter = j+1;
! 308:: var itemid = "logindet_"+counter;
! 309:: personele = document.getElementById(itemid);
! 310:: if (personele != null) {
! 311:: personele.style.display = detval;
! 312:: }
! 313:: }
! 314:: var detheaderele = document.getElementById("logintitledet");
! 315:: if (detheaderele != null) {
! 316:: detheaderele.style.display = detval;
! 317:: }
! 318:: for (var k=0; k<sumrow; k++) {
! 319:: var counter = k+1;
! 320:: var itemid = "loginsum_"+counter;
! 321:: logincatele = document.getElementById(itemid);
! 322:: if (logincatele != null) {
! 323:: logincatele.style.display = sumval;
! 324:: }
! 325:: }
! 326:: var sumheaderele = document.getElementById("logintitlesum");
! 327:: if (sumheaderele != null) {
! 328:: sumheaderele.style.display = sumval;
! 329:: }
! 330:: return;
! 331:: }
! 332:: // ]]>
1.36 raeburn 333: </script>
334: ';
335: }
1.58 albertel 336: my $course_type=&Apache::loncommon::course_type();
1.90 hauer 337: return &Apache::loncommon::start_page("What's New?",
1.58 albertel 338: $scripttag);
1.1 raeburn 339: }
340:
341: #-------------------------------
342: # display_actions_box
343: #
344: # Display the action items
345: #
346: #-------------------------------
347:
1.39 raeburn 348: sub display_actions_box {
1.69 raeburn 349: my ($r,$command,$refpage,$threshold_titles,$interval_titles,$initpage,
350: $cdom,$crs,$checkallowed) = @_;
1.36 raeburn 351: my $udom = $env{'user.domain'};
352: my $uname = $env{'user.name'};
353: my $cid = $env{'request.course.id'};
1.59 albertel 354: my $crstype = &Apache::loncommon::course_type();
1.56 raeburn 355: my $lctype = lc($crstype);
356: my %stulabel = (
357: 'Course' => 'students',
1.95 raeburn 358: 'Community' => 'members',
1.56 raeburn 359: );
1.36 raeburn 360: my %lt = &Apache::lonlocal::texthash(
1.60 raeburn 361: 'yacc' => 'You are accessing an invalid course',
1.36 raeburn 362: 'gtfr' => 'Go to first resource',
363: 'hial' => 'Hide all',
364: 'shal' => 'Show all',
365: );
366:
1.1 raeburn 367: my %unread = ();
368: my %ungraded = ();
369: my %bombed = ();
1.11 raeburn 370: my %triggered = ();
1.33 raeburn 371: my %changed = ();
1.1 raeburn 372: my @newmsgs = ();
373: my @critmsgs = ();
374: my @newdiscussions = ();
375: my @tograde = ();
376: my @bombs = ();
1.11 raeburn 377: my @warnings = ();
1.33 raeburn 378: my $msgcount = 0;
379: my $critmsgcount = 0;
1.77 raeburn 380: my $expirecount;
381: my %expired;
382: my $activecount;
383: my %activated;
1.101.2.1.2.1! (raeburn 384:: my %loggedin;
! 385:: my $logincount;
1.16 raeburn 386: my %res_title = ();
1.33 raeburn 387: my %show = ();
388: my $needitems = 0;
389: my $boxcount = 0;
1.1 raeburn 390:
1.39 raeburn 391: my $result;
392: if ($command eq 'newcourseinit') {
393: $result = &store_courseinit_setting($uname,$udom,$cid,$initpage);
394: }
395:
1.64 banghart 396: my %threshold = ();
1.39 raeburn 397: my %pagedesc = &Apache::lonlocal::texthash (
398: firstres => 'First resource',
1.88 hauer 399: whatsnew => "What's New Page",
1.39 raeburn 400: userpref => 'user preference',
1.56 raeburn 401: coursespecific => $lctype.' only',
1.39 raeburn 402: default => 'default',
403: );
404:
405: my ($initcontrol,$initdisp) = &curr_courseinit();
406: my $currinit = $pagedesc{$initdisp}.' ('.$pagedesc{$initcontrol}.')';
1.13 raeburn 407:
1.36 raeburn 408: unless ($cid) {
1.73 raeburn 409: $r->print('<p><span style="text-align: center; font-weight: bold;">'.$lt{'yacc'}.'</span></p>');
1.1 raeburn 410: return;
411: }
1.33 raeburn 412:
1.97 bisitz 413: my $header = '';
1.39 raeburn 414: if ($refpage eq 'start') {
415: if (tie(my %bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
1.36 raeburn 416: &GDBM_READER(),0640)) {
1.98 raeburn 417: my $furl=&HTML::Entities::encode($bighash{'first_url'},'"<>&');
1.39 raeburn 418: untie(%bighash);
1.97 bisitz 419: $header .= '<b><a href="'.$furl.'">'.$lt{'gtfr'}.
420: '</a></b><br />';
1.39 raeburn 421: }
1.36 raeburn 422: }
1.97 bisitz 423: $header .= &mt('Page set to be displayed after you have selected a role in this '.$lctype).'.'
1.74 bisitz 424: .' <span class="LC_nobreak">'
1.78 bisitz 425: .&mt('Currently: [_1].','<i>'.$currinit.'</i>')
426: .' '
1.96 bisitz 427: .&mt('[_1]Change[_2] for just [_3]this '.$lctype.'[_4] or for [_5]all your courses/communities[_6].'
1.81 bisitz 428: ,'<b>'
429: ,'</b>'
1.74 bisitz 430: ,'<a href="/adm/whatsnew?command=courseinit&refpage='.$refpage.'">'
1.96 bisitz 431: ,'</a>'
1.81 bisitz 432: ,'<a href="/adm/preferences?action=changecourseinit&refpage='.$refpage.'">'
433: ,'</a>')
1.97 bisitz 434: .' </span>';
435:
436: $r->print(&Apache::loncommon::head_subbox($header));
1.56 raeburn 437:
1.36 raeburn 438: if ($command eq 'reset') {
439: $result = &process_reset($cdom,$crs);
440: } elsif ($command eq 'update') {
1.39 raeburn 441: $result = &process_update($uname,$udom,$threshold_titles);
1.36 raeburn 442: } elsif ($command eq 'newinterval') {
443: $result = &store_interval_setting($uname,$udom,$cid,$interval_titles);
1.39 raeburn 444: } elsif ($command eq 'newdiscconf') {
445: $result = &store_discussion_setting($uname,$udom,$cid);
1.36 raeburn 446: }
447:
448: my $store_result=&store_display_settings($uname,$udom,$cid,$checkallowed);
449:
450: unless ($store_result eq 'ok') {
1.71 albertel 451: &Apache::lonnet::logthis('Error saving whatsnew settings: '.
1.56 raeburn 452: $store_result.' for '.'user '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
1.97 bisitz 453: $result .= '<span class="LC_error">'
454: .&mt('Unable to save visibility settings due to [_1]',
455: $store_result)
456: .'</span>';
1.36 raeburn 457: }
458:
459: if ($result) {
1.94 bisitz 460: $r->print($result.'<hr />');
1.36 raeburn 461: }
462: $r->rflush();
463:
1.77 raeburn 464: my (%timediff,%interval);
465: my %display_settings = &get_display_settings($uname,$udom,$cid);
466: $timediff{'versions'} = $display_settings{$cid.':interval'};
467: unless (defined($timediff{'versions'})) { $timediff{'versions'} = 604800; }
468: $interval{'versions'} = $interval_titles->{'versions'}->{$timediff{'versions'}};
469:
470: my %headings = &Apache::lonlocal::texthash(
471: coursediscussion => 'Unread '.$lctype.' discussion posts',
472: handgrading => 'Problems requiring handgrading',
473: haserrors => 'Problems with errors',
474: coursenormalmail => 'New '.$lctype.' messages',
475: coursecritmail => 'New critical messages in '.$lctype,
476: );
477:
478: if ($timediff{'versions'} == -1) {
1.78 bisitz 479: $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since start of '.$lctype);
1.77 raeburn 480: } elsif ($timediff{'versions'} == 2592000) {
1.78 bisitz 481: $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since last month');
1.77 raeburn 482: } elsif ($timediff{'versions'} == 604800) {
1.78 bisitz 483: $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since last week');
1.77 raeburn 484: } elsif ($timediff{'versions'} == 86400) {
1.78 bisitz 485: $headings{'versionchanges'} = &mt('Resources in '.$lctype.' with version changes since yesterday');
1.77 raeburn 486: }
487:
488: $timediff{'oldroles'} = $display_settings{$cid.':oldroleinterval'};
489: unless (defined($timediff{'oldroles'})) { $timediff{'oldroles'} = 604800; }
490: $interval{'oldroles'} = $interval_titles->{'oldroles'}->{$timediff{'oldroles'}};
491:
492: if ($timediff{'oldroles'} == -1) {
1.78 bisitz 493: $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since start of '.$lctype);
1.77 raeburn 494: } elsif ($timediff{'oldroles'} == 2592000) {
1.78 bisitz 495: $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since last month');
1.77 raeburn 496: } elsif ($timediff{'oldroles'} == 604800) {
1.78 bisitz 497: $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since last week');
1.77 raeburn 498: } elsif ($timediff{'oldroles'} == 86400) {
1.78 bisitz 499: $headings{'oldroles'} = &mt('Roles for which access to '.$lctype.' has expired since yesterday');
1.77 raeburn 500: }
501:
502: $timediff{'newroles'} = $display_settings{$cid.':newroleinterval'};
503: unless (defined($timediff{'newroles'})) { $timediff{'newroles'} = 604800; }
504: $interval{'newroles'} = $interval_titles->{'newroles'}->{$timediff{'newroles'}};
505:
506: if ($timediff{'newroles'} == -1) {
1.78 bisitz 507: $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since start of '.$lctype);
1.77 raeburn 508: } elsif ($timediff{'newroles'} == 2592000) {
1.78 bisitz 509: $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since last month');
1.77 raeburn 510: } elsif ($timediff{'newroles'} == 604800) {
1.78 bisitz 511: $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since last week');
1.77 raeburn 512: } elsif ($timediff{'newroles'} == 86400) {
1.78 bisitz 513: $headings{'newroles'} = &mt('Roles for which access to '.$lctype.' has become available since yesterday');
1.77 raeburn 514: }
1.33 raeburn 515:
1.101.2.1.2.1! (raeburn 516:: $timediff{'crslogin'} = $display_settings{$cid.':crslogininterval'};
! 517:: unless (defined($timediff{'crslogin'})) { $timediff{'crslogin'} = 604800; }
! 518:: $interval{'crslogin'} = $interval_titles->{'crslogin'}->{$timediff{'crslogin'}};
! 519::
! 520:: if ($timediff{'crslogin'} == -1) {
! 521:: $headings{'crslogin'} = &mt('Last login for anyone who has ever logged in');
! 522:: } elsif ($timediff{'crslogin'} == 2592000) {
! 523:: $headings{'crslogin'} = &mt('Last login for users in last 30 days');
! 524:: } elsif ($timediff{'crslogin'} == 604800) {
! 525:: $headings{'crslogin'} = &mt('Last login for users in last 7 days');
! 526:: } elsif ($timediff{'crslogin'} == 86400) {
! 527:: $headings{'crslogin'} = &mt('Last login for users in last 24 hours');
! 528:: }
! 529::
1.35 raeburn 530: my $now = time;
1.77 raeburn 531: if ($timediff{'versions'} == -1) {
532: $timediff{'versions'} = time;
533: }
534: my $starttime = $now - $timediff{'versions'};
535:
536: if ($timediff{'newroles'} == -1) {
537: $timediff{'newroles'} = time;
538: }
539: my $activatedstart = $now - $timediff{'newroles'};
540:
541: if ($timediff{'oldroles'} == -1) {
542: $timediff{'oldroles'} = time;
543: }
544: my $expiredstart = $now - $timediff{'oldroles'};
545:
1.101.2.1.2.1! (raeburn 546:: if ($timediff{'crslogin'} == -1) {
! 547:: $timediff{'crslogin'} = time;
! 548:: }
! 549::
! 550:: my $crsloginstart = $now - $timediff{'crslogin'};
! 551::
1.39 raeburn 552: my $countunread = $display_settings{$cid.':countunread'};
553: unless (defined($countunread)) {
554: $countunread = 'on';
555: }
1.36 raeburn 556: if ($$checkallowed{'abovethreshold'}) {
1.39 raeburn 557: &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs);
1.33 raeburn 558: }
559:
1.59 albertel 560: $headings{'abovethreshold'} =
1.80 raeburn 561: &mt('(Problems with av. attempts ≥ [_1] or deg. difficulty ≥ [_2]) [_3] and total number of '.$stulabel{$crstype}.' with submissions ≥ [_4]',
1.59 albertel 562: $threshold{'av_attempts'},$threshold{'degdiff'},
1.80 raeburn 563: '<br />',$threshold{'numstudents'});
1.33 raeburn 564:
1.101.2.1.2.1! (raeburn 565:: my @actionorder = ('handgrading','haserrors','abovethreshold','versionchanges','coursediscussion','coursenormalmail','coursecritmail','newroles','oldroles','crslogin');
1.33 raeburn 566:
1.36 raeburn 567: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 568: if ($key =~ /_section$/) { next; }
1.33 raeburn 569: $show{$key} = 0;
1.36 raeburn 570: if ($$checkallowed{$key}) {
571: unless ($display_settings{$cid.':'.$key} eq 'hide') {
1.33 raeburn 572: $show{$key} = 1;
573: }
574: }
575: }
576:
577: foreach my $item (@actionorder) {
1.77 raeburn 578: unless ($item eq 'coursenormalmail' || $item eq 'coursecritmail' ||
579: $item eq 'newroles' || $item eq 'oldroles') {
1.33 raeburn 580: if ($show{$item}) {
581: $needitems = 1;
582: last;
583: }
584: }
585: }
586:
1.84 raeburn 587: my $itemserror;
1.33 raeburn 588: if ($needitems) {
1.84 raeburn 589: $itemserror = &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread);
1.1 raeburn 590: }
1.33 raeburn 591: if ($show{'coursenormalmail'}) {
1.50 raeburn 592: $msgcount = &getnormalmail(\@newmsgs);
1.7 raeburn 593: }
1.33 raeburn 594: if ($show{'coursecritmail'}) {
1.50 raeburn 595: $critmsgcount = &getcritmail(\@critmsgs);
1.11 raeburn 596: }
1.77 raeburn 597: if ($show{'oldroles'}) {
598: $expirecount = &getexpired(\%expired,$expiredstart,'previous');
599: }
600: if ($show{'newroles'}) {
601: $activecount = &getactivated(\%activated,$activatedstart,'active');
602: }
1.101.2.1.2.1! (raeburn 603:: if ($show{'crslogin'}) {
! 604:: $logincount = &getloggedin($cdom,$crs,\%loggedin,$crsloginstart);
! 605:: }
1.36 raeburn 606: $r->print(qq|<a href="javascript:changeAll('hide');">$lt{'hial'}</a>
607: <a href="javascript:changeAll('show');">$lt{'shal'}</a>
608: <form method="post" name="visible" action="/adm/whatsnew">\n|);
609: foreach my $item (keys(%{$checkallowed})) {
1.44 albertel 610: if ($item =~ /_section$/) { next; }
1.36 raeburn 611: if ($$checkallowed{$item}) {
612: $r->print('<input type="hidden" name="display_'.$item.'" />'."\n");
613: }
614: }
1.1 raeburn 615:
1.73 raeburn 616: $r->print('<input type="hidden" name="refpage" value="'.$refpage.'" /></form><table class="LC_double_column"><tr><td class="LC_left_col">');
1.1 raeburn 617:
1.33 raeburn 618: my $displayed = 0;
1.40 raeburn 619: my $totalboxes = 0;
620: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 621: if ($key =~ /_section$/) { next; }
622: if ($key eq 'whatsnew' ) { next; } # whatsnew check creates no box
1.40 raeburn 623: if ($$checkallowed{$key}) {
624: $totalboxes ++;
625: }
626: }
1.77 raeburn 627: my $halfway = 4;
628: # my $halfway = int($totalboxes/2) + $totalboxes%2;
1.33 raeburn 629: foreach my $actionitem (@actionorder) {
1.36 raeburn 630: if ($$checkallowed{$actionitem}) {
1.33 raeburn 631: if ($displayed == $halfway) {
1.73 raeburn 632: $r->print('</td><td> </td><td class="LC_right_col" >');
1.1 raeburn 633: }
1.101.2.1.2.1! (raeburn 634:: &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,\%expired,$expirecount,\%activated,$activecount,$crstype,$itemserror,\%loggedin,$logincount);
1.33 raeburn 635: $displayed ++;
1.1 raeburn 636: }
637: }
638: $r->print('
1.33 raeburn 639: </td>
640: </tr>
1.73 raeburn 641: </table>
642: ');
1.1 raeburn 643: }
644:
1.11 raeburn 645: #-------------------------------
1.36 raeburn 646: # display_threshold_config
1.11 raeburn 647: #
1.13 raeburn 648: # Display the threshold setting screen
1.11 raeburn 649: #
650: #-------------------------------
651:
1.36 raeburn 652: sub display_threshold_config {
1.69 raeburn 653: my ($r,$refpage,$threshold_titles,$cdom,$crs) = @_;
1.39 raeburn 654: my $uname = $env{'user.name'};
655: my $udom = $env{'user.dom'};
656: my $cid = $env{'request.course.id'};
1.13 raeburn 657: my %threshold = ();
658: my $rowColor1 = "#ffffff";
659: my $rowColor2 = "#eeeeee";
660: my $rowColor;
661:
662: my @thresholditems = ("av_attempts","degdiff","numstudents");
1.39 raeburn 663: my %threshold_titles = &Apache::lonlocal::texthash(
1.13 raeburn 664: av_attempts => 'Average number of attempts',
665: degdiff => 'Degree of difficulty',
666: numstudents => 'Total number of students with submissions',
667: );
1.39 raeburn 668: &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs);
1.13 raeburn 669:
1.68 raeburn 670: $r->print('<br /><form name="thresholdform" method="post" action="/adm/whatsnew">'.
671: &Apache::loncommon::start_data_table().
672: &Apache::loncommon::start_data_table_header_row().
1.70 raeburn 673: '<th>'.&mt('Threshold Name').'</th>'."\n".
674: '<th>'.&mt('Current value').'</th>'."\n".
675: '<th>'.&mt('Change?').'</th>'."\n".
1.68 raeburn 676: &Apache::loncommon::end_data_table_header_row());
1.13 raeburn 677: foreach my $type (@thresholditems) {
1.39 raeburn 678: my $parameter = $env{'request.course.id'}.':threshold_'.$type;
1.13 raeburn 679: # onchange is javascript to automatically check the 'Set' button.
680: my $onchange = 'onFocus="javascript:window.document.forms'.
681: "['thresholdform'].elements['".$parameter."_setparmval']".
682: '.checked=true;"';
1.68 raeburn 683: $r->print(&Apache::loncommon::start_data_table_row()."\n".
684: '<td>'.$threshold_titles{$type}.'</td>'."\n".
685: '<td>'.&Apache::lonhtmlcommon::textbox($parameter.'_value',
1.13 raeburn 686: $threshold{$type},
1.68 raeburn 687: 10,$onchange).'</td>'."\n".
688: '<td>'.
689: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
690: '</td>'."\n".
691: &Apache::loncommon::end_data_table_row());
1.13 raeburn 692: }
1.68 raeburn 693: $r->print(&Apache::loncommon::end_data_table()."\n".
1.87 schafran 694: '<br /><input type="submit" name="threshold" value="'.&mt('Save').'" />
1.36 raeburn 695: <input type="hidden" name="command" value="update" />
1.39 raeburn 696: <input type="hidden" name="refpage" value="'.$refpage.'" />
1.13 raeburn 697: </form>');
1.11 raeburn 698: }
699:
1.36 raeburn 700: #-------------------------------
701: # display_interval_config
702: #
703: # Display the interval setting screen
704: #
705: #-------------------------------
706:
707: sub display_interval_config {
1.77 raeburn 708: my ($r,$refpage,$interval_titles,$context) = @_;
709: my $setting = 'interval';
710: if ($context eq 'oldroles') {
711: $setting = 'oldroleinterval';
712: } elsif ($context eq 'newroles') {
713: $setting = 'newroleinterval';
714: }
1.59 albertel 715: my $lctype = lc(&Apache::loncommon::course_type());
1.39 raeburn 716: my $current = &get_current($env{'user.name'},$env{'user.domain'},
1.77 raeburn 717: $env{'request.course.id'},$setting);
718: if ($context eq 'oldroles') {
719: $r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' expired.').'<br />');
720: } elsif ($context eq 'newroles') {
721: $r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' became available.').'<br />');
1.101.2.1.2.1! (raeburn 722:: } elsif ($context eq 'crslogin') {
! 723:: $r->print('<br />'.&mt('Choose the time window to use to display the last login by a user in the '.$lctype).'<br />');
1.77 raeburn 724: } else {
725: $r->print('<br />'.&mt('Choose the time window to use to display resources in the '.$lctype.' with version changes.').'<br />');
726: }
1.36 raeburn 727: unless ($current eq '') {
1.77 raeburn 728: if (ref($interval_titles->{$context}) eq 'HASH') {
729: $r->print(' '.&mt('Current value is "[_1]".','<b>'.
730: $interval_titles->{$context}->{$current}.'</b>').'<br />');
731: }
1.36 raeburn 732: }
1.77 raeburn 733: $r->print('<br />
1.36 raeburn 734: <form method="post" name="intervalswitch" action="/adm/whatsnew">
735: <input type="hidden" name="command" value="newinterval" />
1.77 raeburn 736: <input type="hidden" name="intervaltype" value="'.$context.'" />
737: <input type="hidden" name="refpage" value="'.$refpage.'" />'.
738: &mt('Display:').'
1.36 raeburn 739: <select name="interval">
1.78 bisitz 740: <option value="" selected="selected">'.&mt('Select').'</option>
1.36 raeburn 741: ');
1.77 raeburn 742: if (ref($interval_titles) eq 'HASH') {
743: if (ref($interval_titles->{$context}) eq 'HASH') {
744: foreach my $key (reverse sort ({$a cmp $b} (keys(%{$interval_titles->{$context}})))) {
1.78 bisitz 745: $r->print('<option value="'.$key.'">'.&mt($interval_titles->{$context}->{$key}).
1.77 raeburn 746: '</option>'."\n");
747: }
748: }
1.36 raeburn 749: }
750: $r->print('</select>
751: <input type="submit" name="display" value="'.
1.87 schafran 752: &mt('Save').'" /></form>');
1.36 raeburn 753: return;
754: }
755:
1.39 raeburn 756: #----------------------------------------------
757: # display_discussion_config
758: #
759: # Display the discussion display setting screen
760: #
761: #----------------------------------------------
762:
763: sub display_discussion_config {
764: my ($r,$refpage) = @_;
765: my $current = &get_current($env{'user.name'},$env{'user.domain'},
766: $env{'request.course.id'},'countunread');
767: if ($current eq '') {
768: $current = 'on';
769: }
1.47 raeburn 770: my %opposite = (
771: 'on' => 'off',
772: 'off' => 'on',
773: );
774: $r->print('<script type="text/javascript">
775: function toggle_countunread(choice) {
776: if (choice == "unchanged") {
777: document.discussionswitch.command.value = "";
778: }
779: document.discussionswitch.submit();
780: }
781: </script>');
1.81 bisitz 782: $r->print('<br />'
1.86 schafran 783: .&mt('Choose whether or not to display a count of the number of new posts for each resource or discussion board which has unread posts.')
1.81 bisitz 784: .'<br />'
1.90 hauer 785: .&mt("This can increase the time taken to gather data for the [_1]What's New Page[_2] by a few seconds.",'<i>','</i>')
1.81 bisitz 786: .' '
787: .&mt('Currently set to [_1].','<b>'.$current.'</b>.')
788: );
1.39 raeburn 789: $r->print('<br /><br />
1.47 raeburn 790: <form method="post" name="discussionswitch" action="/adm/whatsnew">
1.39 raeburn 791: <input type="hidden" name="command" value="newdiscconf" />
792: <input type="hidden" name="refpage" value="'.$refpage.'" />
1.47 raeburn 793: <input type="hidden" name="countunread" value="'.$opposite{$current}.'" />
1.39 raeburn 794: ');
1.47 raeburn 795: $r->print('<br/>
796: <input type="button" name="display" value="'.
1.74 bisitz 797: &mt('Change to [_1]',&mt($opposite{$current})).'"
1.83 raeburn 798: onclick="javascript:toggle_countunread('."'change'".')" />'.
799: (' ' x7).
800: '<input type="button" name="nochange" value="'.
1.47 raeburn 801: &mt("No change").'"
802: onclick="javascript:toggle_countunread('."'unchanged'".')" />
803: </form>');
1.39 raeburn 804: return;
805: }
806:
807: #---------------------------------------------------
808: # courseinit_config
809: #
810: # Set page displayed when course loads after
811: # selecting a role in the course from the roles page.
812: #
813: #---------------------------------------------------
814:
815: sub courseinit_config {
816: my ($r,$refpage,$initpage) = @_;
817: my ($control,$current) = &curr_courseinit();
818: my @chgstate = ('userpref','coursespecific');
819: my @chgentry = ('firstres','whatsnew');
1.59 albertel 820: my $lctype = lc(&Apache::loncommon::course_type());
1.39 raeburn 821: my %lt = &Apache::lonlocal::texthash(
1.56 raeburn 822: 'chwp' => "Choose which page will be displayed when you enter this $lctype after selecting a role.",
1.39 raeburn 823: 'cuva' => 'Current value is determined by',
824: 'anis' => 'and is set to display',
825: 'padc' => 'Page display controlled by',
1.56 raeburn 826: 'chce' => 'Choose '.$lctype.' entry',
1.89 schafran 827: 'moce' => 'Save',
1.39 raeburn 828: );
829: $r->print(<<"END");
830: <br />$lt{'chwp'}
831: <br />$lt{'cuva'}: <b>
832: $$initpage{$control}</b> $lt{'anis'} <b>
833: $$initpage{$current}</b>.<br /><br />
834: <form method="post" name="courseinitswitch" action="/adm/whatsnew">
835: <input type="hidden" name="command" value="newcourseinit" />
836: <input type="hidden" name="refpage" value="$refpage" />
1.56 raeburn 837: $lt{'padc'}:
1.39 raeburn 838: END
839: foreach my $choice (@chgstate) {
1.56 raeburn 840: my $chkstring;
841: if ($choice eq $control) {
842: $chkstring = ' checked="checked" ';
843: }
1.73 raeburn 844: $r->print('<span class="LC_nobreak"><label><input type="radio" name="courseinit_control" value="'.
1.56 raeburn 845: $choice.'"'.$chkstring.'/>'.$$initpage{$choice}.
1.73 raeburn 846: ' </label></span>');
1.39 raeburn 847: }
848: $r->print('<br /><br />'.&mt('If').' '.$$initpage{'coursespecific'}.
1.56 raeburn 849: ' - <br />'.$lt{'chce'}.": \n");
1.39 raeburn 850: foreach my $choice (@chgentry) {
1.56 raeburn 851: my $chkstring;
852: if (($choice eq $current) && ($control eq 'coursespecific')) {
853: $chkstring = ' checked="checked" ';
854: }
1.73 raeburn 855: $r->print('<span class="LC_nobreak"><label><input type="radio" name="courseinit_page" value="'.
1.56 raeburn 856: $choice.'"'.$chkstring.'/>'.$$initpage{$choice}.
1.73 raeburn 857: ' </label></span>');
1.39 raeburn 858: }
859: $r->print('<br /><br /><input type="submit" name="display" value="'.
860: $lt{'moce'}.'" /></form>');
861: return;
862: }
863:
864: sub curr_courseinit {
865: my $current = &get_current($env{'user.name'},$env{'user.domain'},
866: $env{'request.course.id'},'courseinit');
867: my $control;
1.40 raeburn 868: if ($current) {
869: $control = 'coursespecific';
870: } else {
1.39 raeburn 871: $control = 'userpref';
1.40 raeburn 872: my %userenv = &Apache::lonnet::get('environment',
873: ['course_init_display']);
874: if (exists($userenv{'course_init_display'})) {
875: $current = $userenv{'course_init_display'};
876: }
877: unless ($current) {
1.39 raeburn 878: $current = 'whatsnew';
879: }
880: }
881: return ($control,$current);
882: }
883:
1.33 raeburn 884: sub display_launcher {
1.69 raeburn 885: my ($r,$action,$refpage,$checkallowed,$show,$headings,$res_title,
1.68 raeburn 886: $tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered,
887: $newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs,
1.77 raeburn 888: $interval,$countunread,$expired,$expirecount,$activated,$activecount,
1.101.2.1.2.1! (raeburn 889:: $crstype,$itemserror,$loggedin,$logincount) = @_;
1.33 raeburn 890:
891: if ($$checkallowed{$action}) {
1.69 raeburn 892: &start_box($r,$show,$headings,$action,$refpage,$action);
1.33 raeburn 893: if ($$show{$action}) {
894: if ($action eq 'handgrading') { # UNGRADED ITEMS
1.84 raeburn 895: &display_handgrade($r,$tograde,$ungraded,$itemserror);
1.33 raeburn 896: } elsif ($action eq 'haserrors') { # BOMBS
1.84 raeburn 897: &display_haserrors($r,$bombs,$bombed,$res_title,$itemserror);
1.33 raeburn 898: } elsif ($action eq 'versionchanges') { # VERSION CHANGES
1.84 raeburn 899: &display_versionchanges($r,$changed,$res_title,$interval->{'versions'},$itemserror);
1.33 raeburn 900: } elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS
1.39 raeburn 901: &display_abovethreshold($r,$refpage,$warnings,$triggered,
1.84 raeburn 902: $res_title,$itemserror);
1.33 raeburn 903: } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION
904: &display_coursediscussion($r,$newdiscussions,$unread,
1.84 raeburn 905: $countunread,$res_title,$itemserror);
1.33 raeburn 906: } elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES
1.68 raeburn 907: &display_coursenormalmail($r,$msgcount,$newmsgs);
1.33 raeburn 908: } elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES
1.68 raeburn 909: &display_coursecritmail($r,$critmsgcount,$critmsgs);
1.77 raeburn 910: } elsif ($action eq 'newroles') { # ACTIVATED ROLES
911: &display_rolechanges($r,$activecount,$activated,$interval->{'newroles'},
912: $crstype);
913: } elsif ($action eq 'oldroles') { # EXPIRED ROLES
914: &display_rolechanges($r,$expirecount,$expired,$interval->{'oldroles'},
915: $crstype);
1.101.2.1.2.1! (raeburn 916:: } elsif ($action eq 'crslogin') { #LAST LOGIN
! 917:: &display_crslogins($r,$logincount,$loggedin,$interval->{'crslogin'},
! 918:: $crstype);
! 919::
1.33 raeburn 920: }
921: }
922: &end_box($r);
923: }
924: return;
925: }
926:
1.1 raeburn 927: sub getitems {
1.33 raeburn 928: my ($unread,$ungraded,$bombed,$triggered,$changed,$newdiscussions,
1.68 raeburn 929: $tograde,$bombs,$warnings,$threshold,$cdom,$crs,$res_title,$show,
930: $starttime,$countunread) = @_;
1.1 raeburn 931: my $navmap = Apache::lonnavmaps::navmap->new();
1.84 raeburn 932: if (!defined($navmap)) {
933: my $itemserror = '<span class="LC_warning">'.&mt('An error occurred retrieving information about the course.').'<br />'.&mt('It is recommended that you [_1]re-select the course[_2].','<a href="/adm/roles">','</a>').'</span>';
934: return $itemserror;
935: }
1.26 albertel 936: # force retrieve Resource to seed the part id cache we'll need it later
1.37 raeburn 937: my @allres=$navmap->retrieveResources(undef,
938: sub {if ($_[0]->is_problem) { $_[0]->parts();} return 1;});
1.33 raeburn 939: my %resourcetracker;
1.37 raeburn 940: my $discussiontime;
1.33 raeburn 941:
942: # Resource version changes
943: if ($$show{'versionchanges'}) {
944: &checkversions($cdom,$crs,$navmap,$changed,$starttime);
945: }
946:
947: if ($$show{'abovethreshold'}) {
948: %resourcetracker = &Apache::lonnet::dump('nohist_resourcetracker',
949: $cdom,$crs);
950: }
1.1 raeburn 951:
952: foreach my $resource (@allres) {
953: my $result = '';
954: my $applies = 0;
955: my $symb = $resource->symb();
1.33 raeburn 956: %{$$bombed{$symb}} = ();
1.1 raeburn 957: %{$$ungraded{$symb}} = ();
1.11 raeburn 958: %{$$triggered{$symb}} = ();
959: $$triggered{$symb}{numparts} = 0;
1.66 raeburn 960: if ($resource->encrypted()) {
961: $$triggered{$symb}{'enclink'} = $resource->link();
962: $$triggered{$symb}{'encsymb'} = $resource->shown_symb();
963: }
1.1 raeburn 964: my $title = $resource->compTitle();
1.16 raeburn 965: $$res_title{$symb} = $title;
1.8 albertel 966: my $ressymb = $resource->wrap_symb();
1.33 raeburn 967:
1.37 raeburn 968: # Check if there are unread discussion postings
1.33 raeburn 969: if ($$show{'coursediscussion'}) {
1.51 albertel 970: &check_discussions($resource,$symb,$ressymb,$title,
971: $newdiscussions,$unread,$countunread);
1.33 raeburn 972: }
1.1 raeburn 973:
974: # Check for ungraded problems
975: if ($resource->is_problem()) {
1.33 raeburn 976: if ($$show{'handgrading'}) {
977: &check_handgraded($resource,$symb,$title,$cdom,$crs,$ungraded,
978: $tograde);
979: }
1.1 raeburn 980: }
981:
982: # Check for bombs
1.33 raeburn 983: if ($$show{'haserrors'}) {
984: &check_bombed($resource,$symb,$title,$bombs,$bombed);
985: }
986:
987: # Maxtries and degree of difficulty for problem parts, unless handgradeable
988: if ($$show{'abovethreshold'}) {
1.61 albertel 989: &check_thresholds($resource,$symb,\%resourcetracker,
990: $triggered,$threshold,$warnings);
1.33 raeburn 991: }
992:
993: }
1.84 raeburn 994: return;
1.33 raeburn 995: }
996:
997: sub check_discussions {
1.51 albertel 998: my ($resource,$symb,$ressymb,$title,$newdiscussions,$unread,
999: $countunread) = @_;
1000:
1001: if (!$resource->hasDiscussion()) { return; }
1.37 raeburn 1002:
1.51 albertel 1003: %{$$unread{$ressymb}} = ();
1004: $$unread{$ressymb}{'title'} = $title;
1005: $$unread{$ressymb}{'symb'} = $symb;
1.66 raeburn 1006: if ($resource->encrypted()) {
1007: $$unread{$ressymb}{'enclink'} = $resource->link();
1008: $$unread{$ressymb}{'encsymb'} = $resource->shown_symb();
1009: }
1.51 albertel 1010: push(@{$newdiscussions}, $ressymb);
1011:
1012: $$unread{$ressymb}{'lastpost'} = $resource->last_post_time();
1013:
1014: if ($countunread eq 'on') {
1.67 raeburn 1015: $$unread{$ressymb}{'unreadcount'} =
1016: $resource->discussion_info('unread');
1.33 raeburn 1017: }
1018: }
1019:
1020: sub check_handgraded {
1021: my ($resource,$symb,$title,$cdom,$cnum,$ungraded,$tograde) = @_;
1022: if ($resource->is_problem()) {
1023: my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
1024: my $partlist=$resource->parts();
1025: my $handgradeable;
1026: foreach my $part (@$partlist) {
1.31 raeburn 1027: if ($resource->handgrade($part) eq 'yes') {
1.33 raeburn 1028: $handgradeable=1; last;
1.31 raeburn 1029: }
1.33 raeburn 1030: }
1031: if ($handgradeable) {
1.35 raeburn 1032: my @ungraded = &Apache::bridgetask::get_queue_symb_status(
1.33 raeburn 1033: 'gradingqueue',$symb,$cdom,$cnum);
1034: if (@ungraded > 0) {
1035: $$ungraded{$symb}{count} = scalar(@ungraded);
1036: $$ungraded{$symb}{title} = $title;
1.66 raeburn 1037: if ($resource->encrypted()) {
1038: $$ungraded{$symb}{'enclink'} = $resource->link();
1039: $$ungraded{$symb}{'encsymb'} = $resource->shown_symb();
1040: }
1041: push(@{$tograde},$symb);
1.11 raeburn 1042: }
1043: }
1.33 raeburn 1044: }
1045: }
1046:
1047: sub check_bombed {
1048: my ($resource,$symb,$title,$bombs,$bombed) = @_;
1049: if ($resource->getErrors()) {
1050: my $errors = $resource->getErrors();
1051: $errors =~ s/^,//;
1052: my @bombs = split(/,/, $errors);
1053: my $errorcount = scalar(@bombs);
1054: my $errorlink = '<a href="/adm/email?display='.
1.55 www 1055: &escape($bombs[0]).'">'.
1.33 raeburn 1056: $title.'</a>';
1057: $$bombed{$symb}{errorcount} = $errorcount;
1058: $$bombed{$symb}{errorlink} = $errorlink;
1059: push(@{$bombs}, $symb);
1060: }
1061: }
1062:
1063: sub check_thresholds {
1.61 albertel 1064: my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings) = @_;
1.33 raeburn 1065: # Compile maxtries and degree of difficulty for problem parts, unless handgradeable
1066: my @parts = @{$resource->parts()};
1067: my %stats;
1068: my %lastreset = ();
1069: my $warning = 0;
1070: foreach my $part (@parts) {
1071: if ($resource->handgrade($part) eq 'yes') {
1072: next;
1073: }
1.101 raeburn 1074: if ($resource->is_anonsurvey($part)) {
1075: next;
1076: }
1.48 raeburn 1077: if ($resource->is_survey($part)) {
1078: next;
1079: }
1.33 raeburn 1080: %{$stats{$part}} = ();
1081: my ($attempts,$users,$corrects,$degdiff,$av_attempts);
1082: if (exists($$resourcetracker{$symb."\0".$part."\0attempts"})) {
1083: $attempts = $$resourcetracker{$symb."\0".$part."\0attempts"};
1084: }
1085: if (exists($$resourcetracker{$symb."\0".$part."\0users"})) {
1086: $users = $$resourcetracker{$symb."\0".$part."\0users"};
1087: }
1088: if (exists($$resourcetracker{$symb."\0".$part."\0correct"})) {
1089: $corrects = $$resourcetracker{$symb."\0".$part."\0correct"};
1090: }
1091: if ($attempts > 0) {
1092: $degdiff = 1 - ($corrects/$attempts);
1093: $degdiff = sprintf("%.2f",$degdiff);
1094: }
1095: if ($users > 0) {
1096: $av_attempts = $attempts/$users;
1097: $av_attempts = sprintf("%.2f",$av_attempts);
1098: }
1099: if ((($degdiff ne '' && $degdiff >= $$threshold{'degdiff'}) || ($av_attempts ne '' && $av_attempts >= $$threshold{'av_attempts'})) && ($users >= $$threshold{'numstudents'})) {
1100: $stats{$part}{degdiff} = $degdiff;
1101: $stats{$part}{attempts} = $av_attempts;
1102: $stats{$part}{users} = $users;
1103: $lastreset{$part} = $$resourcetracker{$symb."\0".$part."\0resettime"};
1104: if ($lastreset{$part}) {
1105: $lastreset{$part} = &Apache::lonnavmaps::timeToHumanString($lastreset{$part});
1.11 raeburn 1106: }
1.33 raeburn 1107: $warning = 1;
1108: }
1109: }
1110: if ($warning) {
1111: $$triggered{$symb}{title} = $resource->title;
1.62 raeburn 1112: my $partcount = 0;
1113: @{$$triggered{$symb}{text}} = ();
1.33 raeburn 1114: foreach my $part (@parts) {
1115: if (exists($stats{$part}{users})) {
1.55 www 1116: my $resetname = 'reset_'.&escape($symb."\0".$part);
1117: my $resettitle = 'title_'.&escape($symb."\0".$part);
1.33 raeburn 1118: if (@parts > 1) {
1.62 raeburn 1119: $$triggered{$symb}{text}[$partcount] = '
1.74 bisitz 1120: <td>'.&mt('part - ').$part.'</td>';
1.33 raeburn 1121: } else {
1.62 raeburn 1122: $$triggered{$symb}{text}[$partcount] = '
1.74 bisitz 1123: <td>'.&mt('single part').'</td>';
1.11 raeburn 1124: }
1.62 raeburn 1125: $$triggered{$symb}{text}[$partcount] .= '
1.61 albertel 1126: <td>'.$stats{$part}{users}.'</td>
1127: <td>'.$stats{$part}{attempts}.'</td>
1128: <td>'.$stats{$part}{degdiff}.'</td>
1129: <td>'.$lastreset{$part}.'</td>
1.62 raeburn 1130: <td><input type="checkbox" name="'.$resetname.'" /><input type="hidden" name="'.$resettitle.'" value="'.&escape($$triggered{$symb}{title}).'" /></td>';
1131: $partcount ++;
1.11 raeburn 1132: }
1.62 raeburn 1133: $$triggered{$symb}{numparts} = $partcount;
1.11 raeburn 1134: }
1.33 raeburn 1135: push(@{$warnings},$symb);
1.1 raeburn 1136: }
1137: }
1138:
1.33 raeburn 1139:
1.13 raeburn 1140: sub get_curr_thresholds {
1.39 raeburn 1141: my ($threshold,$uname,$udom,$cid,$cdom,$crs) = @_;
1.64 banghart 1142: # set default values
1143: %$threshold = (av_attempts => 2,
1144: degdiff => 0.5,
1145: numstudents => 2
1146: );
1.39 raeburn 1147: my %thresholdsettings = &Apache::lonnet::dump('nohist_whatsnew',$udom,
1148: $uname,$cid.':threshold');
1149: my $thresholdcount = 0;
1150: my ($tmp) = %thresholdsettings;
1.40 raeburn 1151: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 1152: foreach my $item (keys %{$threshold}) {
1153: if (exists($thresholdsettings{$cid.':threshold_'.$item})) {
1154: $$threshold{$item} =
1155: $thresholdsettings{$cid.':threshold_'.$item};
1156: $thresholdcount ++;
1157: }
1158: }
1.13 raeburn 1159: }
1.39 raeburn 1160: if ($thresholdcount == 3) {
1161: return;
1.13 raeburn 1162: }
1.39 raeburn 1163: my %coursesettings = &Apache::lonnet::dump('environment',
1164: $cdom,$crs,'internal.threshold');
1165: my ($temp) = %coursesettings;
1.40 raeburn 1166: unless ($temp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 1167: foreach my $item (keys %{$threshold}) {
1168: unless (exists($thresholdsettings{$cid.':threshold_'.$item})) {
1169: if (exists($coursesettings{'internal.threshold_'.$item})) {
1170: $$threshold{$item} =
1171: $coursesettings{'internal.threshold_'.$item};
1172: }
1173: }
1174: }
1.13 raeburn 1175: }
1.39 raeburn 1176: return;
1.13 raeburn 1177: }
1178:
1.39 raeburn 1179: sub get_current {
1180: my ($uname,$udom,$cid,$caller) = @_;
1181: my $currvalue;
1182: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid.
1183: ':'.$caller);
1.36 raeburn 1184: my ($tmp) = %settings;
1.40 raeburn 1185: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.39 raeburn 1186: $currvalue = $settings{$cid.':'.$caller};
1.36 raeburn 1187: }
1.39 raeburn 1188: return $currvalue;
1.36 raeburn 1189: }
1190:
1.13 raeburn 1191: sub process_reset {
1192: my ($dom,$crs) = @_;
1.39 raeburn 1193: my $result = '<b>'.&mt('Counters reset for following problems (and parts):').
1194: '</b><br />';
1.13 raeburn 1195: my @agg_types = ('attempts','users','correct');
1.39 raeburn 1196: my %agg_titles = &Apache::lonlocal::texthash (
1.13 raeburn 1197: attempts => 'Number of submissions',
1198: users => 'Students with submissions',
1199: correct => 'Number of correct submissions',
1200: );
1201: my @resets = ();
1202: my %titles = ();
1.17 albertel 1203: foreach my $key (keys(%env)) {
1.13 raeburn 1204: next if ($key !~ /^form\.reset_(.+)$/);
1.55 www 1205: my $title = &unescape($env{'form.title_'.$1});
1206: my $reset_item = &unescape($1);
1.13 raeburn 1207: my %curr_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
1208: my %aggregates = ();
1.17 albertel 1209: my ($symb,$part) = split(/\0/,$reset_item);
1.13 raeburn 1210: foreach my $type (@agg_types) {
1211: $aggregates{$reset_item."\0".$type} = 0;
1212: }
1.17 albertel 1213: $aggregates{$reset_item."\0".'resettime'} = time;
1.13 raeburn 1214: my $putresult = &Apache::lonnet::put('nohist_resourcetracker',\%aggregates,
1215: $dom,$crs);
1216: if ($putresult eq 'ok') {
1217: $result .= $title.' -part '.$part.': ';
1218: my %new_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
1219: foreach my $type (@agg_types) {
1220: $result .= $agg_titles{$type}.' = '.$new_aggregates{$reset_item."\0".$type}.'; ';
1221: }
1222: $result =~ s/; $//;
1223: $result .= '<br />';
1224: } else {
1.14 albertel 1225: $result = $title.' -part '.$part.': '.&mt('Unable to reset counters to zero due to [_1]',$putresult).'.<br />'."\n";
1.13 raeburn 1226: }
1227: }
1228: return $result;
1229: }
1230:
1231: sub process_update {
1.39 raeburn 1232: my ($uname,$udom,$threshold_titles) = @_;
1.99 wenzelju 1233: my $setoutput = '<b>'.&mt('Changes to threshold(s) for problem tracking:').'</b><br/><br />';
1.13 raeburn 1234: foreach (keys %env) {
1235: next if ($_!~/^form\.(.+)\_setparmval$/);
1236: my $name = $1;
1237: my $value = $env{'form.'.$name.'_value'};
1.65 banghart 1238: if ($name && defined($value) && ($value ne '')) {
1.39 raeburn 1239: my $put_result = &Apache::lonnet::put('nohist_whatsnew',
1240: {$name=>$value},$udom,$uname);
1.13 raeburn 1241:
1.39 raeburn 1242: my ($shortname) = ($name =~ /^\Q$env{'request.course.id'}\E:threshold_(.+)$/);
1.13 raeburn 1243: if ($put_result eq 'ok') {
1.99 wenzelju 1244: $setoutput.= &Apache::lonhtmlcommon::confirm_success(&mt('Set threshold for [_1] to [_2]',
1.14 albertel 1245: '<b>'.$$threshold_titles{$shortname}.'</b>',
1.99 wenzelju 1246: '<b>'.$value.'</b>').'<br />');
1.14 albertel 1247: } else {
1.99 wenzelju 1248: $setoutput.= &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set threshold for [_1] to [_2] due to [_3].',
1.14 albertel 1249: '<b>'.$name.'</b>','<b>'.$value.'</b>',
1.99 wenzelju 1250: '<tt>'.$put_result.'</tt>').'<br />',1);
1.13 raeburn 1251: }
1252: }
1253: }
1.99 wenzelju 1254: return &Apache::loncommon::confirmwrapper($setoutput);
1.13 raeburn 1255: }
1256:
1.33 raeburn 1257: sub getnormalmail {
1258: my ($newmsgs) = @_;
1.1 raeburn 1259: # Check for unread mail in course
1260: my $msgcount = 0;
1.3 albertel 1261:
1.10 raeburn 1262: my @messages = sort(&Apache::lonnet::getkeys('nohist_email'));
1.3 albertel 1263: foreach my $message (@messages) {
1.55 www 1264: my $msgid=&escape($message);
1.10 raeburn 1265: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1.1 raeburn 1266: &Apache::lonmsg::unpackmsgid($msgid);
1.10 raeburn 1267: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 1268: if (defined($sendtime) && $sendtime!~/error/) {
1.91 lueken 1269: if ($status eq 'new') {
1.93 droeschl 1270: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
1.91 lueken 1271: $msgcount ++;
1.10 raeburn 1272: if ($shortsubj eq '') {
1273: $shortsubj = &mt('No subject');
1274: }
1.1 raeburn 1275: push(@{$newmsgs}, {
1276: msgid => $msgid,
1277: sendtime => $sendtime,
1.10 raeburn 1278: shortsub => $shortsubj,
1.1 raeburn 1279: from => $fromname,
1280: fromdom => $fromdom
1281: });
1282: }
1283: }
1284: }
1285: }
1.33 raeburn 1286: return $msgcount;
1287: }
1.1 raeburn 1288:
1.33 raeburn 1289: sub getcritmail {
1290: my ($critmsgs) = @_;
1.1 raeburn 1291: # Check for critical messages in course
1292: my %what=&Apache::lonnet::dump('critical');
1293: my $result = '';
1294: my $critmsgcount = 0;
1.3 albertel 1295: foreach my $msgid (sort(keys(%what))) {
1.10 raeburn 1296: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
1297: &Apache::lonmsg::unpackmsgid($msgid);
1298: if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
1.1 raeburn 1299: if (defined($sendtime) && $sendtime!~/error/) {
1.93 droeschl 1300: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
1.1 raeburn 1301: $critmsgcount ++;
1.10 raeburn 1302: if ($shortsubj eq '') {
1303: $shortsubj = &mt('No subject');
1304: }
1.1 raeburn 1305: push(@{$critmsgs}, {
1306: msgid => $msgid,
1307: sendtime => $sendtime,
1.10 raeburn 1308: shortsub => $shortsubj,
1.1 raeburn 1309: from => $fromname,
1310: fromdom => $fromdom
1311: });
1312: }
1313: }
1314: }
1.33 raeburn 1315: return $critmsgcount;
1316: }
1317:
1.77 raeburn 1318: sub getexpired {
1319: my ($rolechgs,$rolechgtime,$status) = @_;
1320: my $expirecount = &getrolechanges($rolechgs,$rolechgtime,$status);
1321: return $expirecount;
1322: }
1323:
1324: sub getactivated {
1325: my ($rolechgs,$rolechgtime,$status) = @_;
1326: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1327: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1328: my $now = time();
1329: my $context = 'course';
1330: my ($permission,$allowed) =
1331: &Apache::lonuserutils::get_permission($context);
1332: my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
1333: my %changes=&Apache::lonnet::dump('nohist_rolelog',$cdom,$cnum);
1334: my (%stucounted,%advcounted);
1335: my $activatedcount = 0;
1336: if (keys(%changes) > 0) {
1337: foreach my $chg (sort { $b <=> $a } (keys(%changes))) {
1338: if (ref($changes{$chg}) eq 'HASH') {
1339: my $timestamp = $changes{$chg}{'exe_time'};
1340: if ($timestamp) {
1.79 raeburn 1341: if ($rolechgtime > 0) {
1342: if ($timestamp < $rolechgtime) {
1.77 raeburn 1343: last;
1344: }
1345: }
1346: if (ref($changes{$chg}{'logentry'}) eq 'HASH') {
1347: next if ($changes{$chg}{'delflag'});
1348: my $start = $changes{$chg}{'logentry'}{'start'};
1349: my $end = $changes{$chg}{'logentry'}{'end'};
1350: my $section = $changes{$chg}{'logentry'}{'section'};
1351: my $role = $changes{$chg}{'logentry'}{'role'};
1352: my $uname = $changes{$chg}{'uname'};
1353: my $udom = $changes{$chg}{'udom'};
1354: next if ($end && $end <= $now);
1355: if (($viewablesec ne '') && ($section ne '')) {
1356: next if ($viewablesec ne $section);
1357: }
1358: next if ($start >= $timestamp);
1359: if ($role eq 'st') {
1360: $stucounted{$uname.':'.$udom.':'.$section} = $start.':'.$end;
1361: } else {
1362: $advcounted{$uname.':'.$udom.':'.$role.':'.$section} = $start.':'.$end;
1363: }
1364: my %chginfo = (
1365: 'section' => $section,
1366: 'uname' => $uname,
1367: 'udom' => $udom,
1368: 'role' => $role,
1369: 'status' => $status,
1370: );
1371: $activatedcount ++;
1372: push (@{$rolechgs->{$timestamp}},\%chginfo);
1373: }
1374: }
1375: }
1376: }
1377: }
1378: $activatedcount += &getrolechanges($rolechgs,$rolechgtime,$status,\%stucounted,\%advcounted);
1379: return $activatedcount;
1380: }
1381:
1382: sub getrolechanges {
1383: my ($rolechgs,$rolechgtime,$status,$stucountref,$advcountref) = @_;
1384: my (%stucounted,%advcounted);
1385: if (ref($stucountref) eq 'HASH') {
1386: %stucounted = %{$stucountref};
1387: }
1388: if (ref($advcountref) eq 'HASH') {
1389: %advcounted = %{$advcountref};
1390: }
1391: my $withsec = 1;
1392: my $hidepriv = 1;
1393: my $context = 'course';
1394: my @statuses = ($status);
1395: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1396: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1397: my $now = time();
1398: my ($permission,$allowed) =
1399: &Apache::lonuserutils::get_permission($context);
1400: my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
1401: my $classlist = &Apache::loncoursedata::get_classlist();
1402: my $secidx = &Apache::loncoursedata::CL_SECTION();
1403: my $startidx = &Apache::loncoursedata::CL_START();
1404: my $endidx = &Apache::loncoursedata::CL_END();
1405: my $rolechgcount = 0;
1406: foreach my $key (keys(%{$classlist})) {
1407: my ($userstatus,$eventtime);
1408: my $student = $classlist->{$key};
1409: if (ref($student) eq 'ARRAY') {
1410: my $start = $student->[$startidx];
1411: my $end = $student->[$endidx];
1412: my $sec = $student->[$secidx];
1413: my ($stuname,$studom) = split(/:/,$key);
1414: if ($status eq 'active') {
1415: if (exists($stucounted{$key.':'.$sec})) {
1416: next;
1417: }
1418: }
1419: if (($end == 0) || ($end > $start)) {
1420: if ($start <= $now) {
1421: if ($end && $end < $now) {
1422: if ($rolechgtime > 0) {
1423: if ($end > $rolechgtime) {
1424: $userstatus = 'previous';
1425: }
1426: } else {
1427: $userstatus = 'previous';
1428: }
1429: } else {
1430: if ($rolechgtime > 0) {
1431: if ($start >= $rolechgtime) {
1432: $userstatus = 'active';
1433: }
1434: } else {
1435: $userstatus = 'active';
1436: }
1437: }
1438: }
1439: }
1440: next if ($userstatus ne $status);
1441: if ($status eq 'active') {
1442: $eventtime = $start;
1443: } else {
1444: $eventtime = $end;
1445: }
1446: if (($viewablesec ne '') && ($sec ne '')) {
1447: next if ($viewablesec ne $sec);
1448: }
1449: my %chginfo = (
1450: 'section' => $sec,
1451: 'uname' => $stuname,
1452: 'udom' => $studom,
1453: 'role' => 'st',
1454: 'status' => $userstatus,
1455: );
1456: $rolechgcount ++;
1457: push (@{$rolechgs->{$eventtime}},\%chginfo);
1458: }
1459: }
1460: my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
1461: \@statuses,undef,undef,$withsec,$hidepriv);
1462: foreach my $item (keys(%advrolehash)) {
1463: my ($userstatus,$eventtime);
1464: my ($uname,$udom,$role,$section) = split(/:/,$item,-1);
1465: my ($start,$end) = split(/:/,$advrolehash{$item});
1466: if ($start eq '-1' && $end eq '-1') {
1467: next;
1468: } else {
1469: if ($status eq 'active') {
1470: if (exists($advcounted{$item})) {
1471: next;
1472: }
1473: }
1474: if (($end == 0) || ($end > $start)) {
1475: if ($start <= $now) {
1476: if ($end && $end < $now) {
1477: if ($rolechgtime > 0) {
1478: if ($end > $rolechgtime) {
1479: $userstatus = 'previous';
1480: }
1481: } else {
1482: $userstatus = 'previous';
1483: }
1484: } else {
1485: if ($rolechgtime > 0) {
1486: if ($start >= $rolechgtime) {
1487: $userstatus = 'active';
1488: }
1489: } else {
1490: $userstatus = 'active';
1491: }
1492: }
1493: }
1494: }
1495: next if ($userstatus ne $status);
1496: if ($status eq 'active') {
1497: $eventtime = $start;
1498: } else {
1499: $eventtime = $end;
1500: }
1501: }
1502: if (($viewablesec ne '') && ($section ne '')) {
1503: next if ($viewablesec ne $section);
1504: }
1505: my %chginfo = (
1506: 'section' => $section,
1507: 'uname' => $uname,
1508: 'udom' => $udom,
1509: 'role' => $role,
1510: 'status' => $userstatus,
1511: );
1512: $rolechgcount ++;
1513: push (@{$rolechgs->{$eventtime}},\%chginfo);
1514: }
1515: return $rolechgcount;
1516: }
1.33 raeburn 1517:
1.101.2.1.2.1! (raeburn 1518:: sub getloggedin {
! 1519:: my ($cdom,$crs,$lastlogins,$starttime) = @_;
! 1520:: my $context = 'course';
! 1521:: my ($permission,$allowed) =
! 1522:: &Apache::lonuserutils::get_permission($context);
! 1523:: my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
! 1524:: my %crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$crs);
! 1525:: my $logincount = 0;
! 1526:: my ($tmp) = keys(%crslogins);
! 1527:: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
! 1528:: if (keys(%crslogins) > 0) {
! 1529:: foreach my $key (keys(%crslogins)) {
! 1530:: my ($uname,$udom,$section,$role) = split(/:/,$key);
! 1531:: my $eventtime = $crslogins{$key};
! 1532:: if ($eventtime > $starttime) {
! 1533:: if (($viewablesec ne '') && ($section ne '')) {
! 1534:: next if ($viewablesec ne $section);
! 1535:: }
! 1536:: my %chginfo = (
! 1537:: 'section' => $section,
! 1538:: 'uname' => $uname,
! 1539:: 'udom' => $udom,
! 1540:: 'role' => $role,
! 1541:: );
! 1542:: $logincount ++;
! 1543:: push (@{$lastlogins->{$eventtime}},\%chginfo);
! 1544:: }
! 1545:: }
! 1546:: }
! 1547:: }
! 1548:: return $logincount;
! 1549:: }
! 1550::
1.33 raeburn 1551: sub checkversions {
1552: my ($cdom,$crs,$navmap,$changed,$starttime) = @_;
1553: my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs);
1554: my ($tmp) = keys(%changes);
1.40 raeburn 1555: unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 1556: if (keys(%changes) > 0) {
1557: foreach my $key (sort(keys(%changes))) {
1558: if ($changes{$key} > $starttime) {
1559: my $version;
1560: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
1561: my $currentversion=&Apache::lonnet::getversion($key);
1562: my $revdate =
1563: &Apache::lonnet::metadata($root.'.'.$extension,
1564: 'lastrevisiondate');
1565: $revdate = &Apache::lonlocal::locallocaltime($revdate);
1566: my $linkurl=&Apache::lonnet::clutter($key);
1.101.2.1 raeburn 1567: my $usedversion=$navmap->usedVersion($linkurl);
1.33 raeburn 1568: my @resources = $navmap->getResourceByUrl($linkurl,1);
1569: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1570: $version = $usedversion;
1571: } else {
1572: $version = $currentversion;
1573: }
1574: foreach my $res (@resources) {
1.35 raeburn 1575: if (ref($res) eq 'Apache::lonnavmaps::resource') {
1576: my $symb = $res->symb();
1577: %{$$changed{$symb}} = (
1.33 raeburn 1578: current => $currentversion,
1579: version => $version,
1580: revdate => $revdate,
1.35 raeburn 1581: );
1582: }
1.33 raeburn 1583: }
1584: }
1585: }
1586: }
1587: }
1588: return;
1589: }
1590:
1591: sub display_handgrade {
1.84 raeburn 1592: my ($r,$tograde,$ungraded,$itemserror) = @_;
1.33 raeburn 1593: my %lt = &Apache::lonlocal::texthash(
1594: 'prna' => 'Problem Name',
1595: 'nmun' => 'Number ungraded',
1596: 'nopr' => 'No problems require handgrading',
1597: );
1598: if (@{$tograde} > 0) {
1.68 raeburn 1599: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1600: $lt{'prna'}.'</td><td class="LC_right_item">'.
1601: $lt{'nmun'}.'</td></tr>');
1.33 raeburn 1602: my $rowNum = 0;
1603: foreach my $res (@{$tograde}) {
1.68 raeburn 1604: $rowNum ++;
1605: my $css_class = $rowNum%2?' class="LC_odd_row"':'';
1.33 raeburn 1606: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
1607: my $linkurl=&Apache::lonnet::clutter($url);
1.55 www 1608: $linkurl .= '?symb='.&escape($res);
1.66 raeburn 1609: if ($$ungraded{$res}{'enclink'}) {
1610: $linkurl =
1611: $$ungraded{$res}{'enclink'}.'?symb='.$$ungraded{$res}{'encsymb'};
1612: }
1.68 raeburn 1613: $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 1614: }
1.84 raeburn 1615: } elsif ($itemserror) {
1616: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1617: } else {
1.68 raeburn 1618: $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
1.33 raeburn 1619: }
1620: }
1621:
1622: sub display_haserrors {
1.84 raeburn 1623: my ($r,$bombs,$bombed,$res_title,$itemserror) = @_;
1.33 raeburn 1624: my $bombnum = 0;
1625: my %lt = &Apache::lonlocal::texthash(
1626: reso => 'Resource',
1627: nmer => 'Number of errors',
1628: noer => 'No problems with errors',
1629: );
1630: if (@{$bombs} > 0) {
1.68 raeburn 1631: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1632: $lt{'reso'}.'</td><td class="LC_right_item">'.
1633: $lt{'nmer'}.'</td></tr>');
1.33 raeburn 1634: @{$bombs} = sort { &cmp_title($a,$b,$res_title) } @{$bombs};
1635: foreach my $bomb (@{$bombs}) {
1636: $bombnum ++;
1.68 raeburn 1637: my $css_class = $bombnum%2?' class="LC_odd_row"':'';
1638: $r->print('<tr'.$css_class.'><td>'.$$bombed{$bomb}{errorlink}.
1639: '</td><td class="LC_right_item">'.
1640: $$bombed{$bomb}{errorcount}.'</td></tr>');
1.33 raeburn 1641: }
1.84 raeburn 1642: } elsif ($itemserror) {
1643: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1644: } else {
1.68 raeburn 1645: $r->print('<tr class="LC_empty_row"><td>'.$lt{'noer'}.'</td></tr>');
1.33 raeburn 1646: }
1647: return;
1648: }
1649:
1650: sub display_abovethreshold {
1.84 raeburn 1651: my ($r,$refpage,$warnings,$triggered,$res_title,$itemserror) = @_;
1.33 raeburn 1652: my %lt = &Apache::lonlocal::texthash(
1653: reso => 'Resource',
1654: part => 'Part',
1655: nust => 'Num. students',
1656: avat => 'Av. Attempts',
1657: dedi => 'Deg. Diff',
1658: lare => 'Last Reset',
1659: reco => 'Reset Count?',
1660: rese => 'Reset counters to 0',
1661: nopr => 'No problems satisfy threshold criteria',
1662: );
1663: if (@{$warnings} > 0) {
1664: @{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings};
1.36 raeburn 1665: $r->print('<form name="reset_tracking" method="post" action="/adm/whatsnew">'.
1.39 raeburn 1666: ' <input type="hidden" name="command" value="reset" />'."\n".
1667: ' <input type="hidden" name="refpage" value="'.$refpage.'" />'.
1668: "\n");
1.61 albertel 1669: $r->print('<tr class="LC_info_row">'.
1.68 raeburn 1670: '<td class="LC_left_item">'.$lt{'reso'}.'</td>'.
1.61 albertel 1671: '<td>'.$lt{'part'}.'</td><td>'.$lt{'nust'}.'</td>'.
1672: '<td>'.$lt{'avat'}.'</td><td>'.$lt{'dedi'}.'</td>'.
1.68 raeburn 1673: '<td>'.$lt{'lare'}.'</td><td class="LC_right_item">'.
1674: $lt{'reco'}.'</td></tr>');
1.61 albertel 1675: my $row;
1.33 raeburn 1676: foreach my $res (@{$warnings}) {
1.61 albertel 1677: $row++;
1.33 raeburn 1678: my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
1679: my $linkurl=&Apache::lonnet::clutter($url);
1680: my $rowspan;
1681: if ($$triggered{$res}{numparts} > 1) {
1682: $rowspan = 'rowspan="'.$$triggered{$res}{numparts}.'"';
1683: }
1.55 www 1684: $linkurl .= '?symb='.&escape($res);
1.66 raeburn 1685: if ($$triggered{$res}{'enclink'}) {
1686: $linkurl =
1687: $$triggered{$res}{'enclink'}.'?symb='.$$triggered{$res}{'encsymb'};
1688: }
1.68 raeburn 1689: my $css_class = $row%2?' class="LC_odd_row"':'';
1690: $r->print('<tr'.$css_class.'>'.
1.61 albertel 1691: '<td class="LC_first_item" '.$rowspan.'><a href="'.$linkurl.'">'.
1.62 raeburn 1692: $$triggered{$res}{title}.'</a></td>');
1693: if (ref($$triggered{$res}{text}) eq 'ARRAY') {
1694: $r->print($$triggered{$res}{text}[0]);
1695: }
1696: $r->print('</tr>');
1697: if (ref($$triggered{$res}{text}) eq 'ARRAY') {
1698: if (@{$$triggered{$res}{text}} > 1) {
1699: for (my $i=1; $i<@{$$triggered{$res}{text}}; $i++) {
1700: $r->print('<tr class="'.$css_class.'">'.
1701: $$triggered{$res}{text}[$i].'</tr>');
1702: }
1703: }
1704: }
1.33 raeburn 1705: }
1.68 raeburn 1706: $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.84 raeburn 1707: } elsif ($itemserror) {
1708: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1709: } else {
1.63 albertel 1710: $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
1.33 raeburn 1711: }
1712: }
1713:
1714: sub display_versionchanges {
1.84 raeburn 1715: my ($r,$changed,$res_title,$interval,$itemserror) = @_;
1.33 raeburn 1716: my %lt = &Apache::lonlocal::texthash(
1717: 'reso' => 'Resource',
1718: 'revd' => 'Last revised',
1719: 'newv' => 'New version',
1720: 'veru' => 'Version used',
1721: );
1722: if (keys(%{$changed}) > 0) {
1.68 raeburn 1723: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1724: $lt{'reso'}.'</td><td>'.$lt{'revd'}.'</td><td>'.
1725: $lt{'newv'}.'</td><td class="LC_right_item">'.
1726: $lt{'veru'}.'</td></tr>');
1.33 raeburn 1727: my @changes = sort { &cmp_title($a,$b,$res_title) } keys(%{$changed});
1728: my $changenum = 0;
1729: foreach my $item (@changes) {
1.68 raeburn 1730: $changenum ++;
1731: my $css_class = $changenum%2?' class="LC_odd_row"':'';
1.33 raeburn 1732: my ($map,$id,$url)=&Apache::lonnet::decode_symb($item);
1733: my $linkurl=&Apache::lonnet::clutter($url);
1.55 www 1734: $linkurl .= '?symb='.&escape($item);
1.33 raeburn 1735:
1.68 raeburn 1736: $r->print('<tr'.$css_class.'><td><a href="'.$linkurl.'">'.
1737: $$res_title{$item}.'</a></td><td>'.
1738: $$changed{$item}{'revdate'}.'</td><td>'.
1739: $$changed{$item}{'current'}.'</td><td>'.
1740: $$changed{$item}{'version'}.'</td></tr>');
1.33 raeburn 1741: }
1.84 raeburn 1742: } elsif ($itemserror) {
1743: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1744: } else {
1.78 bisitz 1745: $r->print('<tr class="LC_empty_row"><td>'
1746: .&mt('No '.$interval).'</td></tr>');
1.33 raeburn 1747: }
1748: return;
1749: }
1.77 raeburn 1750:
1751: sub display_rolechanges {
1752: my ($r,$chgcount,$changed,$interval,$crstype) = @_;
1753: my $now = time();
1754: my %lt = &Apache::lonlocal::texthash(
1755: 'user' => 'User',
1756: 'tich' => 'Time of change',
1757: 'role' => 'Role',
1758: 'sec' => 'Section',
1759: 'status' => 'Status',
1760: );
1761: if ($chgcount) {
1762: $r->print('<tr class="LC_info_row">'.
1763: '<td class="LC_left_item">'.$lt{'tich'}.'</td>'.
1764: '<td class="LC_left_item">'.$lt{'user'}.'</td>'.
1765: '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
1766: '<td class="LC_left_item">'.$lt{'sec'}.'</td>'.
1767: '<td class="LC_left_item">'.$lt{'status'}.'</td></tr>');
1768: if (ref($changed) eq 'HASH') {
1769: my @changes = sort { $b <=> $a } (keys(%{$changed}));
1770: my $changenum = 0;
1771: foreach my $item (@changes) {
1772: if (ref($changed->{$item}) eq 'ARRAY') {
1773: foreach my $chg (@{$changed->{$item}}) {
1774: if (ref($chg) eq 'HASH') {
1775: my $section;
1776: my $role =
1777: &Apache::lonnet::plaintext($chg->{'role'},$crstype);
1778: my $status = &mt($chg->{'status'});
1779: if ($chg->{'section'} eq '') {
1780: $section = &mt('none');
1781: } else {
1782: $section = $chg->{'section'};
1783: }
1784: my $uname = $chg->{'uname'};
1785: my $udom = $chg->{'udom'};
1786: $changenum ++;
1787: my $css_class = $changenum%2?' class="LC_odd_row"':'';
1788: my $link =
1789: &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom);
1790: $r->print('<tr'.$css_class.'>'.
1.93 droeschl 1791: '<td>'.&Apache::lonlocal::locallocaltime($item).'</td>'.
1.77 raeburn 1792: '<td>'.$link.'</td>'.
1793: '<td>'.$role.'</td>'.
1794: '<td>'.$section.'</td>'.
1795: '<td>'.$status.'</td></tr>');
1796: }
1797: }
1798: }
1799: }
1800: }
1801: } else {
1.78 bisitz 1802: $r->print('<tr class="LC_empty_row"><td>'
1803: .&mt('There are no '.$interval).'</td></tr>');
1.77 raeburn 1804: }
1805: return;
1806: }
1.101.2.1.2.1! (raeburn 1807::
! 1808:: sub display_crslogins {
! 1809:: my ($r,$logincount,$loggedin,$interval,$crstype) = @_;
! 1810:: my %lt = &Apache::lonlocal::texthash(
! 1811:: 'user' => 'User',
! 1812:: 'role' => 'Role',
! 1813:: 'sec' => 'Section',
! 1814:: 'number' => 'Total number of logins',
! 1815:: );
! 1816:: if ($logincount) {
! 1817::
! 1818:: my $hdr = '<tr class="LC_info_row" style="display:none" id="logintitledet">'.
! 1819:: '<td class="LC_left_item">'.$lt{'user'}.'</td>'.
! 1820:: '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
! 1821:: '<td class="LC_left_item">'.$lt{'sec'}.'</td></tr>'.
! 1822:: '<tr class="LC_info_row" id="logintitlesum">'.
! 1823:: '<td class="LC_left_item">'.$lt{'number'}.'</td>'.
! 1824:: '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
! 1825:: '<td class="LC_left_item">'.$lt{'sec'};
! 1826:: my (%bylastname,%counts);
! 1827:: if (ref($loggedin) eq 'HASH') {
! 1828:: my @logins = sort { $b <=> $a } (keys(%{$loggedin}));
! 1829:: my $numlogin = 0;
! 1830:: foreach my $item (@logins) {
! 1831:: if (ref($loggedin->{$item}) eq 'ARRAY') {
! 1832:: foreach my $user (@{$loggedin->{$item}}) {
! 1833:: if (ref($user) eq 'HASH') {
! 1834:: my $section;
! 1835:: my $role =
! 1836:: &Apache::lonnet::plaintext($user->{'role'},$crstype);
! 1837:: my $status = &mt($user->{'status'});
! 1838:: if ($user->{'section'} eq '') {
! 1839:: $section = &mt('none');
! 1840:: } else {
! 1841:: $section = $user->{'section'};
! 1842:: }
! 1843:: $counts{$user->{'role'}}{$section} ++;
! 1844:: my $uname = $user->{'uname'};
! 1845:: my $udom = $user->{'udom'};
! 1846:: my $fullname = &Apache::loncommon::plainname($uname,$udom,'lastname');
! 1847:: my $link =
! 1848:: &Apache::loncommon::aboutmewrapper($fullname,$uname,$udom);
! 1849:: push(@{$bylastname{$fullname}},
! 1850:: '<td>'.$link.'</td>'.
! 1851:: '<td>'.$role.'</td>'.
! 1852:: '<td>'.$section.'</td>');
! 1853:: }
! 1854:: }
! 1855:: }
! 1856:: }
! 1857:: my $table;
! 1858:: foreach my $person (sort(keys(%bylastname))) {
! 1859:: if (ref($bylastname{$person}) eq 'ARRAY') {
! 1860:: foreach my $item (@{$bylastname{$person}}) {
! 1861:: $numlogin ++;
! 1862:: my $css_class = $numlogin%2?' class="LC_odd_row"':'';
! 1863:: $table .= '<tr'.$css_class.' style="display:none;" id="logindet_'.$numlogin.'">'.$item.'</tr>';
! 1864:: }
! 1865:: }
! 1866:: }
! 1867:: my $numrow = 0;
! 1868:: foreach my $role (sort(keys(%counts))) {
! 1869:: my $showrole = &Apache::lonnet::plaintext($role,$crstype);
! 1870:: if (ref($counts{$role}) eq 'HASH') {
! 1871:: foreach my $sec (sort { $b <=> $a } (keys(%{$counts{$role}}))) {
! 1872:: $numrow ++;
! 1873:: my $css_class = $numrow%2?' class="LC_odd_row"':'';
! 1874:: $table .= '<tr '.$css_class.' id="loginsum_'.$numrow.'">'.
! 1875:: '<td>'.$counts{$role}{$sec}.'</td>'.
! 1876:: '<td>'.$showrole.'</td>'.
! 1877:: '<td>'.$sec.'</td></tr>';
! 1878:: }
! 1879:: }
! 1880:: }
! 1881:: $r->print($hdr.'<input type="hidden" name="logincount" value="'.$numlogin.
! 1882:: '" /><input type="hidden" name="loginrow" value="'.$numrow.
! 1883:: '" /></td></tr>'.$table);
! 1884:: }
! 1885:: } else {
! 1886:: $r->print('<tr class="LC_empty_row"><td>'.
! 1887:: &mt('There are no '.$interval).
! 1888:: '<input type="hidden" name="logincount" value="'.$logincount.
! 1889:: '." /></td></tr>');
! 1890:: }
! 1891:: return;
! 1892:: }
1.33 raeburn 1893:
1894: sub display_coursediscussion {
1.84 raeburn 1895: my ($r,$newdiscussions,$unread,$countunread,$res_title,$itemserror) = @_;
1.59 albertel 1896: my $lctype = lc(&Apache::loncommon::course_type());
1.33 raeburn 1897: my %lt = &Apache::lonlocal::texthash(
1898: 'loca' => 'Location',
1899: 'type' => 'Type',
1900: 'numn' => 'Number of new posts',
1.56 raeburn 1901: 'noun' => 'No unread posts in '.$lctype.' discussions',
1.37 raeburn 1902: 'tmlp' => 'Time of last post',
1.33 raeburn 1903: );
1904: if (@{$newdiscussions} > 0) {
1.68 raeburn 1905: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1906: $lt{'loca'}.'</td><td>'.
1907: $lt{'type'}.'</td>');
1.39 raeburn 1908: if ($countunread eq 'on') {
1.68 raeburn 1909: $r->print('<td>'.$lt{'tmlp'}.'</td>'.
1910: '<td class="LC_right_item">'.$lt{'numn'}.'</td>');
1.37 raeburn 1911: } else {
1.68 raeburn 1912: $r->print('<td class="LC_right_item">'.$lt{'tmlp'}.'</td>');
1.37 raeburn 1913: }
1914: $r->print("</tr>\n");
1.33 raeburn 1915: @{$newdiscussions} = sort { &cmp_title($a,$b,$res_title) }
1916: @{$newdiscussions};
1917: my $rowNum = 0;
1918: foreach my $ressymb (@{$newdiscussions}) {
1.68 raeburn 1919: $rowNum ++;
1.33 raeburn 1920: my $forum_title = $$unread{$ressymb}{'title'};
1921: my $type = 'Resource';
1922: my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
1.66 raeburn 1923: my $disclink = $feedurl.'?symb='.$$unread{$ressymb}{symb};
1.33 raeburn 1924: if ($feedurl =~ /bulletinboard/) {
1.85 schafran 1925: $type = 'Discussion Board';
1.33 raeburn 1926: }
1.66 raeburn 1927: if ($$unread{$ressymb}{'enclink'}) {
1928: $disclink = $$unread{$ressymb}{'enclink'}.'?symb='.$$unread{$ressymb}{'encsymb'};
1929: }
1.68 raeburn 1930: my $css_class = $rowNum%2?' class="LC_odd_row"':'';
1.37 raeburn 1931: my $lastpost = &Apache::lonnavmaps::timeToHumanString(
1932: $$unread{$ressymb}{'lastpost'});
1.70 raeburn 1933: $r->print('<tr'.$css_class.'><td><a href="'.$disclink.'">'.$forum_title.'</a> </td><td>'.&mt($type).' </td>');
1.39 raeburn 1934: if ($countunread eq 'on') {
1.37 raeburn 1935: my $unreadnum = $$unread{$ressymb}{'unreadcount'};
1.68 raeburn 1936: $r->print('<td>'.$lastpost.'</td><td class="LC_right_item">'.
1937: $unreadnum.' </td>');
1.37 raeburn 1938: } else {
1.68 raeburn 1939: $r->print('<td class="LC_right_item">'.$lastpost.'</td>');
1.33 raeburn 1940: }
1.37 raeburn 1941: $r->print("</tr>\n");
1.33 raeburn 1942: }
1.84 raeburn 1943: } elsif ($itemserror) {
1944: $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
1.33 raeburn 1945: } else {
1.68 raeburn 1946: $r->print('<tr class="LC_empty_row"><td>'.$lt{'noun'}.'</td></tr>');
1.33 raeburn 1947: }
1948: }
1949:
1950: sub display_coursenormalmail {
1.68 raeburn 1951: my ($r,$msgcount,$newmsgs) = @_;
1.59 albertel 1952: my $lctype = lc(&Apache::loncommon::course_type());
1.33 raeburn 1953: if ($msgcount > 0) {
1.68 raeburn 1954: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1955: &mt('Number').'</td><td>'.&mt('Subject').'</td><td>'.
1956: &mt('Sender').'</td><td class="LC_right_item">'.
1957: &mt('Date/Time').'</td></tr>');
1958: my $mailcount = 0;
1.33 raeburn 1959: foreach my $msg (@{$newmsgs}) {
1960: $mailcount ++;
1.68 raeburn 1961: my $css_class = $mailcount%2?' class="LC_odd_row"':'';
1.76 raeburn 1962: $r->print('<tr'.$css_class.'><td>'.$mailcount
1963: .'. </td><td><a href="/adm/email?display='
1964: .$msg->{'msgid'}.'">'
1965: .$msg->{'shortsub'}.'</a> </td><td> '
1966: .$msg->{'from'}.':'.$msg->{'fromdom'}.' </td><td>'
1967: .$msg->{'sendtime'}.'</td></tr>');
1.33 raeburn 1968: }
1969: } else {
1.68 raeburn 1970: $r->print('<tr class="LC_empty_row"><td>'.
1971: &mt('No new '.$lctype.' messages').'</td></tr>');
1.33 raeburn 1972: }
1973: }
1974:
1975: sub display_coursecritmail {
1.68 raeburn 1976: my ($r,$critmsgcount,$critmsgs) = @_;
1.59 albertel 1977: my $lctype = lc(&Apache::loncommon::course_type());
1.33 raeburn 1978: if ($critmsgcount > 0) {
1.68 raeburn 1979: $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
1980: &mt('Number').'</td><td>'.&mt('Subject').'</td><td>'.
1981: &mt('Sender').'</td><td class="LC_right_item">'.
1982: &mt('Date/Time').'</td></tr>');
1983: my $mailcount = 0;
1.33 raeburn 1984: foreach my $msg (@{$critmsgs}) {
1985: $mailcount ++;
1.68 raeburn 1986: my $css_class = $mailcount%2?' class="LC_odd_row"':'';
1987: $r->print('<tr'.$css_class.'><td>'.$mailcount.
1988: '. </td><td><a href="/adm/email?folder=critical">'.
1989: $msg->{'shortsub'}.'</a> </td><td> '.
1.72 albertel 1990: $msg->{'from'}.':'.$msg->{'fromdom'}.' </td><td>'.
1.68 raeburn 1991: $msg->{'sendtime'}.'</td></tr>');
1.33 raeburn 1992: }
1993: } else {
1.68 raeburn 1994: $r->print('<tr class="LC_empty_row"><td>'.
1995: &mt('No unread critical messages in '.$lctype).
1996: '</td></tr>');
1.33 raeburn 1997: }
1.1 raeburn 1998: }
1999:
2000: sub cmp_title {
1.16 raeburn 2001: my ($a,$b,$res_title) = @_;
2002: my ($atitle,$btitle) = (lc($$res_title{$a}),lc($$res_title{$b}));
1.1 raeburn 2003: $atitle=~s/^\s*//;
2004: $btitle=~s/^\s*//;
2005: return $atitle cmp $btitle;
2006: }
2007:
1.33 raeburn 2008: sub get_display_settings {
1.36 raeburn 2009: my ($uname,$udom,$cid) = @_;
1.33 raeburn 2010: my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid);
2011: my ($tmp) = keys(%settings);
1.40 raeburn 2012: if ($tmp=~ /^(con_lost|error|no_such_host)/i) {
1.33 raeburn 2013: %settings = ();
1.41 raeburn 2014: unless ($tmp =~ /^error: 2 /) {
1.59 albertel 2015: my $lctype = lc(&Apache::loncommon::course_type());
1.41 raeburn 2016: &Apache::lonnet::logthis('Error retrieving whatsnew settings: '.
1.56 raeburn 2017: $tmp.' for '.$uname.':'.$udom.' for '.$lctype.': '.$cid);
1.33 raeburn 2018: }
2019: }
2020: return %settings;
2021: }
2022:
1.36 raeburn 2023: sub store_display_settings {
2024: my ($uname,$udom,$cid,$checkallowed) = @_;
2025: my %whatsnew_settings;
2026: my $result;
2027: foreach my $key (keys(%{$checkallowed})) {
1.44 albertel 2028: if ($key =~ /_section$/) { next; }
1.36 raeburn 2029: if (exists($env{'form.display_'.$key})) {
2030: unless ($env{'form.display_'.$key} eq '') {
2031: $whatsnew_settings{$cid.':'.$key} = $env{'form.display_'.$key};
2032: }
2033: }
2034: }
2035: if (keys(%whatsnew_settings)) {
2036: $result = &Apache::lonnet::put('nohist_whatsnew',\%whatsnew_settings,
2037: $udom,$uname);
2038: } else {
2039: $result = 'ok';
2040: }
2041: return $result;
2042: }
2043:
2044: sub store_interval_setting {
2045: my ($uname,$udom,$cid,$interval_titles) = @_;
2046: my %interval_settings = ();
2047: my $result;
1.77 raeburn 2048: my $context = $env{'form.intervaltype'};
2049: if ($env{'form.interval'} ne '') {
2050: if ($context eq 'oldroles') {
2051: $interval_settings{$cid.':oldroleinterval'} = $env{'form.interval'};
2052: } elsif ($context eq 'newroles') {
2053: $interval_settings{$cid.':newroleinterval'} = $env{'form.interval'};
1.101.2.1.2.1! (raeburn 2054:: } elsif ($context eq 'crslogin') {
! 2055:: $interval_settings{$cid.':crslogininterval'} = $env{'form.interval'};
1.77 raeburn 2056: } else {
2057: $interval_settings{$cid.':interval'} = $env{'form.interval'};
2058: }
1.36 raeburn 2059: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
2060: \%interval_settings,$udom,$uname);
2061: if ($outcome eq 'ok') {
1.77 raeburn 2062: if (ref($interval_titles->{$context}) eq 'HASH') {
1.99 wenzelju 2063: $result = &Apache::lonhtmlcommon::confirm_success(&mt('New filter setting: [_1].','<b>'.
2064: $interval_titles->{$context}->{$env{'form.interval'}}.'</b>').'<br />');
1.77 raeburn 2065: }
1.36 raeburn 2066: } else {
1.59 albertel 2067: my $lctype = lc(&Apache::loncommon::course_type());
1.77 raeburn 2068: &Apache::lonnet::logthis('Error saving whatsnew '.$context.' interval setting'.
1.56 raeburn 2069: ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
1.99 wenzelju 2070: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set interval to [_1] due to [_2].',
1.77 raeburn 2071: '<b>'.$interval_titles->{$context}->{$env{'form.interval'}}.'</b>',
1.99 wenzelju 2072: '<tt>'.$outcome.'</tt>'),1);
1.36 raeburn 2073: }
2074: }
1.99 wenzelju 2075: return &Apache::loncommon::confirmwrapper($result);
1.36 raeburn 2076: }
2077:
1.39 raeburn 2078: sub store_discussion_setting {
2079: my ($uname,$udom,$cid) = @_;
2080: my %discussion_settings;
2081: my $result;
2082: if (defined($env{'form.countunread'})) {
2083: $discussion_settings{$cid.':countunread'} = $env{'form.countunread'};
2084: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
2085: \%discussion_settings,$udom,$uname);
2086: if ($outcome eq 'ok') {
1.99 wenzelju 2087: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Count unread posts in discussions display set to [_1]',
2088: '<b>'.&mt($env{'form.countunread'}).'</b>').'<br />');
1.39 raeburn 2089:
2090: } else {
1.59 albertel 2091: my $lctype = lc(&Apache::loncommon::course_type());
1.71 albertel 2092: &Apache::lonnet::logthis('Error saving whatsnew countunread setting'.
1.56 raeburn 2093: ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
1.99 wenzelju 2094: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set "number unread posts display" to [_1]'.
1.39 raeburn 2095: ' due to [_2].',
1.74 bisitz 2096: '<b>'.&mt($env{'form.countunread'}).'</b>',
1.99 wenzelju 2097: '<tt>'.$outcome.'</tt>'),1);
1.39 raeburn 2098: }
2099: }
1.99 wenzelju 2100: return &Apache::loncommon::confirmwrapper($result);
1.39 raeburn 2101: }
2102:
2103: sub store_courseinit_setting {
2104: my ($uname,$udom,$cid,$initpage) = @_;
2105: my %courseinit_settings;
2106: my $page_control;
2107: my $result;
2108: if (defined($env{'form.courseinit_control'})) {
2109: if ($env{'form.courseinit_control'} eq 'userpref') {
2110: $courseinit_settings{$cid.':courseinit'} = '';
2111: $page_control = 'global preferences';
2112: } else {
2113: if (defined($env{'form.courseinit_page'})) {
2114: $courseinit_settings{$cid.':courseinit'} =
2115: $env{'form.courseinit_page'};
2116: $page_control = 'course specific setting';
2117: }
2118: }
2119: if ($page_control) {
1.59 albertel 2120: my $lctype = lc(&Apache::loncommon::course_type());
1.39 raeburn 2121: my $outcome = &Apache::lonnet::put('nohist_whatsnew',
2122: \%courseinit_settings,$udom,$uname);
2123: if ($outcome eq 'ok') {
2124: if ($page_control eq 'global preferences') {
1.99 wenzelju 2125: $result = &Apache::lonhtmlcommon::confirm_success(&mt("Page displayed after role selection in $lctype now set by [_1]user's global preferences[_2].",'<b>','</b>'));
1.39 raeburn 2126: } else {
1.99 wenzelju 2127: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Page displayed after role selection in this '.$lctype.' set to [_1].'
2128: ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>'));
1.39 raeburn 2129: }
2130: } else {
1.71 albertel 2131: &Apache::lonnet::logthis('Error saving whatsnew courseinit '.
1.39 raeburn 2132: 'setting: '.$outcome.' for '.$uname.
1.56 raeburn 2133: ':'.$udom.' in '.$lctype.' '.$cid);
1.39 raeburn 2134: if ($page_control eq 'global preferences') {
1.99 wenzelju 2135: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set control of page display to [_1]'.
1.39 raeburn 2136: ' due to [_2].',
2137: '<b>'.$page_control.'</b>',
1.99 wenzelju 2138: '<tt>'.$outcome.'</tt>'),1);
1.39 raeburn 2139: } else {
1.99 wenzelju 2140: $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].'
1.81 bisitz 2141: ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>'
1.99 wenzelju 2142: ,'<tt>'.$outcome.'</tt>'),1);
1.39 raeburn 2143: }
2144: }
2145: }
2146: }
1.99 wenzelju 2147: return &Apache::loncommon::confirmwrapper($result);
1.39 raeburn 2148: }
2149:
1.33 raeburn 2150: sub start_box {
1.69 raeburn 2151: my ($r,$show,$heading,$caller,$refpage) = @_;
1.33 raeburn 2152: my %lt = &Apache::lonlocal::texthash(
2153: chth => 'Change thresholds?',
2154: chin => 'Change interval?',
1.39 raeburn 2155: chop => 'Change options?',
1.33 raeburn 2156: );
1.68 raeburn 2157: my $showhide;
1.33 raeburn 2158: if ($$show{$caller}) {
1.36 raeburn 2159: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1.70 raeburn 2160: 'display_'.$caller.",'hide'".');">'.
2161: &mt('Hide').'</a></b>';
1.33 raeburn 2162:
2163: } else {
1.36 raeburn 2164: $showhide = '<b><a href="javascript:change_display(document.visible.'.
1.70 raeburn 2165: 'display_'.$caller.",'show'".');">'.
2166: &mt('Show').'</a></b>';
1.33 raeburn 2167: }
2168:
2169: $r->print('
1.68 raeburn 2170: <table class="LC_nested_outer">
1.33 raeburn 2171: <tr>
1.73 raeburn 2172: <th class="LC_left_item">'.$$heading{$caller}.'</th>
1.68 raeburn 2173: <th class="LC_right_item">'.$showhide.'</th>
2174: </tr>');
1.33 raeburn 2175: if (($caller eq 'abovethreshold') && ($$show{$caller})) {
1.40 raeburn 2176: if ($$show{$caller}) {
2177: $r->print('
1.33 raeburn 2178: <tr>
1.98 raeburn 2179: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgthreshold&refpage='.$refpage.'">'.$lt{'chth'}.'</a></td>
1.33 raeburn 2180: </tr>');
1.40 raeburn 2181: }
1.33 raeburn 2182: } elsif (($caller eq 'versionchanges') && ($$show{$caller})) {
1.40 raeburn 2183: if ($$show{$caller}) {
2184: $r->print('
1.33 raeburn 2185: <tr>
1.98 raeburn 2186: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chginterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1.39 raeburn 2187: </tr>');
1.40 raeburn 2188: }
1.39 raeburn 2189: } elsif ($caller eq 'coursediscussion') {
1.40 raeburn 2190: if ($$show{$caller}) {
2191: $r->print('
1.39 raeburn 2192: <tr>
1.98 raeburn 2193: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgdisc&refpage='.$refpage.'">'.$lt{'chop'}.'</a></td>
1.33 raeburn 2194: </tr>');
1.40 raeburn 2195: }
1.77 raeburn 2196: } elsif (($caller eq 'newroles') && ($$show{$caller})) {
2197: if ($$show{$caller}) {
2198: $r->print('
2199: <tr>
1.98 raeburn 2200: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgnewroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1.77 raeburn 2201: </tr>');
2202: }
2203: } elsif (($caller eq 'oldroles') && ($$show{$caller})) {
2204: if ($$show{$caller}) {
2205: $r->print('
2206: <tr>
1.98 raeburn 2207: <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgoldroleinterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
1.77 raeburn 2208: </tr>');
2209: }
1.101.2.1.2.1! (raeburn 2210:: } elsif (($caller eq 'crslogin') && ($$show{$caller})) {
! 2211:: if ($$show{$caller}) {
! 2212:: $r->print('
! 2213:: <tr>
! 2214:: <td class="LC_subheader" align="left"><span class="LC_nobreak"><label><input type="radio" name="logindetails" value="0" checked="checked" onclick="javascript:togglelogins();" /> '.&mt('Summary').'</label><label><input type="radio" name="logindetails" value="1" onclick="javascript:togglelogins();" /> '.&mt('Details').'</label></span></td><td class="LC_subheader"><a href="/adm/whatsnew?command=chgcrslogininterval&refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
! 2215:: </tr>');
! 2216:: }
! 2217:: }
! 2218::
1.61 albertel 2219: $r->print('
1.33 raeburn 2220: <tr>
1.68 raeburn 2221: <td colspan="2">
2222: <table class="LC_nested">
1.33 raeburn 2223: ');
2224: return;
2225: }
2226:
2227: sub end_box {
2228: my ($r) = shift;
2229: $r->print('
2230: </table>
2231: </td>
2232: </tr>
2233: </table><br />');
2234: return;
2235: }
2236:
1.7 raeburn 2237: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>