File:  [LON-CAPA] / loncom / interface / lonwhatsnew.pm
Revision 1.88: download - view: text, annotated - select for diffs
Thu Feb 19 16:12:21 2009 UTC (15 years, 2 months ago) by hauer
Branches: MAIN
CVS tags: HEAD
edited all occurencies into "What's New?" and "What's New Page" for consistent wording
CVS ----------------------------------------------------------------------

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

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