--- loncom/interface/lonstatistics.pm 2002/07/19 18:17:34 1.28 +++ loncom/interface/lonstatistics.pm 2002/07/22 20:35:05 1.29 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: lonstatistics.pm,v 1.28 2002/07/19 18:17:34 minaeibi Exp $ +# $Id: lonstatistics.pm,v 1.29 2002/07/22 20:35:05 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,6 +42,9 @@ use Apache::Constants qw(:common :http); use Apache::lonnet(); use Apache::lonhomework; use Apache::loncommon; +use Apache::loncoursedata; +use Apache::lonhtmlcommon; +use Apache::lonchart; use HTML::TokeParser; use GDBM_File; @@ -1114,6 +1117,7 @@ sub TableRow { } $GraphDat{$RealIdx}=$DoD.':'.$Wrng; } + sub StatusOptions { my ($cache)=@_; @@ -1236,8 +1240,8 @@ sub ProblemStatisticsLegend { $Ptr .= 'Sum of Partial Credit Awarded / Total Number of Tries
'; $Ptr .= '2nd Criterion for Sorting the Students: '; $Ptr .= 'Total number of Correct Answers / Total Number of Tries'; - $Ptr .= ''; - $Ptr .= 'Disc.'; + $Ptr .= ''; + $Ptr .= 'Disc.'; $Ptr .= 'Number of Students had at least one discussion.'; $Ptr .= ''; @@ -1348,61 +1352,6 @@ sub OptionResponseTable { #---- Student Assessment Web Page -------------------------------------------- -sub MapOptions { - my ($cache, $page)=@_; - my $Ptr = ''; - $Ptr .= 'Select Map'."\n"; - $Ptr .= '{'OptionResponses'})) { - $Ptr .= '{'reportKey'} = 'false'; - &CheckFormElement(\%cache, 'Students', 'StudentAssessmentStudent', - 'No Student Selected'); - } elsif(defined($ENV{'form.DoDiffGraph'})) { - $cache{'GoToPage'} = 'DoDiffGraph'; - } elsif(defined($ENV{'form.PercentWrongGraph'})) { - $cache{'GoToPage'} = 'PercentWrongGraph'; - } elsif(defined($ENV{'form.ActivityLog'})) { - $cache{'GoToPage'} = 'ActivityLog'; - } else { - $cache{'GoToPage'} = 'Menu'; + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['sort','download']); + &CheckFormElement($cache, 'Status', 'Status', 'Active'); + &CheckFormElement($cache, 'postdata', 'reportSelected', 'Class list'); + &CheckFormElement($cache, 'reportSelected', 'reportSelected', + 'Class list'); + &CheckFormElement($cache, 'DownloadAll', 'DownloadAll', 'false'); + &CheckFormElement($cache, 'sort', 'sort', 'fullname'); + &CheckFormElement($cache, 'download', 'download', 'false'); + + if(defined($ENV{'form.CreateStudentAssessment'}) || + defined($ENV{'form.NextStudent'}) || + defined($ENV{'form.PreviousStudent'})) { + $cache->{'reportSelected'} = 'Student Assessment'; + } + if(defined($ENV{'form.NextStudent'})) { + $cache->{'StudentAssessmentMove'} = 'next'; + } elsif(defined($ENV{'form.PreviousStudent'})) { + $cache->{'StudentAssessmentMove'} = 'previous'; + } else { + $cache->{'StudentAssessmentMove'} = 'selected'; + } + &CheckFormElement($cache, 'StudentAssessmentMap', 'StudentAssessmentMap', + 'All Maps'); + &CheckFormElement($cache, 'StudentAssessmentStudent', + 'StudentAssessmentStudent', 'No Student Selected'); + + foreach (keys(%ENV)) { + if(/form\.Analyze:::/) { +# $cache->{'reportSelected'} = 'Analyze'; +# $cache->{'reportKey'} = 'Problem Analysis'; + my ($uri, $title, $part, $problem); + (undef, $uri, $title, $part, $problem)=split(':::', $_); + $cache->{'AnalyzeURI'} = $uri; + $cache->{'AnalyzeTitle'} = $title; + $cache->{'AnalyzePart'} = $part; + $cache->{'AnalyzeProblem'} = $problem; + + &CheckFormElement($cache, 'Interval', 'Interval', '1'); } + } - &CheckFormElement(\%cache, 'Status', 'Status', 'Active'); - - foreach (keys(%ENV)) { - if(/form\.Analyze:::/) { - $cache{'GoToPage'} = 'Analyze'; - my ($uri, $title, $part, $problem); - (undef, $uri, $title, $part, $problem)=split(':::', $_); - $cache{'AnalyzeURI'} = $uri; - $cache{'AnalyzeTitle'} = $title; - $cache{'AnalyzePart'} = $part; - $cache{'AnalyzeProblem'} = $problem; + return; - &CheckFormElement(\%cache, 'Interval', 'Interval', '1'); - } - } + # Select page to display + if(defined($ENV{'form.ProblemStatistics'}) || + defined($ENV{'form.ProblemStatisticsRecalculate'}) || + defined($ENV{'form.DisplayCSVFormat'})) { + $cache->{'GoToPage'} = 'ProblemStatistics'; + &CheckFormElement($cache, 'DisplayCSVFormat', + 'DisplayFormat', 'Display Table Format'); + &CheckFormElement($cache, 'Ascend','ProblemStatisticsAscend', + 'Ascending'); + &CheckFormElement($cache, 'Maps', 'ProblemStatisticsMap', + 'All Maps'); + } elsif(defined($ENV{'form.ProblemAnalysis'})) { + $cache->{'GoToPage'} = 'ProblemAnalysis'; + &CheckFormElement($cache, 'Interval', 'Interval', '1'); + } elsif(defined($ENV{'form.DoDiffGraph'})) { + $cache->{'GoToPage'} = 'DoDiffGraph'; + } elsif(defined($ENV{'form.PercentWrongGraph'})) { + $cache->{'GoToPage'} = 'PercentWrongGraph'; + } elsif(defined($ENV{'form.ActivityLog'})) { + $cache->{'GoToPage'} = 'ActivityLog'; + } else { + $cache->{'GoToPage'} = 'Menu'; } + &CheckFormElement($cache, 'Status', 'Status', 'Active'); + return; } @@ -1663,51 +1583,24 @@ Output: \@order =cut sub SortStudents { - my ($students,$cache)=@_; + my ($cache)=@_; + my @students = split(':::',$cache->{'NamesOfStudents'}); my @sorted1Students=(); - foreach (@$students) { - push(@sorted1Students, $_); - } -# my ($end,$start)=split(/\:/,$cache->{$_.':date'}); -# my $active=1; -# my $now=time; -# my $Status=$cache->{'form.Status'}; -# $Status = ($Status) ? $Status : 'Active'; -# if((($end) && $now > $end) && (($Status eq 'Active'))) { -# $active=0; -# } -# if(($Status eq 'Expired') && ($end == 0 || $now < $end)) { -# $active=0; -# } -# if($active) { -# push(@sorted1Students, $_); -# } -# } - - my $Pos = $cache->{'form.ChartSort'}; - my %sortData; - if($Pos eq 'Last Name') { - for(my $index=0; $index{$sorted1Students[$index].':fullname'}}= - $sorted1Students[$index]; - } - } elsif($Pos eq 'Section') { - for(my $index=0; $index{$sorted1Students[$index].':section'}. - $sorted1Students[$index]}=$sorted1Students[$index]; - } - } else { - # Sort by user name - for(my $index=0; $index{'Status'} eq 'Any' || + $cache->{$_.':Status'} eq $cache->{'Status'}) { + push(@sorted1Students, $_); + } } - my @order = (); - foreach my $key (sort(keys(%sortData))) { - push (@order,$sortData{$key}); + my $sortBy = ''; + if(defined($cache->{'sort'})) { + $sortBy = ':'.$cache->{'sort'}; } + my @order = sort { $cache->{$a.$sortBy} cmp $cache->{$b.$sortBy} || + $cache->{$a.':fullname'} cmp $cache->{$b.':fullname'} } + @sorted1Students; return \@order; } @@ -1716,79 +1609,106 @@ sub PrepareData { my ($c, $cacheDB)=@_; # Test for access to the cache data - my $isCached=0; my $courseID=$ENV{'request.course.id'}; my $isRecalculate=0; - if(defined($ENV{'form.ProblemStatisticsRecalculate'}) || - defined($ENV{'form.ChartRecalculate'})) { + if(defined($ENV{'form.Recalculate'})) { $isRecalculate=1; } - $isRecalculate=1; - - $isCached=&Apache::loncoursedata::TestCacheData($cacheDB, $isRecalculate); + my $isCached = &Apache::loncoursedata::TestCacheData($cacheDB, + $isRecalculate); if($isCached < 0) { return "Unable to tie hash to db file."; } - &ProcessFormData($cacheDB, $isCached); # Download class list information if not using cached data my %cache; - my @students=(); - if(!$isCached) { - unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) { - return "Unable to tie hash to db file."; - } + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) { + return "Unable to tie hash to db file."; + } + if(!$isCached) { my $processTopResourceMapReturn= &Apache::loncoursedata::ProcessTopResourceMap(\%cache, $c); if($processTopResourceMapReturn ne 'OK') { untie(%cache); return $processTopResourceMapReturn; } + } - if($c->aborted()) { - untie(%cache); - return 'aborted'; - } + if($c->aborted()) { + untie(%cache); + return 'aborted'; + } - my $classlist=&Apache::loncoursedata::DownloadStudentNamePIDSection( - $courseID, - $c); - my ($checkForError)=keys(%$classlist); - if($checkForError =~ /^(con_lost|error|no_such_host)/i || - defined($classlist->{'error'})) { + my $classlist=&Apache::loncoursedata::DownloadClasslist($courseID, + $cache{'ClasslistTimestamp'}, + $c); + foreach (keys(%$classlist)) { + if(/^(con_lost|error|no_such_host)/i) { untie(%cache); return "Error getting student data."; } + } - if($c->aborted()) { - untie(%cache); - return 'aborted'; - } + if($c->aborted()) { + untie(%cache); + return 'aborted'; + } - # Active is a temporary solution, remember to change - @students=&Apache::loncoursedata::ProcessClassList(\%cache, - $classlist, - $courseID, - 'Active', $c); + # Active is a temporary solution, remember to change + Apache::loncoursedata::ProcessClasslist(\%cache,$classlist,$courseID,$c); + if($c->aborted()) { + untie(%cache); + return 'aborted'; + } - if($c->aborted()) { - untie(%cache); - return 'aborted'; - } + &ProcessFormData(\%cache); + my $students = &SortStudents(\%cache); - untie(%cache); - } else { - if(!$c->aborted() && tie(%cache,'GDBM_File',$cacheDB, - &GDBM_READER,0640)) { - @students=split(/:::/,$cache{'NamesOfStudents'}); + if($cache{'download'} ne 'false') { + my $who = $cache{'download'}; + my $courseData = + &Apache::loncoursedata::DownloadStudentCourseInformation( + $who, $courseID, + $cache{$who.':lastDownloadTime'}); + &Apache::loncoursedata::ProcessStudentData(\%cache, $courseData, $who); + $cache{'download'} = 'false'; + } elsif($cache{'DownloadAll'} ne 'false') { + my @allStudents; + if($cache{'DownloadAll'} eq 'sorted') { + @allStudents = @$students; } else { - return 'aborted'; + @allStudents = split(':::', $cache{'NamesOfStudents'}); } + foreach (@allStudents) { + my $courseData = + &Apache::loncoursedata::DownloadStudentCourseInformation( + $_, $courseID, + $cache{$_.':lastDownloadTime'}); + &Apache::loncoursedata::ProcessStudentData(\%cache, $courseData, + $_); + if($c->aborted()) { + untie(%cache); + return 'aborted'; + } + } + $cache{'DownloadAll'} = 'false'; } - return ('OK', $isCached, \@students); + if($c->aborted()) { + untie(%cache); + return 'aborted'; + } + + if($c->aborted()) { + untie(%cache); + return 'aborted'; + } + + untie(%cache); + + return ('OK', $students); } # Create progress @@ -1856,7 +1776,7 @@ sub initial { #---- END HELPER FUNCTIONS --------------------------------------------------- sub BuildProblemStatisticsPage { - my ($cacheDB, $students)=@_; + my ($cacheDB, $students, $courseID, $c)=@_; my %cache; unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { @@ -1865,36 +1785,48 @@ sub BuildProblemStatisticsPage { } my $Ptr = ''; - $Ptr .= '
print($Ptr); - - $r->print(&MapOptions(\%cache, 'ProblemStatistics')); - $r->print(&StatusOptions()); $r->print(&AscendOrderOptions()); $r->print(&ProblemStatisticsButtons(\%cache)); $r->print(''); $r->print(&ProblemStatisticsLegend()); -# my $discriminantFactor; -# my @list=(); -# foreach (@$students) { -# ($discriminantFactor, $list) = &ExtractStudentData(\%cache, $_, -# \@list); -# } + untie(%cache); + foreach (@$students) { + my $courseData = + &Apache::loncoursedata::DownloadStudentCourseInformation($_, + $courseID); + last if ($c->aborted()); + if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) { + &Apache::loncoursedata::ProcessStudentData(\%cache, + $courseData, $_); + untie(%cache); + } + } + if($c->aborted()) { return; } -# my ($upper, $lower) = &Discriminant($discriminantFactor); -# my %Header = (0,"Homework Sets Order",1,"#Stdnts",2,"Tries",3,"Mod", -# 4,"Mean",5,"#YES",6,"#yes",7,"%Wrng",8,"DoDiff", -# 9,"S.D.",10,"Skew.",11,"D.F.1st",12,"D.F.2nd", 13, "Disc."); -# &BuildStatisticsTable(\%cache, $discriminantFactor, \@list, \%Header, -# $students); + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { + $r->print('Unable to tie database.'); + return; + } + my $discriminantFactor; + my @list=(); + foreach (@$students) { + $discriminantFactor = &ExtractStudentData(\%cache, $_, \@list); + } - $r->print('
'); + my ($upper, $lower) = &Discriminant($discriminantFactor); + my %Header = (0,"Homework Sets Order",1,"#Stdnts",2,"Tries",3,"Mod", + 4,"Mean",5,"#YES",6,"#yes",7,"%Wrng",8,"DoDiff", + 9,"S.D.",10,"Skew.",11,"D.F.1st",12,"D.F.2nd", 13, "Disc."); + &BuildStatisticsTable(\%cache, $discriminantFactor, \@list, \%Header, + $students); untie(%cache); @@ -1944,13 +1876,8 @@ sub BuildProblemAnalysisPage { return; } - $r->print('
print('action="/adm/statistics">'."\n"); - $r->print('print('name="Menu" value="Return to Menu" />'."\n"); $r->print(&IntervalOptions()); $r->print(&OptionResponseTable(\%cache)); - $r->print('
'."\n"); untie(%cache); @@ -1958,16 +1885,12 @@ sub BuildProblemAnalysisPage { } sub BuildStudentAssessmentPage { - my ($cacheDB, $students, $courseID)=@_; + my ($cacheDB, $students, $courseID, $c)=@_; my %cache; my $Ptr = ''; - $Ptr .= '
print($Ptr); unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { @@ -1976,31 +1899,43 @@ sub BuildStudentAssessmentPage { } my $selectedName = $cache{'StudentAssessmentStudent'}; - for(my $index=0; $index<(scalar @$students); $index++) { - my ($username) = split(':', $students->[$index]); - if($username eq $selectedName) { + for(my $index=0; + ($selectedName ne 'All Students') && ($index<(scalar @$students)); + $index++) { + my $fullname = $cache{$students->[$index].':fullname'}; + if($fullname eq $selectedName) { if($cache{'StudentAssessmentMove'} eq 'next') { if($index == ((scalar @$students) - 1)) { - ($selectedName) = split(':',$students->[0]); + $selectedName = $students->[0]; } else { - ($selectedName) = split(':',$students->[$index+1]); + $selectedName = $students->[$index+1]; } } elsif($cache{'StudentAssessmentMove'} eq 'previous') { if($index == 0) { - ($selectedName) = split(':', - $students->[(scalar @$students)-1]); + $selectedName = $students->[-1]; } else { - ($selectedName)=split(':',$students->[$index-1]); + $selectedName = $students->[$index-1]; } + } else { + $selectedName = $students->[$index]; } last; } } - $r->print(&MapOptions(\%cache, 'StudentAssessment')); - $r->print(&StudentOptions($students, $selectedName)); + $Ptr .= 'Select Map'."\n"; + $Ptr .= ''; + $Ptr .= &Apache::lonhtmlcommon::MapOptions(\%cache, 'StudentAssessment'); + $Ptr .= ''."\n"; + $Ptr .= 'Select Student'."\n"; + $Ptr .= ''."\n"; + $Ptr .= &Apache::lonhtmlcommon::StudentOptions(\%cache, $students, + $selectedName, + 'StudentAssessment'); + $Ptr .= ''."\n"; + untie(%cache); - $Ptr = ''; + $Ptr .= ''; $Ptr .= 'print($Ptr); - untie(%cache); - if($selectedName eq 'No Student Selected') { $r->print('

WARNING: '); $r->print('Please select a student

'); return; } - my $name = ''; + my $selected=0; foreach (@$students) { - my ($currentName) = split(':',$_); - if($currentName eq $selectedName) { - $name = $_; - last; + next if ($_ ne $selectedName && + $selectedName ne 'All Students'); + $selected = 1; + my $courseData = + &Apache::loncoursedata::DownloadStudentCourseInformation($_, + $courseID); + last if ($c->aborted()); + if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) { + &Apache::loncoursedata::ProcessStudentData(\%cache, + $courseData, $_); + if(!$c->aborted()) { $r->print(&StudentReport(\%cache, $_)); } + untie(%cache); } } - if($name eq '') { - $r->print('

ERROR: Unknown student selected.'); - $r->print('

'); + if($selected == 0) { + $r->print('

WARNING: '); + $r->print('Please select a student

'); return; } - my $courseData = - &Apache::loncoursedata::DownloadStudentCourseInformation($name, - $courseID); - if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) { - &Apache::loncoursedata::ProcessStudentData(\%cache, - $courseData, $name); - untie(%cache); - } - - unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { - $Ptr .= 'Could not tie database.'; - return $Ptr; - } - $r->print(&StudentReport(\%cache, $name)); - untie(%cache); - return; } -sub BuildMenu { - my ($cacheDB)=@_; +sub BuildClasslist { + my ($cacheDB,$students,$studentInformation,$headings,$spacePadding)=@_; my %cache; unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { - $r->print('Unable to tie database.'); - return; + return 'Unable to tie database.'; } - $r->print(''); - $r->print(&CreateMenuForm(\%cache)); - $r->print('
'."\n"); + my $Str=''; + $Str .= '
'."\n"; + $Str .= ''."\n"; + + my $displayString = ''."\n"; + $Str .= &Apache::lonhtmlcommon::CreateStudentInformationHeadings(\%cache, + $studentInformation, + $headings, + $displayString); + $Str .= ''."\n"; + $Str .= ''."\n"; + my $alternate=0; + foreach (@$students) { + my ($username, $domain) = split(':', $_); + if($alternate) { + $Str .= ''."\n"; } - # Set document type for header only - if($r->header_only) { - if ($ENV{'browser.mathml'}) { - $r->content_type('text/xml'); - } else { - $r->content_type('text/html'); - } - &Apache::loncommon::no_cache($r); - $r->send_http_header; - return OK; - } + $Str .= '
DISPLAYDATA '; + $Str .= ''; + $Str .= 'Last Updated  
'; + } else { + $Str .= '
'; + } + $alternate = ($alternate + 1) % 2; + foreach my $data (@$studentInformation) { + if($data eq 'fullname') { + $Str .= ''; + } - untie(%cache); + $Str .= $cache{$_.':'.$data}.' '; - return; -} + if($data eq 'fullname') { + $Str .= ''; + } -# ================================================================ Main Handler + $Str .= ''; + } -sub handler { - $r=shift; - &initial(); + $Str .= ''; + my $downloadTime = $cache{$_.':lastDownloadTime'}; + if($downloadTime ne 'Not downloaded') { + $downloadTime = localtime($downloadTime); + } + $Str .= $downloadTime; - unless(&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) { - $ENV{'user.error.msg'}= - $r->uri.":vgr:0:0:Cannot view grades for complete course"; - return HTTP_NOT_ACCEPTABLE; + $Str .= ' 
'."\n"; - unless($ENV{'request.course.fn'}) { - my $requrl=$r->uri; - $ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized"; - return HTTP_NOT_ACCEPTABLE; - } + untie(%cache); - $r->content_type('text/html'); - $r->send_http_header; + return $Str; +} + +sub BuildStatistics { + my ($r)=@_; + + my $c = $r->connection; + my @studentInformation=('fullname','section','id','domain','username'); + my @headings=('Full Name', 'Section', 'PID', 'Domain', 'User Name'); + my $spacePadding = ' '; + my %reports = ('classlist' => 'Class list', + 'problem_statistics' => 'Problem Statistics', + 'student_assessment' => 'Student Assessment', + 'reportSelected' => 'Class list'); my %cache; my $courseID=$ENV{'request.course.id'}; my $cacheDB = "/home/httpd/perl/tmp/$ENV{'user.name'}". "_$ENV{'user.domain'}_$courseID\_statistics.db"; - my $c = $r->connection; - my ($returnValue, $isCached, $students) = &PrepareData($c, $cacheDB); + &setbgcolor(0); + my ($returnValue, $students) = &PrepareData($c, $cacheDB); if($returnValue ne 'OK') { $r->print(''.$returnValue."\n".''); return OK; } - my $downloadTime=0; my $GoToPage; if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { - $students = &SortStudents($students, \%cache); - if(defined($cache{'time'})) { - $downloadTime=$cache{'time'}; - } else { - $downloadTime=localtime(); - } - if(!defined($cache{'GoToPage'})) { - $GoToPage = 'Menu'; - } else { - $GoToPage = $cache{'GoToPage'}; + $GoToPage = $cache{'reportSelected'}; + $reports{'reportSelected'} = $cache{'reportSelected'}; +# if(defined($cache{'reportKey'}) && $cache{'reportKey'} ne 'false') { +# $reports{$cache{'reportKey'}} = $cache{'reportSelected'}; +# } + + if(defined($cache{'OptionResponses'})) { + $reports{'problem_analysis'} = 'Problem Analysis'; } + + $r->print(&Apache::lonhtmlcommon::Title('LON-CAPA Statistics')); + $r->print('
print('method="post" action="/adm/statistics">'); + $r->print(&Apache::lonhtmlcommon::CreateStatisticsMainMenu( + $cache{'Status'}, + \%reports)); untie(%cache); } else { $r->print('Unable to tie database.'); return OK; } - &setbgcolor(0); - $r->print(&Title()); - - if($GoToPage eq 'ActivityLog') { + if($GoToPage eq 'Activity Log') { &Activity(); - } elsif($GoToPage eq 'ProblemStatistics') { - &BuildProblemStatisticsPage($cacheDB, $students); - } elsif($GoToPage eq 'ProblemAnalysis') { + } elsif($GoToPage eq 'Problem Statistics') { + &BuildProblemStatisticsPage($cacheDB, $students, $courseID, $c); + } elsif($GoToPage eq 'Problem Analysis') { &BuildProblemAnalysisPage($cacheDB); - } elsif($GoToPage eq 'StudentAssessment') { - &BuildStudentAssessmentPage($cacheDB, $students, $courseID); + } elsif($GoToPage eq 'Student Assessment') { + &BuildStudentAssessmentPage($cacheDB, $students, $courseID, $c); } elsif($GoToPage eq 'Analyze') { &BuildAnalyzePage($cacheDB, $students, $courseID); } elsif($GoToPage eq 'DoDiffGraph') { &BuildDiffGraph($courseID); } elsif($GoToPage eq 'PercentWrongGraph') { &BuildWrongGraph($courseID); - } else { - &BuildMenu($cacheDB); + } elsif($GoToPage eq 'Class list') { + $r->print(&BuildClasslist($cacheDB, $students, \@studentInformation, + \@headings, $spacePadding)); } + $r->print('
'."\n"); $r->print("\n".''."\n".''); $r->rflush(); return OK; } + +# ================================================================ Main Handler + +sub handler { + $r=shift; + &initial(); + + unless(&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) { + $ENV{'user.error.msg'}= + $r->uri.":vgr:0:0:Cannot view grades for complete course"; + return HTTP_NOT_ACCEPTABLE; + } + + # Set document type for header only + if($r->header_only) { + if ($ENV{'browser.mathml'}) { + $r->content_type('text/xml'); + } else { + $r->content_type('text/html'); + } + &Apache::loncommon::no_cache($r); + $r->send_http_header; + return OK; + } + + unless($ENV{'request.course.fn'}) { + my $requrl=$r->uri; + $ENV{'user.error.msg'}="$requrl:bre:0:0:Course not initialized"; + return HTTP_NOT_ACCEPTABLE; + } + + $r->content_type('text/html'); + $r->send_http_header; + + &BuildStatistics($r); + + return OK; +} 1; __END__