'."\n");
- $r->print(''."\n");
- my $Str = '';
- foreach (@Header) {
- if (/^(Part)$/) { # Do not allow sorting on this field
- $Str .= ''.$_.' | ';
- } else {
- $Str .= ''.
- ''.
- $_.' | ';
- }
- }
- $r->print(''.$Str." \n");
$r->rflush();
#
# Compile the data
- my %Statshash;
my @Statsarray;
foreach my $sequence (@Sequences) {
next if ($sequence->{'num_assess'}<1);
@@ -336,14 +326,16 @@ sub output_html_ungrouped {
$SKEW) = &Apache::loncoursedata::get_problem_statistics
(undef,$resource->{'symb'},$part,
$ENV{'request.course.id'});
+ #
+ $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;
}
- my $key = $resource->{'symb'}.':'.$part;
- $Statshash{$key} =
- {
- 'sequence' => $sequence,
+ push (@Statsarray,
+ { 'sequence' => $sequence,
'resource' => $resource,
'Title' => $resource->{'title'},
'Part' => $part,
@@ -357,39 +349,40 @@ sub output_html_ungrouped {
'DoDiff' => $DegOfDiff,
'S.D.' => $STD,
'Skew' => $SKEW,
- };
- push (@Statsarray,$Statshash{$key});
+ });
}
}
}
#
+ # 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)$/) {
+ $Str .= ''.$_.' | ';
+ } else {
+ $Str .= ''.
+ ''.
+ $_.' | ';
+ }
+ }
+ $r->print(''.$Str." \n");
+ #
# Sort the data
+ my @OutputOrder;
if ($sortby eq 'Container') {
- 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'}}) {
- my $key = $resource->{'symb'}.':'.$part;
- $r->print('');
- if ($show_container) {
- $r->print(''
- .$sequence->{'title'}.' | ');
- }
- $r->print(&stats_row_from_hash($Statshash{$key}));
- $r->print(" \n");
- }
- }
- }
+ @OutputOrder = @Statsarray;
} else {
# $sortby is already defined, so we can charge ahead
- my @OutputOrder;
if ($sortby =~ /^(title|part)$/i) {
# Alpha comparison
@OutputOrder = sort {
- $b->{$sortby} cmp $a->{$sortby} ||
- $b->{'Title'} cmp $a->{'Title'} ||
- $b->{'Part'} cmp $a->{'Part'};
+ 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
@@ -409,21 +402,21 @@ sub output_html_ungrouped {
}
if ($retvalue eq '0') {
$retvalue = $b->{$sortby} <=> $a->{$sortby} ||
- $b->{'Title'} <=> $a->{'Title'} ||
- $b->{'Part'} <=> $a->{'Part'};
+ lc($a->{'Title'}) <=> lc($b->{'Title'}) ||
+ lc($a->{'Part'}) <=> lc($b->{'Part'});
}
$retvalue;
} @Statsarray;
}
- foreach my $row (@OutputOrder) {
- $r->print('');
- if ($show_container) {
- $r->print(''
- .$row->{'sequence'}->{'title'}.' | ');
- }
- $r->print(&stats_row_from_hash($row));
- $r->print(" \n");
+ }
+ foreach my $row (@OutputOrder) {
+ $r->print('');
+ if ($show_container) {
+ $r->print(''
+ .$row->{'sequence'}->{'title'}.' | ');
}
+ $r->print(&stats_row_from_hash($row,$show_part));
+ $r->print(" \n");
}
$r->print(" \n");
$r->print(" \n");
@@ -433,17 +426,14 @@ sub output_html_ungrouped {
}
sub stats_row_from_hash {
- my ($data) = @_;
- if (ref($data) ne 'HASH') {
- my %Tmp = @_;
- $data = \%Tmp;
- }
+ my ($data,$show_part) = @_;
return &statistics_html_table_data($data->{'resource'},$data->{'Part'},
$data->{'#Stdnts'}, $data->{'Tries'},
$data->{'Mod'}, $data->{'Mean'},
$data->{'#YES'}, $data->{'#yes'},
$data->{"\%Wrng"}, $data->{'DoDiff'},
- $data->{'S.D.'}, $data->{'Skew'});
+ $data->{'S.D.'}, $data->{'Skew'},
+ $show_part);
}
###############################################
@@ -453,13 +443,13 @@ sub stats_row_from_hash {
###############################################
sub statistics_html_table_data {
my ($resource,$part,$num,$tries,$mod,$mean,$Solved,$solved,$wrongpercent,
- $DegOfDiff,$STD,$SKEW) = @_;
+ $DegOfDiff,$STD,$SKEW,$show_part) = @_;
my $row = '';
$row .= ' | '.
''.
$resource->{'title'}.''.
' | ';
- $row .= ''.$part.' | ' if (defined($part));
+ $row .= ''.$part.' | ' if ($show_part);
foreach ($num,$tries) {
$row .= ''.$_.' | ';
}