'."\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',
@@ -105,118 +195,77 @@ 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 .= '
Sections
';
+ $Str .= '
Enrollment Status
';
+ $Str .= '
Sequences and Folders
';
+ $Str .= '
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 .= '
\n");
}
}
@@ -292,37 +337,43 @@ sub output_html_grouped_by_sequence {
###############################################
###############################################
+=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) {
@@ -330,58 +381,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 .= '