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

matthew lon-capa-cvs@mail.lon-capa.org
Fri, 16 Jan 2004 20:19:33 -0000


This is a MIME encoded message

--matthew1074284373
Content-Type: text/plain

matthew		Fri Jan 16 15:19:33 2004 EDT

  Modified files:              
    /loncom/interface/statistics	lonproblemanalysis.pm 
  Log:
  Implement basic radio response analysis.
  
  
--matthew1074284373
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20040116151933.txt"

Index: loncom/interface/statistics/lonproblemanalysis.pm
diff -u loncom/interface/statistics/lonproblemanalysis.pm:1.55 loncom/interface/statistics/lonproblemanalysis.pm:1.56
--- loncom/interface/statistics/lonproblemanalysis.pm:1.55	Fri Jan 16 10:35:04 2004
+++ loncom/interface/statistics/lonproblemanalysis.pm	Fri Jan 16 15:19:33 2004
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonproblemanalysis.pm,v 1.55 2004/01/16 15:35:04 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.56 2004/01/16 20:19:33 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -159,14 +159,11 @@
                                     '.'.
                                     $current_problem->{'respid'}};
             if ($current_problem->{'resptype'} eq 'option') {
-                &OptionResponseAnalysis($r,$resource,
-                                        $current_problem->{'respid'},
+                &OptionResponseAnalysis($r,$current_problem,
                                         $ProblemData,
                                         \@Students);
             } elsif ($current_problem->{'resptype'} eq 'radiobutton') {
-                &RadioResponseAnalysis($r,$resource,
-                                       $current_problem->{'part'},
-                                       $current_problem->{'respid'},
+                &RadioResponseAnalysis($r,$current_problem,
                                        $ProblemData,
                                        \@Students);
             } else {
@@ -183,9 +180,6 @@
     }
 }
 
-=pod
-
-Removed code:
 
 #########################################################
 #########################################################
@@ -195,7 +189,9 @@
 #########################################################
 #########################################################
 sub RadioResponseAnalysis {
-    my ($r,$resource,$part,$respid,$ProblemData,$Students) = @_;
+    my ($r,$problem,$ProblemData,$Students) = @_;
+    my ($resource,$respid) = ($problem->{'resource'},
+                                    $problem->{'respid'});
     my $analysis_html;
     my $PerformanceData = 
         &Apache::loncoursedata::get_response_data
@@ -209,14 +205,14 @@
         return;
     }
     if (exists($ENV{'form.ExcelOutput'})) {
-        $analysis_html .= &RR_Excel_output($r,$resource,$PerformanceData,
-                                          $ProblemData);
+        $analysis_html .= &RR_Excel_output($r,$problem->{'resource'},
+                                           $PerformanceData,$ProblemData);
     } elsif ($ENV{'form.AnalyzeOver'} eq 'Tries') {
-        $analysis_html .= &RR_Tries_Analysis($r,$resource,$PerformanceData,
-                                           $ProblemData);
+        $analysis_html .= &RR_Tries_Analysis($r,$problem->{'resource'},
+                                             $PerformanceData,$ProblemData);
     } elsif ($ENV{'form.AnalyzeOver'} eq 'Time') {
-        $analysis_html .= &RR_Time_Analysis($r,$resource,$PerformanceData,
-                                           $ProblemData);
+        $analysis_html .= &RR_Time_Analysis($r,$problem->{'resource'},
+                                            $PerformanceData,$ProblemData);
     } else {
         $analysis_html .= '<h2>'.
            &mt('The analysis you have selected is not supported at this time').
@@ -225,7 +221,6 @@
     $r->print($analysis_html);
 }
 
-
 sub RR_Excel_output   { 
     my ($r,$PerformanceData,$ProblemData) = @_;
     return '<h1>No!</h1>';
@@ -246,15 +241,15 @@
     }
     $analysis_html .= $table;
     my @TryData = &RR_tries_data_analysis($r,$PerformanceData);
-    if ($ENV{'form.AnalyzeAs'} eq 'Foils') {
-        $analysis_html = &RR_Tries_Foil_Analysis($mintries,$maxtries,$Foils,
+#    if ($ENV{'form.AnalyzeAs'} eq 'Foils') {
+        $analysis_html .= &RR_Tries_Foil_Analysis($mintries,$maxtries,$Foils,
                                                  \@TryData,$ProblemData);
-    } else {
-        $analysis_html = &RR_Tries_Concept_Analysis($mintries,$maxtries,
-                                                    $Concepts,
-                                                    \@TryData,
-                                                    $ProblemData);
-    }
+#    } else {
+#        $analysis_html = &RR_Tries_Concept_Analysis($mintries,$maxtries,
+#                                                    $Concepts,
+#                                                    \@TryData,
+#                                                    $ProblemData);
+#    }
     return $analysis_html;
 }
 
@@ -284,8 +279,8 @@
         my @PlotData_Correct; 
         my @PlotData_Incorrect;
         next if ($try > scalar(@{$TryData}));
-        next if (! defined($TryData->[$try-1]));
-        my %DataSet = %{$TryData->[$try-1]};
+        next if (! defined($TryData->[$try]));
+        my %DataSet = %{$TryData->[$try]};
         my $total = 0;
         foreach my $foilid (@$Foils) {
             $total += $DataSet{$foilid};
@@ -316,7 +311,6 @@
                                                   \@PlotData_Correct,
                                                   \@PlotData_Incorrect);
     }
