File:  [LON-CAPA] / loncom / interface / lonwhatsnew.pm
Revision 1.126: download - view: text, annotated - select for diffs
Mon Mar 30 11:04:13 2020 UTC (4 years, 2 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Last activity data for course users from server's in course's domain on
  "What's New" page.

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>