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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 10 Nov 2003 16:28:10 -0000


albertel		Mon Nov 10 11:28:10 2003 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  - if you only set the score on 1 part of a multipart problem, it actually got thrown away (BUG#2102)
  - removed most of the
     perl_code if(); formulations as they were hard to read
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.152 loncom/homework/grades.pm:1.153
--- loncom/homework/grades.pm:1.152	Fri Nov  7 14:25:26 2003
+++ loncom/homework/grades.pm	Mon Nov 10 11:28:10 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.152 2003/11/07 19:25:26 albertel Exp $
+# $Id: grades.pm,v 1.153 2003/11/10 16:28:10 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2007,28 +2007,37 @@
 	    $pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ? 
 		    $ENV{'form.GD_BOX'.$newflg.'_'.$_} : 
 		    $ENV{'form.RADVAL'.$newflg.'_'.$_});
-	    return 'no_score' if ($pts eq '' && $ENV{'form.GD_SEL'.$newflg.'_'.$_} eq '');
+	    if ($pts eq '' && $ENV{'form.GD_SEL'.$newflg.'_'.$_} eq '') {
+		next;
+	    }
 	    $wgt = $ENV{'form.WGT'.$newflg.'_'.$_} eq '' ? 1 : 
 		$ENV{'form.WGT'.$newflg.'_'.$_};
 	    my $partial= $pts/$wgt;
-	    next if ($partial eq $record{'resource.'.$_.'.awarded'}); #do not update score for part if not changed.
-	    $newrecord{'resource.'.$_.'.awarded'}  = $partial 
-		if ($record{'resource.'.$_.'.awarded'} ne $partial);
+	    if ($partial eq $record{'resource.'.$_.'.awarded'}) {
+		#do not update score for part if not changed.
+		next;
+	    }
+	    if ($record{'resource.'.$_.'.awarded'} ne $partial) {
+		$newrecord{'resource.'.$_.'.awarded'}  = $partial;
+	    }
 	    my $reckey = 'resource.'.$_.'.solved';
 	    if ($partial == 0) {
-		$newrecord{$reckey} = 'incorrect_by_override' 
-		    if ($record{$reckey} ne 'incorrect_by_override');
+		if ($record{$reckey} ne 'incorrect_by_override') {
+		    $newrecord{$reckey} = 'incorrect_by_override';
+		}
 	    } else {
-		$newrecord{$reckey} = 'correct_by_override' 
-		    if ($record{$reckey} ne 'correct_by_override');
+		if ($record{$reckey} ne 'correct_by_override') {
+		    $newrecord{$reckey} = 'correct_by_override';
+		}
+	    }	    
+	    if ($submitter && 
+		($record{'resource.'.$_.'.submitted_by'} ne $submitter)) {
+		$newrecord{'resource.'.$_.'.submitted_by'} = $submitter;
 	    }
-	    
-	    $newrecord{'resource.'.$_.'.submitted_by'} = $submitter 
-		if ($submitter && ($record{'resource.'.$_.'.submitted_by'} ne $submitter));
-	    $newrecord{'resource.'.$_.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
+	    $newrecord{'resource.'.$_.'.regrader'}=
+		"$ENV{'user.name'}:$ENV{'user.domain'}";
 	}
     }
-
     if (scalar(keys(%newrecord)) > 0) {
 	&Apache::lonnet::cstore(\%newrecord,$symb,
 				$ENV{'request.course.id'},$domain,$stuname);