File:  [LON-CAPA] / loncom / interface / lonstatistics.pm
Revision 1.33: download - view: text, annotated - select for diffs
Fri Jul 26 16:22:09 2002 UTC (21 years, 10 months ago) by stredwic
Branches: MAIN
CVS tags: HEAD
Added section selection.  I added a new multiselect box for sections.  All
students without a section number or a space or undefined will fall under
the none category.  A list of possible sections for a course will be displayed.
Only students with a section number matching one of the selected sections
will be selectable in the students menu and/or display their report.  If
the currently view student doesn't have the correct section when the section
selection changes, the student selection will revert to no student selected.

Note: To refresh the reports after changing which sections to display, press
the refresh button or any of the other onchange interface controls.

    1: # The LearningOnline Network with CAPA
    2: # (Publication Handler
    3: #
    4: # $Id: lonstatistics.pm,v 1.33 2002/07/26 16:22:09 stredwic Exp $
    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: # (Navigate problems for statistical reports
   29: # YEAR=2001
   30: # 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei
   31: # 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei
   32: # YEAR=2002
   33: # 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6 Behrouz Minaei
   34: # 5/12,5/14,5/15,5/19,5/26,7/16,25/7  Behrouz Minaei
   35: #
   36: ###
   37: 
   38: package Apache::lonstatistics; 
   39: 
   40: use strict;
   41: use Apache::Constants qw(:common :http);
   42: use Apache::lonnet();
   43: use Apache::lonhomework;
   44: use Apache::loncommon;
   45: use Apache::loncoursedata;
   46: use Apache::lonhtmlcommon;
   47: use Apache::lonproblemanalysis;
   48: use Apache::lonproblemstatistics;
   49: use Apache::lonstudentassessment;
   50: use Apache::lonchart;
   51: use HTML::TokeParser;
   52: use GDBM_File;
   53: 
   54: 
   55: sub CheckFormElement {
   56:     my ($cache, $ENVName, $cacheName, $default)=@_;
   57: 
   58:     if(defined($ENV{'form.'.$ENVName})) {
   59:         $cache->{$cacheName} = $ENV{'form.'.$ENVName};
   60:     } elsif(!defined($cache->{$cacheName})) {
   61:         $cache->{$cacheName} = $default;
   62:     }
   63: 
   64:     return;
   65: }
   66: 
   67: sub ProcessFormData{
   68:     my ($cache)=@_;
   69: 
   70:     $cache->{'reportKey'} = 'false';
   71: 
   72:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
   73:                                             ['sort','download','reportSelected',
   74:                                              'StudentAssessmentStudent']);
   75:     &CheckFormElement($cache, 'Status', 'Status', 'Active');
   76:     &CheckFormElement($cache, 'postdata', 'reportSelected', 'Class list');
   77:     &CheckFormElement($cache, 'reportSelected', 'reportSelected', 
   78:                       'Class list');
   79:     $cache->{'reportSelected'} = 
   80:         &Apache::lonnet::unescape($cache->{'reportSelected'});
   81:     &CheckFormElement($cache, 'DownloadAll', 'DownloadAll', 'false');
   82:     &CheckFormElement($cache, 'sort', 'sort', 'fullname');
   83:     &CheckFormElement($cache, 'download', 'download', 'false');
   84: 
   85:     if(defined($ENV{'form.CreateStudentAssessment'}) ||
   86:        defined($ENV{'form.NextStudent'}) ||
   87:        defined($ENV{'form.PreviousStudent'})) {
   88:         $cache->{'reportSelected'} = 'Student Assessment';
   89:     }
   90:     if(defined($ENV{'form.NextStudent'})) {
   91:         $cache->{'StudentAssessmentMove'} = 'next';
   92:     } elsif(defined($ENV{'form.PreviousStudent'})) {
   93:         $cache->{'StudentAssessmentMove'} = 'previous';
   94:     } else {
   95:         $cache->{'StudentAssessmentMove'} = 'selected';
   96:     }
   97:     &CheckFormElement($cache, 'StudentAssessmentStudent', 
   98:                       'StudentAssessmentStudent', 'All Students');
   99:     $cache->{'StudentAssessmentStudent'} = 
  100:         &Apache::lonnet::unescape($cache->{'StudentAssessmentStudent'});
  101: 
  102:     if(defined($ENV{'form.Section'})) {
  103:         my @sectionsSelected = (ref($ENV{'form.Section'}) ?
  104:                                @{$ENV{'form.Section'}} :
  105:                                 ($ENV{'form.Section'}));
  106:         $cache->{'sectionsSelected'} = join(':', @sectionsSelected);
  107:     } elsif(!defined($cache->{'sectionsSelected'})) {
  108:         $cache->{'sectionsSelected'} = $cache->{'sectionList'};
  109:     }
  110: 
  111:     foreach (keys(%ENV)) {
  112:         if(/form\.Analyze:::/) {
  113: #            $cache->{'reportSelected'} = 'Analyze';
  114: #            $cache->{'reportKey'} = 'Problem Analysis';
  115:             my ($uri, $title, $part, $problem);
  116:             (undef, $uri, $title, $part, $problem)=split(':::', $_);
  117:             $cache->{'AnalyzeURI'}     = $uri;
  118:             $cache->{'AnalyzeTitle'}   = $title;
  119:             $cache->{'AnalyzePart'}    = $part;
  120:             $cache->{'AnalyzeProblem'} = $problem;
  121:             
  122:             &CheckFormElement($cache, 'Interval', 'Interval', '1');
  123:         }
  124:     }
  125: 
  126:     return;
  127: 
  128:     # Select page to display
  129:     if(defined($ENV{'form.ProblemStatistics'}) ||
  130:        defined($ENV{'form.ProblemStatisticsRecalculate'}) || 
  131:        defined($ENV{'form.DisplayCSVFormat'})) {
  132:         $cache->{'GoToPage'} = 'ProblemStatistics';
  133:         &CheckFormElement($cache, 'DisplayCSVFormat',
  134:                           'DisplayFormat', 'Display Table Format');
  135:         &CheckFormElement($cache, 'Ascend','ProblemStatisticsAscend',
  136:                           'Ascending');
  137:         &CheckFormElement($cache, 'Maps', 'ProblemStatisticsMap', 
  138:                           'All Maps');
  139:     } elsif(defined($ENV{'form.ProblemAnalysis'})) {
  140:         $cache->{'GoToPage'} = 'ProblemAnalysis';
  141:         &CheckFormElement($cache, 'Interval', 'Interval', '1');
  142:     } elsif(defined($ENV{'form.DoDiffGraph'})) {
  143:         $cache->{'GoToPage'} = 'DoDiffGraph';
  144:     } elsif(defined($ENV{'form.PercentWrongGraph'})) {
  145:         $cache->{'GoToPage'} = 'PercentWrongGraph';
  146:     } elsif(defined($ENV{'form.ActivityLog'})) {
  147:         $cache->{'GoToPage'} = 'ActivityLog';
  148:     } else {
  149:         $cache->{'GoToPage'} = 'Menu';
  150:     }
  151: 
  152:     &CheckFormElement($cache, 'Status', 'Status', 'Active');
  153: 
  154:     return;
  155: }
  156: 
  157: =pod
  158: 
  159: =item &SortStudents()
  160: 
  161: Determines which students to display and in which order.  Which are 
  162: displayed are determined by their status(active/expired).  The order
  163: is determined by the sort button pressed (default to username).  The
  164: type of sorting is username, lastname, or section.
  165: 
  166: =over 4
  167: 
  168: Input: $students, $CacheData
  169: 
  170: $students: A array pointer to a list of students (username:domain)
  171: 
  172: $CacheData: A pointer to the hash tied to the cached data
  173: 
  174: Output: \@order
  175: 
  176: @order: An ordered list of students (username:domain)
  177: 
  178: =back
  179: 
  180: =cut
  181: 
  182: sub SortStudents {
  183:     my ($cache)=@_;
  184: 
  185:     my @students = split(':::',$cache->{'NamesOfStudents'});
  186:     my @sorted1Students=();
  187:     foreach (@students) {
  188:         if($cache->{'Status'} eq 'Any' || 
  189:            $cache->{$_.':Status'} eq $cache->{'Status'}) {
  190:             push(@sorted1Students, $_);
  191:         }
  192:     }
  193: 
  194:     my $sortBy = '';
  195:     if(defined($cache->{'sort'})) {
  196:         $sortBy = ':'.$cache->{'sort'};
  197:     }
  198:     my @order = sort { $cache->{$a.$sortBy} cmp $cache->{$b.$sortBy} ||
  199:                        $cache->{$a.':fullname'} cmp $cache->{$b.':fullname'} } 
  200:                 @sorted1Students;
  201: 
  202:     return \@order;
  203: }
  204: 
  205: =pod
  206: 
  207: =item &SpaceColumns()
  208: 
  209: Determines the width of all the columns in the chart.  It is based on
  210: the max of the data for that column and its header.
  211: 
  212: =over 4
  213: 
  214: Input: $students, $studentInformation, $headings, $ChartDB
  215: 
  216: $students: An array pointer to a list of students (username:domain)
  217: 
  218: $studentInformatin: The type of data for the student information.  It is
  219: used as part of the key in $CacheData.
  220: 
  221: $headings: The name of the student information columns.
  222: 
  223: $ChartDB: The name of the cache database which is opened for read/write.
  224: 
  225: Output: None - All data stored in cache.
  226: 
  227: =back
  228: 
  229: =cut
  230: 
  231: sub SpaceColumns {
  232:     my ($students,$studentInformation,$headings,$cache)=@_;
  233: 
  234:     # Initialize Lengths
  235:     for(my $index=0; $index<(scalar @$headings); $index++) {
  236:         my @titleLength=split(//,$headings->[$index]);
  237:         $cache->{$studentInformation->[$index].':columnWidth'}=
  238:             scalar @titleLength;
  239:     }
  240: 
  241:     foreach my $name (@$students) {
  242:         foreach (@$studentInformation) {
  243:             my @dataLength=split(//,$cache->{$name.':'.$_});
  244:             my $length=(scalar @dataLength);
  245:             if($length > $cache->{$_.':columnWidth'}) {
  246:                 $cache->{$_.':columnWidth'}=$length;
  247:             }
  248:         }
  249:     }
  250: 
  251:     return;
  252: }
  253: 
  254: sub PrepareData {
  255:     my ($c, $cacheDB, $studentInformation, $headings)=@_;
  256: 
  257:     # Test for access to the cache data
  258:     my $courseID=$ENV{'request.course.id'};
  259:     my $isRecalculate=0;
  260:     if(defined($ENV{'form.Recalculate'})) {
  261:         $isRecalculate=1;
  262:     }
  263: 
  264:     my $isCached = &Apache::loncoursedata::TestCacheData($cacheDB, 
  265:                                                          $isRecalculate);
  266:     if($isCached < 0) {
  267:         return "Unable to tie hash to db file.";
  268:     }
  269: 
  270:     # Download class list information if not using cached data
  271:     my %cache;
  272:     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) {
  273:         return "Unable to tie hash to db file.";
  274:     }
  275: 
  276:     if(!$isCached) {
  277:         my $processTopResourceMapReturn=
  278:             &Apache::loncoursedata::ProcessTopResourceMap(\%cache, $c);
  279:         if($processTopResourceMapReturn ne 'OK') {
  280:             untie(%cache);
  281:             return $processTopResourceMapReturn;
  282:         }
  283:     }
  284: 
  285:     if($c->aborted()) {
  286:         untie(%cache);
  287:         return 'aborted'; 
  288:     }
  289: 
  290:     my $classlist=&Apache::loncoursedata::DownloadClasslist($courseID,
  291:                                                 $cache{'ClasslistTimestamp'},
  292:                                                 $c);
  293:     foreach (keys(%$classlist)) {
  294:         if(/^(con_lost|error|no_such_host)/i) {
  295:             untie(%cache);
  296:             return "Error getting student data.";
  297:         }
  298:     }
  299: 
  300:     if($c->aborted()) {
  301:         untie(%cache);
  302:         return 'aborted'; 
  303:     }
  304: 
  305:     # Active is a temporary solution, remember to change
  306:     Apache::loncoursedata::ProcessClasslist(\%cache,$classlist,$courseID,$c);
  307:     if($c->aborted()) {
  308:         untie(%cache);
  309:         return 'aborted'; 
  310:     }
  311: 
  312:     &ProcessFormData(\%cache);
  313:     my $students = &SortStudents(\%cache);
  314:     &SpaceColumns($students, $studentInformation, $headings, \%cache);
  315:     $cache{'updateTime:columnWidth'}=24;
  316: 
  317:     if($cache{'download'} ne 'false') {
  318:         my $who = $cache{'download'};
  319:         my $courseData = 
  320:             &Apache::loncoursedata::DownloadCourseInformation(
  321:                                              $who, $courseID, 
  322:                                              $cache{$who.':lastDownloadTime'});
  323:         &Apache::loncoursedata::ProcessStudentData(\%cache, $courseData, $who);
  324:         $cache{'download'} = 'false';
  325:     } elsif($cache{'DownloadAll'} ne 'false') {
  326:         my @allStudents;
  327:         if($cache{'DownloadAll'} eq 'sorted') {
  328:             @allStudents = @$students;
  329:         } else {
  330:             @allStudents = split(':::', $cache{'NamesOfStudents'});
  331:         }
  332:         foreach (@allStudents) {
  333:             my $courseData = 
  334:                 &Apache::loncoursedata::DownloadCourseInformation(
  335:                                              $_, $courseID, 
  336:                                              $cache{$_.':lastDownloadTime'});
  337:             &Apache::loncoursedata::ProcessStudentData(\%cache, $courseData, 
  338:                                                        $_);
  339:             if($c->aborted()) {
  340:                 untie(%cache);
  341:                 return 'aborted'; 
  342:             }
  343:         }
  344:         $cache{'DownloadAll'} = 'false';
  345:     }
  346: 
  347:     if($c->aborted()) {
  348:         untie(%cache);
  349:         return 'aborted'; 
  350:     }
  351: 
  352:     untie(%cache);
  353: 
  354:     return ('OK', $students);
  355: }
  356: 
  357: 
  358: # Create progress
  359: sub Create_PrgWin {
  360:     my ($r)=@_;
  361:     $r->print(<<ENDPOP);
  362:     <script>
  363:     popwin=open('','popwin','width=400,height=100');
  364:     popwin.document.writeln('<html><body bgcolor="#88DDFF">'+
  365:       '<title>LON-CAPA Statistics</title>'+
  366:       '<h4>Computation Progress</h4>'+
  367:       '<form name=popremain>'+
  368:       '<input type=text size=35 name=remaining value=Starting></form>'+
  369:       '</body></html>');
  370:     popwin.document.close();
  371:     </script>
  372: ENDPOP
  373: 
  374:     $r->rflush();
  375: }
  376: 
  377: # update progress
  378: sub Update_PrgWin {
  379:     my ($totalStudents,$index,$name,$r)=@_;
  380:     $r->print('<script>popwin.document.popremain.remaining.value="'.
  381:               'Computing '.$index.'/'.$totalStudents.': '.
  382:               $name.'";</script>');
  383:     $r->rflush();
  384: }
  385: 
  386: # close Progress Line
  387: sub Close_PrgWin {
  388:     my ($r)=@_;
  389:     $r->print('<script>popwin.close()</script>');
  390:     $r->rflush(); 
  391: }
  392: 
  393: # For loading the colored table for display or un-colored for print
  394: sub setbgcolor {
  395:     my $PrintTable=shift;
  396:     my %color;
  397:     if ($PrintTable){
  398: 	$color{"gb"}="#FFFFFF";
  399: 	$color{"red"}="#FFFFFF";
  400: 	$color{"yellow"}="#FFFFFF";
  401: 	$color{"green"}="#FFFFFF";
  402: 	$color{"purple"}="#FFFFFF";
  403:     } else {
  404: 	$color{"gb"}="#DDFFFF";
  405: 	$color{"red"}="#FFDDDD";
  406: 	$color{"yellow"}="#EEFFCC";
  407: 	$color{"green"}="#DDFFDD";
  408: 	$color{"purple"}="#FFDDFF";
  409:     }
  410: 
  411:     return \%color;
  412: }
  413: 
  414: sub BuildClasslist {
  415:     my ($cacheDB,$students,$studentInformation,$headings)=@_;
  416: 
  417:     my %cache;
  418:     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
  419:         return '<html><body>Unable to tie database.</body></html>';
  420:     }
  421: 
  422:     my $Str='';
  423:     $Str .= '<table border="0"><tr><td bgcolor="#777777">'."\n";
  424:     $Str .= '<table border="0" cellpadding="3"><tr bgcolor="#e6ffff">'."\n";
  425: 
  426:     my $displayString = '<td align="left"><a href="/adm/statistics?';
  427:     $displayString .= 'sort=LINKDATA">DISPLAYDATA&nbsp</a></td>'."\n";
  428:     $Str .= &Apache::lonhtmlcommon::CreateHeadings(\%cache, $studentInformation,
  429:                                                    $headings, $displayString);
  430:     $Str .= '</tr>'."\n";
  431:     my $alternate=0;
  432:     foreach (@$students) {
  433:         my ($username, $domain) = split(':', $_);
  434:         if($alternate) {
  435:             $Str .= '<tr bgcolor="#ffffe6">';
  436:         } else {
  437:             $Str .= '<tr bgcolor="#ffffc6">';
  438:         }
  439:         $alternate = ($alternate + 1) % 2;
  440:         foreach my $data (@$studentInformation) {
  441:             $Str .= '<td>';
  442:             if($data eq 'fullname') {
  443:                 $Str .= '<a href="/adm/statistics?reportSelected=';
  444:                 $Str .= &Apache::lonnet::escape('Student Assessment');
  445:                 $Str .= '&StudentAssessmentStudent=';
  446:                 $Str .= &Apache::lonnet::escape($cache{$_.':'.$data}).'">';
  447:                 $Str .= $cache{$_.':'.$data}.'&nbsp';
  448:                 $Str .= '</a>';
  449:             } elsif($data eq 'updateTime') {
  450:                 $Str .= '<a href="/adm/statistics?reportSelected=';
  451:                 $Str .= &Apache::lonnet::escape('Class list');
  452:                 $Str .= '&download='.$_.'">';
  453:                 $Str .= $cache{$_.':'.$data}.'&nbsp';
  454:                 $Str .= '&nbsp</a>';
  455:             } else {
  456:                 $Str .= $cache{$_.':'.$data}.'&nbsp';
  457:             }
  458: 
  459:             $Str .= '</td>'."\n";
  460:         }
  461:     }
  462: 
  463:     $Str .= '</tr>'."\n";
  464:     $Str .= '</table></td></tr></table>'."\n";
  465: 
  466:     untie(%cache);
  467: 
  468:     return $Str;
  469: }
  470: 
  471: sub CreateMainMenu {
  472:     my ($status, $reports)=@_;
  473: 
  474:     my $Str = '';
  475: 
  476:     $Str .= '<table border="0"><tbody><tr>'."\n";
  477:     $Str .= '<td></td><td></td>'."\n";
  478:     $Str .= '<td align="center"><b>Analysis Reports:</b></td>'."\n";
  479:     $Str .= '<td align="center"><b>Student Status:</b></td></tr>'."\n";
  480:     $Str .= '<tr>'."\n";
  481:     $Str .= '<td align="center"><input type="submit" name="Refresh" ';
  482:     $Str .= 'value="Refresh" /></td>'."\n";
  483:     $Str .= '<td align="center"><input type="submit" name="DownloadAll" ';
  484:     $Str .= 'value="Update All Student Data" /></td>'."\n";
  485:     $Str .= '<td align="center">';
  486:     $Str .= '<select name="reportSelected" onchange="document.';
  487:     $Str .= 'Statistics.submit()">'."\n";
  488: 
  489:     foreach (sort(keys(%$reports))) {
  490:         next if($_ eq 'reportSelected');
  491:         $Str .= '<option name="'.$_.'"';
  492:         if($reports->{'reportSelected'} eq $reports->{$_}) {
  493:             $Str .= ' selected=""';
  494:         }
  495:         $Str .= '>'.$reports->{$_}.'</option>'."\n";
  496:     }
  497:     $Str .= '</select></td>'."\n";
  498: 
  499:     $Str .= '<td align="center">';
  500:     $Str .= &Apache::lonhtmlcommon::StatusOptions($status, 'Statistics');
  501:     $Str .= '</td>'."\n";
  502: 
  503:     $Str .= '</tr></tbody></table>'."\n";
  504:     $Str .= '<hr>'."\n";
  505: 
  506:     return $Str;
  507: }
  508: 
  509: sub BuildStatistics {
  510:     my ($r)=@_;
  511: 
  512:     my $c = $r->connection;
  513:     my @studentInformation=('fullname','section','id','domain','username',
  514:                             'updateTime');
  515:     my @headings=('Full Name', 'Section', 'PID', 'Domain', 'User Name',
  516:                   'Last Updated');
  517:     my $spacing = '   ';
  518:     my %reports = ('classlist'          => 'Class list',
  519:                    'problem_statistics' => 'Problem Statistics',
  520:                    'student_assessment' => 'Student Assessment',
  521:                    'reportSelected'     => 'Class list');
  522: 
  523:     my %cache;
  524:     my $courseID=$ENV{'request.course.id'};
  525:     my $cacheDB = "/home/httpd/perl/tmp/$ENV{'user.name'}".
  526:                   "_$ENV{'user.domain'}_$courseID\_statistics.db";
  527: 
  528:     my %color=&setbgcolor(0);
  529:     my ($returnValue, $students) = &PrepareData($c, $cacheDB, 
  530:                                                 \@studentInformation, 
  531:                                                 \@headings);
  532:     if($returnValue ne 'OK') {
  533:         $r->print('<html><body>'.$returnValue."\n".'</body></html>');
  534:         return OK;
  535:     }
  536: 
  537:     my $GoToPage;
  538:     if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
  539:         $GoToPage = $cache{'reportSelected'};
  540:         $reports{'reportSelected'} = $cache{'reportSelected'};
  541: #        if(defined($cache{'reportKey'}) && $cache{'reportKey'} ne 'false') {
  542: #            $reports{$cache{'reportKey'}} = $cache{'reportSelected'};
  543: #        }
  544: 
  545:         if(defined($cache{'OptionResponses'})) {
  546:             $reports{'problem_analysis'} = 'Problem Analysis';
  547:         }
  548: 
  549:         $r->print(&Apache::lonhtmlcommon::Title('LON-CAPA Statistics'));
  550:         $r->print('<form name="Statistics" ');
  551:         $r->print('method="post" action="/adm/statistics">');
  552:         $r->print(&CreateMainMenu($cache{'Status'}, \%reports));
  553:         untie(%cache);
  554:     } else {
  555:         $r->print('<html><body>Unable to tie database.</body></html>');
  556:         return OK;
  557:     }
  558: 
  559:     if($GoToPage eq 'Activity Log') {
  560:         &Apache::lonproblemstatistics::Activity();
  561:     } elsif($GoToPage eq 'Problem Statistics') {
  562:         $r->print(
  563:         &Apache::lonproblemstatistics::BuildProblemStatisticsPage($cacheDB, 
  564:                                                                   $students, 
  565:                                                                   $courseID, 
  566:                                                                   $c,$r,
  567: 								  \%color));
  568:     } elsif($GoToPage eq 'Problem Analysis') {
  569:         $r->print(
  570:               &Apache::lonproblemanalysis::BuildProblemAnalysisPage($cacheDB));
  571:     } elsif($GoToPage eq 'Student Assessment') {
  572:         $r->print(
  573:             &Apache::lonstudentassessment::BuildStudentAssessmentPage($cacheDB,
  574:                                                             $students,
  575:                                                             $courseID,
  576:                                                             'Statistics',
  577:                                                             \@headings,
  578:                                                             $spacing,
  579:                                                             \@studentInformation,
  580:                                                             $r, $c));
  581:     } elsif($GoToPage eq 'Analyze') {
  582:         $r->print(&Apache::lonproblemanalysis::BuildAnalyzePage($cacheDB, 
  583:                                                                 $students, 
  584:                                                                 $courseID));
  585:     } elsif($GoToPage eq 'DoDiffGraph') {
  586:         &Apache::lonproblemstatistics::BuildDiffGraph($r);
  587:     } elsif($GoToPage eq 'PercentWrongGraph') {
  588:         &Apache::lonproblemstatistics::BuildWrongGraph($r);
  589:     } elsif($GoToPage eq 'Class list') {
  590:         $r->print(&BuildClasslist($cacheDB, $students, \@studentInformation,
  591:                                   \@headings));
  592:     }
  593: 
  594:     $r->print('</form>'."\n");
  595:     $r->print("\n".'</body>'."\n".'</html>');
  596:     $r->rflush();
  597: 
  598:     return OK;
  599: }
  600: 
  601: # ================================================================ Main Handler
  602: 
  603: sub handler {
  604:     my $r=shift;
  605: 
  606:     unless(&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {
  607:         $ENV{'user.error.msg'}=
  608:         $r->uri.":vgr:0:0:Cannot view grades for complete course";
  609:         return HTTP_NOT_ACCEPTABLE; 
  610:     }
  611: 
  612:     # Set document type for header only
  613:     if($r->header_only) {
  614:         if ($ENV{'browser.mathml'}) {
  615:             $r->content_type('text/xml');
  616:         } else {
  617:             $r->content_type('text/html');
  618:         }
  619:         &Apache::loncommon::no_cache($r);
  620:         $r->send_http_header;
  621:         return OK;
  622:     }
  623: 
  624:     unless($ENV{'request.course.fn'}) {
  625: 	my $requrl=$r->uri;
  626:         $ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized";
  627:         return HTTP_NOT_ACCEPTABLE; 
  628:     }
  629: 
  630:     $r->content_type('text/html');
  631:     $r->send_http_header;
  632: 
  633:     &BuildStatistics($r);
  634: 
  635:     return OK;
  636: }
  637: 1;
  638: __END__
  639: 

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