'."\n");
+ $r->rflush();
+ #
+ # Compile the data
+ my @Statsarray;
+ foreach my $sequence (@Sequences) {
+ next if ($sequence->{'num_assess'}<1);
+ foreach my $resource (@{$sequence->{'contents'}}) {
+ next if ($resource->{'type'} ne 'assessment');
+ foreach my $part (@{$resource->{'parts'}}) {
+ $problem_num++;
+ my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
+ $SKEW) = &get_statistics($resource->{'symb'},$part);
+ #
+ $show_part = 1 if ($part ne '0');
+ $part = ' ' if ($part == 0);
+ #
+ my $wrongpercent = 0;
+ if (defined($num) && $num > 0) {
+ $wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10;
+ }
+ push (@Statsarray,
+ { 'sequence' => $sequence,
+ 'resource' => $resource,
+ 'Title' => $resource->{'title'},
+ 'Part' => $part,
+ '#Stdnts' => $num,
+ 'Tries' => $tries,
+ 'Mod' => $mod,
+ 'Mean' => $mean,
+ '#YES' => $Solved,
+ '#yes' => $solved,
+ '%Wrng' => $wrongpercent,
+ 'DoDiff' => $DegOfDiff,
+ 'S.D.' => $STD,
+ 'Skew' => $SKEW,
+ 'problem_num' => $problem_num,
+ });
+ }
+ }
+ }
+ #
+ # Table Headers
+ $r->print(''."\n");
+ my $Str = '';
+ foreach (@Header) {
+ next if ($_ eq 'Part' && !$show_part);
+ # Do not allow sorting on some fields
+ if ($_ eq $sortby || /^(Part|P\#)$/) {
+ $Str .= ''.$_.' | ';
+ } else {
+ $Str .= ''.
+ ''.
+ $_.' | ';
+ }
+ }
+ $r->print(''.$Str." \n");
+ #
+ # Sort the data
+ my @OutputOrder;
+ if ($sortby eq 'Container') {
+ @OutputOrder = @Statsarray;
} else {
- @list = sort (@list);
+ # $sortby is already defined, so we can charge ahead
+ if ($sortby =~ /^(title|part)$/i) {
+ # Alpha comparison
+ @OutputOrder = sort {
+ lc($a->{$sortby}) cmp lc($b->{$sortby}) ||
+ lc($a->{'Title'}) cmp lc($b->{'Title'}) ||
+ lc($a->{'Part'}) cmp lc($b->{'Part'});
+ } @Statsarray;
+ } else {
+ # Numerical comparison
+ @OutputOrder = sort {
+ my $retvalue = 0;
+ if ($b->{$sortby} eq 'nan') {
+ if ($a->{$sortby} ne 'nan') {
+ $retvalue = -1;
+ } else {
+ $retvalue = 0;
+ }
+ }
+ if ($a->{$sortby} eq 'nan') {
+ if ($b->{$sortby} ne 'nan') {
+ $retvalue = 1;
+ }
+ }
+ if ($retvalue eq '0') {
+ $retvalue = $b->{$sortby} <=> $a->{$sortby} ||
+ lc($a->{'Title'}) <=> lc($b->{'Title'}) ||
+ lc($a->{'Part'}) <=> lc($b->{'Part'});
+ }
+ $retvalue;
+ } @Statsarray;
+ }
}
- my $cIdx=0;
-
- if ( $pos == 0 ) {
- foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
- if($cache->{'ProblemStatisticsMaps'} ne 'All Maps' &&
- $cache->{'ProblemStatisticsMaps'} ne $cache->{$sequence.':title'}) {
- next;
- }
- if ($cIdx==$p_count) {
- return \%TempCache;
- }
- $r->print(&CreateProblemStatisticsTableHeading(
- $cache->{'DisplayFormat'},
- $cache->{$sequence.':source'},
- $cache->{$sequence.':title'},
- $headings,$r));
-
- my ($tar)=split(/\&/,$list[$cIdx]);
- $tar=~s/\+//eg;
- my ($SqOrd)=split(/\@/,$tar);
- $sequence+=100;
- while ($SqOrd==$sequence && $cIdx<$p_count) {
- my($Pre, $Post) = split(/\+/,$list[$cIdx]);
- &TableRow($cache,$Post,$cIdx,$cIdx,$r,$color,\%TempCache);
- $cIdx++;
- my ($tar)=split(/\&/,$list[$cIdx]);
- $tar=~s/\+//eg;
- ($SqOrd)=split(/\@/,$tar);
- }
- &CloseTable($cache,$r);
- }
+ $option .= ',no part' if (! $show_part);
+ foreach my $row (@OutputOrder) {
+ $r->print('');
+ if (defined($option) && $option =~ /show probnum/) {
+ $r->print(''.$row->{'problem_num'}.' | ');
+ }
+ if ($show_container) {
+ $r->print(''
+ .$row->{'sequence'}->{'title'}.' | ');
+ }
+ $r->print(&statistics_html_table_data
+ ($row->{'resource'},$row->{'Part'},$row->{'#Stdnts'},
+ $row->{'Tries'},$row->{'Mod'},$row->{'Mean'},
+ $row->{'#YES'},$row->{'#yes'},$row->{"\%Wrng"},
+ $row->{'DoDiff'},$row->{'S.D.'},$row->{'Skew'},
+ $option));
+ $r->print(" \n");
}
- else {
- $r->print(&CreateProblemStatisticsTableHeading(
- $cache->{'DisplayFormat'},
- 'Sorted by: ',
- $headings->{$pos-1},
- $headings,$r));
- for ( my $nIndex = 0; $nIndex < $p_count; $nIndex++ ) {
- my($Pre, $Post) = split(/\+/,$list[$nIndex]);
- &TableRow($cache,$Post,$nIndex,$nIndex,$r,$color,\%TempCache);
- }
- &CloseTable($cache,$r);
- }
-
- return \%TempCache;
+ $r->print(" \n");
+ $r->print(" |