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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 09 Feb 2004 19:43:22 -0000


albertel		Mon Feb  9 14:43:22 2004 EDT

  Modified files:              
    /loncom/homework	matchresponse.pm 
  Log:
  - 'submission' string for <mathcresponse> now correct
  - properly handles <matchresponse> for partial correctness
  
  
Index: loncom/homework/matchresponse.pm
diff -u loncom/homework/matchresponse.pm:1.33 loncom/homework/matchresponse.pm:1.34
--- loncom/homework/matchresponse.pm:1.33	Mon Feb  9 14:38:00 2004
+++ loncom/homework/matchresponse.pm	Mon Feb  9 14:43:22 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Full matching style response
 #
-# $Id: matchresponse.pm,v 1.33 2004/02/09 19:38:00 albertel Exp $
+# $Id: matchresponse.pm,v 1.34 2004/02/09 19:43:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -314,7 +314,7 @@
     }
     my @items;
     foreach my $name (@whichfoils) {
-	my $response = &Apache::response::getresponse($temp);
+	my $response = &Apache::response::getresponse($temp,'letter');
 	push(@items,$response);
 	my $responsename = $letter_name_map{$response};
 	my $value=$Apache::response::foilgroup{$name.'.value'};
@@ -338,26 +338,41 @@
     my $gradestr   =&Apache::lonnet::hash2str(%grade);
     my %previous=&Apache::response::check_for_previous($responsestr,$part,$id);
     &Apache::lonxml::debug("Got $right right and $wrong wrong, and $ignored were ignored ");
-    my $ad;
-    if ($wrong==0 && $ignored==0) {
-	$ad='EXACT_ANS';
-    } elsif ($wrong==0 && $right==0) {
-	#nothing submitted
-    } else {
-	if ($ignored==0) {
-	    $ad='INCORRECT';
-	} else {
-	    $ad='MISSING_ANSWER';
-	}
-    }
     $Apache::lonhomework::results{"resource.$part.$id.submission"}=
 	$responsestr;
     $Apache::lonhomework::results{"resource.$part.$id.submissionitems"}=
 	$itemstr;
     $Apache::lonhomework::results{"resource.$part.$id.submissiongrading"}=
 	$gradestr;
-    $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
-    &Apache::response::handle_previous(\%previous,$ad);
+    if (!$Apache::lonhomework::scantronmode) {
+	my $ad;
+	if ($wrong==0 && $ignored==0) {
+	    $ad='EXACT_ANS';
+	} elsif ($wrong==0 && $right==0) {
+	    #nothing submitted
+	} else {
+	    if ($ignored==0) {
+		$ad='INCORRECT';
+	    } else {
+		$ad='MISSING_ANSWER';
+	    }
+	}
+	$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
+	&Apache::response::handle_previous(\%previous,$ad);
+    } else {
+	my $ad;
+	if ($wrong==0 && $right==0) {
+	    #nothing submitted
+	} else {
+	    $ad='ASSIGNED_SCORE';
+	    $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=
+		$ad;
+	    $Apache::lonhomework::results{"resource.$part.$id.awarded"}=
+		$right/(scalar(@whichopt));
+	    $Apache::lonhomework::results{"resource.$part.$id.numfoils"}=
+		scalar(@whichopt);
+	}
+    }
 }
 
 sub itemdisplay {