[LON-CAPA-cvs] cvs: loncom /interface lonstatistics.pm /interface/statistics loncorrectproblemplot.pm lonproblemanalysis.pm lonproblemstatistics.pm lonstathelpers.pm lonstudentassessment.pm lonstudentsubmissions.pm lonsubmissiontimeanalysis.pm lonsurveyreports.pm

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 14 Mar 2005 20:28:22 -0000


This is a MIME encoded message

--matthew1110832102
Content-Type: text/plain

matthew		Mon Mar 14 15:28:22 2005 EDT

  Modified files:              
    /loncom/interface	lonstatistics.pm 
    /loncom/interface/statistics	loncorrectproblemplot.pm 
                                	lonproblemanalysis.pm 
                                	lonproblemstatistics.pm 
                                	lonstathelpers.pm 
                                	lonstudentassessment.pm 
                                	lonstudentsubmissions.pm 
                                	lonsubmissiontimeanalysis.pm 
                                	lonsurveyreports.pm 
  Log:
  lonstatistics.pm:Removed package variable @SelectedSections. 
      Added &get_selected_sections 
      Added &section_and_enrollment_description to provide a brief
          description of those students selected for statistics work
          (hopefully this descriptive line will make it in to bug reports).
  Added &section_and_enrollment_description to all statistics pages
  Replaced use of @SelectedSections with &get_selected_sections in statistics
      pages.
  
  
--matthew1110832102
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20050314152822.txt"

Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.118 loncom/interface/lonstatistics.pm:1.119
--- loncom/interface/lonstatistics.pm:1.118	Tue Mar  1 17:25:59 2005
+++ loncom/interface/lonstatistics.pm	Mon Mar 14 15:28:21 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstatistics.pm,v 1.118 2005/03/01 22:25:59 matthew Exp $
+# $Id: lonstatistics.pm,v 1.119 2005/03/14 20:28:21 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -50,7 +50,6 @@
     @FullClasslist 
     @Students
     @Sections 
-    @SelectedSections
     %StudentData
     @StudentDataOrder
     @SelectedStudentData
@@ -124,8 +123,6 @@
 
 =item @Sections
 
-=item @SelectedSections
-
 =item %StudentData
 
 =item @StudentDataOrder
@@ -148,7 +145,6 @@
     undef(@FullClasslist);
     undef(@Students);
     undef(@Sections);
-    undef(@SelectedSections);
     undef(%StudentData);
     undef(@SelectedStudentData);
     undef($curr_student);
@@ -174,8 +170,6 @@
 
 =item @Sections
 
-=item @SelectedSections
-
 =item %StudentData
 
 =item @SelectedStudentData
@@ -205,23 +199,11 @@
     my $cnum = $ENV{'course.'.$cid.'.num'};
     my ($classlist,$field_names) = &Apache::loncoursedata::get_classlist($cid,
                                                                   $cdom,$cnum);
-    if (exists($ENV{'form.Section'})) {
-        if (ref($ENV{'form.Section'})) {
-            @SelectedSections = @{$ENV{'form.Section'}};
-        } elsif ($ENV{'form.Section'} !~ /^\s*$/) {
-            @SelectedSections = ($ENV{'form.Section'});
-        }
-    }
-    @SelectedSections = ('all') if (! @SelectedSections);
-    foreach (@SelectedSections) {
-        if ($_ eq 'all') {
-            @SelectedSections = ('all');
-        }
-    }
+    my @selected_sections = &get_selected_sections();
     #
     # Deal with instructors with restricted section access
     if ($ENV{'request.course.sec'} !~ /^\s*$/) {
-        @SelectedSections = ($ENV{'request.course.sec'});
+        @selected_sections = ($ENV{'request.course.sec'});
     }
     #
     # Set up %StudentData
@@ -262,7 +244,7 @@
         $Sections{$section}++;
         #
         # Only put in the list those students we are interested in
