[LON-CAPA-cvs] cvs: loncom /homework grades.pm

www lon-capa-cvs-allow@mail.lon-capa.org
Sat, 16 Jun 2007 23:00:10 -0000


www		Sat Jun 16 19:00:10 2007 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  All that's left to do is store the grade ...
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.414 loncom/homework/grades.pm:1.415
--- loncom/homework/grades.pm:1.414	Sat Jun 16 16:24:25 2007
+++ loncom/homework/grades.pm	Sat Jun 16 19:00:09 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.414 2007/06/16 20:24:25 www Exp $
+# $Id: grades.pm,v 1.415 2007/06/16 23:00:09 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -6463,7 +6463,9 @@
 # Get correct result
 # FIXME: Possibly need delimiter other than ":"
     my @correct=();
-    if ($env{'form.gradingmechanism'} ne 'attendance') {
+    my $gradingmechanism=$env{'form.gradingmechanism'};
+    my $number=$env{'form.number'};
+    if ($gradingmechanism ne 'attendance') {
        foreach my $key (keys(%env)) {
           if ($key=~/^form\.correct\:/) {
              my @input=split(/\,/,$env{$key});
@@ -6479,7 +6481,7 @@
              }
           }
        }
-       for (my $i=0;$i<$env{'form.number'};$i++) {
+       for (my $i=0;$i<$number;$i++) {
           if (!$correct[$i]) {
              $result.='<br /><span class="LC_error">'.
                       &mt('No correct result given for question "[_1]"!',
@@ -6489,6 +6491,31 @@
        $result.='<br />'.&mt("Correct answer: [_1]",join(', ',map { ($_?$_:'-') } @correct));
     }
 # Start grading
+    my $pcorrect=$env{'form.pcorrect'};
+    my $pincorrect=$env{'form.pincorrect'};
+    foreach my $key (keys(%env)) {
+       if ($key=~/^form\.student\:(.*)$/) {
+          my $user=$1;
+          my @answer=split(/\,/,$env{$key});
+          my $sum=0;
+          for (my $i=0;$i<$number;$i++) {
+             if ($answer[$i]) {
+                if ($gradingmechanism eq 'attendance') {
+                   $sum+=$pcorrect;
+                } else {
+                   if ($answer[$i] eq $correct[$i]) {
+                      $sum+=$pcorrect;
+                   } else {
+                      $sum+=$pincorrect;
+                   }
+                }
+             }
+          }
+          my $ave=$sum/$number;
+          $result.='<br />'.$user.' - '.$env{$key}.': '.$ave;
+       }
+    }
+# We are done
     $result.='</td></tr></table>'."\n".
              '</td></tr></table><br /><br />'."\n";
     return $result.&show_grading_menu_form($symb);