--- loncom/interface/statistics/lonproblemstatistics.pm 2003/08/29 21:11:25 1.57
+++ loncom/interface/statistics/lonproblemstatistics.pm 2003/12/08 19:37:44 1.62
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemstatistics.pm,v 1.57 2003/08/29 21:11:25 matthew Exp $
+# $Id: lonproblemstatistics.pm,v 1.62 2003/12/08 19:37:44 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -51,11 +51,20 @@ package Apache::lonproblemstatistics;
use strict;
use Apache::lonnet();
+use Apache::loncommon();
use Apache::lonhtmlcommon;
use Apache::loncoursedata;
use Apache::lonstatistics;
+use Apache::lonlocal;
use Spreadsheet::WriteExcel;
+##
+## Localization notes:
+##
+## in @Fields[0]->{'long_title'} is placed in Excel files and is used as the
+## header for plots created with Graph.pm, both of which more than likely do
+## not support localization.
+##
my @Fields = (
{ name => 'problem_num',
title => 'P#',
@@ -201,10 +210,10 @@ sub CreateInterface {
my $Str = '';
$Str .= '
'."\n";
$Str .= '';
- $Str .= 'Sections ';
- $Str .= 'Enrollment Status ';
- $Str .= 'Sequences and Folders ';
- $Str .= 'Output ';
+ $Str .= ''.&mt('Sections').' ';
+ $Str .= ''.&mt('Enrollment Status').' ';
+ $Str .= ''.&mt('Sequences and Folders').' ';
+ $Str .= ''.&mt('Output').' ';
$Str .= ' '."\n";
#
$Str .= ''."\n";
@@ -232,9 +241,11 @@ sub CreateInterface {
$Str .= $html;
$Str .= ' '."\n";
$Str .= '
'."\n";
- $Str .= ' ';
+ $Str .= ' ';
$Str .= ' 'x5;
- $Str .= ' ';
+ $Str .= ' ';
$Str .= ' 'x5;
return ($Str,$outputmode,$show);
}
@@ -255,6 +266,18 @@ Main interface to problem statistics.
sub BuildProblemStatisticsPage {
my ($r,$c)=@_;
#
+ my %Saveable_Parameters = ('Status' => 'scalar',
+ 'statsoutputmode' => 'scalar',
+ 'Section' => 'array',
+ 'StudentData' => 'array',
+ 'Maps' => 'array');
+ &Apache::loncommon::store_course_settings('statistics',
+ \%Saveable_Parameters);
+ &Apache::loncommon::restore_course_settings('statistics',
+ \%Saveable_Parameters);
+ #
+ &Apache::lonstatistics::PrepareClasslist();
+ #
my ($interface,$output_mode,$show) = &CreateInterface();
$r->print($interface);
$r->print(' ');
@@ -280,10 +303,10 @@ sub BuildProblemStatisticsPage {
&output_html_ungrouped($r);
}
} elsif ($output_mode eq 'excel') {
- $r->print("Preparing Excel Spreadsheet ");
+ $r->print(''.&mt('Preparing Excel Spreadsheet').' ');
&output_excel($r);
} else {
- $r->print("Not implemented ");
+ $r->print(''.&mt('Not implemented').' ');
}
return;
}
@@ -490,9 +513,9 @@ sub output_excel {
# Check for errors
if (! defined($excel_workbook)) {
$r->log_error("Error creating excel spreadsheet $filename: $!");
- $r->print("Problems creating new Excel file. ".
+ $r->print(&mt("Problems creating new Excel file. ".
"This error has been logged. ".
- "Please alert your LON-CAPA administrator");
+ "Please alert your LON-CAPA administrator."));
return ;
}
#
@@ -507,7 +530,9 @@ sub output_excel {
if (length($sheetname) > 31) {
$sheetname = substr($sheetname,0,31);
}
- $excel_sheet = $excel_workbook->addworksheet($sheetname);
+ $excel_sheet = $excel_workbook->addworksheet(
+ &Apache::loncommon::clean_excel_name($sheetname)
+ );
#
# Put the course description in the header
$excel_sheet->write($rows_output,$cols_output++,
@@ -556,6 +581,8 @@ sub output_excel {
# Brief headers
foreach my $field (@Fields) {
next if ($field->{'name'} eq 'problem_num');
+ # Use english for excel as I am not sure how well excel handles
+ # other character sets....
$excel_sheet->write($rows_output,$cols_output++,$field->{'title'});
}
$rows_output++;
@@ -589,7 +616,8 @@ sub output_excel {
$excel_workbook->close();
# Tell the user where to get their excel file
$r->print(' '.
- 'Your Excel spreadsheet. '."\n");
+ ''.
+ &mt('Your Excel Spreadsheet').' '."\n");
$r->rflush();
return;
}
@@ -645,7 +673,7 @@ sub statistics_table_header {
'document.Statistics.sortby.value='."'".$field->{'name'}."'".
';document.Statistics.submit();">';
}
- $header_row .= $field->{'title'};
+ $header_row .= &mt($field->{'title'});
if ($options =~ /sortable/) {
$header_row.= '';
}
@@ -656,7 +684,7 @@ sub statistics_table_header {
$header_row .= '';
- $header_row .= 'plot )';
+ $header_row .= &mt('plot').')';
}
$header_row .= '';
}
@@ -738,8 +766,12 @@ sub plot_statistics {
}
}
- $r->print("".&DrawGraph(\@Data,$title,'Problem Number',$yaxis,
- $Max)."
\n");
+ $r->print("".&Apache::loncommon::DrawBarGraph($title,
+ 'Problem Number',
+ $yaxis,
+ $Max,
+ undef,
+ \@Data)."
\n");
#
# Print out the data
$ENV{'form.sortby'} = 'Contents';
@@ -747,35 +779,6 @@ sub plot_statistics {
return;
}
-###############################################
-###############################################
-
-=pod
-
-=item &DrawGraph()
-
-=cut
-
-###############################################
-###############################################
-sub DrawGraph {
- my ($values,$title,$xaxis,$yaxis,$Max)=@_;
- $title = '' if (! defined($title));
- $xaxis = '' if (! defined($xaxis));
- $yaxis = '' if (! defined($yaxis));
- #
- my $sendValues = join(',', @$values);
- my $sendCount = scalar(@$values);
- $Max =1 if ($Max < 1);
- if ( int($Max) < $Max ) {
- $Max++;
- $Max = int($Max);
- }
- my @GData = ($title,$xaxis,$yaxis,$Max,$sendCount,$sendValues);
- return ' ';
-}
-
sub get_statistics {
my ($sequence,$resource,$part,$problem_num) = @_;
#
@@ -805,6 +808,8 @@ sub get_statistics {
=item &ProblemStatisticsLegend()
+HELP This needs to be localized, or at least generated automatically.
+
=cut
###############################################