File:  [LON-CAPA] / loncom / interface / lonstatistics.pm
Revision 1.44: download - view: text, annotated - select for diffs
Wed Aug 14 16:18:55 2002 UTC (21 years, 9 months ago) by stredwic
Branches: MAIN
CVS tags: HEAD
Added section selection to problem statistics and problem analysis.
Fixed some divide by zeros in lonproblemstatistics.
Broke up the table of option response problems and gave them the
heading of the sequence in which they lie.

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

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