File:  [LON-CAPA] / loncom / interface / lonwhatsnew.pm
Revision 1.127: download - view: text, annotated - select for diffs
Mon Mar 30 16:26:46 2020 UTC (4 years, 1 month ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Update actions which require call to &getitems() to retrieve data.

    1: #
    2: # $Id: lonwhatsnew.pm,v 1.127 2020/03/30 16:26:46 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:                 $item eq 'crslogin' || $item eq 'sessions') {
  658:             if ($show{$item}) {
  659:                 $needitems = 1;
  660:                 last;
  661:             }
  662:         }
  663:     }
  664: 
  665:     my $itemserror;
  666:     if ($needitems) {
  667:         $itemserror = &getitems(\%unread,\%ungraded,\%bombed,\%triggered,\%changed,\@newdiscussions,\@tograde,\@bombs,\@warnings,\%threshold,$cdom,$crs,\%res_title,\%show,$starttime,$countunread,$checkallowed);
  668:     }
  669:     my $classlist;
  670:     if ($show{'oldroles'} || $show{'newroles'} || $show{'crslogin'} || $show{'sessions'}) {
  671:         $classlist = &Apache::loncoursedata::get_classlist();
  672:     }
  673:     if ($show{'coursenormalmail'}) {
  674:         $msgcount = &getnormalmail(\@newmsgs);
  675:     }
  676:     if ($show{'coursecritmail'}) {
  677:         $critmsgcount = &getcritmail(\@critmsgs);
  678:     }
  679:     if ($show{'oldroles'}) {
  680:         $expirecount = &getexpired(\%expired,$expiredstart,'previous',$classlist);
  681:     }
  682:     if ($show{'newroles'}) {
  683:         $activecount = &getactivated(\%activated,$activatedstart,'active',$classlist);
  684:     }
  685:     if ($show{'crslogin'}) {
  686:         $logincount = &getloggedin($cdom,$crs,\%loggedin,$crsloginstart);
  687:     }
  688:     if ($show{'sessions'}) {
  689:         $sessioncount = &getsessions($cdom,$crs,\%sessions,$timediff{'sessions'},$classlist);
  690:     }
  691:     $r->print(qq|<a href="javascript:changeAll('hide');">$lt{'hial'}</a>
  692:      &nbsp;&nbsp;<a href="javascript:changeAll('show');">$lt{'shal'}</a>
  693:      <form method="post" name="visible" action="/adm/whatsnew">\n|);
  694:     foreach my $item (keys(%{$checkallowed})) {
  695: 	if ($item =~ /_section$/) { next; }
  696:         if ($$checkallowed{$item}) {
  697:             $r->print('<input type="hidden" name="display_'.$item.'" />'."\n");
  698:         }
  699:     }
  700: 
  701:     $r->print('<input type="hidden" name="refpage" value="'.$refpage.'" /><table class="LC_double_column"><tr><td class="LC_left_col">');
  702: 
  703:     my $displayed = 0;
  704:     my $totalboxes = 0;
  705:     foreach my $key (keys(%{$checkallowed})) {
  706: 	if ($key =~ /_section$/) { next; }
  707: 	if ($key eq 'whatsnew' ) { next; } # whatsnew check creates no box
  708:         if ($$checkallowed{$key}) {
  709:             $totalboxes ++;
  710:         }
  711:     }
  712:     my $currcolumn = 'left';
  713: #    my $halfway = int($totalboxes/2) + $totalboxes%2;
  714:     foreach my $actionitem (@actionorder) {
  715:         if ($checkallowed->{$actionitem}) {
  716:             if (($actioncolumn{$actionitem} eq 'right') && ($currcolumn eq 'left')) {
  717:                 $r->print('</td><td>&nbsp;</td><td class="LC_right_col" >');
  718:                 $currcolumn = 'right'; 
  719:             }
  720:             &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);
  721:             $displayed ++; 
  722:         }
  723:     }
  724:     $r->print('
  725:       </td>
  726:     </tr>
  727:    </table>
  728:    </form>
  729: ');
  730: }
  731: 
  732: #-------------------------------
  733: # display_threshold_config
  734: #
  735: # Display the threshold setting screen 
  736: #
  737: #-------------------------------
  738:                                                                                 
  739: sub display_threshold_config {
  740:     my ($r,$refpage,$threshold_titles,$cdom,$crs) = @_;
  741:     my $uname = $env{'user.name'};
  742:     my $udom = $env{'user.dom'};
  743:     my $cid = $env{'request.course.id'};
  744:     my %threshold = ();
  745:     my $rowColor1 = "#ffffff";
  746:     my $rowColor2 = "#eeeeee";
  747:     my $rowColor;
  748: 
  749:     my @thresholditems = ("av_attempts","degdiff","numstudents");
  750:     my %threshold_titles = &Apache::lonlocal::texthash(
  751:                          av_attempts => 'Average number of attempts',
  752:                          degdiff => 'Degree of difficulty',
  753:                          numstudents => 'Total number of students with submissions',
  754:                          );
  755:     &get_curr_thresholds(\%threshold,$uname,$udom,$cid,$cdom,$crs);
  756: 
  757:     $r->print('<br /><form name="thresholdform" method="post" action="/adm/whatsnew">'.
  758:               &Apache::loncommon::start_data_table().
  759:               &Apache::loncommon::start_data_table_header_row().
  760:              '<th>'.&mt('Threshold Name').'</th>'."\n".
  761:              '<th>'.&mt('Current value').'</th>'."\n".
  762:              '<th>'.&mt('Change?').'</th>'."\n".
  763:               &Apache::loncommon::end_data_table_header_row());
  764:     foreach my $type (@thresholditems) {
  765:         my $parameter = $env{'request.course.id'}.':threshold_'.$type;
  766: # onchange is javascript to automatically check the 'Set' button.
  767:         my $onchange = 'onfocus="javascript:window.document.forms'.
  768:               "['thresholdform'].elements['".$parameter."_setparmval']".
  769:               '.checked=true;"';
  770:         $r->print(&Apache::loncommon::start_data_table_row()."\n".
  771:                  '<td>'.$threshold_titles{$type}.'</td>'."\n".
  772:                  '<td>'.&Apache::lonhtmlcommon::textbox($parameter.'_value',
  773:                                             $threshold{$type},
  774:                                             10,$onchange).'</td>'."\n".
  775:                  '<td>'.
  776:                  &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
  777:                  '</td>'."\n".
  778:                  &Apache::loncommon::end_data_table_row());
  779:     }
  780:     $r->print(&Apache::loncommon::end_data_table()."\n".
  781:           '<br /><input type="submit" name="threshold" value="'.&mt('Save').'" />
  782:                  <input type="hidden" name="command" value="update" />
  783:                  <input type="hidden" name="refpage" value="'.$refpage.'" />
  784:                </form>');
  785: }
  786: 
  787: #-------------------------------
  788: # display_interval_config
  789: #
  790: # Display the interval setting screen
  791: #
  792: #-------------------------------
  793:                                                                                    
  794: sub display_interval_config {
  795:     my ($r,$refpage,$interval_titles,$context) = @_;
  796:     my $setting = 'interval';
  797:     if ($context eq 'oldroles') {
  798:         $setting = 'oldroleinterval';
  799:     } elsif ($context eq 'newroles') {
  800:         $setting = 'newroleinterval'; 
  801:     } elsif ($context eq 'sessions') {
  802:         $setting = 'sessionactivity';
  803:     }
  804:     my $lctype = lc(&Apache::loncommon::course_type());
  805:     my $current = &get_current($env{'user.name'},$env{'user.domain'},
  806:                                 $env{'request.course.id'},$setting);
  807:     if ($context eq 'oldroles') {
  808:         $r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' expired.').'<br />');
  809:     } elsif ($context eq 'newroles') {
  810:         $r->print('<br />'.&mt('Choose the time window to use to display roles for which access to the '.$lctype.' became available.').'<br />');
  811:     } elsif ($context eq 'crslogin') {
  812:         $r->print('<br />'.&mt('Choose the time window to use to display the last login by a user in the '.$lctype).'<br />');
  813:     } elsif ($context eq 'sessions') {
  814:         $r->print('<br />'.&mt('Choose the time limit to use to display active user sessions in the '.$lctype.'.').'<br />');
  815:     } else {
  816:         $r->print('<br />'.&mt('Choose the time window to use to display resources in the '.$lctype.' with version changes.').'<br />');
  817:     }
  818:     unless ($current eq '') {
  819:         if (ref($interval_titles->{$context}) eq 'HASH') {
  820:             $r->print(' '.&mt('Current value is "[_1]".','<b>'.
  821:                       $interval_titles->{$context}->{$current}.'</b>').'<br />');
  822:         }
  823:     }
  824:     $r->print('<br />
  825: <form method="post" name="intervalswitch" action="/adm/whatsnew">
  826: <input type="hidden" name="command" value="newinterval" />
  827: <input type="hidden" name="intervaltype" value="'.$context.'" />
  828: <input type="hidden" name="refpage" value="'.$refpage.'" />'.
  829: &mt('Display:').' 
  830: <select name="interval">
  831: <option value="" selected="selected">'.&mt('Select').'</option>
  832: ');
  833:     if (ref($interval_titles) eq 'HASH') {
  834:         if (ref($interval_titles->{$context}) eq 'HASH') {
  835:             my @sorted;
  836:             if ($context eq 'sessions') {
  837:                 @sorted = sort { $a <=> $b } (keys(%{$interval_titles->{$context}}));
  838:                 push(@sorted,shift(@sorted));
  839:             } else {
  840:                 @sorted = reverse sort ({$a cmp $b} (keys(%{$interval_titles->{$context}})));
  841:             }
  842:             foreach my $key (@sorted) {
  843:                 $r->print('<option value="'.$key.'">'.&mt($interval_titles->{$context}->{$key}).
  844:                           '</option>'."\n");
  845:             }
  846:         }
  847:     }
  848:     $r->print('</select>&nbsp;&nbsp;
  849:                <input type="submit" name="display" value="'.
  850:                &mt('Save').'" /></form>');
  851:     return;
  852: }
  853: 
  854: #----------------------------------------------
  855: # display_discussion_config
  856: #
  857: # Display the discussion display setting screen
  858: #
  859: #----------------------------------------------
  860:                                                                                   
  861: sub display_discussion_config {
  862:     my ($r,$refpage) = @_;
  863:     my $current = &get_current($env{'user.name'},$env{'user.domain'},
  864:                                 $env{'request.course.id'},'countunread');
  865:     if ($current eq '') {
  866:         $current = 'on';
  867:     }
  868:     my %opposite = ( 
  869:                       'on' => 'off',
  870:                       'off' => 'on',
  871:                     );
  872:     $r->print('<script type="text/javascript">
  873: function toggle_countunread(choice) {
  874:     if (choice == "unchanged") {
  875:         document.discussionswitch.command.value = "";
  876:     }
  877:     document.discussionswitch.submit();
  878: }
  879: </script>');
  880:     $r->print('<br />'
  881:              .&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.')
  882:              .'<br />'
  883:              .&mt("This can increase the time taken to gather data for the [_1]What's New Page[_2] by a few seconds.",'<i>','</i>')
  884:              .'&nbsp;&nbsp;'
  885:              .&mt('Currently set to [_1].','<b>'.$current.'</b>')
  886:     );
  887:     $r->print('<br /><br />
  888: <form method="post" name="discussionswitch" action="/adm/whatsnew">
  889: <input type="hidden" name="command" value="newdiscconf" />
  890: <input type="hidden" name="refpage" value="'.$refpage.'" />
  891: <input type="hidden" name="countunread" value="'.$opposite{$current}.'" />
  892: ');
  893:     $r->print('<br/>
  894:                <input type="button" name="display" value="'.
  895:                &mt('Change to [_1]',&mt($opposite{$current})).'" 
  896:                onclick="javascript:toggle_countunread('."'change'".')" />'.
  897:                ('&nbsp;' x7).
  898:                '<input type="button" name="nochange" value="'.
  899:                &mt("No change").'" 
  900:                onclick="javascript:toggle_countunread('."'unchanged'".')" />
  901:                </form>');
  902:     return;
  903: }
  904: 
  905: #---------------------------------------------------
  906: # courseinit_config
  907: #
  908: # Set page displayed when course loads after 
  909: # selecting a role in the course from the roles page. 
  910: #
  911: #---------------------------------------------------
  912: 
  913: sub courseinit_config {
  914:     my ($r,$refpage,$initpage) = @_;
  915:     my ($control,$current) = &curr_courseinit();
  916:     my @chgstate = ('userpref','coursespecific');
  917:     my @chgentry = ('firstres','whatsnew');
  918:     my $lctype = lc(&Apache::loncommon::course_type());
  919:     my %lt = &Apache::lonlocal::texthash(
  920:                              'chwp' => "Choose which page will be displayed when you enter this $lctype after selecting a role.",
  921:                              'cuva' => 'Current value is determined by',
  922:                              'anis' => 'and is set to display',
  923:                              'padc' => 'Page display controlled by',
  924:                              'chce' => 'Choose '.$lctype.' entry',
  925:                              'moce' => 'Save',
  926:     );
  927:     $r->print(<<"END"); 
  928: <br />$lt{'chwp'}
  929: <br />$lt{'cuva'}: <b>
  930: $$initpage{$control}</b> $lt{'anis'} <b>
  931: $$initpage{$current}</b>.<br /><br />
  932: <form method="post" name="courseinitswitch" action="/adm/whatsnew">
  933: <input type="hidden" name="command" value="newcourseinit" />
  934: <input type="hidden" name="refpage" value="$refpage" />
  935: $lt{'padc'}:&nbsp;&nbsp;
  936: END
  937:     foreach my $choice (@chgstate) {
  938:         my $chkstring;
  939:         if ($choice eq $control) {
  940:             $chkstring = ' checked="checked" ';
  941:         }  
  942:         $r->print('<span class="LC_nobreak"><label><input type="radio" name="courseinit_control" value="'.
  943:                    $choice.'"'.$chkstring.'/>'.$$initpage{$choice}.
  944:                    '&nbsp;&nbsp;</label></span>');
  945:     }
  946:     $r->print('<br /><br />'.&mt('If').' '.$$initpage{'coursespecific'}.
  947:               ' - <br />'.$lt{'chce'}.": \n");
  948:     foreach my $choice (@chgentry) {
  949:         my $chkstring;
  950:         if (($choice eq $current) && ($control eq 'coursespecific')) {
  951:             $chkstring = ' checked="checked" ';
  952:         }
  953:         $r->print('<span class="LC_nobreak"><label><input type="radio" name="courseinit_page" value="'.
  954:                   $choice.'"'.$chkstring.'/>'.$$initpage{$choice}.
  955:                   '&nbsp;&nbsp;</label></span>');
  956:     }
  957:     $r->print('<br /><br /><input type="submit" name="display" value="'.
  958:                $lt{'moce'}.'" /></form>');
  959:     return;
  960: }
  961: 
  962: sub curr_courseinit {
  963:     my $current = &get_current($env{'user.name'},$env{'user.domain'},
  964:                                 $env{'request.course.id'},'courseinit');
  965:     my $control;
  966:     if ($current) {
  967:         $control = 'coursespecific';
  968:     } else {
  969:         $control = 'userpref';
  970:         my %userenv = &Apache::lonnet::get('environment',
  971:                                                       ['course_init_display']);
  972:         if (exists($userenv{'course_init_display'})) {
  973:             $current = $userenv{'course_init_display'};
  974:         }
  975:         unless ($current) {
  976:             $current = 'whatsnew';
  977:         }
  978:     }
  979:     return ($control,$current);
  980: }
  981: 
  982: sub display_launcher {
  983:     my ($r,$action,$refpage,$checkallowed,$show,$headings,$res_title,
  984:         $tograde,$ungraded,$bombs,$bombed,$changed,$warnings,$triggered,
  985:         $newdiscussions,$unread,$msgcount,$newmsgs,$critmsgcount,$critmsgs,
  986:         $interval,$countunread,$expired,$expirecount,$activated,$activecount,
  987:         $crstype,$itemserror,$loggedin,$logincount,$sessions,$sessioncount,
  988:         $classlist) = @_;
  989: 
  990:     if ($$checkallowed{$action}) {
  991:         &start_box($r,$show,$headings,$action,$refpage);
  992:         if ($$show{$action}) {
  993:             if ($action eq 'handgrading') {    # UNGRADED ITEMS
  994:                 &display_handgrade($r,$tograde,$ungraded,$itemserror);
  995:             } elsif ($action eq 'haserrors') { # BOMBS
  996:                 &display_haserrors($r,$bombs,$bombed,$res_title,$itemserror);
  997:             } elsif ($action eq 'versionchanges') { # VERSION CHANGES
  998:                 &display_versionchanges($r,$changed,$res_title,$interval->{'versions'},$itemserror);
  999:             } elsif ($action eq 'abovethreshold') { # DEGDIFF/AV. TRIES TRIGGERS
 1000:                 &display_abovethreshold($r,$refpage,$warnings,$triggered,
 1001: 					$res_title,$itemserror,$checkallowed);
 1002:             } elsif ($action eq 'coursediscussion') { # UNREAD COURSE DISCUSSION
 1003:                 &display_coursediscussion($r,$newdiscussions,$unread,
 1004:                                 $countunread,$res_title,$itemserror);
 1005:             } elsif ($action eq 'coursenormalmail') { # NORMAL MESSAGES
 1006:                 &display_coursenormalmail($r,$msgcount,$newmsgs);
 1007:             } elsif ($action eq 'coursecritmail') { # CRITICAL MESSAGES
 1008:                 &display_coursecritmail($r,$critmsgcount,$critmsgs);
 1009:             } elsif ($action eq 'newroles') { # ACTIVATED ROLES
 1010:                 &display_rolechanges($r,$activecount,$activated,$interval->{'newroles'},
 1011:                                      $crstype,$classlist);
 1012:             } elsif ($action eq 'oldroles') { # EXPIRED ROLES
 1013:                 &display_rolechanges($r,$expirecount,$expired,$interval->{'oldroles'},
 1014:                                      $crstype,$classlist);
 1015:             } elsif ($action eq 'crslogin') { #LAST LOGIN
 1016:                 &display_activity($r,'logins',$logincount,$loggedin,$interval->{'crslogin'},
 1017:                                    $crstype,$classlist);
 1018:             } elsif ($action eq 'sessions') { #ACTIVE SESSIONS
 1019:                 &display_activity($r,'sessions',$sessioncount,$sessions,$interval->{'sessions'},
 1020:                                   $crstype,$classlist);
 1021:             }
 1022:         }
 1023:         &end_box($r);
 1024:     }
 1025:     return;
 1026: }
 1027: 
 1028: sub getitems {
 1029:     my ($unread,$ungraded,$bombed,$triggered,$changed,$newdiscussions,
 1030:         $tograde,$bombs,$warnings,$threshold,$cdom,$crs,$res_title,$show,
 1031:         $starttime,$countunread,$checkallowed) = @_;
 1032:     my $navmap = Apache::lonnavmaps::navmap->new();
 1033:     if (!defined($navmap)) {
 1034:         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>';
 1035:         return $itemserror;
 1036:     }
 1037:     # force retrieve Resource to seed the part id cache we'll need it later
 1038:     my @allres=$navmap->retrieveResources(undef,
 1039:                      sub {if ($_[0]->is_problem) { $_[0]->parts();} return 1;});
 1040:     my %resourcetracker;
 1041:     my $discussiontime;
 1042: 
 1043: # Resource version changes
 1044:     if ($$show{'versionchanges'}) {
 1045:         &checkversions($cdom,$crs,$navmap,$changed,$starttime);
 1046:     }
 1047: 
 1048:     if ($$show{'abovethreshold'}) {
 1049:         %resourcetracker =  &Apache::lonnet::dump('nohist_resourcetracker',
 1050:                                                                    $cdom,$crs);
 1051:     }
 1052: 
 1053:     foreach my $resource (@allres) {
 1054:         my $result = '';
 1055:         my $applies = 0;
 1056:         my $symb = $resource->symb();
 1057:         %{$$bombed{$symb}} = ();
 1058:         %{$$ungraded{$symb}} = ();
 1059:         %{$$triggered{$symb}} = ();
 1060:         $$triggered{$symb}{numparts} = 0;
 1061:         if ($resource->encrypted()) {
 1062:             $$triggered{$symb}{'enclink'} = $resource->link();
 1063:             $$triggered{$symb}{'encsymb'} = $resource->shown_symb();
 1064:         }
 1065:         my $title = $resource->compTitle();
 1066:         $$res_title{$symb} = $title;
 1067:         my $ressymb = $resource->wrap_symb();
 1068: 
 1069: # Check if there are unread discussion postings
 1070:         if ($$show{'coursediscussion'}) {
 1071:             &check_discussions($resource,$symb,$ressymb,$title,
 1072: 			       $newdiscussions,$unread,$countunread);
 1073:         }
 1074: 
 1075: # Check for ungraded problems
 1076:         if ($resource->is_problem()) {
 1077:             if ($$show{'handgrading'}) {
 1078:                 &check_handgraded($resource,$symb,$title,$cdom,$crs,$ungraded,
 1079:                                                                      $tograde);
 1080:             }
 1081:         }
 1082: 
 1083: # Check for bombs
 1084:         if ($$show{'haserrors'}) {
 1085:             &check_bombed($resource,$symb,$title,$bombs,$bombed);
 1086:         }
 1087: 
 1088: # Maxtries and degree of difficulty for problem parts, unless handgradeable
 1089:         if ($$show{'abovethreshold'}) {  
 1090:             &check_thresholds($resource,$symb,\%resourcetracker,
 1091: 			      $triggered,$threshold,$warnings,
 1092:                               $checkallowed);
 1093:         }
 1094:     }
 1095:     return; 
 1096: }
 1097: 
 1098: sub check_discussions {
 1099:     my ($resource,$symb,$ressymb,$title,$newdiscussions,$unread,
 1100: 	$countunread) = @_;
 1101: 
 1102:     if (!$resource->hasDiscussion()) { return; }
 1103: 
 1104:     %{$$unread{$ressymb}} = ();
 1105:     $$unread{$ressymb}{'title'} = $title;
 1106:     $$unread{$ressymb}{'symb'} = $symb;
 1107:     if ($resource->encrypted()) {
 1108:         $$unread{$ressymb}{'enclink'} = $resource->link();
 1109:         $$unread{$ressymb}{'encsymb'} = $resource->shown_symb();
 1110:     }
 1111:     push(@{$newdiscussions}, $ressymb);
 1112:     
 1113:     $$unread{$ressymb}{'lastpost'} = $resource->last_post_time();
 1114:     
 1115:     if ($countunread eq 'on') {
 1116: 	$$unread{$ressymb}{'unreadcount'} = 
 1117:                             $resource->discussion_info('unread');
 1118:     }
 1119: }
 1120: 
 1121: sub check_handgraded {
 1122:     my ($resource,$symb,$title,$cdom,$cnum,$ungraded,$tograde) = @_;
 1123:     if ($resource->is_problem()) {
 1124:         my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
 1125:         my $partlist=$resource->parts();
 1126:         my $handgradeable;
 1127:         foreach my $part (@$partlist) {
 1128:             if ($resource->handgrade($part) eq 'yes') {
 1129:                 $handgradeable=1; last;
 1130:             }
 1131:         }
 1132:         if ($handgradeable) {
 1133:             my @ungraded = &Apache::bridgetask::get_queue_symb_status(
 1134:                                              'gradingqueue',$symb,$cdom,$cnum);
 1135:             if (@ungraded > 0) {
 1136:                 $$ungraded{$symb}{count} = scalar(@ungraded);
 1137:                 $$ungraded{$symb}{title} = $title;
 1138:                 if ($resource->encrypted()) {
 1139:                     $$ungraded{$symb}{'enclink'} = $resource->link();
 1140:                     $$ungraded{$symb}{'encsymb'} = $resource->shown_symb();
 1141:                 }
 1142:                 push(@{$tograde},$symb);
 1143:             }
 1144:         }
 1145:     }
 1146: }
 1147: 
 1148: sub check_bombed {
 1149:     my ($resource,$symb,$title,$bombs,$bombed) = @_;
 1150:     if ($resource->getErrors()) {
 1151:         my $errors = $resource->getErrors();
 1152:         $errors =~ s/^,//;
 1153:         my @bombs = split(/,/, $errors);
 1154:         my $errorcount = scalar(@bombs);
 1155:         my $errorlink = '<a href="/adm/email?display='.
 1156:                         &escape($bombs[0]).'">'.
 1157:                         $title.'</a>';
 1158:         $$bombed{$symb}{errorcount} = $errorcount;
 1159:         $$bombed{$symb}{errorlink} = $errorlink;
 1160:         push(@{$bombs}, $symb);
 1161:     }
 1162: }
 1163: 
 1164: sub check_thresholds {
 1165:     my ($resource,$symb,$resourcetracker,$triggered,$threshold,$warnings,
 1166:         $checkallowed) = @_;
 1167: # Compile maxtries and degree of difficulty for problem parts, unless handgradeable
 1168:     my @parts = @{$resource->parts()};
 1169:     my %stats;
 1170:     my %lastreset = ();
 1171:     my $warning = 0;
 1172:     foreach my $part (@parts) {
 1173:         if ($resource->handgrade($part) eq 'yes') {
 1174:             next;
 1175:         }
 1176:         if ($resource->is_anonsurvey($part)) {
 1177:             next;
 1178:         }
 1179:         if ($resource->is_survey($part)) {
 1180:             next;
 1181:         }
 1182:         %{$stats{$part}} = ();
 1183:         my ($attempts,$users,$corrects,$degdiff,$av_attempts);
 1184:         if (exists($$resourcetracker{$symb."\0".$part."\0attempts"})) {
 1185:             $attempts = $$resourcetracker{$symb."\0".$part."\0attempts"};
 1186:         }
 1187:         if (exists($$resourcetracker{$symb."\0".$part."\0users"})) {
 1188:             $users = $$resourcetracker{$symb."\0".$part."\0users"};
 1189:         }
 1190:         if (exists($$resourcetracker{$symb."\0".$part."\0correct"})) {
 1191:             $corrects = $$resourcetracker{$symb."\0".$part."\0correct"};
 1192:         }
 1193:         if ($attempts > 0) {
 1194:             $degdiff =  1 - ($corrects/$attempts);
 1195:             $degdiff = sprintf("%.2f",$degdiff);
 1196:         }
 1197:         if ($users > 0) {
 1198:             $av_attempts = $attempts/$users;
 1199:             $av_attempts = sprintf("%.2f",$av_attempts);
 1200:         }
 1201:         &Apache::lonnet::statslog($symb,$part,$users,$av_attempts,$degdiff);
 1202:         if ((($degdiff ne '' && $degdiff >= $$threshold{'degdiff'}) || ($av_attempts ne '' && $av_attempts >= $$threshold{'av_attempts'})) && ($users >= $$threshold{'numstudents'})) {
 1203:             $stats{$part}{degdiff} = $degdiff;
 1204:             $stats{$part}{attempts} = $av_attempts;
 1205:             $stats{$part}{users} = $users;
 1206:             $lastreset{$part} = $$resourcetracker{$symb."\0".$part."\0resettime"};
 1207:             if ($lastreset{$part}) {
 1208:                 $lastreset{$part} = &Apache::lonnavmaps::timeToHumanString($lastreset{$part});
 1209:             }
 1210:             $warning = 1;
 1211:         }
 1212:     }
 1213:     if ($warning) {
 1214:         $$triggered{$symb}{title} = $resource->title;
 1215:         my $partcount = 0;
 1216:         @{$$triggered{$symb}{text}} = ();
 1217:         foreach my $part (@parts) {
 1218:             if (exists($stats{$part}{users})) {
 1219:                 my $resetname = 'reset_'.&escape($symb."\0".$part);
 1220:                 my $resettitle = 'title_'.&escape($symb."\0".$part);
 1221:                 if (@parts > 1) {
 1222:                     $$triggered{$symb}{text}[$partcount] = '
 1223:                      <td>'.&mt('part - ').$part.'</td>';
 1224:                 } else {
 1225:                     $$triggered{$symb}{text}[$partcount] = '
 1226:                      <td>'.&mt('single part').'</td>';
 1227:                 }
 1228:                 $$triggered{$symb}{text}[$partcount] .= '
 1229:                      <td>'.$stats{$part}{users}.'</td>
 1230:                      <td>'.$stats{$part}{attempts}.'</td>
 1231:                      <td>'.$stats{$part}{degdiff}.'</td>
 1232:                      <td>'.$lastreset{$part}.'</td>';
 1233:                 if ($checkallowed->{'resetcounters'}) {
 1234:                     $$triggered{$symb}{text}[$partcount] .=
 1235:                         '<td><input type="checkbox" name="'.$resetname.'" />'.
 1236:                         '<input type="hidden" name="'.$resettitle.'" value="'.&escape($$triggered{$symb}{title}).'" /></td>';
 1237:                 }
 1238:                 $partcount ++;
 1239:             }
 1240:             $$triggered{$symb}{numparts} = $partcount;
 1241:         }
 1242:         push(@{$warnings},$symb);
 1243:     }
 1244: }
 1245: 
 1246: 
 1247: sub get_curr_thresholds {
 1248:     my ($threshold,$uname,$udom,$cid,$cdom,$crs) = @_;
 1249:     # set default values
 1250:     %$threshold = (av_attempts => 2,
 1251:                   degdiff => 0.5,
 1252:                   numstudents => 2
 1253:                   );
 1254:     my %thresholdsettings = &Apache::lonnet::dump('nohist_whatsnew',$udom,
 1255:                                                      $uname,$cid.':threshold');
 1256:     my $thresholdcount = 0;
 1257:     my ($tmp) = %thresholdsettings;
 1258:     unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
 1259:         foreach my $item (keys(%{$threshold})) { 
 1260:             if (exists($thresholdsettings{$cid.':threshold_'.$item})) {
 1261:                 $$threshold{$item} = 
 1262:                              $thresholdsettings{$cid.':threshold_'.$item};
 1263:                 $thresholdcount ++;
 1264:             }
 1265:         }
 1266:     }
 1267:     if ($thresholdcount == 3) {
 1268:         return;
 1269:     }
 1270:     my %coursesettings = &Apache::lonnet::dump('environment',
 1271:                                               $cdom,$crs,'internal.threshold');
 1272:     my ($temp) = %coursesettings;
 1273:     unless ($temp =~ /^(con_lost|error|no_such_host)/i) {  
 1274:         foreach my $item (keys(%{$threshold})) {
 1275:             unless (exists($thresholdsettings{$cid.':threshold_'.$item})) {
 1276:                 if (exists($coursesettings{'internal.threshold_'.$item})) {
 1277:                     $$threshold{$item} = 
 1278:                              $coursesettings{'internal.threshold_'.$item};
 1279:                 }
 1280:             }
 1281:         }
 1282:     }
 1283:     return;
 1284: }
 1285: 
 1286: sub get_current {
 1287:     my ($uname,$udom,$cid,$caller) = @_;
 1288:     my $currvalue;
 1289:     my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid.
 1290:                                                                 ':'.$caller);
 1291:     my ($tmp) = %settings;
 1292:     unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
 1293:         $currvalue = $settings{$cid.':'.$caller};
 1294:     }
 1295:     return $currvalue;
 1296: }
 1297: 
 1298: sub process_reset {
 1299:     my ($dom,$crs,$checkallowed) = @_;
 1300:     if (!$checkallowed->{'resetcounters'}) {
 1301:         return '<b>'.&mt('You do not have the required privileges to reset counters').
 1302:                '</b><br />';
 1303:     }
 1304:     my $result = '<b>'.&mt('Counters reset for following problems (and parts):').
 1305:                            '</b><br />';
 1306:     my @agg_types = ('attempts','users','correct');
 1307:     my %agg_titles = &Apache::lonlocal::texthash (
 1308:                      attempts => 'Number of submissions',
 1309:                      users => 'Students with submissions',
 1310:                      correct => 'Number of correct submissions',
 1311:                      );
 1312:     my @resets = ();
 1313:     my %titles = ();
 1314:     foreach my $key (keys(%env)) {
 1315:         next if ($key !~ /^form\.reset_(.+)$/);
 1316:         my $title = &unescape($env{'form.title_'.$1});
 1317:         my $reset_item = &unescape($1);
 1318:         my %curr_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
 1319:         my %aggregates = ();
 1320:         my ($symb,$part) = split(/\0/,$reset_item);
 1321:         foreach my $type (@agg_types) {
 1322:             $aggregates{$reset_item."\0".$type} = 0;
 1323:         }  
 1324: 	$aggregates{$reset_item."\0".'resettime'} = time;
 1325:         my $putresult = &Apache::lonnet::put('nohist_resourcetracker',\%aggregates,
 1326:                           $dom,$crs);
 1327:         if ($putresult eq 'ok') {
 1328:             $result .= $title.' -part '.$part.': ';
 1329:             my %new_aggregates = &Apache::lonnet::dump('nohist_resourcetracker',$dom,$crs,$reset_item);
 1330:             foreach my $type (@agg_types) {
 1331:                 $result .= $agg_titles{$type}.' = '.$new_aggregates{$reset_item."\0".$type}.'; ';
 1332:             }
 1333:             $result =~ s/; $//;
 1334:             $result .= '<br />';
 1335:         } else {
 1336:             $result = $title.' -part '.$part.': '.&mt('Unable to reset counters to zero due to [_1]',$putresult).'.<br />'."\n";
 1337:         }
 1338:     }
 1339:     return $result;
 1340: }
 1341: 
 1342: sub process_update {
 1343:     my ($uname,$udom,$threshold_titles) = @_;
 1344:     my $setoutput = '<b>'.&mt('Changes to threshold(s) for problem tracking:').'</b><br/><br />';
 1345:     foreach my $key (keys(%env)) {
 1346:         my $name;
 1347:         if ($key =~/^form\.(.+)\_setparmval$/) {
 1348:             $name  = $1;
 1349:         } else {
 1350:             next;
 1351:         }
 1352:         my $value = $env{'form.'.$name.'_value'};
 1353:         if ($name && defined($value) && ($value ne '')) {
 1354:             my $put_result = &Apache::lonnet::put('nohist_whatsnew',
 1355:                                                   {$name=>$value},$udom,$uname);
 1356:            
 1357:             my ($shortname) = ($name =~ /^\Q$env{'request.course.id'}\E:threshold_(.+)$/);
 1358:             if ($put_result eq 'ok') {
 1359:                 $setoutput.= &Apache::lonhtmlcommon::confirm_success(&mt('Set threshold for [_1] to [_2]',
 1360: 				'<b>'.$$threshold_titles{$shortname}.'</b>',
 1361: 				'<b>'.$value.'</b>').'<br />');
 1362: 	    } else {
 1363:                 $setoutput.= &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set threshold for [_1] to [_2] due to [_3].',
 1364: 				'<b>'.$name.'</b>','<b>'.$value.'</b>',
 1365: 				'<tt>'.$put_result.'</tt>').'<br />',1);
 1366:             }
 1367:         }
 1368:     }
 1369:     return &Apache::loncommon::confirmwrapper($setoutput);
 1370: }
 1371: 
 1372: sub getnormalmail {
 1373:     my ($newmsgs) = @_;
 1374: # Check for unread messages in user's INBOX (which were sent in context of current course).
 1375:     my $msgcount = 0;
 1376:     my @messages = &Apache::lonnet::getkeys('nohist_email');
 1377:     return $msgcount if (!@messages);
 1378:     my %emailstatus = &Apache::lonnet::dump('email_status');
 1379:     foreach my $msgid (sort(@messages)) {
 1380:         if ((!$emailstatus{$msgid}) || ($emailstatus{$msgid} eq 'new')) {
 1381:             my $skipstatus;
 1382:             if ($emailstatus{$msgid} eq 'new') {
 1383:                 $skipstatus = 1;
 1384:             }
 1385:             my $esc_msgid = &escape($msgid);
 1386:             my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
 1387:                 &Apache::lonmsg::unpackmsgid($esc_msgid,undef,$skipstatus,undef,
 1388:                                              $env{'request.course.id'});
 1389:             if (($fromcid) && ($fromcid eq $env{'request.course.id'})) {
 1390:                 if (defined($sendtime) && $sendtime!~/error/) {
 1391:                     if (($emailstatus{$msgid} eq 'new') || ($status eq 'new')) {
 1392:                         $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
 1393: 		        $msgcount ++;
 1394:                         if ($shortsubj eq '') {
 1395:                             $shortsubj = &mt('No subject');
 1396:                         }
 1397:                         push(@{$newmsgs}, {
 1398:                             msgid    => $esc_msgid,
 1399:                             sendtime => $sendtime,
 1400:                             shortsub => $shortsubj,
 1401:                             from     => $fromname,
 1402:                             fromdom  => $fromdom
 1403:                             });
 1404:                     }
 1405:                 }
 1406:             }
 1407:         }
 1408:     }
 1409:     return $msgcount;
 1410: }
 1411: 
 1412: sub getcritmail {
 1413:     my ($critmsgs) = @_; 
 1414: # Check for critical messages which were sent in context of current course.
 1415:     my %what=&Apache::lonnet::dump('critical');
 1416:     my $result = '';
 1417:     my $critmsgcount = 0;
 1418:     foreach my $msgid (sort(keys(%what))) {
 1419:         my $esc_msgid = &escape($msgid);
 1420:         my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
 1421:             &Apache::lonmsg::unpackmsgid($esc_msgid,undef,1,undef,
 1422:                                          $env{'request.course.id'});
 1423:         if (($fromcid) && ($fromcid eq  $env{'request.course.id'})) {
 1424:             if (defined($sendtime) && $sendtime!~/error/) {
 1425:                 $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
 1426:                 $critmsgcount ++;
 1427:                 if ($shortsubj eq '') {
 1428:                     $shortsubj = &mt('No subject');
 1429:                 }
 1430:                 push(@{$critmsgs}, {
 1431:                         msgid    => $esc_msgid,
 1432:                         sendtime => $sendtime,
 1433:                         shortsub => $shortsubj,
 1434:                         from     => $fromname,
 1435:                         fromdom  => $fromdom
 1436:                         });
 1437:             }
 1438:         }
 1439:     }
 1440:     return $critmsgcount;
 1441: }
 1442: 
 1443: sub getexpired {
 1444:     my ($rolechgs,$rolechgtime,$status,$classlist) = @_;
 1445:     my $expirecount = &getrolechanges($rolechgs,$rolechgtime,$status,$classlist);
 1446:     return $expirecount;
 1447: }
 1448: 
 1449: sub getactivated {
 1450:     my ($rolechgs,$rolechgtime,$status,$classlist) = @_;
 1451:     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
 1452:     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
 1453:     my $now = time();
 1454:     my $context = 'course';
 1455:     my ($permission,$allowed) =
 1456:         &Apache::lonuserutils::get_permission($context);
 1457:     my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
 1458:     my %changes=&Apache::lonnet::dump('nohist_rolelog',$cdom,$cnum);
 1459:     my (%stucounted,%advcounted);
 1460:     my $activatedcount = 0;
 1461:     if (keys(%changes) > 0) {
 1462:         foreach my $chg (keys(%changes)) {
 1463:             if (ref($changes{$chg}) eq 'HASH') {
 1464:                 next if ($changes{$chg}{'delflag'});
 1465:                 if ($rolechgtime > 0) {
 1466:                     next if ($changes{$chg}{'exe_time'} < $rolechgtime);
 1467:                 }
 1468:                 if ($changes{$chg}{'exe_time'}) {
 1469:                     my $timestamp = $changes{$chg}{'exe_time'};
 1470:                     if (ref($changes{$chg}{'logentry'}) eq 'HASH') {
 1471:                         my $end = $changes{$chg}{'logentry'}{'end'};
 1472:                         next if ($end && $end <= $now);
 1473:                         my $start = $changes{$chg}{'logentry'}{'start'};
 1474:                         next if ($start >= $timestamp);
 1475:                         my $section = $changes{$chg}{'logentry'}{'section'};
 1476:                         if (($viewablesec ne '') && ($section ne '')) {
 1477:                             next if ($viewablesec ne $section);
 1478:                         }
 1479:                         my $role = $changes{$chg}{'logentry'}{'role'};
 1480:                         my $uname = $changes{$chg}{'uname'};
 1481:                         my $udom = $changes{$chg}{'udom'};
 1482:                         if ($role eq 'st') {
 1483:                             $stucounted{$uname.':'.$udom.':'.$section} = $start.':'.$end;
 1484:                         } else {
 1485:                             $advcounted{$uname.':'.$udom.':'.$role.':'.$section} = $start.':'.$end;
 1486:                         }
 1487:                         my %chginfo = (
 1488:                                        'section' => $section,
 1489:                                        'uname'   => $uname,
 1490:                                        'udom'    => $udom,
 1491:                                        'role'    => $role,
 1492:                                        'status'  => $status,
 1493:                         );
 1494:                         $activatedcount ++;
 1495:                         push (@{$rolechgs->{$timestamp}},\%chginfo);
 1496:                     }
 1497:                 }
 1498:             }
 1499:         }
 1500:     }
 1501:     $activatedcount += &getrolechanges($rolechgs,$rolechgtime,$status,$classlist,\%stucounted,
 1502:                                        \%advcounted);
 1503:     return $activatedcount;
 1504: }
 1505: 
 1506: sub getrolechanges {
 1507:     my ($rolechgs,$rolechgtime,$status,$classlist,$stucountref,$advcountref) = @_;
 1508:     my (%stucounted,%advcounted);
 1509:     if (ref($stucountref) eq 'HASH') {
 1510:         %stucounted = %{$stucountref};
 1511:     }
 1512:     if (ref($advcountref) eq 'HASH') {
 1513:         %advcounted = %{$advcountref};
 1514:     }
 1515:     my $withsec = 1;
 1516:     my $hidepriv = 1;
 1517:     my $context = 'course';
 1518:     my @statuses = ($status);
 1519:     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
 1520:     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
 1521:     my $now = time();
 1522:     my ($permission,$allowed) =
 1523:         &Apache::lonuserutils::get_permission($context);
 1524:     my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
 1525:     my $secidx = &Apache::loncoursedata::CL_SECTION();
 1526:     my $startidx = &Apache::loncoursedata::CL_START();
 1527:     my $endidx = &Apache::loncoursedata::CL_END();
 1528:     my $rolechgcount = 0;
 1529:     if (ref($classlist) eq 'HASH') {
 1530:         foreach my $key (keys(%{$classlist})) {
 1531:             my ($userstatus,$eventtime);   
 1532:             my $student = $classlist->{$key};
 1533:             if (ref($student) eq 'ARRAY') {
 1534:                 my $start = $student->[$startidx];
 1535:                 my $end = $student->[$endidx];
 1536:                 my $sec = $student->[$secidx]; 
 1537:                 my ($stuname,$studom) = split(/:/,$key);
 1538:                 if ($status eq 'active') {
 1539:                     if (exists($stucounted{$key.':'.$sec})) {
 1540:                         next;
 1541:                     }
 1542:                 }
 1543:                 if (($end == 0) || ($end > $start)) {
 1544:                     if ($start <= $now) {
 1545:                         if ($end && $end < $now) {
 1546:                             if ($rolechgtime > 0) {
 1547:                                 if ($end > $rolechgtime) {
 1548:                                     $userstatus = 'previous';
 1549:                                 }
 1550:                             } else {
 1551:                                 $userstatus = 'previous';
 1552:                             }
 1553:                         } else {
 1554:                             if ($rolechgtime > 0) {
 1555:                                 if ($start >= $rolechgtime) {
 1556:                                     $userstatus = 'active';
 1557:                                 }
 1558:                             } else {
 1559:                                 $userstatus = 'active';
 1560:                             }
 1561:                         }
 1562:                     }
 1563:                 }
 1564:                 next if ($userstatus ne $status);
 1565:                 if ($status eq 'active') {
 1566:                     $eventtime = $start;
 1567:                 } else {
 1568:                     $eventtime = $end;
 1569:                 }
 1570:                 if (($viewablesec ne '') && ($sec ne '')) {
 1571:                     next if ($viewablesec ne $sec);
 1572:                 }
 1573:                 my %chginfo = (
 1574:                                 'section' => $sec,
 1575:                                 'uname'   => $stuname,
 1576:                                 'udom'    => $studom,
 1577:                                 'role'    => 'st', 
 1578:                                 'status'  => $userstatus,
 1579:                               );
 1580:                 $rolechgcount ++;
 1581:                 push(@{$rolechgs->{$eventtime}},\%chginfo);
 1582:             }
 1583:         }
 1584:     }
 1585:     my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
 1586:                               \@statuses,undef,undef,$withsec,$hidepriv);
 1587:     foreach my $item (keys(%advrolehash)) {
 1588:         my ($userstatus,$eventtime);
 1589:         my ($uname,$udom,$role,$section) = split(/:/,$item,-1);
 1590:         my ($start,$end) = split(/:/,$advrolehash{$item});
 1591:         if ($start eq '-1' && $end eq '-1') {
 1592:             next;
 1593:         } else {
 1594:             if ($status eq 'active') {
 1595:                 if (exists($advcounted{$item})) {
 1596:                     next;
 1597:                 }
 1598:             }
 1599:             if (($end == 0) || ($end > $start)) {
 1600:                 if ($start <= $now) {
 1601:                     if ($end && $end < $now) {
 1602:                         if ($rolechgtime > 0) {
 1603:                             if ($end > $rolechgtime) {
 1604:                                 $userstatus = 'previous';
 1605:                             }
 1606:                         } else {
 1607:                             $userstatus = 'previous';
 1608:                         }
 1609:                     } else {
 1610:                         if ($rolechgtime > 0) {
 1611:                             if ($start >= $rolechgtime) {
 1612:                                 $userstatus = 'active';
 1613:                             }
 1614:                         } else {
 1615:                             $userstatus = 'active';
 1616:                         }
 1617:                     }
 1618:                 }
 1619:             }
 1620:             next if ($userstatus ne $status);
 1621:             if ($status eq 'active') {
 1622:                 $eventtime = $start;
 1623:             } else {
 1624:                 $eventtime = $end;
 1625:             }
 1626:         }
 1627:         if (($viewablesec ne '') && ($section ne '')) {
 1628:             next if ($viewablesec ne $section);
 1629:         }
 1630:         my %chginfo = ( 
 1631:                         'section' => $section,
 1632:                         'uname'   => $uname,
 1633:                         'udom'    => $udom,
 1634:                         'role'    => $role,
 1635:                         'status'  => $userstatus,    
 1636:                       );
 1637:         $rolechgcount ++; 
 1638:         push (@{$rolechgs->{$eventtime}},\%chginfo); 
 1639:     }
 1640:     return $rolechgcount;
 1641: }
 1642: 
 1643: sub getloggedin {
 1644:     my ($cdom,$crs,$lastlogins,$starttime) = @_;
 1645:     my $context = 'course';
 1646:     my ($permission,$allowed) =
 1647:         &Apache::lonuserutils::get_permission($context);
 1648:     my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
 1649:     my %crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$crs);
 1650:     my $logincount = 0;
 1651:     my ($tmp) = keys(%crslogins);
 1652:     unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
 1653:         if (keys(%crslogins) > 0) {
 1654:             foreach my $key (keys(%crslogins)) {
 1655:                 my ($uname,$udom,$section,$role) = split(/:/,$key);
 1656:                 my $eventtime = $crslogins{$key};
 1657:                 if ($eventtime > $starttime) {
 1658:                     if (($viewablesec ne '') && ($section ne '')) {
 1659:                         next if ($viewablesec ne $section);
 1660:                     }
 1661:                     my %chginfo = (
 1662:                                    'section' => $section,
 1663:                                    'uname'   => $uname,
 1664:                                    'udom'    => $udom,
 1665:                                    'role'    => $role,
 1666:                     );
 1667:                     $logincount ++;
 1668:                     push (@{$lastlogins->{$eventtime}},\%chginfo);
 1669:                 }
 1670:             }
 1671:         }
 1672:     }
 1673:     return $logincount;
 1674: }
 1675: 
 1676: sub getsessions {
 1677:     my ($cdom,$cnum,$sessions,$lastactive,$classlist) = @_;
 1678:     my $context = 'course';
 1679:     my ($permission,$allowed) =
 1680:         &Apache::lonuserutils::get_permission($context);
 1681:     my %crs_sessions = &Apache::lonnet::get_course_sessions($cnum,$cdom,$lastactive);
 1682:     my $sessioncount = 0;
 1683:     if (keys(%crs_sessions) > 0) {
 1684:         if (ref($classlist) eq 'HASH') {
 1685:             my $viewablesec = &Apache::lonuserutils::viewable_section($permission);
 1686:             my $secidx = &Apache::loncoursedata::CL_SECTION();
 1687:             my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'_'.$cnum,1);
 1688:             my %personnel;
 1689:             foreach my $role (sort(keys(%coursepersonnel))) {
 1690:                 my ($rolecode,$section);
 1691:                 if ($role =~ /:/) {
 1692:                     ($rolecode,$section) = split(/:/,$role);
 1693:                 } else {
 1694:                     $rolecode = $role;
 1695:                 }
 1696:                 if ($viewablesec ne '') {
 1697:                     next if ($viewablesec ne $section);
 1698:                 }
 1699:                 foreach my $user (split(/\,/,$coursepersonnel{$role})) {
 1700:                     push(@{$personnel{$user}{$rolecode}},$section);
 1701:                 }
 1702:             }
 1703:             foreach my $key (keys(%crs_sessions)) {
 1704:                 if (exists($classlist->{$key})) {
 1705:                     my $student = $classlist->{$key};
 1706:                     my $section = $student->[$secidx];
 1707:                     my $lastaccess = $crs_sessions{$key};
 1708:                     if ($viewablesec ne '') {
 1709:                         next if ($viewablesec ne $section);
 1710:                     }
 1711:                     my ($stuname,$studom) = split(/:/,$key);
 1712:                     my %info = (
 1713:                                  'section' => $section,
 1714:                                  'role'    => 'st',
 1715:                                  'uname'   => $stuname,
 1716:                                  'udom'    => $studom,
 1717:                     );
 1718:                     $sessioncount ++;
 1719:                     push(@{$sessions->{$lastaccess}},\%info);
 1720:                 } elsif (exists($personnel{$key})) {
 1721:                     my $lastaccess = $crs_sessions{$key};
 1722:                     my ($uname,$udom) = split(/:/,$key);
 1723:                     if (ref($personnel{$key}) eq 'HASH') {
 1724:                         my ($showrole,$showsec);
 1725:                         foreach my $possrole ('cc','co','in','ta','ep','ad','st') {
 1726:                             if (exists($personnel{$key}{$possrole})) {
 1727:                                 $showrole = $possrole;
 1728:                                 $showsec = join(', ',@{$personnel{$key}{$possrole}});
 1729:                                 last;
 1730:                             }
 1731:                         }
 1732:                         my %info = (
 1733:                                      'section' => $showsec,
 1734:                                      'role'    => $showrole,
 1735:                                      'uname'   => $uname,
 1736:                                      'udom'    => $udom,
 1737:                         );
 1738:                         $sessioncount ++;
 1739:                         push(@{$sessions->{$lastaccess}},\%info);
 1740:                     }
 1741:                 }
 1742:             }
 1743:         }
 1744:     }
 1745:     return $sessioncount;
 1746: }
 1747: 
 1748: sub checkversions {
 1749:     my ($cdom,$crs,$navmap,$changed,$starttime) = @_;
 1750:     my %changes=&Apache::lonnet::dump('versionupdate',$cdom,$crs);
 1751:     my ($tmp) = keys(%changes);
 1752:     unless ($tmp =~ /^(con_lost|error|no_such_host)/i) {
 1753:         if (keys(%changes) > 0) {
 1754:             foreach my $key (sort(keys(%changes))) {
 1755:                 if ($changes{$key} > $starttime) {
 1756:                     my $version;
 1757:                     my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
 1758:                     my $currentversion=&Apache::lonnet::getversion($key);
 1759:                     my $revdate = 
 1760:                           &Apache::lonnet::metadata($root.'.'.$extension,
 1761:                                                      'lastrevisiondate');
 1762:                     $revdate =  &Apache::lonlocal::locallocaltime($revdate);
 1763:                     my $linkurl=&Apache::lonnet::clutter($key);
 1764:                     my $usedversion=$navmap->usedVersion($linkurl);
 1765:                     my @resources = $navmap->getResourceByUrl($linkurl,1);
 1766:                     if (($usedversion) && ($usedversion ne 'mostrecent')) {
 1767:                         $version = $usedversion;     
 1768:                     } else {
 1769:                         $version = $currentversion;
 1770:                     }
 1771:                     foreach my $res (@resources) {
 1772:                          if (ref($res) eq 'Apache::lonnavmaps::resource') { 
 1773:                             my $symb = $res->symb();
 1774:                             %{$$changed{$symb}} = (
 1775:                                                 current => $currentversion,
 1776:                                                 version => $version,
 1777:                                                 revdate => $revdate,
 1778:                             );
 1779:                         }
 1780:                     }
 1781:                 }
 1782:             }
 1783:         }
 1784:     }
 1785:     return;
 1786: }
 1787: 
 1788: sub display_handgrade {
 1789:     my ($r,$tograde,$ungraded,$itemserror) = @_;
 1790:     my %lt = &Apache::lonlocal::texthash(
 1791:                         'prna' => 'Problem Name',
 1792:                         'nmun' => 'Number ungraded',
 1793:                         'nopr' => 'No problems require handgrading',
 1794:     );
 1795:     if (@{$tograde} > 0) {
 1796:         $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
 1797:                   $lt{'prna'}.'</td><td class="LC_right_item">'.
 1798:                   $lt{'nmun'}.'</td></tr>');
 1799:         my $rowNum = 0;
 1800:         foreach my $res (@{$tograde}) {
 1801:             $rowNum ++;
 1802:             my $css_class = $rowNum%2?' class="LC_odd_row"':'';
 1803:             my $linkurl='/adm/grades';
 1804:             if ($$ungraded{$res}{'enclink'}) {
 1805:                 $linkurl.='?symb='.$$ungraded{$res}{'encsymb'};
 1806:             } else {
 1807:                 $linkurl.='?symb='.&escape($res);
 1808:             }
 1809:             $linkurl.='&amp;command=ungraded';
 1810:             $r->print('<tr'.$css_class.'><td><a href="'.$linkurl.'">'.$$ungraded{$res}{title}.'</a></td><td class="LC_right_item">'.$$ungraded{$res}{count}.'</td></tr>');
 1811:         }
 1812:     } elsif ($itemserror) {
 1813:         $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
 1814:     } else {
 1815:         $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
 1816:     }
 1817: }
 1818: 
 1819: sub display_haserrors {
 1820:     my ($r,$bombs,$bombed,$res_title,$itemserror) = @_;
 1821:     my $bombnum = 0;
 1822:     my %lt = &Apache::lonlocal::texthash(
 1823:                                    reso => 'Resource',
 1824:                                    nmer => 'Number of errors',
 1825:                                    noer => 'No problems with errors',
 1826:     );
 1827:     if (@{$bombs} > 0) {
 1828:         $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
 1829:                   $lt{'reso'}.'</td><td class="LC_right_item">'.
 1830:                   $lt{'nmer'}.'</td></tr>');
 1831:         @{$bombs} = sort { &cmp_title($a,$b,$res_title) } @{$bombs};
 1832:         foreach my $bomb (@{$bombs}) {
 1833:             $bombnum ++;
 1834:             my $css_class = $bombnum%2?' class="LC_odd_row"':'';
 1835:             $r->print('<tr'.$css_class.'><td>'.$$bombed{$bomb}{errorlink}.
 1836:                       '</td><td class="LC_right_item">'.
 1837:                       $$bombed{$bomb}{errorcount}.'</td></tr>');
 1838:         }
 1839:     } elsif ($itemserror) {
 1840:         $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
 1841:     } else {
 1842:         $r->print('<tr class="LC_empty_row"><td>'.$lt{'noer'}.'</td></tr>');
 1843:     }
 1844:     return;
 1845: }
 1846: 
 1847: sub display_abovethreshold {
 1848:     my ($r,$refpage,$warnings,$triggered,$res_title,$itemserror,$checkallowed) = @_;
 1849:     my %lt = &Apache::lonlocal::texthash(
 1850:                  reso => 'Resource',
 1851:                  part => 'Part',
 1852:                  nust => 'Num. students',
 1853:                  avat => 'Av. Attempts',
 1854:                  dedi => 'Deg. Diff',
 1855:                  lare => 'Last Reset',
 1856:                  reco => 'Reset Count?',
 1857:                  rese => 'Reset counters to 0',
 1858:                  nopr => 'No problems satisfy threshold criteria',
 1859:     );
 1860:     if (@{$warnings} > 0) {
 1861:         @{$warnings} = sort { &cmp_title($a,$b,$res_title) } @{$warnings};
 1862:         $r->print('<tr class="LC_info_row">'.
 1863: 		  '<td class="LC_left_item">'.$lt{'reso'}.
 1864:                   '<input type="hidden" name="command" value="" /></td>'.
 1865: 		  '<td>'.$lt{'part'}.'</td><td>'.$lt{'nust'}.'</td>'.
 1866: 		  '<td>'.$lt{'avat'}.'</td><td>'.$lt{'dedi'}.'</td>'.
 1867: 		  '<td>'.$lt{'lare'}.'</td>');
 1868:         if ($checkallowed->{'resetcounters'}) {
 1869:             $r->print('<td  class="LC_right_item">'.$lt{'reco'}.'</td>');
 1870:         }
 1871:         $r->print('</tr>');
 1872: 	my $row;
 1873:         foreach my $res (@{$warnings}) {
 1874: 	    $row++;
 1875:             my ($map,$id,$url)=&Apache::lonnet::decode_symb($res);
 1876:             my $linkurl=&Apache::lonnet::clutter($url);
 1877:             my $rowspan;
 1878:             if ($$triggered{$res}{numparts} > 1) {
 1879:                 $rowspan = 'rowspan="'.$$triggered{$res}{numparts}.'"';
 1880:             }
 1881:             $linkurl .= '?symb='.&escape($res);
 1882:             if ($$triggered{$res}{'enclink'}) {
 1883:                 $linkurl = 
 1884:                   $$triggered{$res}{'enclink'}.'?symb='.$$triggered{$res}{'encsymb'};
 1885:             }
 1886:             my $css_class = $row%2?' class="LC_odd_row"':'';
 1887:             $r->print('<tr'.$css_class.'>'.
 1888: 		      '<td class="LC_first_item" '.$rowspan.'><a href="'.$linkurl.'">'.
 1889: 		      $$triggered{$res}{title}.'</a></td>');
 1890:                       if (ref($$triggered{$res}{text}) eq 'ARRAY') {
 1891: 		          $r->print($$triggered{$res}{text}[0]);
 1892:                       }
 1893:                       $r->print('</tr>');
 1894:             if (ref($$triggered{$res}{text}) eq 'ARRAY') {
 1895:                 if (@{$$triggered{$res}{text}} > 1) {
 1896:                     for (my $i=1; $i<@{$$triggered{$res}{text}}; $i++) {
 1897:                         $r->print('<tr '.$css_class.'>'.
 1898:                                   $$triggered{$res}{text}[$i].'</tr>');
 1899:                     }
 1900:                 }
 1901:             }
 1902:         }
 1903:         if ($checkallowed->{'resetcounters'}) {
 1904:             $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>');
 1905:         }
 1906:     } elsif ($itemserror) {
 1907:         $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
 1908:     } else {
 1909:         $r->print('<tr class="LC_empty_row"><td>'.$lt{'nopr'}.'</td></tr>');
 1910:     }
 1911: }
 1912: 
 1913: sub display_versionchanges {
 1914:     my ($r,$changed,$res_title,$interval,$itemserror) = @_;
 1915:     my %lt = &Apache::lonlocal::texthash(
 1916:         'reso' => 'Resource',
 1917:         'revd' => 'Last revised',
 1918:         'newv' => 'New version',
 1919:         'veru' => 'Version used',
 1920:     );
 1921:     if (keys(%{$changed}) > 0) {
 1922:         $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
 1923:                   $lt{'reso'}.'</td><td>'.$lt{'revd'}.'</td><td>'.
 1924:                   $lt{'newv'}.'</td><td class="LC_right_item">'.
 1925:                   $lt{'veru'}.'</td></tr>');
 1926:         my @changes = sort { &cmp_title($a,$b,$res_title) } keys(%{$changed});
 1927:         my $changenum = 0;
 1928:         foreach my $item (@changes) {
 1929:             $changenum ++;
 1930:             my $css_class = $changenum%2?' class="LC_odd_row"':'';
 1931:             my ($map,$id,$url)=&Apache::lonnet::decode_symb($item);
 1932:             my $linkurl=&Apache::lonnet::clutter($url);
 1933:             $linkurl .= '?symb='.&escape($item);
 1934: 
 1935:             $r->print('<tr'.$css_class.'><td><a href="'.$linkurl.'">'.
 1936:                       $$res_title{$item}.'</a></td><td>'.
 1937:                       $$changed{$item}{'revdate'}.'</td><td>'.
 1938:                       $$changed{$item}{'current'}.'</td><td>'.
 1939:                       $$changed{$item}{'version'}.'</td></tr>');
 1940:         }
 1941:     } elsif ($itemserror) {
 1942:         $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
 1943:     } else {
 1944:         $r->print('<tr class="LC_empty_row"><td>'
 1945:                  .&mt('No '.$interval).'</td></tr>');
 1946:     }
 1947:     return;
 1948: }
 1949: 
 1950: sub display_rolechanges {
 1951:     my ($r,$chgcount,$changed,$interval,$crstype,$classlist) = @_;
 1952:     my $now = time();
 1953:     my %lt = &Apache::lonlocal::texthash(
 1954:         'user'  => 'User',
 1955:         'tich'  => 'Time of change',
 1956:         'role'  => 'Role',
 1957:         'sec'   => 'Section',
 1958:         'status'  => 'Status',
 1959:     );
 1960:     if ($chgcount) {
 1961:         $r->print('<tr class="LC_info_row">'.
 1962:                   '<td class="LC_left_item">'.$lt{'tich'}.'</td>'.
 1963:                   '<td class="LC_left_item">'.$lt{'user'}.'</td>'.
 1964:                   '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
 1965:                   '<td class="LC_left_item">'.$lt{'sec'}.'</td>'.
 1966:                   '<td class="LC_left_item">'.$lt{'status'}.'</td></tr>');
 1967:         if (ref($changed) eq 'HASH') {
 1968:             my @changes = sort { $b <=> $a } (keys(%{$changed}));
 1969:             my $changenum = 0;
 1970:             my $fullnameidx = &Apache::loncoursedata::CL_FULLNAME();
 1971:             foreach my $item (@changes) {
 1972:                 if (ref($changed->{$item}) eq 'ARRAY') {
 1973:                     foreach my $chg (@{$changed->{$item}}) {
 1974:                         if (ref($chg) eq 'HASH') {
 1975:                             my $section;
 1976:                             my $role = 
 1977:                                 &Apache::lonnet::plaintext($chg->{'role'},$crstype);
 1978:                             my $status = &mt($chg->{'status'});
 1979:                             if ($chg->{'section'} eq '') {
 1980:                                 $section = &mt('none');
 1981:                             } else {
 1982:                                 $section = $chg->{'section'};
 1983:                             }
 1984:                             my $uname = $chg->{'uname'};
 1985:                             my $udom = $chg->{'udom'};
 1986:                             $changenum ++;
 1987:                             my $css_class = $changenum%2?' class="LC_odd_row"':'';
 1988:                             my $fullname;
 1989:                             if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') {
 1990:                                 $fullname = $classlist->{$uname.':'.$udom}->[$fullnameidx];
 1991:                             } else {
 1992:                                 $fullname = &Apache::loncommon::plainname($uname,$udom,'lastname');
 1993:                             }
 1994:                             my $link = 
 1995:                                 &Apache::loncommon::aboutmewrapper($fullname,$uname,$udom);
 1996:                             $r->print('<tr'.$css_class.'>'.
 1997:                                       '<td>'.&Apache::lonlocal::locallocaltime($item).'</td>'.
 1998:                                       '<td>'.$link.'</td>'.
 1999:                                       '<td>'.$role.'</td>'.
 2000:                                       '<td>'.$section.'</td>'.
 2001:                                       '<td>'.$status.'</td></tr>');
 2002:                         }
 2003:                     }
 2004:                 }
 2005:             }
 2006:         }
 2007:     } else {
 2008:         $r->print('<tr class="LC_empty_row"><td>'
 2009:                  .&mt('There are no '.$interval).'</td></tr>');
 2010:     }
 2011:     return;
 2012: }
 2013: 
 2014: sub display_activity {
 2015:     my ($r,$context,$count,$details,$interval,$crstype,$classlist) = @_;
 2016:     return unless (ref($classlist) eq 'HASH');
 2017:     my %lt = &Apache::lonlocal::texthash(
 2018:         'user'   => 'User',
 2019:         'role'   => 'Role',
 2020:         'sec'    => 'Section',
 2021:         'number' => 'Total number of logins',
 2022:     );
 2023:     my $prefix = 'login';
 2024:     if ($context eq 'sessions') {
 2025:         $lt{'number'} = &mt('Total number of active user sessions');
 2026:         $lt{'active'} = &mt('Last active');
 2027:         $prefix = 'session';
 2028:     }
 2029:     if ($count) {
 2030: 
 2031:         my $hdr = '<tr class="LC_info_row" style="display:none" id="'.$prefix.'titledet">'.
 2032:                   '<td class="LC_left_item">'.$lt{'user'}.'</td>'.
 2033:                   '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
 2034:                   '<td class="LC_left_item">'.$lt{'sec'}.'</td>';
 2035:         if ($context eq 'sessions') {
 2036:             $hdr .= '<td class="LC_left_item">'.$lt{'active'}.'</td>';
 2037:         }
 2038:         $hdr .= '</tr>'."\n".
 2039:                 '<tr class="LC_info_row" id="'.$prefix.'titlesum">'.
 2040:                 '<td class="LC_left_item">'.$lt{'number'}.'</td>'.
 2041:                 '<td class="LC_left_item">'.$lt{'role'}.'</td>'.
 2042:                 '<td class="LC_left_item">'.$lt{'sec'};
 2043:         my (%bylastname,%counts);
 2044:         if (ref($details) eq 'HASH') {
 2045:             my @items = sort { $b <=> $a } (keys(%{$details}));
 2046:             my $num = 0;
 2047:             my $fullnameidx = &Apache::loncoursedata::CL_FULLNAME();
 2048:             foreach my $item (@items) {
 2049:                 if (ref($details->{$item}) eq 'ARRAY') {
 2050:                     foreach my $user (@{$details->{$item}}) {
 2051:                         if (ref($user) eq 'HASH') {
 2052:                             my $section;
 2053:                             my $role =
 2054:                                 &Apache::lonnet::plaintext($user->{'role'},$crstype);
 2055:                             if ($user->{'section'} eq '') {
 2056:                                 $section = &mt('none');
 2057:                             } else {
 2058:                                 $section = $user->{'section'};
 2059:                             }
 2060:                             $counts{$user->{'role'}}{$section} ++;
 2061:                             my $uname = $user->{'uname'};
 2062:                             my $udom = $user->{'udom'};
 2063:                             my $fullname;
 2064:                             if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') {
 2065:                                 $fullname = $classlist->{$uname.':'.$udom}->[$fullnameidx];
 2066:                             } else {
 2067:                                 $fullname = &Apache::loncommon::plainname($uname,$udom,'lastname');
 2068:                             }
 2069:                             my $link =
 2070:                                 &Apache::loncommon::aboutmewrapper($fullname,$uname,$udom);
 2071:                             my $entry = '<td>'.$link.'</td>'.
 2072:                                         '<td>'.$role.'</td>'.
 2073:                                         '<td>'.$section.'</td>';
 2074:                             if ($context eq 'sessions') {
 2075:                                 $entry .= '<td>'.&Apache::lonlocal::locallocaltime($item).'</td>';
 2076:                             }
 2077:                             push(@{$bylastname{$fullname}},$entry);
 2078:                         }
 2079:                     }
 2080:                 }
 2081:             }
 2082:             my $table;
 2083:             foreach my $person (sort(keys(%bylastname))) {
 2084:                 if (ref($bylastname{$person}) eq 'ARRAY') {
 2085:                     foreach my $item (@{$bylastname{$person}}) {
 2086:                         $num ++;
 2087:                         my $css_class = $num%2?' class="LC_odd_row"':'';
 2088:                         $table .= '<tr'.$css_class.' style="display:none;"  id="'.$prefix.'det_'.$num.'">'.$item.'</tr>';
 2089:                     }
 2090:                 }
 2091:             }
 2092:             my $numrow = 0;
 2093:             foreach my $role (sort(keys(%counts))) {
 2094:                 my $showrole = &Apache::lonnet::plaintext($role,$crstype);
 2095:                 if (ref($counts{$role}) eq 'HASH') {
 2096:                     foreach my $sec (sort { $b <=> $a } (keys(%{$counts{$role}}))) {
 2097:                         $numrow ++;
 2098:                         my $css_class = $numrow%2?' class="LC_odd_row"':'';
 2099:                         $table .= '<tr '.$css_class.' id="'.$prefix.'sum_'.$numrow.'">'.
 2100:                                   '<td>'.$counts{$role}{$sec}.'</td>'.
 2101:                                   '<td>'.$showrole.'</td>'.
 2102:                                   '<td>'.$sec.'</td></tr>';
 2103:                    }
 2104:                 }
 2105:             }
 2106:             $r->print($hdr.'<input type="hidden" name="'.$prefix.'count" value="'.$num.
 2107:                       '" /><input type="hidden" name="'.$prefix.'row" value="'.$numrow.
 2108:                       '" /></td></tr>'.$table);
 2109:         }
 2110:     } else {
 2111:         $r->print('<tr class="LC_empty_row"><td>'.
 2112:                   &mt('There are no '.$interval).
 2113:                   '<input type="hidden" name="'.$prefix.'count" value="'.$count.
 2114:                   '." /></td></tr>');
 2115:     }
 2116:     return;
 2117: }
 2118: 
 2119: sub display_coursediscussion {
 2120:     my ($r,$newdiscussions,$unread,$countunread,$res_title,$itemserror) = @_;
 2121:     my $lctype = lc(&Apache::loncommon::course_type());
 2122:     my %lt = &Apache::lonlocal::texthash(
 2123:                 'loca' => 'Location',
 2124:                 'type' => 'Type',
 2125:                 'numn' => 'Number of new posts',
 2126:                 'noun' => 'No unread posts in '.$lctype.' discussions',
 2127:                 'tmlp' => 'Time of last post', 
 2128:     );
 2129:     if (@{$newdiscussions} > 0) {
 2130:         $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
 2131:                   $lt{'loca'}.'</td><td>'.
 2132:                   $lt{'type'}.'</td>');
 2133:         if ($countunread eq 'on') {
 2134:             $r->print('<td>'.$lt{'tmlp'}.'</td>'.
 2135:                       '<td class="LC_right_item">'.$lt{'numn'}.'</td>');
 2136:         } else {
 2137:             $r->print('<td class="LC_right_item">'.$lt{'tmlp'}.'</td>');
 2138:         }
 2139:         $r->print("</tr>\n");
 2140:         @{$newdiscussions} = sort { &cmp_title($a,$b,$res_title) }
 2141:                                                             @{$newdiscussions};
 2142:         my $rowNum = 0;
 2143:         foreach my $ressymb (@{$newdiscussions}) {
 2144:             $rowNum ++;
 2145:             my $forum_title = $$unread{$ressymb}{'title'};
 2146:             my $type = 'Resource';
 2147:             my $feedurl=&Apache::lonfeedback::get_feedurl($ressymb);
 2148:             my $disclink = $feedurl.'?symb='. &escape($$unread{$ressymb}{symb});
 2149:             if ($feedurl =~ /bulletinboard/) {
 2150:                 $type = 'Discussion Board';
 2151:             }
 2152:             if ($$unread{$ressymb}{'enclink'}) {
 2153:                 $disclink = $$unread{$ressymb}{'enclink'}.'?symb='.$$unread{$ressymb}{'encsymb'};
 2154:             }
 2155:             my $css_class = $rowNum%2?' class="LC_odd_row"':'';
 2156:             my $lastpost = &Apache::lonnavmaps::timeToHumanString(
 2157:                                                $$unread{$ressymb}{'lastpost'});
 2158:             $r->print('<tr'.$css_class.'><td><a href="'.$disclink.'">'.$forum_title.'</a>&nbsp;</td><td>'.&mt($type).'&nbsp;</td>');
 2159:             if ($countunread eq 'on') {
 2160:                 my $unreadnum = $$unread{$ressymb}{'unreadcount'};
 2161:                 $r->print('<td>'.$lastpost.'</td><td class="LC_right_item">'.
 2162:                           $unreadnum.'&nbsp;</td>');
 2163:             } else {
 2164:                 $r->print('<td class="LC_right_item">'.$lastpost.'</td>');
 2165:             }
 2166:             $r->print("</tr>\n");
 2167:         }
 2168:     } elsif ($itemserror) {
 2169:         $r->print('<tr class="LC_empty_row"><td>'.$itemserror.'</td></tr>');
 2170:     } else {
 2171:         $r->print('<tr class="LC_empty_row"><td>'.$lt{'noun'}.'</td></tr>');
 2172:     }
 2173: }
 2174: 
 2175: sub display_coursenormalmail {
 2176:     my ($r,$msgcount,$newmsgs) = @_;
 2177:     my $lctype = lc(&Apache::loncommon::course_type());
 2178:     if ($msgcount > 0) {
 2179:         $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
 2180:                   &mt('Number').'</td><td>'.&mt('Subject').'</td><td>'.
 2181:                   &mt('Sender').'</td><td class="LC_right_item">'.
 2182:                   &mt('Date/Time').'</td></tr>');
 2183:         my $mailcount = 0;
 2184:         foreach my $msg (@{$newmsgs}) {
 2185:             $mailcount ++;
 2186:             my $css_class = $mailcount%2?' class="LC_odd_row"':'';
 2187:             $r->print('<tr'.$css_class.'><td>'.$mailcount
 2188:                       .'.&nbsp;</td><td><a href="/adm/email?display='
 2189:                       .$msg->{'msgid'}.'">'
 2190:                       .$msg->{'shortsub'}.'</a>&nbsp;&nbsp;</td><td>&nbsp;'
 2191:                       .$msg->{'from'}.':'.$msg->{'fromdom'}.'&nbsp;</td><td>'
 2192:                       .$msg->{'sendtime'}.'</td></tr>');
 2193:         }
 2194:     } else {
 2195:         $r->print('<tr class="LC_empty_row"><td>'.
 2196:                   &mt('No new '.$lctype.' messages').'</td></tr>');
 2197:     }
 2198: }
 2199: 
 2200: sub display_coursecritmail {
 2201:     my ($r,$critmsgcount,$critmsgs) = @_;
 2202:     my $lctype = lc(&Apache::loncommon::course_type());
 2203:     if ($critmsgcount > 0) {
 2204:         $r->print('<tr class="LC_info_row"><td class="LC_left_item">'.
 2205:                   &mt('Number').'</td><td>'.&mt('Subject').'</td><td>'.
 2206:                   &mt('Sender').'</td><td class="LC_right_item">'.
 2207:                   &mt('Date/Time').'</td></tr>');
 2208:         my $mailcount = 0;
 2209:         foreach my $msg (@{$critmsgs}) {
 2210:             $mailcount ++;
 2211:             my $css_class = $mailcount%2?' class="LC_odd_row"':'';
 2212:             $r->print('<tr'.$css_class.'><td>'.$mailcount.
 2213:                       '. &nbsp;</td><td><a href="/adm/email?folder=critical">'.
 2214:                       $msg->{'shortsub'}.'</a>&nbsp; &nbsp;</td><td>&nbsp;'.
 2215:                       $msg->{'from'}.':'.$msg->{'fromdom'}.'&nbsp;</td><td>'.
 2216:                       $msg->{'sendtime'}.'</td></tr>');
 2217:         }
 2218:     } else {
 2219:         $r->print('<tr class="LC_empty_row"><td>'.
 2220:                   &mt('No unread critical messages in '.$lctype).
 2221:                   '</td></tr>');
 2222:     }
 2223: }
 2224: 
 2225: sub cmp_title {
 2226:     my ($a,$b,$res_title) = @_;
 2227:     my ($atitle,$btitle) = (lc($$res_title{$a}),lc($$res_title{$b}));
 2228:     $atitle=~s/^\s*//;
 2229:     $btitle=~s/^\s*//;
 2230:     return $atitle cmp $btitle;
 2231: }
 2232: 
 2233: sub get_display_settings {
 2234:     my ($uname,$udom,$cid) = @_;
 2235:     my %settings = &Apache::lonnet::dump('nohist_whatsnew',$udom,$uname,$cid); 
 2236:     my ($tmp) = keys(%settings);
 2237:     if ($tmp=~ /^(con_lost|error|no_such_host)/i) {
 2238:         %settings = ();
 2239:         unless ($tmp =~ /^error: 2 /) {
 2240: 	    my $lctype = lc(&Apache::loncommon::course_type());
 2241:             &Apache::lonnet::logthis('Error retrieving whatsnew settings: '.
 2242:             $tmp.' for '.$uname.':'.$udom.' for '.$lctype.': '.$cid);
 2243:         }
 2244:     }
 2245:     return %settings;
 2246: }
 2247: 
 2248: sub store_display_settings {
 2249:     my ($uname,$udom,$cid,$checkallowed) = @_;
 2250:     my %whatsnew_settings;
 2251:     my $result;
 2252:     foreach my $key (keys(%{$checkallowed})) {
 2253: 	if ($key =~ /_section$/) { next; }
 2254:         if (exists($env{'form.display_'.$key})) {
 2255:             unless ($env{'form.display_'.$key} eq '') {
 2256:                 $whatsnew_settings{$cid.':'.$key} = $env{'form.display_'.$key};
 2257:             }
 2258:         }
 2259:     }
 2260:     if (keys(%whatsnew_settings)) {
 2261:         $result = &Apache::lonnet::put('nohist_whatsnew',\%whatsnew_settings,
 2262:                                                                  $udom,$uname);
 2263:     } else {
 2264:         $result = 'ok';
 2265:     }
 2266:     return $result;
 2267: }
 2268: 
 2269: sub store_interval_setting {
 2270:     my ($uname,$udom,$cid,$interval_titles) = @_;
 2271:     my %interval_settings = ();
 2272:     my $result;
 2273:     my $context = $env{'form.intervaltype'};
 2274:     if ($env{'form.interval'} ne '') {
 2275:         if ($context eq 'oldroles') {
 2276:             $interval_settings{$cid.':oldroleinterval'} = $env{'form.interval'};
 2277:         } elsif ($context eq 'newroles') {
 2278:             $interval_settings{$cid.':newroleinterval'} = $env{'form.interval'};
 2279:         } elsif ($context eq 'crslogin') {
 2280:             $interval_settings{$cid.':crslogininterval'} = $env{'form.interval'};
 2281:         } elsif ($context eq 'sessions') {
 2282:             $interval_settings{$cid.':sessionactivity'} = $env{'form.interval'};
 2283:         } else {
 2284:             $interval_settings{$cid.':interval'} = $env{'form.interval'};
 2285:         }
 2286:         my $outcome = &Apache::lonnet::put('nohist_whatsnew',
 2287:                                              \%interval_settings,$udom,$uname);
 2288:         if ($outcome eq 'ok') {
 2289:             if (ref($interval_titles->{$context}) eq 'HASH') {
 2290:                 $result = &Apache::lonhtmlcommon::confirm_success(&mt('New filter setting: [_1].','<b>'. 
 2291:                               $interval_titles->{$context}->{$env{'form.interval'}}.'</b>').'<br />');
 2292:             }
 2293:         } else {
 2294: 	    my $lctype = lc(&Apache::loncommon::course_type());
 2295:             &Apache::lonnet::logthis('Error saving whatsnew '.$context.' interval setting'.
 2296:                 ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
 2297:             $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set interval to [_1] due to [_2].',
 2298:                          '<b>'.$interval_titles->{$context}->{$env{'form.interval'}}.'</b>',
 2299:                          '<tt>'.$outcome.'</tt>'),1);
 2300:         }
 2301:     }
 2302:     return &Apache::loncommon::confirmwrapper($result);
 2303: }
 2304: 
 2305: sub store_discussion_setting {
 2306:     my ($uname,$udom,$cid) = @_;
 2307:     my %discussion_settings;
 2308:     my $result;
 2309:     if (defined($env{'form.countunread'})) {
 2310:         $discussion_settings{$cid.':countunread'} = $env{'form.countunread'};
 2311:         my $outcome = &Apache::lonnet::put('nohist_whatsnew',
 2312:                                              \%discussion_settings,$udom,$uname);
 2313:         if ($outcome eq 'ok') {
 2314:             $result = &Apache::lonhtmlcommon::confirm_success(&mt('Count unread posts in discussions display set to [_1]',
 2315:                   '<b>'.&mt($env{'form.countunread'}).'</b>').'<br />');
 2316:                                                                                   
 2317:         } else {
 2318: 	    my $lctype = lc(&Apache::loncommon::course_type());
 2319:             &Apache::lonnet::logthis('Error saving whatsnew countunread setting'.
 2320:                 ' '.$outcome.' for '.$uname.':'.$udom.' in '.$lctype.' '.$cid);
 2321:             $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set "number unread posts display" to [_1]'.
 2322:                           ' due to [_2].',
 2323:                          '<b>'.&mt($env{'form.countunread'}).'</b>',
 2324:                          '<tt>'.$outcome.'</tt>'),1);
 2325:         }
 2326:     }
 2327:     return &Apache::loncommon::confirmwrapper($result);
 2328: }
 2329: 
 2330: sub store_courseinit_setting {
 2331:     my ($uname,$udom,$cid,$initpage) = @_;
 2332:     my %courseinit_settings;
 2333:     my $page_control;
 2334:     my $result;
 2335:     if (defined($env{'form.courseinit_control'})) {
 2336:         if ($env{'form.courseinit_control'} eq 'userpref') {
 2337:             $courseinit_settings{$cid.':courseinit'} = '';
 2338:             $page_control = 'global preferences';
 2339:         } else {
 2340:             if (defined($env{'form.courseinit_page'})) {
 2341:                 $courseinit_settings{$cid.':courseinit'} = 
 2342:                                                   $env{'form.courseinit_page'};
 2343:                 $page_control = 'course specific setting';
 2344:             }
 2345:         }
 2346:         if ($page_control) {
 2347: 	    my $lctype = lc(&Apache::loncommon::course_type());
 2348:             my $outcome = &Apache::lonnet::put('nohist_whatsnew',
 2349:                                            \%courseinit_settings,$udom,$uname);
 2350:             if ($outcome eq 'ok') {
 2351:                 if ($page_control eq 'global preferences') {
 2352:                     $result = &Apache::lonhtmlcommon::confirm_success(&mt("Page displayed after role selection in $lctype now set by [_1]user's global preferences[_2].",'<b>','</b>'));
 2353:                 } else {
 2354:                     $result = &Apache::lonhtmlcommon::confirm_success(&mt('Page displayed after role selection in this '.$lctype.' set to [_1].'
 2355:                                  ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>'));
 2356:                 }
 2357:             } else {
 2358:                 &Apache::lonnet::logthis('Error saving whatsnew courseinit '.
 2359:                                          'setting: '.$outcome.' for '.$uname.
 2360:                                          ':'.$udom.' in '.$lctype.' '.$cid);
 2361:                 if ($page_control eq 'global preferences') {
 2362:                     $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set control of page display to [_1]'.
 2363:                           ' due to [_2].',
 2364:                          '<b>'.$page_control.'</b>',
 2365:                          '<tt>'.$outcome.'</tt>'),1);
 2366:                 } else {
 2367:                     $result = &Apache::lonhtmlcommon::confirm_success(&mt('Unable to set page display, after role selection, for this '.$lctype.' to [_1] due to [_2].'
 2368:                                  ,'<b>'.$$initpage{$env{'form.courseinit_page'}}.'</b>'
 2369:                                  ,'<tt>'.$outcome.'</tt>'),1);
 2370:                 }
 2371:             }
 2372:         }
 2373:     }
 2374:     return &Apache::loncommon::confirmwrapper($result);
 2375: }
 2376: 
 2377: sub start_box {
 2378:     my ($r,$show,$heading,$caller,$refpage) = @_;
 2379:     my %lt = &Apache::lonlocal::texthash( 
 2380:                        chth => 'Change thresholds?',
 2381:                        chin => 'Change interval?',
 2382:                        chop => 'Change options?',
 2383:     );
 2384:     my $showhide;
 2385:     if ($$show{$caller}) {
 2386:         $showhide = '<b><a href="javascript:change_display(document.visible.'.
 2387:                                'display_'.$caller.",'hide'".');">'.
 2388:                                &mt('Hide').'</a></b>';
 2389:    
 2390:     } else {
 2391:         $showhide = '<b><a href="javascript:change_display(document.visible.'.
 2392:                                'display_'.$caller.",'show'".');">'.
 2393:                                &mt('Show').'</a></b>';
 2394:     }
 2395:     
 2396:     $r->print('
 2397:          <table class="LC_nested_outer">
 2398:           <tr>
 2399:            <th class="LC_left_item">'.$$heading{$caller}.'</th>
 2400:            <th class="LC_right_item">'.$showhide.'</th>
 2401:           </tr>');
 2402:      if (($caller eq 'abovethreshold') && ($$show{$caller})) {
 2403:          if ($$show{$caller}) {
 2404:              $r->print('
 2405:               <tr>
 2406:                 <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgthreshold&amp;refpage='.$refpage.'">'.$lt{'chth'}.'</a></td>
 2407:               </tr>');
 2408:          }
 2409:      } elsif (($caller eq 'versionchanges') && ($$show{$caller})) {
 2410:          if ($$show{$caller}) {
 2411:              $r->print('
 2412:               <tr>
 2413:                 <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chginterval&amp;refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
 2414:               </tr>');
 2415:          }
 2416:      } elsif ($caller eq 'coursediscussion') {
 2417:          if ($$show{$caller}) {
 2418:              $r->print('
 2419:               <tr>
 2420:                 <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgdisc&amp;refpage='.$refpage.'">'.$lt{'chop'}.'</a></td>
 2421:               </tr>');
 2422:          }
 2423:      } elsif (($caller eq 'newroles') && ($$show{$caller})) {
 2424:          if ($$show{$caller}) {
 2425:              $r->print('
 2426:               <tr>
 2427:                 <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgnewroleinterval&amp;refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
 2428:               </tr>');
 2429:          }
 2430:      } elsif (($caller eq 'oldroles') && ($$show{$caller})) {
 2431:          if ($$show{$caller}) {
 2432:              $r->print('
 2433:               <tr>
 2434:                 <td class="LC_subheader" colspan="2"><a href="/adm/whatsnew?command=chgoldroleinterval&amp;refpage='.$refpage.'">'.$lt{'chin'}.'</a></td>
 2435:               </tr>');
 2436:          }
 2437:     } elsif (($caller eq 'crslogin') && ($$show{$caller})) {
 2438:         if ($$show{$caller}) {
 2439:             $r->print('
 2440:               <tr>
 2441:                 <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>
 2442:               </tr>');
 2443:         }
 2444:     } elsif (($caller eq 'sessions') && ($$show{$caller})) {
 2445:         if ($$show{$caller}) {
 2446:             $r->print('
 2447:               <tr>
 2448:                 <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>
 2449:               </tr>');
 2450:         }
 2451:     }
 2452:     $r->print('
 2453:               <tr>
 2454:                <td colspan="2">
 2455:                 <table class="LC_nested">
 2456: ');
 2457:     return;
 2458: }
 2459: 
 2460: sub end_box {
 2461:     my ($r) = shift;
 2462:     $r->print('
 2463:    </table>
 2464:   </td>
 2465:  </tr>
 2466: </table><br />');
 2467:     return;
 2468: }
 2469: 
 2470: 1;

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