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

matthew lon-capa-cvs@mail.lon-capa.org
Tue, 01 Apr 2003 16:53:50 -0000


matthew		Tue Apr  1 11:53:50 2003 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm 
  Log:
  Modified &get_problem_statistics to return a hash reference.
  
  
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.65 loncom/interface/loncoursedata.pm:1.66
--- loncom/interface/loncoursedata.pm:1.65	Fri Mar 28 13:14:59 2003
+++ loncom/interface/loncoursedata.pm	Tue Apr  1 11:53:50 2003
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursedata.pm,v 1.65 2003/03/28 18:14:59 bowersj2 Exp $
+# $Id: loncoursedata.pm,v 1.66 2003/04/01 16:53:50 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1163,27 +1163,31 @@
 
 =back
 
-Outputs: See the code for up to date information.
+Outputs: See the code for up to date information.  A hash reference is
+returned.  The hash has the following keys defined:
 
 =over 4
 
-=item $num The number of students attempting the problem
+=item num_students The number of students attempting the problem
+      
+=item tries The total number of tries for the students
+      
+=item max_tries The maximum number of tries taken
+      
+=item mean_tries The average number of tries
+      
+=item num_solved The number of students able to solve the problem
+      
+=item num_override The number of students whose answer is 'correct_by_override'
+      
+=item deg_of_diff The degree of difficulty of the problem
+      
+=item std_tries The standard deviation of the number of tries
+      
+=item skew_tries The skew of the number of tries
 
-=item $tries The total number of tries for the students
-
-=item $mod The maximum number of tries taken
-
-=item $mean The average number of tries
-
-=item $Solved The number of students able to solve the problem
-
-=item $solved The number of students whose answer is 'correct_by_override'
-
-=item $DegOfDiff The degree of difficulty of the problem
-
-=item $STD The standard deviation of the number of tries
-
-=item $SKEW The skew of the number of tries
+=item per_wrong The number of students attempting the problem who were not
+able to answer it correctly.
 
 =back
 
@@ -1247,17 +1251,28 @@
     $solved = 0 if (! defined($solved));
     #
     my $DegOfDiff = 'nan';
-    $DegOfDiff = 1-($Solved + $solved)/$tries if ($tries>0);
+    $DegOfDiff = 1-($Solved)/$tries if ($tries>0);
 
     my $SKEW = 'nan';
+    my $wrongpercent = 0;
     if ($num > 0) {
         ($SKEW) = &execute_SQL_request($dbh,'SELECT SQRT(SUM('.
                                      'POWER(tries - '.$STD.',3)'.
                                      '))/'.$num.' FROM '.$stats_table);
+        $wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10;
     }
     #
     $dbh->do('DROP TABLE '.$stats_table);  # May return an error
-    return ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,$SKEW);
+    return { num_students => $num,
+             tries        => $tries,
+             max_tries    => $mod,
+             mean_tries   => $mean,
+             std_tries    => $STD,
+             skew_tries   => $SKEW,
+             num_solved   => $Solved,
+             num_override => $solved,
+             per_wrong    => $wrongpercent,
+             deg_of_diff  => $DegOfDiff }
 }
 
 sub execute_SQL_request {