[LON-CAPA-cvs] cvs: loncom /interface/statistics lonproblemstatistics.pm

matthew lon-capa-cvs@mail.lon-capa.org
Fri, 28 Mar 2003 15:20:59 -0000


matthew		Fri Mar 28 10:20:59 2003 EDT

  Modified files:              
    /loncom/interface/statistics	lonproblemstatistics.pm 
  Log:
  Implemented wrapper for &Apache::loncoursedata::get_problem_statistics to
  deal with the situation where 'any' section is selected for statistics 
  generation.
  
  
Index: loncom/interface/statistics/lonproblemstatistics.pm
diff -u loncom/interface/statistics/lonproblemstatistics.pm:1.47 loncom/interface/statistics/lonproblemstatistics.pm:1.48
--- loncom/interface/statistics/lonproblemstatistics.pm:1.47	Thu Mar 27 14:26:33 2003
+++ loncom/interface/statistics/lonproblemstatistics.pm	Fri Mar 28 10:20:59 2003
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonproblemstatistics.pm,v 1.47 2003/03/27 19:26:33 matthew Exp $
+# $Id: lonproblemstatistics.pm,v 1.48 2003/03/28 15:20:59 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -340,9 +340,7 @@
             foreach my $part (@{$resource->{'parts'}}) {
                 $problem_num++;
                 my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
-                    $SKEW) = &Apache::loncoursedata::get_problem_statistics
-                        (undef,$resource->{'symb'},$part,
-                         $ENV{'request.course.id'});
+                    $SKEW) = &get_statistics($resource->{'symb'},$part);
                 #
                 $part = ' ' if ($part == 0);
                 #
@@ -425,9 +423,7 @@
             foreach my $part (@{$resource->{'parts'}}) {
                 $problem_num++;
                 my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
-                    $SKEW) = &Apache::loncoursedata::get_problem_statistics
-                        (undef,$resource->{'symb'},$part,
-                         $ENV{'request.course.id'});
+                    $SKEW) = &get_statistics($resource->{'symb'},$part);
                 #
                 $show_part = 1 if ($part ne '0');
                 $part = ' ' if ($part == 0);
@@ -636,9 +632,7 @@
             foreach my $part (@{$resource->{'parts'}}) {
                 $cols_output=0;
                 my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
-                    $SKEW) = &Apache::loncoursedata::get_problem_statistics
-                        (undef,$resource->{'symb'},$part,
-                         $ENV{'request.course.id'});
+                    $SKEW) = &get_statistics($resource->{'symb'},$part);
                 #
                 if (!defined($part) || $part eq '') {
                     $part = ' ';
@@ -750,9 +744,7 @@
         foreach my $resource (@{$sequence->{'contents'}}) {
             next if ($resource->{'type'} ne 'assessment');
             foreach my $part (@{$resource->{'parts'}}) {
-                my @Results = &Apache::loncoursedata::get_problem_statistics
-                        (undef,$resource->{'symb'},$part,
-                         $ENV{'request.course.id'});
+                my @Results= &get_statistics($resource->{'symb'},$part);
                 my ($num,$Solved,$solved) = @Results[0,4,5];
                 my $wrongpercent = 0;
                 if (defined($num) && $num > 0) {
@@ -845,6 +837,20 @@
     my @GData = ($title,$xaxis,$yaxis,$Max,$sendCount,$sendValues);
     return '<IMG src="/cgi-bin/graph.png?'.
         (join('&', @GData)).'" border="1" />';
+}
+
+sub get_statistics {
+    my ($symb,$part) = @_;
+    #
+    my $courseid = $ENV{'request.course.id'};
+    #
+    my $students = \@Apache::lonstatistics::Students;
+    if ($Apache::lonstatistics::SelectedSections[0] eq 'all') {
+        $students = undef;
+    }
+    my @Results = &Apache::loncoursedata::get_problem_statistics
+                        ($students,$symb,$part,$courseid);
+    return @Results;
 }
 
 ###############################################