'."\n";
$Str .= '';
- return $Str;
-}
-
-#######################################################
-#######################################################
-
-=pod
-
-=item &CreateAndParseOutputSelector()
-
-Construct a selection list of options for output and parse output selections.
-The current output selected is indicated by the values of the two package
-variables $output_mode and $show. @OutputOptions holds the descriptions of
-the output options and the values for $output_mode and $show.
-
-Based on code from lonstudentassessment.pm.
-
-=cut
-
-#######################################################
-#######################################################
-my $output_mode;
-my $show;
-
-my @OutputOptions =
- (
- { name => 'problem statistics grouped by sequence',
- value => 'HTML problem statistics grouped',
- description => 'Output statistics for the problem parts.',
- mode => 'html',
- show => 'grouped',
- },
- { name => 'problem statistics ungrouped',
- value => 'HTML problem statistics ungrouped',
- description => 'Output statistics for the problem parts.',
- mode => 'html',
- show => 'ungrouped',
- },
- { name => 'problem statistics, Excel',
- value => 'Excel problem statistics',
- description => 'Output statistics for the problem parts '.
- 'in an Excel workbook',
- mode => 'excel',
- show => 'all',
- },
- );
-
-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 {
- my $Str = '';
- my $elementname = 'statsoutputmode';
- #
- # Format for output options is 'mode, restrictions';
- my $selected = 'HTML problem statistics grouped';
- if (exists($ENV{'form.'.$elementname})) {
- if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) {
- $selected = $ENV{'form.'.$elementname}->[0];
- } else {
- $selected = $ENV{'form.'.$elementname};
- }
- }
- #
- # 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'};
- }
- #
- # Build the form element
- $Str = qq/";
- return $Str;
-}
-
-###############################################
-###############################################
-
-=pod
-
-=item &Gather_Student_Data()
-
-Ensures all student data is up to date.
-
-=cut
-
-###############################################
-###############################################
-sub Gather_Student_Data {
- my ($r) = @_;
- my $c = $r->connection();
- #
- my @Sequences = &Apache::lonstatistics::Sequences_with_Assess();
- #
- my @Students = @Apache::lonstatistics::Students;
- #
- # Open the progress window
- my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
- ($r,'Statistics Compilation Status',
- 'Statistics Compilation Progress', scalar(@Students));
- #
- while (my $student = shift @Students) {
- return if ($c->aborted());
- my ($status,undef) = &Apache::loncoursedata::ensure_current_data
- ($student->{'username'},$student->{'domain'},
- $ENV{'request.course.id'});
- &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
- 'last student');
- }
- &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
- $r->rflush();
+ $Str .= ' 'x5;
+ $Str .= '';
+ $Str .= ' 'x5;
+ return ($Str,$outputmode,$show);
}
###############################################
@@ -354,10 +255,8 @@ Main interface to problem statistics.
sub BuildProblemStatisticsPage {
my ($r,$c)=@_;
#
- $output_mode = 'html';
- $show = 'grouped';
- #
- $r->print(&CreateInterface());
+ my ($interface,$output_mode,$show) = &CreateInterface();
+ $r->print($interface);
$r->print('');
$r->print('');
@@ -366,7 +265,7 @@ sub BuildProblemStatisticsPage {
return;
}
#
- &Gather_Student_Data($r);
+ &Apache::lonstatistics::Gather_Student_Data($r);
#
#
if ($output_mode eq 'html') {
@@ -642,7 +541,19 @@ sub output_excel {
$rows_output++;
$cols_output=0;
#
- # Add the headers
+ # Long Headersheaders
+ foreach my $field (@Fields) {
+ next if ($field->{'name'} eq 'problem_num');
+ if (exists($field->{'long_title'})) {
+ $excel_sheet->write($rows_output,$cols_output++,
+ $field->{'long_title'});
+ } else {
+ $excel_sheet->write($rows_output,$cols_output++,'');
+ }
+ }
+ $rows_output++;
+ $cols_output=0;
+ # Brief headers
foreach my $field (@Fields) {
next if ($field->{'name'} eq 'problem_num');
$excel_sheet->write($rows_output,$cols_output++,$field->{'title'});
@@ -707,8 +618,7 @@ sub statistics_html_table_data {
}
$row .= '>';
if (exists($field->{'special'}) && $field->{'special'} eq 'link') {
- $row .= '';
+ $row .= '';
}
if (exists($field->{'format'})) {
$row .= sprintf($field->{'format'},$data->{$field->{'name'}});
@@ -882,7 +792,8 @@ sub get_statistics {
$data->{'problem_num'} = $problem_num;
$data->{'container'} = $sequence->{'title'};
$data->{'title'} = $resource->{'title'};
- $data->{'title.link'} = $resource->{'src'};
+ $data->{'title.link'} = $resource->{'src'}.'?symb='.
+ &Apache::lonnet::escape($resource->{'symb'});
#
return $data;
}