version 1.103, 2005/09/26 21:39:53
|
version 1.106, 2005/12/20 20:00:42
|
Line 182 sub caparesponse_check {
|
Line 182 sub caparesponse_check {
|
|
|
sub caparesponse_check_list { |
sub caparesponse_check_list { |
my $response=$LONCAPA::CAPAresponse_args{'response'}; |
my $response=$LONCAPA::CAPAresponse_args{'response'}; |
my ($result,@list); |
my $result="Got response :".join(':',@LONCAPA::CAPAresponse_answer).":\n"; |
@list=@LONCAPA::CAPAresponse_answer; |
&LONCAPA_INTERNAL_DEBUG("args ".join(':',%LONCAPA::CAPAresponse_args)); |
my $aresult=''; |
|
my $current_answer; |
|
my $answers=join(':',@list); |
|
$result.="Got response :$answers:\n"; |
|
&LONCAPA_INTERNAL_DEBUG("<blink>Yo!</blink> got ".join(':',%LONCAPA::CAPAresponse_args)); |
|
my @responselist; |
my @responselist; |
my $type = $LONCAPA::CAPAresponse_args{'type'}; |
my $type = $LONCAPA::CAPAresponse_args{'type'}; |
$result.="Got type :$type:\n"; |
$result.="Got type :$type:\n"; |
if ($type ne '' && $#list > 0) { |
if ($type ne '' && $#LONCAPA::CAPAresponse_answer > 0) { |
(@responselist)=split /,/,$response; |
(@responselist)=split(/,/,$response); |
|
if (@responselist < @LONCAPA::CAPAresponse_answer) { |
|
return 'MISSING_ANSWER'; |
|
} |
|
if (@responselist > @LONCAPA::CAPAresponse_answer) { |
|
return 'EXTRA_ANSWER'; |
|
} |
} else { |
} else { |
(@responselist)=($response); |
(@responselist)=($response); |
} |
} |
my $unit=''; |
|
$result.="Initial final response :$responselist['-1']:\n"; |
$result.="Initial final response :$responselist['-1']:\n"; |
|
my $unit; |
if ($type eq '' || $type eq 'float') { |
if ($type eq '' || $type eq 'float') { |
#for numerical problems split off the unit |
#for numerical problems split off the unit |
if ( $responselist['-1']=~ /(.*[^\s])\s+([^\s]+)/ ) { |
if ( $responselist['-1']=~ /(.*[^\s])\s+([^\s]+)/ ) { |
Line 207 sub caparesponse_check_list {
|
Line 208 sub caparesponse_check_list {
|
} |
} |
} |
} |
$result.="Final final response :$responselist['-1']:$unit:\n"; |
$result.="Final final response :$responselist['-1']:$unit:\n"; |
$result.=":$#list: answers\n"; |
|
$unit=~s/\s//; |
$unit=~s/\s//; |
my $i=0; |
|
my $awards=''; |
my ($awards, @msgs, $i); |
my @msgs; |
foreach my $thisanswer (@LONCAPA::CAPAresponse_answer) { |
for ($i=0; $i<@list;$i++) { |
my ($msg,$aresult); |
my $msg; |
|
$result.="trying answer :$list[$i]:\n"; |
|
my $thisanswer=$list[$i]; |
|
$result.="trying answer :$thisanswer:\n"; |
$result.="trying answer :$thisanswer:\n"; |
if ($unit eq '') { |
if (defined($thisanswer)) { |
($aresult,$msg)=&caparesponse_check($thisanswer,$responselist[$i]); |
if ($unit eq '') { |
|
($aresult,$msg)=&caparesponse_check($thisanswer, |
|
$responselist[$i]); |
|
} else { |
|
($aresult,$msg)=&caparesponse_check($thisanswer, |
|
$responselist[$i]." $unit"); |
|
} |
} else { |
} else { |
($aresult,$msg)=&caparesponse_check($thisanswer, |
$aresult='ERROR'; |
$responselist[$i]." $unit"); |
$msg='answer was undefined'; |
} |
} |
my ($temp)=split /:/, $aresult; |
&LONCAPA_INTERNAL_DEBUG("after if $aresult -- $msg"); |
|
my ($temp)=split(/:/, $aresult); |
$awards.="$temp,"; |
$awards.="$temp,"; |
$result.=$aresult; |
$result.=$aresult; |
push(@msgs,$msg); |
push(@msgs,$msg); |
|
$i++; |
} |
} |
chop $awards; |
chop($awards); |
return ("$awards:\n$result",@msgs); |
return ("$awards:\n$result",@msgs); |
} |
} |
|
|