Annotation of loncom/interface/lonwhatsnew.pm, revision 1.105.2.18

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

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