--- loncom/homework/matchresponse.pm 2004/01/06 20:16:17 1.32
+++ loncom/homework/matchresponse.pm 2004/02/09 19:43:22 1.34
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Full matching style response
#
-# $Id: matchresponse.pm,v 1.32 2004/01/06 20:16:17 sakharuk Exp $
+# $Id: matchresponse.pm,v 1.34 2004/02/09 19:43:22 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -306,7 +306,7 @@ sub grade_response {
if (!defined($ENV{'form.submitted'})) { return; }
my %responsehash;
my %grade;
- my ($temp,$right,$wrong,$ignored)=(0,0,0,0);
+ my ($temp,$right,$wrong,$ignored)=(1,0,0,0);
my %letter_name_map;
if (defined(%{ $Apache::response::itemgroup{'letter_name_map'} })) {
%letter_name_map=
@@ -314,13 +314,13 @@ sub grade_response {
}
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'};
if ( $response =~ /[^\s]/) {
$responsehash{$name}=$responsename;
- &Apache::lonxml::debug("submitted a $response for $value
\n");
+ &Apache::lonxml::debug("submitted a $response($responsename) for $value
\n");
if ($value eq $responsename) {
$grade{$name}='1'; $right++;
} else {
@@ -338,26 +338,41 @@ sub grade_response {
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 {