'."\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',
@@ -104,118 +203,91 @@ my @OutputOptions =
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 .= '
'."\n";
+ $Str .= '
';
+ $Str .= '
'.&mt('Sections').'
';
+ $Str .= '
'.&mt('Enrollment Status').'
';
+ $Str .= '
'.&mt('Sequences and Folders').'
';
+ $Str .= '
'.&mt('Output').'
';
+ $Str .= '
'."\n";
#
- # Set package variables describing output mode
- $output_mode = 'html';
- $show = 'all';
- foreach my $option (@OutputOptions) {
- next if ($option->{'value'} ne $selected);
- $output_mode = $option->{'mode'};
- $show = $option->{'show'};
- }
+ $Str .= '
');
}
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()) {
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'}}) {
- if ($part == 0) {
- $part = ' ';
- }
- my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
- $SKEW) = &Apache::loncoursedata::get_problem_statistics
- (undef,$resource->{'symb'},$part,
- $ENV{'request.course.id'});
- my $wrongpercent = 0;
- if (defined($num) && $num > 0) {
- $wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10;
- }
- $r->print('
';
+ if (! defined($sortby) || $sortby eq '' || $sortby eq 'problem_num') {
+ $sortby = 'container';
+ }
+ # If there is more than one sequence, list their titles
+ my @Sequences = &Apache::lonstatistics::Sequences_with_Assess();
+ if (@Sequences < 1) {
+ $option .= ' no container';
}
- $r->print('
'.$Str."
\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'}}) {
- my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
- $SKEW) = &Apache::loncoursedata::get_problem_statistics
- (undef,$resource->{'symb'},$part,
- $ENV{'request.course.id'});
- if ($part == 0) {
- $part = ' ';
+ $problem_num++;
+ my $data = &get_statistics($sequence,$resource,$part,
+ $problem_num);
+ $show_part = 1 if ($part ne '0');
+ #
+ push (@Statsarray,$data);
+ }
+ }
+ }
+ #
+ # Sort the data
+ my @OutputOrder;
+ if ($sortby eq 'container') {
+ @OutputOrder = @Statsarray;
+ } else {
+ # $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;
+ }
}
- my $wrongpercent = 0;
- if (defined($num) && $num > 0) {
- $wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10;
+ if ($a->{$sortby} eq 'nan') {
+ if ($b->{$sortby} ne 'nan') {
+ $retvalue = 1;
+ }
}
- if ($show_container) {
- $r->print('
'."\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 .= '