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

matthew lon-capa-cvs@mail.lon-capa.org
Fri, 29 Aug 2003 21:11:25 -0000


This is a MIME encoded message

--matthew1062191485
Content-Type: text/plain

matthew		Fri Aug 29 17:11:25 2003 EDT

  Modified files:              
    /loncom/interface/statistics	lonproblemstatistics.pm 
    /loncom/interface	lonstatistics.pm 
  Log:
  Moved CreateAndParseOutputSelector from lonproblemstatistics to 
  lonstatistics as I intend to use it elsewhere in the statistics universe.
  
  
--matthew1062191485
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20030829171125.txt"

Index: loncom/interface/statistics/lonproblemstatistics.pm
diff -u loncom/interface/statistics/lonproblemstatistics.pm:1.56 loncom/interface/statistics/lonproblemstatistics.pm:1.57
--- loncom/interface/statistics/lonproblemstatistics.pm:1.56	Wed Aug 27 17:33:33 2003
+++ loncom/interface/statistics/lonproblemstatistics.pm	Fri Aug 29 17:11:25 2003
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonproblemstatistics.pm,v 1.56 2003/08/27 21:33:33 matthew Exp $
+# $Id: lonproblemstatistics.pm,v 1.57 2003/08/29 21:11:25 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -174,6 +174,29 @@
 
 ###############################################
 ###############################################
+my @OutputOptions = 
+    (
+     { name  => 'problem statistics grouped by sequence',
+       value => 'HTML problem statistics grouped',
+       description => 'Output statistics for the problem parts.',
+       mode => 'html',
+       show => 'grouped',
+     },
+     { name  => 'problem statistics ungrouped',
+       value => 'HTML problem statistics ungrouped',
+       description => 'Output statistics for the problem parts.',
+       mode => 'html',
+       show => 'ungrouped',
+     },
+     { name  => 'problem statistics, Excel',
+       value => 'Excel problem statistics',
+       description => 'Output statistics for the problem parts '.
+           'in an Excel workbook',
+       mode => 'excel',
+       show => 'all',
+     },
+     );
+
 sub CreateInterface {
     my $Str = '';
     $Str .= '<table cellspacing="5">'."\n";
@@ -201,108 +224,19 @@
     $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5,
                                               $only_seq_with_assessments);
     $Str .= '</td><td>'."\n";
-    $Str .= &CreateAndParseOutputSelector();
+    my ($html,$outputmode,$show) = 
+        &Apache::lonstatistics::CreateAndParseOutputSelector(
+                                            'statsoutputmode',
+                                            'HTML problem statistics grouped',
+                                            @OutputOptions);
+    $Str .= $html;
     $Str .= '</td></tr>'."\n";
     $Str .= '</table>'."\n";
     $Str .= '<input type="submit" value="Generate Statistics" />';
     $Str .= '&nbsp;'x5;
     $Str .= '<input type="submit" name="ClearCache" value="Clear Caches" />';
     $Str .= '&nbsp;'x5;
-    return $Str;
-}
-
-#######################################################
-#######################################################
-
-=pod
-
-=item &CreateAndParseOutputSelector()
-
-Construct a selection list of options for output and parse output selections.
-The current output selected is indicated by the values of the two package
-variables $output_mode and $show.  @OutputOptions holds the descriptions of
-the output options and the values for $output_mode and $show.
-
-Based on code from lonstudentassessment.pm.
-
-=cut
-
-#######################################################
-#######################################################
-my $output_mode;
-my $show;
-
-my @OutputOptions = 
-    (
-     { name  => 'problem statistics grouped by sequence',
-       value => 'HTML problem statistics grouped',
-       description => 'Output statistics for the problem parts.',
-       mode => 'html',
-       show => 'grouped',
-     },
-     { name  => 'problem statistics ungrouped',
-       value => 'HTML problem statistics ungrouped',
-       description => 'Output statistics for the problem parts.',
-       mode => 'html',
-       show => 'ungrouped',
-     },
-     { name  => 'problem statistics, Excel',
-       value => 'Excel problem statistics',
-       description => 'Output statistics for the problem parts '.
-           'in an Excel workbook',
-       mode => 'excel',
-       show => 'all',
-     },
-     );
-
-sub OutputDescriptions {
-    my $Str = '';
-    $Str .= "<h2>Output Modes</h2>\n";
-    $Str .= "<dl>\n";
-    foreach my $outputmode (@OutputOptions) {
-	$Str .="    <dt>".$outputmode->{'name'}."</dt>\n";
-	$Str .="        <dd>".$outputmode->{'description'}."</dd>\n";
-    }
-    $Str .= "</dl>\n";
-    return $Str;
-}
-
-sub CreateAndParseOutputSelector {
-    my $Str = '';
-    my $elementname = 'statsoutputmode';
-    #
-    # Format for output options is 'mode, restrictions';
-    my $selected = 'HTML problem statistics grouped';
-    if (exists($ENV{'form.'.$elementname})) {
-        if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) {
-            $selected = $ENV{'form.'.$elementname}->[0];
-        } else {
-            $selected = $ENV{'form.'.$elementname};
-        }
-    }
-    #
-    # Set package variables describing output mode
-    $output_mode = 'html';
-    $show        = 'all';
-    foreach my $option (@OutputOptions) {
-        next if ($option->{'value'} ne $selected);
-        $output_mode = $option->{'mode'};
-        $show        = $option->{'show'};
-    }
-    #
-    # Build the form element
-    $Str = qq/<select size="5" name="$elementname">/;
-    foreach my $option (@OutputOptions) {
-        if (exists($option->{'special'}) && 
-            $option->{'special'} =~ /do not show/) {
-            next;
-        }
-        $Str .= "\n".'    <option value="'.$option->{'value'}.'"';
-        $Str .= " selected " if ($option->{'value'} eq $selected);
-        $Str .= ">".$option->{'name'}."<\/option>";
-    }
-    $Str .= "\n</select>";
-    return $Str;
+    return ($Str,$outputmode,$show);
 }
 
 ###############################################
