--- loncom/homework/matchresponse.pm 2003/11/07 08:52:20 1.30 +++ loncom/homework/matchresponse.pm 2004/02/09 19:47:53 1.35 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Full matching style response # -# $Id: matchresponse.pm,v 1.30 2003/11/07 08:52:20 albertel Exp $ +# $Id: matchresponse.pm,v 1.35 2004/02/09 19:47:53 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}; - $responsehash{$name}=$responsename; my $value=$Apache::response::foilgroup{$name.'.value'}; if ( $response =~ /[^\s]/) { - &Apache::lonxml::debug("submitted a $response for $value
\n"); + $responsehash{$name}=$responsename; + &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(@whichfoils)); + $Apache::lonhomework::results{"resource.$part.$id.numfoils"}= + scalar(@whichfoils); + } + } } sub itemdisplay { @@ -465,11 +480,19 @@ sub displayfoils { } elsif ($result=&itemdisplay('bottom')) { $result=$question.$result; } elsif ($result=&itemdisplay('right')) { - $result='
'.$question.''.$result. - '
'; + if ($target ne 'tex') { + $result='
'.$question.''.$result. + '
'; + } else { + $result='\begin{tabular}{p{\textwidth/2}p{\textwidth/2}}\begin{minipage}{\textwidth/2}'.$question.'\end{minipage}&\begin{minipage}{\textwidth/2}'.$result.'\end{minipage}\end{tabular}'; + } } elsif ($result=&itemdisplay('left')) { - $result='
'.$result.''.$question. - '
'; + if ($target ne 'tex') { + $result='
'.$result.''.$question. + '
'; + } else { + $result='\begin{tabular}{p{\textwidth/2}p{\textwidth/2}}\begin{minipage}{\textwidth/2}'.$result.'\end{minipage}&\begin{minipage}{\textwidth/2}'.$question.'\end{minipage}\end{tabular}'; + } } if ($target ne 'tex') {$result.="
";} else {$result.=' \\\\ ';} return $result;