'."\n";
- return $Str;
-}
+###############################################
+###############################################
-#######################################################
-#######################################################
+=pod
-=pod
+=item &CreateInterface()
-=item &CreateAndParseOutputSelector()
+Create the main intereface for the statistics page. Allows the user to
+select sections, maps, and output.
=cut
-#######################################################
-#######################################################
-my $output_mode;
-my $show;
-
+###############################################
+###############################################
my @OutputOptions =
(
- { name => 'problem statistics grouped by sequence',
+ { name => 'grouped by sequence',
value => 'HTML problem statistics grouped',
description => 'Output statistics for the problem parts.',
mode => 'html',
show => 'grouped',
},
- { name => 'problem statistics ungrouped',
+ { name => 'ungrouped',
value => 'HTML problem statistics ungrouped',
description => 'Output statistics for the problem parts.',
mode => 'html',
show => 'ungrouped',
},
- { name => 'problem statistics, Excel',
+ { name => 'Excel',
value => 'Excel problem statistics',
description => 'Output statistics for the problem parts '.
'in an Excel workbook',
mode => 'excel',
show => 'all',
},
- { name => 'Degree of Difficulty Plot',
- value => 'plot deg diff',
- description => 'Generate a plot of the degree of difficulty of each '.
- 'problem part.',
- mode => 'plot',
- show => 'deg of diff',
- },
- { name => 'Percent Wrong Plot',
- value => 'plot per wrong',
- description => 'Generate a plot showing the percent of students who '.
- 'were unable to complete each problem part',
- mode => 'plot',
- show => 'per wrong',
- },
);
-sub OutputDescriptions {
- my $Str = '';
- $Str .= "
Output Modes
\n";
- $Str .= "
\n";
- foreach my $outputmode (@OutputOptions) {
- $Str .="
".$outputmode->{'name'}."
\n";
- $Str .="
".$outputmode->{'description'}."
\n";
- }
- $Str .= "
\n";
- return $Str;
-}
-
-sub CreateAndParseOutputSelector {
+sub CreateInterface {
my $Str = '';
- my $elementname = 'outputmode';
- #
- # Format for output options is 'mode, restrictions';
- my $selected = 'html, with links';
- if (exists($ENV{'form.'.$elementname})) {
- if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) {
- $selected = $ENV{'form.'.$elementname}->[0];
- } else {
- $selected = $ENV{'form.'.$elementname};
- }
- }
+ $Str .= &Apache::lonhtmlcommon::breadcrumbs
+ (undef,'Overall Problem Statistics','Statistics_Overall_Key');
+ $Str .= '
");
+ my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
+ if (defined($starttime) || defined($endtime)) {
+ # Inform the user what the time limits on the data are.
+ $r->print('
'.&mt('Statistics on submissions from [_1] to [_2]',
+ &Apache::lonlocal::locallocaltime($starttime),
+ &Apache::lonlocal::locallocaltime($endtime)).
+ '
');
+ }
+ $r->print("
".&mt('Compiled on [_1]',
+ &Apache::lonlocal::locallocaltime(time))."
');
}
return;
}
+###############################################
+###############################################
+
+=pod
+
+=item &output_html_grouped_by_sequence()
+
+Presents the statistics data as an html table organized by the order
+the assessments appear in the course.
+
+=cut
+
+###############################################
+###############################################
sub output_html_grouped_by_sequence {
my ($r) = @_;
+ my $problem_num = 0;
#$r->print(&ProblemStatisticsLegend());
- my @Header = ("Title","Part","#Stdnts","Tries","Mod",
- "Mean","#YES","#yes","%Wrng","DoDiff",
- "S.D.","Skew.");#,"D.F.1st","D.F.2nd");
- # #FFFFE6 #EEFFCC #DDFFFF FFDDDD #DDFFDD #FFDDFF
foreach my $sequence (&Apache::lonstatistics::Sequences_with_Assess()) {
- my $show_part = 0;
next if ($sequence->{'num_assess'}<1);
$r->print("
".$sequence->{'title'}."
");
$r->print('
'."\n");
$r->print('
'."\n");
- $r->print('
'.
- join("
",@Header)."
\n");
+ $r->print('
');
+ my $Str = &statistics_table_header('no container no plots');
+ $r->print('
'.$Str."
\n");
foreach my $resource (@{$sequence->{'contents'}}) {
next if ($resource->{'type'} ne 'assessment');
foreach my $part (@{$resource->{'parts'}}) {
- my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
- $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;
- }
- $r->print('
\n");
}
}
@@ -280,41 +371,46 @@ sub output_html_grouped_by_sequence {
return;
}
-
###############################################
###############################################
+=pod
+
+=item &output_html_ungrouped()
+
+Presents the statistics data in a single html table which can be sorted by
+different columns.
+
+=cut
+
###############################################
###############################################
sub output_html_ungrouped {
- my ($r) = @_;
+ my ($r,$option) = @_;
+ #
+ if (exists($ENV{'form.plot'}) && $ENV{'form.plot'} ne '') {
+ &plot_statistics($r,$ENV{'form.plot'});
+ }
#
+ my $problem_num = 0;
my $show_container = 0;
my $show_part = 0;
#$r->print(&ProblemStatisticsLegend());
- my @Header = ("Title","Part","#Stdnts","Tries","Mod",
- "Mean","#YES","#yes","%Wrng","DoDiff",
- "S.D.","Skew");#,"D.F.1st","D.F.2nd");
- #
my $sortby = undef;
- foreach (@Header) {
- if ($ENV{'form.sortby'} eq $_) {
- $sortby = $_;
+ foreach my $field (@Fields) {
+ if ($ENV{'form.sortby'} eq $field->{'name'}) {
+ $sortby = $field->{'name'};
}
}
- if (! defined($sortby) || $sortby eq '') {
- $sortby = 'Container';
+ if (! defined($sortby) || $sortby eq '' || $sortby eq 'problem_num') {
+ $sortby = 'container';
}
- # #FFFFE6 #EEFFCC #DDFFFF FFDDDD #DDFFDD #FFDDFF
+ # If there is more than one sequence, list their titles
my @Sequences = &Apache::lonstatistics::Sequences_with_Assess();
- if (@Sequences > 1) {
- unshift(@Header,"Container");
- $show_container = 1;
+ if (@Sequences < 1) {
+ $option .= ' no container';
}
#
- $r->print('
'."\n");
- $r->rflush();
- #
# Compile the data
my @Statsarray;
foreach my $sequence (@Sequences) {
@@ -322,58 +418,19 @@ sub output_html_ungrouped {
foreach my $resource (@{$sequence->{'contents'}}) {
next if ($resource->{'type'} ne 'assessment');
foreach my $part (@{$resource->{'parts'}}) {
- my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
- $SKEW) = &Apache::loncoursedata::get_problem_statistics
- (undef,$resource->{'symb'},$part,
- $ENV{'request.course.id'});
- #
+ $problem_num++;
+ my $data = &get_statistics($sequence,$resource,$part,
+ $problem_num);
$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,
- });
+ push (@Statsarray,$data);
}
}
}
#
- # 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 .= '
'."\n");
+###############################################
+###############################################
+
+=pod
+
+=item &statistics_html_table_data()
+
+Help function used to format the rows for HTML table output.
+
+=cut
+
+###############################################
+###############################################
+sub statistics_html_table_data {
+ my ($data,$options) = @_;
+ my $row = '';
+ foreach my $field (@Fields) {
+ next if ($options =~ /no $field->{'name'}/);
+ $row .= '