--- loncom/interface/statistics/lonproblemstatistics.pm	2003/09/29 16:20:18	1.59
+++ loncom/interface/statistics/lonproblemstatistics.pm	2004/02/20 16:38:49	1.68
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonproblemstatistics.pm,v 1.59 2003/09/29 16:20:18 matthew Exp $
+# $Id: lonproblemstatistics.pm,v 1.68 2004/02/20 16:38:49 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -51,6 +51,7 @@ package Apache::lonproblemstatistics;
 
 use strict;
 use Apache::lonnet();
+use Apache::loncommon();
 use Apache::lonhtmlcommon;
 use Apache::loncoursedata;
 use Apache::lonstatistics;
@@ -146,7 +147,7 @@ my @Fields = (
              title  => '#YES',
              align  => 'right',
              color  => '#FFDDDD',
-             format => '%d',
+             format => '%4.1f',#             format => '%d',
              sortable  => 'yes',
              graphable => 'yes',
              long_title => 'Number of Students able to Solve' },
@@ -154,7 +155,7 @@ my @Fields = (
              title  => '#yes',
              align  => 'right',
              color  => '#FFDDDD',
-             format => '%d',
+             format => '%4.1f',#             format => '%d',
              sortable  => 'yes',
              graphable => 'yes',
              long_title => 'Number of Students given Override' },
@@ -207,6 +208,8 @@ my @OutputOptions =
 
 sub CreateInterface {
     my $Str = '';
+    $Str .= &Apache::lonhtmlcommon::breadcrumbs
+        (undef,&mt('Overall Problem Statistics'),'Statistics_Overall_Key');
     $Str .= '<table cellspacing="5">'."\n";
     $Str .= '<tr>';
     $Str .= '<td align="center"><b>'.&mt('Sections').'</b></td>';
@@ -265,6 +268,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('<input type="hidden" name="statsfirstcall" value="no" />');
@@ -517,7 +532,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++,
@@ -751,8 +768,13 @@ sub plot_statistics {
         }
     }
     
-    $r->print("<p>".&DrawGraph(\@Data,$title,'Problem Number',$yaxis,
-                               $Max)."</p>\n");
+    $r->print("<p>".&Apache::loncommon::DrawBarGraph($title,
+                                                     'Problem Number',
+                                                     $yaxis,
+                                                     $Max,
+                                                     undef, # colors
+                                                     undef, # labels
+                                                     \@Data)."</p>\n");
     #
     # Print out the data
     $ENV{'form.sortby'} = 'Contents';
@@ -760,50 +782,16 @@ 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));
-    $title = &Apache::lonnet::escape($title);
-    $xaxis = &Apache::lonnet::escape($xaxis);
-    $yaxis = &Apache::lonnet::escape($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 '<IMG src="/cgi-bin/graph.png?'.
-        (join('&', @GData)).'" border="1" />';
-}
-
 sub get_statistics {
     my ($sequence,$resource,$part,$problem_num) = @_;
     #
     my $symb = $resource->{'symb'};
     my $courseid = $ENV{'request.course.id'};
     #
-    my $students = \@Apache::lonstatistics::Students;
-    if ($Apache::lonstatistics::SelectedSections[0] eq 'all') {
-        $students = undef;
-    }
     my $data = &Apache::loncoursedata::get_problem_statistics
-                        ($students,$symb,$part,$courseid);
+                        (\@Apache::lonstatistics::SelectedSections,
+                         $Apache::lonstatistics::enrollment_status,
+                         $symb,$part,$courseid);
     $data->{'part'}        = $part;
     $data->{'problem_num'} = $problem_num;
     $data->{'container'}   = $sequence->{'title'};