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

matthew lon-capa-cvs@mail.lon-capa.org
Thu, 11 Mar 2004 19:34:11 -0000


matthew		Thu Mar 11 14:34:11 2004 EDT

  Modified files:              
    /loncom/interface/statistics	lonproblemanalysis.pm 
  Log:
  &OR_Tries_Foil_Analysis: Variable name cleanup,  Use $Concepts instead
  of $Foils for looping.
  
  
Index: loncom/interface/statistics/lonproblemanalysis.pm
diff -u loncom/interface/statistics/lonproblemanalysis.pm:1.74 loncom/interface/statistics/lonproblemanalysis.pm:1.75
--- loncom/interface/statistics/lonproblemanalysis.pm:1.74	Mon Mar  1 11:39:19 2004
+++ loncom/interface/statistics/lonproblemanalysis.pm	Thu Mar 11 14:34:10 2004
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonproblemanalysis.pm,v 1.74 2004/03/01 16:39:19 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.75 2004/03/11 19:34:10 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -99,7 +99,7 @@
     }
     $r->rflush();
     #
-    my $problem_types = '(option|radiobutton|numerical)';
+    my $problem_types = '(option|radiobutton)';
     if (exists($ENV{'form.problemchoice'}) && 
         ! exists($ENV{'form.SelectAnother'})) {
         foreach my $button (@SubmitButtons) {
@@ -552,7 +552,7 @@
                                                      $mintries,$maxtries);
     my $analysis = '';
     if ($ENV{'form.AnalyzeAs'} eq 'Foils') {
-        $analysis = &OR_Tries_Foil_Analysis($mintries,$maxtries,$Foils,
+        $analysis = &OR_Tries_Foil_Analysis($mintries,$maxtries,$Concepts,
                                          \%ResponseData,$ORdata);
     } else {
         $analysis = &OR_Tries_Concept_Analysis($mintries,$maxtries,
@@ -563,34 +563,36 @@
 }
 
 sub OR_Tries_Foil_Analysis {
-    my ($mintries,$maxtries,$Foils,$respdat,$ORdata) = @_;
+    my ($mintries,$maxtries,$Concepts,$respdat,$ORdata) = @_;
     my %ResponseData = %$respdat;
     #
     # Compute the data neccessary to make the plots
     my @PlotData; 
-    foreach my $foilid (@$Foils) {
-        for (my $i=$mintries;$i<=$maxtries;$i++) {
-            if ($ResponseData{$foilid}->[$i]->{'_total'} == 0) {
-                push(@{$PlotData[$i]->{'_correct'}},0);
-            } else {
-                push(@{$PlotData[$i]->{'_correct'}},
-                     100*$ResponseData{$foilid}->[$i]->{'_correct'}/
-                     $ResponseData{$foilid}->[$i]->{'_total'});
-            }
-            foreach my $option (@{$ORdata->{'_Options'}}) {
-                push(@{$PlotData[$i]->{'_total'}},
-                     $ResponseData{$foilid}->[$i]->{'_total'});
+    foreach my $concept (@$Concepts) {
+        foreach my $foilid (@{$concept->{'foils'}}) {
+            for (my $i=$mintries;$i<=$maxtries;$i++) {
                 if ($ResponseData{$foilid}->[$i]->{'_total'} == 0) {
-                    push (@{$PlotData[$i]->{$option}},0);
+                    push(@{$PlotData[$i]->{'_correct'}},0);
                 } else {
-                    if ($ResponseData{$foilid}->[$i]->{'_total'} ==
-                        $ResponseData{$foilid}->[$i]->{'_correct'}) {
-                        push(@{$PlotData[$i]->{$option}},0);
+                    push(@{$PlotData[$i]->{'_correct'}},
+                         100*$ResponseData{$foilid}->[$i]->{'_correct'}/
+                         $ResponseData{$foilid}->[$i]->{'_total'});
+                }
+                foreach my $option (@{$ORdata->{'_Options'}}) {
+                    push(@{$PlotData[$i]->{'_total'}},
+                         $ResponseData{$foilid}->[$i]->{'_total'});
+                    if ($ResponseData{$foilid}->[$i]->{'_total'} == 0) {
+                        push (@{$PlotData[$i]->{$option}},0);
                     } else {
-                        push (@{$PlotData[$i]->{$option}},
+                        if ($ResponseData{$foilid}->[$i]->{'_total'} ==
+                            $ResponseData{$foilid}->[$i]->{'_correct'}) {
+                            push(@{$PlotData[$i]->{$option}},0);
+                        } else {
+                            push (@{$PlotData[$i]->{$option}},
                               100 * $ResponseData{$foilid}->[$i]->{$option} / 
                               ($ResponseData{$foilid}->[$i]->{'_total'} - 
                                $ResponseData{$foilid}->[$i]->{'_correct'}));
+                        }
                     }
                 }
             }
@@ -599,9 +601,9 @@
     # 
     # Build a table for the plots
     my $analysis_html = "<table>\n";
-    my $foilkey = &build_option_index($ORdata);
-    for (my $i=$mintries;$i<=$maxtries;$i++) {
-        my $count = $ResponseData{'_total'}->[$i];
+    my $optionkey = &build_option_index($ORdata);
+    for (my $try=$mintries;$try<=$maxtries;$try++) {
+        my $count = $ResponseData{'_total'}->[$try];
         if ($count == 0) {
             $count = 'no submissions';
         } elsif ($count == 1) {
@@ -609,23 +611,25 @@
         } else {
             $count = $count.' submissions';
         }
-        my $title = 'Attempt '.$i.', '.$count;
+        my $title = 'Attempt '.$try.', '.$count;
         my @Datasets;
         foreach my $option ('_correct',@{$ORdata->{'_Options'}}) {
-            next if (! exists($PlotData[$i]->{$option}));
-            push(@Datasets,$PlotData[$i]->{$option});
+            next if (! exists($PlotData[$try]->{$option}));
+            push(@Datasets,$PlotData[$try]->{$option});
         }
         my $correctgraph = &Apache::loncommon::DrawBarGraph
             ($title,'Foil Number','Percent Correct',
              100,$plotcolors,undef,$Datasets[0]);
         $analysis_html.= '<tr><td>'.$correctgraph.'</td>';
-        ##
-        ##
+        
+        #
+        #
         next if (! defined($Datasets[0]));
         for (my $i=0; $i< scalar(@{$Datasets[0]});$i++) {
             $Datasets[0]->[$i]=0;
         }
-        $count = $ResponseData{'_total'}->[$i]-$ResponseData{'_correct'}->[$i];
+        $count = $ResponseData{'_total'}->[$try] - 
+                                           $ResponseData{'_correct'}->[$try];
         if ($count == 0) {
             $count = 'no submissions';
         } elsif ($count == 1) {
@@ -633,12 +637,12 @@
         } else {
             $count = $count.' submissions';
         }
-        $title = 'Attempt '.$i.', '.$count;
+        $title = 'Attempt '.$try.', '.$count;
         my $incorrectgraph = &Apache::loncommon::DrawBarGraph
             ($title,'Foil Number','% Option Chosen Incorrectly',
              100,$plotcolors,undef,@Datasets);
         $analysis_html.= '<td>'.$incorrectgraph.'</td>';
-        $analysis_html.= '<td>'.$foilkey."<td></tr>\n";
+        $analysis_html.= '<td>'.$optionkey."<td></tr>\n";
     }
     $analysis_html .= "</table>\n";
     return $analysis_html;