-    &Apache::lonnet::logthis('plot = '.$html);
     return $html;
 }
 
@@ -339,14 +333,12 @@
 }
 
 
-
 sub get_Radio_problem_data {
     my ($url) = @_;
     my $Answ=&Apache::lonnet::ssi($url,('grade_target' => 'analyze'));
     (my $garbage,$Answ)=split('_HASH_REF__',$Answ,2);
     my %Answer = &Apache::lonnet::str2hash($Answ);
     my %Partdata;
-    &Apache::lonnet::logthis('url = '.$url);
     foreach my $part (@{$Answer{'parts'}}) {
         while (my($key,$value) = each(%Answer)) {
 #            if (ref($value) eq 'ARRAY') {
@@ -372,9 +364,6 @@
     return %Partdata;
 }
 
-=cut
-
-
 #########################################################
 #########################################################
 ##
@@ -383,7 +372,10 @@
 #########################################################
 #########################################################
 sub OptionResponseAnalysis {
-    my ($r,$resource,$respid,$ProblemData,$Students) = @_;
+    my ($r,$problem,$ProblemData,$Students) = @_;
+    my ($resource,$respid) = ($problem->{'resource'},
+                              $problem->{'respid'});
+    # Note: part data is not needed.
     my $PerformanceData = 
         &Apache::loncoursedata::get_response_data
         ($Students,$resource->{'symb'},$respid);
@@ -1517,8 +1509,8 @@
                 for (my $i=0;$i<scalar(@{$partdata->{'ResponseTypes'}});$i++){
                     my $respid = $partdata->{'ResponseIds'}->[$i];
                     my $resptype = $partdata->{'ResponseTypes'}->[$i];
-                    if ($resptype eq 'option' ){
-#                    if ($resptype eq 'option' || $resptype eq 'radiobutton') {
+#                    if ($resptype eq 'option' ){
+                    if ($resptype eq 'option' || $resptype eq 'radiobutton') {
                         my $value = &make_target_id({symb=>$res->{'symb'},
                                                      part=>$part,
                                                      respid=>$respid,
@@ -1533,7 +1525,8 @@
                         }
                         $seq_str .= '<tr><td>'.
   '<input type="radio" name="problemchoice" value="'.$value.'" '.$checked.'/>'.
-  '</td><td>'.
+  '</td><td>'.          
+#.$resptype.'</td><td>'.
   '<a href="'.$res->{'src'}.'">'.$title.'</a> ';
 #  '<a href="'.$res->{'src'}.'">'.$resptype.' '.$res->{'title'}.'</a> ';
                         if ($partdata->{'option'} > 1) {
@@ -1594,7 +1587,8 @@
                 for (my $i=0;$i<scalar(@{$partdata->{'ResponseTypes'}});$i++){
                     my $respid = $partdata->{'ResponseIds'}->[$i];
                     my $resptype = $partdata->{'ResponseTypes'}->[$i];
-                    next if ($resptype ne 'option');
+                    next if ($resptype ne 'option' && 
+                             $resptype ne 'radiobutton');
                     push (@Resource,
                             { symb     => $res->{symb},
                               part     => $part,

--matthew1074284373--