@@ -321,10 +255,8 @@
 sub BuildProblemStatisticsPage {
     my ($r,$c)=@_;
     #
-    $output_mode = 'html';
-    $show = 'grouped';
-    #
-    $r->print(&CreateInterface());
+    my ($interface,$output_mode,$show) = &CreateInterface();
+    $r->print($interface);
     $r->print('<input type="hidden" name="statsfirstcall" value="no" />');
     $r->print('<input type="hidden" name="sortby" value="'.$ENV{'form.sortby'}.
               '" />');
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.79 loncom/interface/lonstatistics.pm:1.80
--- loncom/interface/lonstatistics.pm:1.79	Wed Aug 27 17:33:33 2003
+++ loncom/interface/lonstatistics.pm	Fri Aug 29 17:11:25 2003
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstatistics.pm,v 1.79 2003/08/27 21:33:33 matthew Exp $
+# $Id: lonstatistics.pm,v 1.80 2003/08/29 21:11:25 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -795,6 +795,72 @@
     }
     $Str .= "</select>\n";
     return $Str;
+}
+
+#######################################################
+#######################################################
+
+=pod
+
+=item &CreateAndParseOutputSelector()
+
+Construct a selection list of options for output and parse output selections.
+
+=cut
+
+#######################################################
+#######################################################
+sub OutputDescriptions {
+    my (@OutputOptions) = @_;
+    my $Str = '';
+    $Str .= "<h2>Output Modes</h2>\n";
+    $Str .= "<dl>\n";
+    foreach my $outputmode (@OutputOptions) {
+	$Str .="    <dt>".$outputmode->{'name'}."</dt>\n";
+	$Str .="        <dd>".$outputmode->{'description'}."</dd>\n";
+    }
+    $Str .= "</dl>\n";
+    return $Str;
+}
+
+sub CreateAndParseOutputSelector {
+    my ($elementname,$default,@OutputOptions) = @_;
+    my $output_mode;
+    my $show;
+    my $Str = '';
+    #
+    # Format for output options is 'mode, restrictions';
+    my $selected = $default;
+    if (exists($ENV{'form.'.$elementname})) {
+        if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) {
+            $selected = $ENV{'form.'.$elementname}->[0];
+        } else {
+            $selected = $ENV{'form.'.$elementname};
+        }
+    }
+    #
+    # Set package variables describing output mode
+    $output_mode = 'html';
+    $show        = 'all';
+    foreach my $option (@OutputOptions) {
+        next if ($option->{'value'} ne $selected);
+        $output_mode = $option->{'mode'};
+        $show        = $option->{'show'};
+    }
+    #
+    # Build the form element
+    $Str = qq/<select size="5" name="$elementname">/;
+    foreach my $option (@OutputOptions) {
+        if (exists($option->{'special'}) && 
+            $option->{'special'} =~ /do not show/) {
+            next;
+        }
+        $Str .= "\n".'    <option value="'.$option->{'value'}.'"';
+        $Str .= " selected " if ($option->{'value'} eq $selected);
+        $Str .= ">".$option->{'name'}."<\/option>";
+    }
+    $Str .= "\n</select>";
+    return ($Str,$output_mode,$show);
 }
 
 ###############################################

--matthew1062191485--