File:  [LON-CAPA] / loncom / interface / lonwhatsnew.pm
Revision 1.80.2.3: download - view: text, annotated - select for diffs
Sun Dec 21 16:41:15 2008 UTC (15 years, 5 months ago) by raeburn
Branches: version_2_8_X
CVS tags: version_2_8_2, version_2_8_1, version_2_8_0, version_2_7_99_1, version_2_7_99_0, GCI_1
Diff to branchpoint 1.80: preferred, unified
_ Backport 1.84.

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

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