'."\n");
+ $r->print(''."\n");
+ $r->print(&CreateProblemStatisticsTableHeading($headings, $r));
+ } else {
+ if($sortProblems eq 'Sort Within Sequence') {
+ $r->print('"'.$cache->{$sequence.':title'}.'"');
}
-# 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++;
+ $r->print(' ');
}
+ $currentSequence = $sequence;
}
- }
- my $pstr;
- if($totalTries) {
- my $DisFac = ($totalAwarded/$totalTries);
- my $DisFactor = sprintf( "%.4f", $DisFac );
- my $TS = sprintf( "%.2f", $spent );
- my $TS_yes = sprintf( "%.2f", $spent_yes );
- $pstr=$DisFactor.':'.$name.':'.$ProbTot.':'.$TotalOpend.':'.
- $totalTries.':'.$ProbSolved.':'.$TotFirst.':'.
- $TS_yes.':'.$TS.':'.$TotDiscuss;
- (%$discriminant)->{$pstr}=$discrim;
- }
-}
-
-
-
-sub MySort {
- my $pos=shift;
- if ( $pos > 0 ) {
- if ($ENV{'form.order'} eq 'Descending') {$b <=> $a;}
- else { $a <=> $b; }
- }
- else {
-# if ($ENV{'form.order'} eq 'Descending') {$b cmp $a;}
-# else { $a cmp $b; }
- $a cmp $b;
- }
-}
-
-
-
-sub BuildStatisticsTable {
- my ($cache,$upper,$lower,$list,$headings,$students,$r,$color)=@_;
- my $NoElements = scalar @$list;
- my @list=sort(@$list);
-
-#6666666
-# my $file="/home/httpd/perl/tmp/183d.txt";
-# open(OUT, ">$file");
-#6666666
-## &Apache::lonstatistics::Create_PrgWin($r);
-##777777
-## my (%Activity) = &LoadActivityLog();
-## $r->print('');
-## my ($doDiffFile) = &LoadDoDiffFile();
-
-##777777
-## $Str .= &Classify($discriminantFactor, $students);
-
- my $p_count = 0;
- my $dummy;
- my $p_val;
- my $ResId;
- my %TempCache;
- my $cIdx=0;
- foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
- if($cache->{'ProblemStatisticsMaps'} ne 'All Maps' &&
- $cache->{'ProblemStatisticsMaps'} ne $cache->{$sequence.':title'}) {
- next;
+ my $ref = ''.$cache->{$problem.':title'}.'';
+ my $title = $cache->{$problem.':title'};
+ if($part != 0) {
+ $title .= ' Part '.$part;
}
- &CreateProblemStatisticsTableHeading($cache->{'DisplayFormat'},
- $cache->{$sequence.':source'},
- $cache->{$sequence.':title'},
- $headings,$r);
- my ($tar,$Tries,$Wrongs,$Code,$Disc)=split(/\&/,
- $list[$cIdx]);
- my ($SqOrd,$PrOrd,$Prob)=split(/\:/,$tar);
- $sequence+=100;
- while ($SqOrd==$sequence && $cIdx<$NoElements) {
- my %storestats=();
- my $pOrd=$PrOrd;
- my $Temp = $Prob;
- my $MxTries = 0;
- my $TotalTries = 0;
- my $YES = 0;
- my $Incorrect = 0;
- my $Override = 0;
- my $StdNo = 0;
- my $DiscNo=0;
- my @StdLst;
- while ($pOrd==$PrOrd && $cIdx<$NoElements)
- {
- $cIdx++;
- $StdNo++;
- $StdLst[ $StdNo ] = $Tries;
- $TotalTries += $Tries;
- if ( $MxTries < $Tries ) { $MxTries = $Tries; }
- if ( $Code eq 'C' ){ $YES++; }
- elsif( $Code eq 'I' ) { $Incorrect++; }
- elsif( $Code eq 'O' ) { $Override++; }
- elsif( $Code eq '-' ) { $StdNo--; }
- ($tar,$Tries,$Wrongs,$Code,$Disc)=split(/\&/,
- $list[$cIdx]);
- ($SqOrd,$PrOrd,$Prob)=split(/\:/,$tar);
- }
-
- $p_count++;
- my $Dummy;
- ($ResId,$Dummy)=split(/\*/,$Temp);
-
-######################
- $Temp = ''.$cache->{$ResId.':title'}.$Dummy.'';
-
- #$r->print(' rid='.$ResId);
- #$r->print(' src='.$cache->{$ResId.':source'});
- #$r->print(' tit='.$cache->{$ResId.':title'});
-
- my $res = &Apache::lonnet::declutter($cache->{$ResId.':source'});
- my $urlres=$res;
-
- $ResId=~/(\d+)\.(\d+)/;
- my $Map = &Apache::lonnet::declutter( $cache->{'map_id_'.$1} );
- $urlres=$Map;
-#######################
-
-# $res = ''.$res.'';
- #$Map = ''.$res.'';
-
-#------------------------ Compute the Average of Tries about one problem
- my $Average = ($StdNo) ? $TotalTries/$StdNo : 0;
-
- $storestats{$ENV{'request.course.id'}.'___'.$urlres.'___timestamp'}=time;
- $storestats{$ENV{'request.course.id'}.'___'.$urlres.'___stdno'}=$StdNo;
- $storestats{$ENV{'request.course.id'}.'___'.$urlres.'___avetries'}=$Average;
-
-#-------------------------------- Compute percentage of Wrong tries
- my $Wrong = ( $StdNo ) ? 100 * ( $Incorrect / $StdNo ) : 0;
-
-#-------------------------------- Compute Standard Deviation
- my $StdDev = 0;
- if ( $StdNo > 1 ) {
- for ( my $n = 0; $n < $StdNo; $n++ ) {
- my $Dif = $StdLst[ $n ]-$Average;
- $StdDev += $Dif*$Dif;
- }
- $StdDev /= ( $StdNo - 1 );
- $StdDev = sqrt( $StdDev );
- }
-
-#-------------------------------- Compute Degree of Difficulty
- my $DoDiff = 0;
- if( $TotalTries > 0 ) {
- $DoDiff = 1 - ( ( $YES + $Override ) / $TotalTries );
-# $DoDiff = ($TotalTries)/($YES + $Override+ 0.1);
- }
-
- $storestats{$ENV{'request.course.id'}.'___'.$urlres.'___difficulty'}=$DoDiff;
-
-#-------------------------------- Compute the Skewness
- my $Skewness = 0;
- my $Sum = 0;
- if ( $StdNo > 0 && $StdDev > 0 ) {
- for ( my $n = 0; $n < $StdNo; $n++ ) {
- my $Dif = $StdLst[ $n ]-$Average;
- $Skewness += $Dif*$Dif*$Dif;
- }
- $Skewness /= $StdNo;
- $Skewness /= $StdDev*$StdDev*$StdDev;
- }
-
-#--------------------- Compute the Discrimination Factors
- my ($Up1,$Up2)=split(/\:/,$upper->{$sequence.'@'.$pOrd});
- my ($Lw1,$Lw2)=split(/\:/,$lower->{$sequence.'@'.$pOrd});
-
- my $Dis1 = $Up1 - $Lw1;
- my $Dis2 = $Up2 - $Lw2;
- my $_D1 = sprintf("%.2f", $Dis1);
- my $_D2 = sprintf("%.2f", $Dis2);
-
-#----------------- Some restition in presenting the float numbers
- my $Avg = sprintf( "%.2f", $Average );
- my $Wrng = sprintf( "%.1f", $Wrong );
- my $SD = sprintf( "%.1f", $StdDev );
- my $DoD = sprintf( "%.2f", $DoDiff );
- my $Sk = sprintf( "%.1f", $Skewness );
- my $join = $sequence.'@'.$pOrd.'&'.$Temp.'&'.$StdNo.'&'.
- $TotalTries.'&'.$MxTries.'&'.$Avg.'&'.
- $YES.'&'.$Override.'&'.$Wrng.'&'.$DoD.'&'.
- $SD.'&'.$Sk.'&'.$_D1.'&'.$_D2.'&'.
- $DiscNo.'&'.$Prob;
-
-#####{$sequence.'@'.$pOrd}
- $TempCache{'CacheTable:'.($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);
- }
-#-------------------------------- Row of statistical table
- &TableRow($cache,$join,$cIdx,($p_count-1),$r,$color,
- \%TempCache);
- }
- $TempCache{'ProblemCount'}=$p_count;
- &CloseTable($cache,$r);
- }
-### &Close_PrgWin();
-#666666
-# close( OUT );
-#666666
- return \%TempCache;
-}
-
-
-sub CacheStatisticsTable {
- my ($state,$cache,$Header,$r,$color)=@_;
- my @list = ();
- my $Useful;
- my $UnUseful;
- my %TempCache;
- my %myHeader = reverse( %$Header );
- my $pos = $myHeader{$state};
- if ($pos > 0) {$pos++;}
- my $p_count = $cache->{'ProblemCount'};
-
- for ( my $k=0; $k<$p_count;$k++) {
- my $key=$cache->{'CacheTable:'.$k};
- my @Temp=split(/\&/,$key);
- if ( $pos == 0 ) {
- ($UnUseful,$Useful)=split(/\>/,$Temp[$pos]);
- }
- else {
- $Useful = $Temp[$pos];
- }
- $list[$k]=$Useful.'@'.$key;
- $r->print(' '.$list[$k]);
- }
-
-
- @list = sort MySort (@list);
-
- my $nIndex=0;
-
- return \%TempCache;
-}
-
-
-=pod
-
- if ( $Pos == 0 ) {
- foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
- if($cache->{'ProblemStatisticsMaps'} ne 'All Maps' &&
- $cache->{'ProblemStatisticsMaps'} ne $cache->{$sequence.':title'}) {
- next;
- }
- &CreateProblemStatisticsTableHeading($cache->{'DisplayFormat'},
- $cache->{$sequence.':source'},
- $cache->{$sequence.':title'},
- $headings,$r);
-
- my ($tar,$Tries,$Wrongs,$Code,$Disc)=split(/\&/,
- $list[$cIdx]);
- my ($SqOrd,$PrOrd,$Prob)=split(/\:/,$tar);
- $sequence+=100;
- while ($SqOrd==$sequence && $cIdx<$NoElements) {
- my %storestats=();
- my @lpr=split(/\&/,$pr);
- for (my $i=1; $i<=$#lpr; $i++) {
- my($Pre, $Post) = split(/\@/,$list[$nIndex]);
- #$r->print(' '.$Pre.'---'.$Post);
- &TableRow($cache,$Post,$i,$nIndex,$color,\%GraphDat);
- $nIndex++;
- }
- &CloseTable($cache);
- }
- }
- else {
- &CreateProblemStatisticsTableHeading($cache->{'DisplayFormat'},
- $cache->{$sequence.':source'},
- $cache->{$sequence.':title'},
- $headings,$r);
- for ( my $nIndex = 0; $nIndex < $p_count; $nIndex++ ) {
- my($Pre, $Post) = split(/\@/,$list[$nIndex]);
- &TableRow($cache,$Post,$nIndex,$nIndex,$color,\%GraphDat);
- }
- &CloseTable($cache);
+ my $source = $cache->{$problem.':source'};
+ my $tableData = join('&', $ref, $title, $source,
+ $cache->{$_.':studentCount'},
+ $cache->{$_.':totalTries'},
+ $cache->{$_.':maxTries'},
+ $cache->{$_.':mean'},
+ $cache->{$_.':correct'},
+ $cache->{$_.':correctByOverride'},
+ $cache->{$_.':percentWrong'},
+ $cache->{$_.':degreeOfDifficulty'},
+ $cache->{$_.':standardDeviation'},
+ $cache->{$_.':skewness'},
+ $cache->{$_.':discriminationFactor1'},
+ $cache->{$_.':discriminationFactor2'});
+
+ &TableRow($displayFormat,$tableData,$count,$r,$color);
+
+ $count++;
+ }
+ if($displayFormat ne 'Display CSV Format') {
+ $r->print(' '."\n");
+ $r->print(' |