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

matthew lon-capa-cvs@mail.lon-capa.org
Tue, 27 May 2003 14:51:24 -0000


matthew		Tue May 27 10:51:24 2003 EDT

  Modified files:              
    /loncom/interface	lonstatistics.pm 
  Log:
  Added &get_students which returns the student list.  Added initialization
  checking to &SectionSelector.  Removed $r as a parameter to &PrepareClasslist
  All of this is to allow Spreadsheet::classcalc to use the statistics student
  handling subroutines.  We *should* move most of these routines to another
  module, but not until after the 1.0 release.
  
  
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.70 loncom/interface/lonstatistics.pm:1.71
--- loncom/interface/lonstatistics.pm:1.70	Tue May 13 10:30:26 2003
+++ loncom/interface/lonstatistics.pm	Tue May 27 10:51:24 2003
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstatistics.pm,v 1.70 2003/05/13 14:30:26 matthew Exp $
+# $Id: lonstatistics.pm,v 1.71 2003/05/27 14:51:24 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -206,7 +206,6 @@
 #######################################################
 #######################################################
 sub PrepareClasslist {
-    my $r = shift;
     my %Sections;
     &clear_classlist_variables();
     #
@@ -342,6 +341,27 @@
     return;
 }
 
+
+#######################################################
+#######################################################
+
+=pod
+
+=item get_students
+
+Returns a list of the selected students
+
+=cut
+
+#######################################################
+#######################################################
+sub get_students {
+    if (! @Students) {
+        &PrepareClasslist()
+    }
+    return @Students;
+}
+
 #######################################################
 #######################################################
 
@@ -739,6 +759,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
 =over 4
 
 =item $elementname The name of the HTML form element
@@ -747,13 +768,6 @@
 
 =item $numvisible The number of options to be visible
 
-=item $selected Array ref to the names of the already selected sections.
-If undef, $ENV{'form.'.$elementname} is used.  
-If $ENV{'form.'.$elementname} is also empty, none will be selected.
-
-=item $restriction Code reference to subroutine which returns true or 
-false.  The code must expect a reference to a sequence data structure.
-
 =back
 
 =cut
@@ -766,6 +780,11 @@
         return;
     }
     #
+    # Make sure we have the data we need to continue
+    if (! @Sections) {
+        &PrepareClasslist()
+    }
+    #
     # Build the form element
     my $Str = "\n";
     $Str .= '<select name="'.$elementname.'" ';
@@ -952,7 +971,7 @@
     }
     #
     # Set up the statistics and chart environment
-    &PrepareClasslist($r);
+    &PrepareClasslist();
     &PrepareCourseData($r);
     #
     # Begin form output