-        foreach my $sect (@SelectedSections) {
+        foreach my $sect (@selected_sections) {
             if ( (($sect eq 'all') || 
                   ($section eq $sect)) &&
                  (($studenthash->{'status'} eq $enrollment_status) || 
@@ -334,6 +316,70 @@
     return;
 }
 
+#######################################################
+#######################################################
+
+=pod
+
+=item get_selected_sections
+
+Returns an array of the selected sections
+
+=cut
+
+#######################################################
+#######################################################
+sub get_selected_sections {
+    my @selected_sections;
+    if (exists($ENV{'form.Section'})) {
+        if (ref($ENV{'form.Section'})) {
+            @selected_sections = @{$ENV{'form.Section'}};
+        } elsif ($ENV{'form.Section'} !~ /^\s*$/) {
+            @selected_sections = ($ENV{'form.Section'});
+        }
+    }
+    @selected_sections = ('all') if (! @selected_sections);
+    foreach (@selected_sections) {
+        if ($_ eq 'all') {
+            @selected_sections = ('all');
+        }
+    }
+    #
+    # Deal with instructors with restricted section access
+    if ($ENV{'request.course.sec'} !~ /^\s*$/) {
+        @selected_sections = ($ENV{'request.course.sec'});
+    }
+    return @selected_sections;
+}
+
+#######################################################
+#######################################################
+
+=pod
+
+=item &section_and_enrollment_description
+
+=cut
+
+#######################################################
+#######################################################
+sub section_and_enrollment_description {
+    my @sections = &Apache::lonstatistics::get_selected_sections();
+    my $description = &mt('Unable to determine section and enrollment');
+    if (scalar(@sections) == 1 && $sections[0] ne 'all') {
+        $description = &mt('Section [_1]. [_2] enrollment status',
+                           $sections[0],$ENV{'form.Status'});
+    } elsif (scalar(@sections) && $sections[0] eq 'all') {
+        $description = &mt('All sections. [_1] enrollment status',
+                           $ENV{'form.Status'});
+    } elsif (scalar(@sections)) {
+        my $lastsection = pop(@sections);
+        $description = &mt('Sections [_1] and [_2]. [_3] enrollment status',
+                           join(', ',@sections),$lastsection,
+                           $ENV{'form.Status'});
+    }
+    return $description;
+}
 
 #######################################################
 #######################################################
@@ -644,7 +690,7 @@
 Returns html for a selection box allowing the user to choose one (or more) 
 of the sections in the course.  
 
-Uses the package variables @Sections and @SelectedSections
+Uses the package variables @Sections
 =over 4
 
 =item $elementname The name of the HTML form element
@@ -681,7 +727,7 @@
     # Loop through the sequences
     foreach my $s (@Sections) {
         $Str .= '    <option value="'.$s.'" ';
-        foreach (@SelectedSections) {
+        foreach (&get_selected_sections()) {
             if ($s eq $_) {
                 $Str .= 'selected ';
                 last;
@@ -726,8 +772,9 @@
     my @Fields = ('fullname','username','domain','id','section','status');
     #
     $Str = '';
+    my @selected_sections = &get_selected_sections();
     if (! @Students) {
-        if ($SelectedSections[0] eq 'all') { 
+        if ($selected_sections[0] eq 'all') { 
             if (lc($ENV{'form.Status'}) eq 'any') {
                 $Str .= '<h2>'.
                     &mt('There are no students in the course.').
Index: loncom/interface/statistics/loncorrectproblemplot.pm
diff -u loncom/interface/statistics/loncorrectproblemplot.pm:1.16 loncom/interface/statistics/loncorrectproblemplot.pm:1.17
--- loncom/interface/statistics/loncorrectproblemplot.pm:1.16	Mon Mar  7 15:12:08 2005
+++ loncom/interface/statistics/loncorrectproblemplot.pm	Mon Mar 14 15:28:22 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncorrectproblemplot.pm,v 1.16 2005/03/07 20:12:08 matthew Exp $
+# $Id: loncorrectproblemplot.pm,v 1.17 2005/03/14 20:28:22 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -122,6 +122,9 @@
                 }
             }
         }
+        $r->print('<h4>'.
+                  &Apache::lonstatistics::section_and_enrollment_description().
+                  '</h4>');
         my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
         if (defined($starttime) || defined($endtime)) {
             # Inform the user what the time limits on the data are.
@@ -131,7 +134,7 @@
         }
         &Apache::loncoursedata::populate_weight_table();
         my $score_data = &Apache::loncoursedata::get_student_scores
-            (\@Apache::lonstatistics::SelectedSections,
+            ([&Apache::lonstatistics::get_selected_sections()],
              \@ProblemSymbs,
              $Apache::lonstatistics::enrollment_status,undef,
              $starttime,$endtime);
Index: loncom/interface/statistics/lonproblemanalysis.pm
diff -u loncom/interface/statistics/lonproblemanalysis.pm:1.117 loncom/interface/statistics/lonproblemanalysis.pm:1.118
--- loncom/interface/statistics/lonproblemanalysis.pm:1.117	Fri Mar 11 16:14:41 2005
+++ loncom/interface/statistics/lonproblemanalysis.pm	Mon Mar 14 15:28:22 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonproblemanalysis.pm,v 1.117 2005/03/11 21:14:41 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.118 2005/03/14 20:28:22 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -132,6 +132,7 @@
             my $resource = $current_problem->{'resource'};
             $r->print('<h1>'.$resource->compTitle.'</h1>');
             $r->print('<h3>'.$resource->src.'</h3>');
+            $r->print('<h4>'.&Apache::lonstatistics::section_and_enrollment_description().'</h4>');
             if ($ENV{'form.show_prob'} eq 'true') {
                 $r->print(&Apache::lonstathelpers::render_resource($resource));
             }
@@ -186,7 +187,7 @@
                                       $problem->{'respid'});
     # Gather student data
     my $response_data = &Apache::loncoursedata::get_response_data
-        (\@Apache::lonstatistics::SelectedSections,
+        ([&Apache::lonstatistics::get_selected_sections()],
          $Apache::lonstatistics::enrollment_status,
          $resource->symb,$respid);
     #
@@ -765,7 +766,7 @@
     $analysis_html .= $table;
     # Gather student data
     my $response_data = &Apache::loncoursedata::get_response_data
-        (\@Apache::lonstatistics::SelectedSections,
+        ([&Apache::lonstatistics::get_selected_sections()],
          $Apache::lonstatistics::enrollment_status,
          $resource->symb,$respid);
     my $correct;   # either a hash reference or a scalar
@@ -1172,7 +1173,7 @@
                               $problem->{'respid'});
     # Note: part data is not needed.
     my $PerformanceData = &Apache::loncoursedata::get_response_data
-        (\@Apache::lonstatistics::SelectedSections,
+        ([&Apache::lonstatistics::get_selected_sections()],
          $Apache::lonstatistics::enrollment_status,
          $resource->symb,$respid);
     if (! defined($PerformanceData) || 
Index: loncom/interface/statistics/lonproblemstatistics.pm
diff -u loncom/interface/statistics/lonproblemstatistics.pm:1.101 loncom/interface/statistics/lonproblemstatistics.pm:1.102
--- loncom/interface/statistics/lonproblemstatistics.pm:1.101	Thu Mar 10 12:33:57 2005
+++ loncom/interface/statistics/lonproblemstatistics.pm	Mon Mar 14 15:28:22 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonproblemstatistics.pm,v 1.101 2005/03/10 17:33:57 matthew Exp $
+# $Id: lonproblemstatistics.pm,v 1.102 2005/03/14 20:28:22 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -721,11 +721,17 @@
         return;
     }
     if (exists($ENV{'form.Excel'})) {
+        $r->print('<h4>'.
+                  &Apache::lonstatistics::section_and_enrollment_description().
+                  '</h4>');
         &Excel_output($r);
     } else { 
         $r->print('<input type="submit" name="Excel" value="'.
                   &mt('Produce Excel Output').'" />'.'&nbsp;'x5);
         $r->rflush();
+        $r->print('<h4>'.
+                  &Apache::lonstatistics::section_and_enrollment_description().
+                  '</h4>');
         my $count = 0;
         foreach my $seq (@sequences) {
             my @resources = 
@@ -1294,9 +1300,9 @@
     my $sectionstring = '';
     $excel_sheet->write($rows_output,$cols_output++,
                         &Apache::lonstathelpers::sections_description
-                            (@Apache::lonstatistics::SelectedSections),
+                            (&Apache::lonstatistics::get_selected_sections()),
                         $format->{'h3'});
-    $cols_output += scalar(@Apache::lonstatistics::SelectedSections);
+    $cols_output += scalar(&Apache::lonstatistics::get_selected_sections());
     #
     # Time restrictions
     my $time_string;
@@ -1537,7 +1543,7 @@
     my $courseid = $ENV{'request.course.id'};
     #
     my $data = &Apache::loncoursedata::get_problem_statistics
-                        (\@Apache::lonstatistics::SelectedSections,
+                        ([&Apache::lonstatistics::get_selected_sections()],
                          $Apache::lonstatistics::enrollment_status,
                          $symb,$part,$courseid,$starttime,$endtime);
     $data->{'symb'}        = $symb;
@@ -1555,7 +1561,7 @@
     #
     # Store in metadata if computations were done for all students
     if ($data->{'num_students'} > 1) {
-        my @Sections = @Apache::lonstatistics::SelectedSections;
+        my @Sections = &Apache::lonstatistics::get_selected_sections();
         my $sections = '"'.join(' ',@Sections).'"';
         $sections =~ s/&+/_/g;  # Ensure no special characters
         $data->{'sections'}=$sections;
@@ -1615,7 +1621,7 @@
     my $ranking = 
         &Apache::loncoursedata::rank_students_by_scores_on_resources
         (\@Resources,
-         \@Apache::lonstatistics::SelectedSections,
+         [&Apache::lonstatistics::get_selected_sections()],
          $Apache::lonstatistics::enrollment_status,undef,
          $starttime,$endtime);
     #
@@ -1680,7 +1686,7 @@
     # First compute statistics based on student scores
     my ($smin,$smax,$sMean,$sSTD,$scount,$sMAX) = 
         &Apache::loncoursedata::score_stats
-                    (\@Apache::lonstatistics::SelectedSections,
+                    ([&Apache::lonstatistics::get_selected_sections()],
                      $Apache::lonstatistics::enrollment_status,
                      \@Resources,$starttime,$endtime,undef);
     $SeqStat{$symb}->{'title'}  = $seq->compTitle;
@@ -1695,7 +1701,7 @@
     # 'correct' is taken to mean 
     my ($cmin,$cmax,$cMean,$cSTD,$ccount)=
         &Apache::loncoursedata::count_stats
-        (\@Apache::lonstatistics::SelectedSections,
+        ([&Apache::lonstatistics::get_selected_sections()],
          $Apache::lonstatistics::enrollment_status,
          \@Resources,$starttime,$endtime,undef);
     my $K = $part_count;
Index: loncom/interface/statistics/lonstathelpers.pm
diff -u loncom/interface/statistics/lonstathelpers.pm:1.43 loncom/interface/statistics/lonstathelpers.pm:1.44
--- loncom/interface/statistics/lonstathelpers.pm:1.43	Thu Mar 10 11:58:52 2005
+++ loncom/interface/statistics/lonstathelpers.pm	Mon Mar 14 15:28:22 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstathelpers.pm,v 1.43 2005/03/10 16:58:52 matthew Exp $
+# $Id: lonstathelpers.pm,v 1.44 2005/03/14 20:28:22 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1292,7 +1292,7 @@
 
 Inputs: @Sections, an array of sections
 
-Returns: A text description of the sections selected.
+Returns: A plaintext description of the sections selected.
 
 =cut
 
@@ -1340,7 +1340,7 @@
         join(',',
              map {
                      &Apache::lonnet::escape($_);
-                 } sort(@Apache::lonstatistics::SelectedSections)
+                 } sort(&Apache::lonstatistics::get_selected_sections())
              );
     my $statuskey = $Apache::lonstatistics::enrollment_status;
     if (exists($ENV{'form.ClearCache'}) || 
Index: loncom/interface/statistics/lonstudentassessment.pm
diff -u loncom/interface/statistics/lonstudentassessment.pm:1.118 loncom/interface/statistics/lonstudentassessment.pm:1.119
--- loncom/interface/statistics/lonstudentassessment.pm:1.118	Fri Mar 11 15:26:32 2005
+++ loncom/interface/statistics/lonstudentassessment.pm	Mon Mar 14 15:28:22 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstudentassessment.pm,v 1.118 2005/03/11 20:26:32 matthew Exp $
+# $Id: lonstudentassessment.pm,v 1.119 2005/03/14 20:28:22 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -173,6 +173,9 @@
     if (! exists($ENV{'form.notfirstrun'}) && ! $single_student_mode) {
         return;
     }
+    $r->print('<h4>'.
+              &Apache::lonstatistics::section_and_enrollment_description().
+              '</h4>');
     #
     my $initialize     = \&html_initialize;
     my $output_student = \&html_outputstudent;
@@ -1048,7 +1051,7 @@
     #
     # Put a description of the sections listed
     my $sectionstring = '';
-    my @Sections = @Apache::lonstatistics::SelectedSections;
+    my @Sections = &Apache::lonstatistics::get_selected_sections();
     if (scalar(@Sections) > 1) {
         if (scalar(@Sections) > 2) {
             my $last = pop(@Sections);
Index: loncom/interface/statistics/lonstudentsubmissions.pm
diff -u loncom/interface/statistics/lonstudentsubmissions.pm:1.36 loncom/interface/statistics/lonstudentsubmissions.pm:1.37
--- loncom/interface/statistics/lonstudentsubmissions.pm:1.36	Thu Mar 10 12:28:59 2005
+++ loncom/interface/statistics/lonstudentsubmissions.pm	Mon Mar 14 15:28:22 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstudentsubmissions.pm,v 1.36 2005/03/10 17:28:59 matthew Exp $
+# $Id: lonstudentsubmissions.pm,v 1.37 2005/03/14 20:28:22 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -110,6 +110,9 @@
             push(@Problems,$resource);
         }
         # 
+        $r->print('<h4>'.
+                  &Apache::lonstatistics::section_and_enrollment_description().
+                  '</h4>');
         if (! scalar(@Problems) || ! defined($Problems[0])) {
             $r->print('resource is undefined');
         } else {
Index: loncom/interface/statistics/lonsubmissiontimeanalysis.pm
diff -u loncom/interface/statistics/lonsubmissiontimeanalysis.pm:1.21 loncom/interface/statistics/lonsubmissiontimeanalysis.pm:1.22
--- loncom/interface/statistics/lonsubmissiontimeanalysis.pm:1.21	Thu Mar 10 12:06:21 2005
+++ loncom/interface/statistics/lonsubmissiontimeanalysis.pm	Mon Mar 14 15:28:22 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonsubmissiontimeanalysis.pm,v 1.21 2005/03/10 17:06:21 matthew Exp $
+# $Id: lonsubmissiontimeanalysis.pm,v 1.22 2005/03/14 20:28:22 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -127,6 +127,9 @@
         } else {
             $r->print('<h1>'.$resource->compTitle.'</h1>');
             $r->print('<h3>'.$resource->src.'</h3>');
+            $r->print('<h4>'.
+                 &Apache::lonstatistics::section_and_enrollment_description().
+                      '</h4>');
             $r->rflush();
             $r->print(&Apache::lonstathelpers::render_resource($resource));
             $r->print('<br />');
@@ -169,7 +172,7 @@
     my $html; # holds results of analysis
     # Get the data
     my $SubData = &Apache::loncoursedata::get_response_time_data
-        (\@Apache::lonstatistics::SelectedSections,
+        ([&Apache::lonstatistics::get_selected_sections()],
          $Apache::lonstatistics::enrollment_status,
          $symb,$part);
     if (! defined($SubData) || ! ref($SubData)) {
Index: loncom/interface/statistics/lonsurveyreports.pm
diff -u loncom/interface/statistics/lonsurveyreports.pm:1.4 loncom/interface/statistics/lonsurveyreports.pm:1.5
--- loncom/interface/statistics/lonsurveyreports.pm:1.4	Wed Mar  9 19:23:15 2005
+++ loncom/interface/statistics/lonsurveyreports.pm	Mon Mar 14 15:28:22 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonsurveyreports.pm,v 1.4 2005/03/10 00:23:15 matthew Exp $
+# $Id: lonsurveyreports.pm,v 1.5 2005/03/14 20:28:22 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -91,6 +91,9 @@
         }
         #
         $r->print('<hr />');
+        $r->print('<h4>'.
+                  &Apache::lonstatistics::section_and_enrollment_description().
+                  '</h4>');
         $r->rflush();
         #
         # Determine which problem we are to analyze

--matthew1110832102--