--- loncom/interface/lonstatistics.pm 2002/07/17 12:53:00 1.27 +++ 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.27 2002/07/17 12:53:00 stredwic Exp $ +# $Id: lonstatistics.pm,v 1.29 2002/07/22 20:35:05 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # @@ -31,7 +31,7 @@ # 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei # YEAR=2002 # 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 -# 5/12,5/14,5/15,5/19,5/26 Behrouz Minaei +# 5/12,5/14,5/15,5/19,5/26,7/16 Behrouz Minaei # ### @@ -43,6 +43,8 @@ use Apache::lonnet(); use Apache::lonhomework; use Apache::loncommon; use Apache::loncoursedata; +use Apache::lonhtmlcommon; +use Apache::lonchart; use HTML::TokeParser; use GDBM_File; @@ -50,17 +52,204 @@ use GDBM_File; my %hash; my %CachData; my %GraphDat; -my %mapsort; -my $Pos; my $r; my $GData; my %color; my %foil_to_concept; my @Concepts; my %ConceptData; -my %Answer = (); +my %Answer=(); +my %mapsort; + +my %Activity=(); +my %Grade=(); +my %DoDiff=(); +my %Discuss=(); +my $TotalDiscuss=0; +my $TotalDiscuss_=0; + + +sub LoadDiscussion { +# my $symb=shift; +# $r->print('
$cid ... '.$symb); +# my %contrib=&Apache::lonnet::dump('msu_2964385f9033c63msul1','msu','2964385f9033c63msul1'); + my $cid=$ENV{'request.course.id'}; + my %contrib=&Apache::lonnet::dump( + $ENV{'request.course.id'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + + foreach my $temp(keys %contrib) { + if ($temp=~/^version/) { + my $ver=$contrib{$temp}; + my ($dummy,$prb)=split(':',$temp); + for (my $idx=1; $idx<=$ver; $idx++ ) { + my $name=$contrib{"$idx:$prb:sendername"}; + $Discuss{"$name:$prb"}=$idx; + } + } + } +# $r->print('
cid='.$cid); +# my %contrib=&Apache::lonnet::restore($symb,$cid, +# $ENV{$cid.'.domain'}, +# $ENV{'course.'.$cid.'.num'}); + +# $Apache::lonxml::debug=1; +# &Apache::lonhomework::showhash(%Discuss); +# $Apache::lonxml::debug=0; +} + +sub LoadDoDiffFile { + my $file="/home/minaeibi/183d.txt"; + open(FILEID, "<$file"); + my $line=; + %DoDiff=(); + my @Act=split('&',$line); + +# $r->print('
'.$#Act); + for(my $n=0;$n<=$#Act;$n++){ + my ($res,$Degree)=split('@',$Act[$n]); + $DoDiff{$res}=$Degree; + } +} + + +sub LoadClassFile { + my $file="/home/minaeibi/class.txt"; + open(FILEID, "<$file"); + my $line; + %Grade=(); + while ($line=) { + my ($id,$ex1,$ex2,$ex3,$ex4,$hw,$final,$grade)=split(' ',$line); + $Grade{$id}=$grade; + } +} + + +#------- Classification +sub Classify { + my ($DiscFac, $students)=@_; + &LoadClassFile(); + my $Count=0; + my @List=(); + my @LS=(); + my @LF=(); + my @LM=(); + my $cf=0; + my $cs=0; + my $cm=0; + foreach (keys(%$DiscFac)){ + my @l=split(/\:/,$_); + if (!($students->{$l[1]})) {next;} + my $Grade=$Grade{$students->{$l[1]}}; + if( $Grade > 3 ) { + $cs++; + push(@LS,("$l[6],$l[5],$l[4],$l[7],$l[8],$l[9],Successful")); + } elsif ( $Grade > 2 ) { + $cm++; + push(@LM,("$l[6],$l[5],$l[4],$l[7],$l[8],$l[9],Average")); + } else { + $cf++; + push(@LF,("$l[6],$l[5],$l[4],$l[7],$l[8],$l[9],Failed")); + } + } + for(my $n=0;$n<$cs;$n++){$r->print('
'.$LS[$n]);} + for(my $n=0;$n<$cm;$n++){$r->print('
'.$LM[$n]);} + for(my $n=0;$n<$cf;$n++){$r->print('
'.$LF[$n]);} +} + + +sub ProcAct { + # return; + my ($Act,$Submit)=@_; + my @Act=split(/\@/,$Act); + @Act = sort(@Act); + + ##$r->print('
'.$#Act); + ##for(my $n=0;$n<=$#Act;$n++){ +## $r->print('
n='.$n.')'.$Act[$n]); +## } + +# my $Beg=$Act[0]; + my $Dif=$Submit-$Act[0]; + $Dif = ($Dif>0) ? ($Dif/3600) : 0; + +# $r->print('
Access Number = '.$#Act.'
Submit Time='.$Submit.'
First Access='.$Act[0].'
Last Access='.$Act[$#Act].'
Submit - First = '.$Dif.''); + + +#time spent for solving the problem +# $r->print('
Def'.($Act[$#Act-1]-$Act[0])); + + return $Dif; +} + + + +sub LoadActivityLog { +# my $CacheDB = "/home/minaeibi/act183.log.cache"; + my $CacheDB = "/home/httpd/perl/tmp/act183.log.cache"; + + if (-e "$CacheDB") { + if (tie(%Activity,'GDBM_File',"$CacheDB",&GDBM_READER,0640)) { + return; + } + else { + $r->print("Unable to tie log Cache hash to db file"); + } + } + else { + if (tie(%Activity,'GDBM_File',$CacheDB,&GDBM_WRCREAT,0640)) { + foreach (keys %Activity) {delete $Activity{$_};} + &Build_log(); + } + else { + $r->print("Unable to tie log Build hash to db file"); + } + } +} + +sub Build_log { + my $file="/home/minaeibi/act183.log"; + open(FILEID, "<$file"); + my $line; + my $count=0; + while ($line=) { + my ($time,$machine,$what)=split(':',$line); + $what=&Apache::lonnet::unescape($what); + my @accesses=split('&',$what); + + foreach my $access (@accesses) { + + $count++; + + my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access); + if (!$resource) { next; } + my $res=&Apache::lonnet::unescape($resource); + if (($res =~ /\.problem/)) { + $Activity{$who.':'.$res}.=$date.'@'; + #$r->print('
'.$time.':'.$who.'---'.$res); + &Update_PrgInit($count); + + } + } + } + +# my $c=1; +# foreach (sort keys %Activity) { +# $r->print('
'.$c.')'.$_.' ... '.$Activity{$_}); +# $c++; +# } + +} sub Activity { +# $rid=~/(\d+)\.(\d+)/; +# my $MapId=$1; +# my $PrbId=$2; +# my $MapOrg = $hash{'map_id_'.$MapId}; +# my $Map = &Apache::lonnet::declutter($MapOrg); +# my $URI = $hash{'src_'.$rid}; +# my $Symb = $Map.'___'.$PrbId.'___'.&Apache::lonnet::declutter($URI); my $file="/home/minaeibi/activity.log"; my $userid='adamsde1'; $r->print("
Using $file"); @@ -75,11 +264,11 @@ sub Activity { my @accesses=split('&',$what); foreach my $access (@accesses) { my ($date,$resource,$who,$domain,$post,@posts)=split(':',$access); - if ($who ne $userid) { next; } + #if ($who ne $userid) { next; } if (!$resource) { next; } my $res=&Apache::lonnet::unescape($resource); - if (($res =~ /\.(problem|htm|html)/)) { - $Count++; + if (($res =~ /\.(sequence|problem|htm|html|page)/)) { + $Count++; $r->print("
$Count) ".localtime($date).": $who --> $res"); # if ($post) { # $Count++; @@ -88,7 +277,7 @@ sub Activity { # } $r->rflush(); } - ## push (@allaccess,unescape($access)); + #push (@allaccess,unescape($access)); #print $machine; } } @@ -105,29 +294,25 @@ sub Activity { # } } -#---- Analyze Web Page --------------------------------------------------- sub InitAnalysis { my ($uri,$part,$problem,$student,$courseID)=@_; - my ($username,$userdomain)=split(/\:/,$student); + my ($uname,$udom)=split(/\:/,$student); + # Render the student's view of the problem. $Answ is the problem # Stringafied - my $Answ=&Apache::lonnet::ssi($uri,('grade_target' => 'analyze', - 'grade_username' => $username, - 'grade_domain' => $userdomain, - 'grade_courseid' => $courseID, - 'grade_symb' => $problem)); -# my $Answ=&Apache::lonnet::ssi($uri,('grade_target' => 'analyze')); + my $Answ=&Apache::lonnet::ssi($uri,('grade_target' => 'analyze', + 'grade_username' => $uname, + 'grade_domain' => $udom, + 'grade_courseid' => $courseID, + 'grade_symb' => $problem)); +# my $Answ=&Apache::lonnet::ssi($URI,('grade_target' => 'analyze')); -# (undef,$Answ)=split(/_HASH_REF__/,$Answ,2); +# (my $garbage,$Answ)=split(/_HASH_REF__/,$Answ,2); %Answer=(); %Answer=&Apache::lonnet::str2hash($Answ); -# foreach (sort(keys(%Answer))) { -# $r->print($_.' '.$Answer{$_}.'
'); -# } - my $parts=''; foreach my $elm (@{$Answer{"parts"}}) { $parts.="$elm,"; @@ -150,32 +335,34 @@ sub InitAnalysis { return; } + sub Interval { my ($part,$symb)=@_; - my $interval=$ConceptData{"Interval"}; - my $due = &Apache::lonnet::EXT('resource.'.$part.'.duedate',$symb)+1; - my $open = &Apache::lonnet::EXT('resource.'.$part.'.opendate',$symb); - my $add=int(($due-$open)/$interval); - $ConceptData{'Interval.0'}=$open; - for (my $i=1;$i<$interval;$i++) { - $ConceptData{'Interval.'.$i}=$open+$i*$add; + my $Int=$ConceptData{"Interval"}; + my $due = &Apache::lonnet::EXT('resource.$part.duedate',$symb)+1; + my $opn = &Apache::lonnet::EXT('resource.$part.opendate',$symb); + my $add=int(($due-$opn)/$Int); + $ConceptData{"Int.0"}=$opn; + for (my $i=1;$i<$Int;$i++) { + $ConceptData{"Int.$i"}=$opn+$i*$add; } - $ConceptData{'Interval.'.$interval}=$due; - for (my $i=0;$i<$interval;$i++) { + $ConceptData{"Int.$Int"}=$due; + for (my $i=0;$i<$Int;$i++) { for (my $n=0; $n<=$#Concepts; $n++ ) { my $tmp=$Concepts[$n]; - $ConceptData{$tmp.'.'.$i.'.true'}=0; - $ConceptData{$tmp.'.'.$i.'.false'}=0; + $ConceptData{"$tmp.$i.true"}=0; + $ConceptData{"$tmp.$i.false"}=0; } } } + sub ShowOpGraph { my ($cache, $students, $courseID)=@_; my $uri = $cache->{'AnalyzeURI'}; my $part = $cache->{'AnalyzePart'}; my $problem = $cache->{'AnalyzeProblem'}; - my $title = $cache->{'AnalyzeProblem'}; + my $title = $cache->{'AnalyzeTitle'}; my $interval = $cache->{'Interval'}; $ConceptData{"Interval"} = $interval; @@ -188,21 +375,21 @@ sub ShowOpGraph { $title =~ s/\ /"_"/eg; $r->print('
'.$uri.''); $r->rflush(); - + #Java script Progress window &Create_PrgWin(); - &Update_PrgWin("Starting to analyze problem",0,0,''); - for(my $index=0; $index<(scalar @$students); $index++) { - &Update_PrgWin(scalar @$students, $index+1, $students->[$index]); - &OpStatus($problem, $students->[$index], $courseID); + &Update_PrgWin("Starting-to-analyze-problem"); + for (my $index=0;$index<(scalar @$students);$index++) { + &Update_PrgWin($index); + &OpStatus($problem,$students->[$index],$courseID); } &Close_PrgWin(); $r->print('
'); - for(my $k=0; $k<$interval; $k++ ) { + for (my $k=0; $k<$interval; $k++ ) { &DrawGraph($k,$title); } - for(my $k=0; $k<$interval; $k++ ) { + for (my $k=0; $k<$interval; $k++ ) { &DrawTable($k); } #$Apache::lonxml::debug=1; @@ -212,6 +399,7 @@ sub ShowOpGraph { $r->print("
Here you can see the Problem:
$Answ"); } + sub DrawTable { my $k=shift; my $Max=0; @@ -266,38 +454,35 @@ sub DrawTable { sub DrawGraph { - my ($currentInterval,$title)=@_; + my ($k,$Src)=@_; my $Max=0; my @data1; my @data2; # Adjust Data and find the Max - for(my $n=0; $n<=$#Concepts; $n++ ) { + for (my $n=0; $n<=$#Concepts; $n++ ) { my $tmp=$Concepts[$n]; - $data1[$n]=$ConceptData{$tmp.'.'.$currentInterval.'.true'}; - $data2[$n]=$ConceptData{$tmp.'.'.$currentInterval.'.false'}; + $data1[$n]=$ConceptData{"$tmp.$k.true"}; + $data2[$n]=$ConceptData{"$tmp.$k.false"}; my $Sum=$data1[$n]+$data2[$n]; - if($Max < $Sum) { $Max = $Sum; } + if ( $Max<$Sum ) {$Max=$Sum;} } - for(my $n=0; $n<=$#Concepts; $n++) { - if($data1[$n]+$data2[$n]<$Max) { + for (my $n=0; $n<=$#Concepts; $n++ ) { + if ($data1[$n]+$data2[$n]<$Max) { $data2[$n]+=$Max-($data1[$n]+$data2[$n]); } } - my $P_No = scalar @data1; + my $P_No = $#data1+1; - if($Max > 1) { + if ( $Max > 1 ) { $Max += (10 - $Max % 10); $Max = int($Max); - } else { - $Max = 1; - } + } else { $Max = 1; } - my $Titr=($ConceptData{'Interval'}>1) ? - $title.'_interval_'.($currentInterval+1) : $title; + my $Titr=($ConceptData{'Interval'}>1) ? $Src.'_interval_'.($k+1) : $Src; # $GData=$Titr.'&Concepts'.'&'.'Answers'.'&'.$Max.'&'.$P_No.'&'.$data1.'&'.$data2; - $GData = $Titr.'&Concepts&Answers&'.$Max.'&'.$P_No.'&'; - $GData .= (join(',',@data1)).'&'.(join(',',@data2)); + $GData="$Titr&Concepts&Answers&$Max&$P_No&". + (join(',',@data1)).'&'.(join(',',@data2)); $r->print(''); } @@ -312,7 +497,6 @@ sub Decide { $ConceptData{"$foil_to_concept{$foil}.$k.$type"}++; } - #restore the student submissions and finding the result sub OpStatus { my ($problem, $student, $courseID)=@_; @@ -356,6 +540,7 @@ sub OpStatus { } } + #---- END Analyze Web Page ---------------------------------------------- #---- Problem Statistics Web Page --------------------------------------- @@ -398,6 +583,7 @@ sub ProcessDiscriminant { } + #------- Creating Discimination factor sub Discriminant { my ($discriminantFactor)=@_; @@ -430,10 +616,12 @@ sub Discriminant { return (\%DisUp, \%DisLow); } + sub NumericSort { $a <=> $b; } + sub CreateProblemStatisticsTableHeading { my ($displayFormat,$sequenceSource,$sequenceTitle,$headings)=@_; if($displayFormat eq 'Display CSV Format') { @@ -465,15 +653,26 @@ sub CloseTable { $r->rflush(); } + + # ------ Dump the Student's DB file and handling the data for statistics table sub ExtractStudentData { - my ($cache,$name)=@_; + my ($cache,$name,$list)=@_; my %discriminantFactor; - my @list=(); my $totalTries = 0; my $totalAwarded = 0; my $tempProblemOrder=0; + my $spent=0; + my $spent_yes=0; + my $TotDiscuss=0; + my $TotalOpend = 0; + my $ProbSolved = 0; + my $ProbTot = 0; + my $TotFirst = 0; + my $TimeTot = 0; + my $Discussed=0; + foreach my $sequence (split(':', $cache->{'orderedSequences'})) { if($cache->{'ProblemStatisticsMap'} ne 'All Maps' && $cache->{'ProblemStatisticsMap'} ne $cache->{$sequence.':title'}) { @@ -525,6 +724,7 @@ sub ExtractStudentData { my $tries=0; my $time=0; my $awarded=0; + $Discussed=0; my $code='U'; $awarded = $cache->{$name. @@ -571,6 +771,11 @@ sub ExtractStudentData { $ptr .= "*(part $_)"; $Dis .= '&'; } + + my ($pr_no,$dod)=split('&',$ptr); + my $DoDiff=$DoDiff{$dod}; +# $r->print('
'.$name.'---'.$ptr.'==='.$DoDiff); + my $Fac = ($partData{$_.':Tries'}) ? ($partData{$_.':awarded'}/$partData{$_.':tries'}) : 0; my $DisF; @@ -579,24 +784,60 @@ sub ExtractStudentData { } else { $DisF = $Fac; } + + if ($Discuss{"$name:$problem"}) { + $TotDiscuss++; + $Discussed=1; + } + my $time = $cache->{"$name:$LatestVersion:$problem:timestamp"}; $Dis .= $tempProblemOrder.'='.$DisF.'+'.$Yes; $ptr .= '&'.$partData{$_.'.Tries'}. '&'.$partData{$_.'.Wrongs'}. '&'.$partData{$_.'.Code'}; - push (@list, $ptr); + push (@$list, $ptr."&$Discussed"); + +#### if ($DoDiff>0.85) { + + $TimeTot += $time; + + if ($Yes==1 && $partData{$_.'.Tries'}==1) { + $TotFirst++; + } + my $Acts= $Activity{$name.':'.$problem}; + if ($Acts) { + my $Pt=&ProcAct( $Acts, $time ); + #my ($spe,$beg) = split(/\+/,$Pt); + my $spe= $Pt; + if ($Yes==1) {$spent_yes += $spe;} + $spent += $spe; + #$Beg += $beg; +# $r->print('
'.$name.'---'.$problem.'---'.$spe); + } + $TotalOpend++; + $ProbTot++; + $tempProblemOrder++; } } + my $pstr; if($totalTries) { my $DisFac = ($totalAwarded/$totalTries); my $DisFactor = sprintf( "%.4f", $DisFac ); - $discriminantFactor{$DisFactor}=$Dis; + my $TS = sprintf( "%.2f", $spent ); + my $TS_yes = sprintf( "%.2f", $spent_yes ); + # $DiscFac{$DisFactor}=$Dis; + $pstr=$DisFactor.':'.$name.':'.$ProbTot.':'.$TotalOpend.':'. + $totalTries.':'.$ProbSolved.':'.$TotFirst.':'. + $TS_yes.':'.$TS.':'.$TotDiscuss; + $discriminantFactor{$pstr}=$Dis; } } - return (\%discriminantFactor, \@list); + return (\%discriminantFactor); } + +=pod sub MySort { if ( $Pos > 0 ) { if ($ENV{'form.order'} eq 'Descending') {$b <=> $a;} @@ -607,9 +848,22 @@ sub MySort { else { $a cmp $b; } } } +=cut sub BuildStatisticsTable { - my ($cache,$discriminantFactor,$list,$headings)=@_; + my ($cache,$discriminantFactor,$list,$headings,$students)=@_; + +#6666666 +# my $file="/home/httpd/perl/tmp/183d.txt"; +# open(OUT, ">$file"); +#6666666 + &Create_PrgWin(); +##777777 +## &LoadActivityLog(); +## $r->print(''); +## &LoadDoDiffFile(); + &LoadDiscussion(); my $p_count = 0; my $nIndex = 0; @@ -628,11 +882,16 @@ sub BuildStatisticsTable { $cache->{$sequence.':source'}, $cache->{$sequence.':title'}, $headings); + +##777777 +## &Classify($discriminantFactor, $students); + + my ($Hid,$pr)=split(/\:/,$mapsort{$_}); my @lpr=split(/\&/,$pr); for (my $i=1; $i<=$#lpr; $i++) { my %storestats=(); - my ($PrOrd,$Prob,$Tries,$Wrongs,$Code)=split(/\&/,$list->[$nIndex]); + my ($PrOrd,$Prob,$Tries,$Wrongs,$Code,$Disc)=split(/\&/,$list->[$nIndex]); my $Temp = $Prob; my $MxTries = 0; my $TotalTries = 0; @@ -640,6 +899,7 @@ sub BuildStatisticsTable { my $Incorrect = 0; my $Override = 0; my $StdNo = 0; + my $DiscNo=0; my @StdLst; while ( $PrOrd == $lpr[$i] ) { @@ -652,7 +912,7 @@ sub BuildStatisticsTable { elsif( $Code eq 'I' ) { $Incorrect++; } elsif( $Code eq 'O' ) { $Override++; } elsif( $Code eq 'U' ) { $StdNo--; } - ($PrOrd,$Prob,$Tries,$Wrongs,$Code)=split(/\&/,$list->[$nIndex]); + ($PrOrd,$Prob,$Tries,$Wrongs,$Code,$Disc)=split(/\&/,$list->[$nIndex]); } $p_count++; @@ -732,9 +992,14 @@ sub BuildStatisticsTable { $TotalTries.'&'.$MxTries.'&'.$Avg.'&'. $YES.'&'.$Override.'&'.$Wrng.'&'.$DoD.'&'. $SD.'&'.$Sk.'&'.$_D1.'&'.$_D2.'&'. - $Prob; + $DiscNo.'&'.$Prob; $CachData{($p_count-1)}=$join; +#6666666 +# $r->print('
'.$out.'&'.$DoD); +# print (OUT $out.'@'.$DoD.'&'); +#6666666 + $urlres=~/^(\w+)\/(\w+)/; if ($StdNo) { &Apache::lonnet::put('resevaldata',\%storestats,$1,$2); @@ -745,6 +1010,9 @@ sub BuildStatisticsTable { &CloseTable($cache); } &Close_PrgWin(); +#666666 +# close( OUT ); +#666666 } =pod @@ -797,12 +1065,15 @@ sub Cache_Statistics { &CloseTable($cache); } } -=cut +=cut + + + sub TableRow { - my ($cache,$Str,$Idx,$RealIdx)=@_; + my ($Str,$Idx,$RealIdx)=@_; my($PrOrd,$Temp,$StdNo,$TotalTries,$MxTries,$Avg,$YES,$Override, - $Wrng,$DoD,$SD,$Sk,$_D1,$_D2,$Prob)=split(/\&/,$Str); - if($cache->{'DisplayFormat'} eq 'Display CSV Format') { + $Wrng,$DoD,$SD,$Sk,$_D1,$_D2,$DiscNo,$Prob)=split(/\&/,$Str); + if ($ENV{'form.showcsv'}) { my ($ResId,$Dummy)=split(/\*/,$Prob); my $Ptr = "\n".'
'. "\n".'"'.($RealIdx+1).'",'. @@ -819,9 +1090,12 @@ sub TableRow { "\n".'"'.$SD.'",'. "\n".'"'.$Sk.'",'. "\n".'"'.$_D1.'",'. - "\n".'"'.$_D2.'"'; + "\n".'"'.$_D2.'"'. + "\n".'"'.$DiscNo.'"'; + $r->print("\n".$Ptr); - } else { + } + else{ my $Ptr = "\n".''. "\n".''.($RealIdx+1).''. # "\n".''.$PrOrd.$Temp.''. @@ -837,7 +1111,8 @@ sub TableRow { "\n".' '.$SD.''. "\n".' '.$Sk.''. "\n".' '.$_D1.''. - "\n".' '.$_D2.''; + "\n".' '.$_D2.''. + "\n".' '.$DiscNo.''; $r->print("\n".$Ptr.'' ); } $GraphDat{$RealIdx}=$DoD.':'.$Wrng; @@ -965,6 +1240,9 @@ 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 .= 'Number of Students had at least one discussion.'; $Ptr .= ''; return $Ptr; @@ -974,55 +1252,50 @@ sub ProblemStatisticsLegend { #---- Problem Statistics Graph Web Page -------------------------------------- +# ------------------------------------------- Prepare data for Graphical chart + sub GetGraphData { - my ($whichGraph, $courseID)=@_; - my $Col=0; - my $graphTitle=''; + my $ylab = shift; + my $Col; my $data=''; my $count = 0; my $Max = 0; - my $graphData='Graph data does not exist.'; + my $cid=$ENV{'request.course.id'}; my $GraphDB = "/home/httpd/perl/tmp/$ENV{'user.name'}". - "_$ENV{'user.domain'}_$courseID\_graph.db"; - if(-e $GraphDB) { - if(tie(%GraphDat,'GDBM_File',"$GraphDB",&GDBM_READER,0640)) { - if($whichGraph eq 'DiffGraph') { - $graphTitle = 'Degree-of-Difficulty'; + "_$ENV{'user.domain'}_$cid\_graph.db"; + foreach (keys %GraphDat) {delete $GraphDat{$_};} + if (-e "$GraphDB") { + if (tie(%GraphDat,'GDBM_File',"$GraphDB",&GDBM_READER,0640)) { + if ( $ylab eq 'DoDiff Graph' ) { + $ylab = 'Degree-of-Difficulty'; $Col = 0; - } else { - $graphTitle = 'Wrong-Percentage'; + } + else { + $ylab = 'Wrong-Percentage'; $Col = 1; } foreach (sort NumericSort keys %GraphDat) { my @Temp=split(/\:/,$GraphDat{$_}); my $inf = $Temp[$Col]; - if($Max < $inf) { - $Max = $inf; - } + if ( $Max < $inf ) {$Max = $inf;} $data .= $inf.','; $count++; } - if($Max > 1) { + if ( $Max > 1 ) { $Max += (10 - $Max % 10); $Max = int($Max); - } else { - $Max = 1; - } + } + else { $Max = 1; } untie(%GraphDat); - my $Course = $ENV{'course.'.$courseID.'.description'}; + my $Course = $ENV{'course.'.$cid.'.description'}; $Course =~ s/\ /"_"/eg; - $graphData = $Course.'&'.'Problems'.'&'.$graphTitle.'&'.$Max.'&'; - $graphData .= $count.'&'.$data; - } else { - $graphData = "Unable to tie hash to db file"; + $GData=$Course.'&'.'Problems'.'&'.$ylab.'&'.$Max.'&'.$count.'&'.$data; + } + else { + $r->print("Unable to tie hash to db file"); } } - - return $graphData; } - -#---- END Problem Statistics Graph Web Page ---------------------------------- - #---- Problem Analysis Web Page ---------------------------------------------- sub IntervalOptions { @@ -1079,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; } @@ -1394,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; } @@ -1447,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'; + } + + if($c->aborted()) { + untie(%cache); + return 'aborted'; } - return ('OK', $isCached, \@students); + if($c->aborted()) { + untie(%cache); + return 'aborted'; + } + + untie(%cache); + + return ('OK', $students); } # Create progress @@ -1581,14 +1770,13 @@ sub initial { undef %CachData; undef %GraphDat; undef %ConceptData; - undef $Pos; undef $GData; } #---- END HELPER FUNCTIONS --------------------------------------------------- sub BuildProblemStatisticsPage { - my ($cacheDB, $students)=@_; + my ($cacheDB, $students, $courseID, $c)=@_; my %cache; unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) { @@ -1597,34 +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($_); -# } + 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"); -# &BuildStatisticsTable(\%cache, $discriminantFactor, $list, \%Header); + 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); @@ -1674,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); @@ -1688,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)) { @@ -1706,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__