version 1.241, 2010/10/14 19:55:04
|
version 1.244, 2011/01/25 04:30:13
|
Line 451 sub check_submission {
|
Line 451 sub check_submission {
|
my ($result,@msgs) = |
my ($result,@msgs) = |
&Apache::run::run("&caparesponse_check_list()",$safeeval); |
&Apache::run::run("&caparesponse_check_list()",$safeeval); |
&Apache::lonxml::debug("checking $name $result with $response took ".&Time::HiRes::tv_interval($t0)); |
&Apache::lonxml::debug("checking $name $result with $response took ".&Time::HiRes::tv_interval($t0)); |
|
|
&Apache::lonxml::debug('msgs are '.join(':',@msgs)); |
&Apache::lonxml::debug('msgs are '.join(':',@msgs)); |
my ($awards)=split(/:/,$result); |
my ($awards)=split(/:/,$result); |
my @awards= split(/,/,$awards); |
my @awards= split(/,/,$awards); |
Line 1223 sub end_stringresponse {
|
Line 1224 sub end_stringresponse {
|
$$args_ref{'type'} = 'ci'; |
$$args_ref{'type'} = 'ci'; |
} |
} |
&add_in_tag_answer($parstack,$safeeval); |
&add_in_tag_answer($parstack,$safeeval); |
my (@final_awards,@final_msgs,@names); |
my (@final_awards,@final_msgs,@names,%ansstring); |
foreach my $name (keys(%answer)) { |
foreach my $name (keys(%answer)) { |
&Apache::lonxml::debug(" doing $name with ".join(':',@{ $answer{$name}{'answers'} })); |
&Apache::lonxml::debug(" doing $name with ".join(':',@{ $answer{$name}{'answers'} })); |
${$safeeval->varglob('LONCAPA::CAPAresponse_answer')}=dclone($answer{$name}); |
${$safeeval->varglob('LONCAPA::CAPAresponse_answer')}=dclone($answer{$name}); |
my ($result, @msgs)=&Apache::run::run("&caparesponse_check_list()",$safeeval); |
my ($result, @msgs)=&Apache::run::run("&caparesponse_check_list()",$safeeval); |
if ($$args_ref{'type'} =~ /^c[si]$/) { |
if ($$args_ref{'type'} =~ /^c[si]$/) { |
|
$ansstring{$name} = pop(@msgs); |
|
} |
|
if ($$args_ref{'type'} =~ /^c[si]$/) { |
|
my $control_chars_removed = pop(@msgs); |
my $error = pop(@msgs); |
my $error = pop(@msgs); |
if ($error ne '') { |
if (($error ne '') || |
my ($symb,$courseid,$domain,$name) = |
($control_chars_removed ne '')) { |
|
my ($symb,$courseid,$sdomain,$sname) = |
&Apache::lonnet::whichuser(); |
&Apache::lonnet::whichuser(); |
&Apache::lonnet::logthis("Stringresponse grading error: $error for $name:$domain in $courseid for part: $part response: $id and symb: $symb"); |
if ($control_chars_removed ne '') { |
|
my $showresponse = $response; |
|
if ($response =~ /[\000-\037]/) { |
|
$response =~ s/[\000-\037]//g; |
|
} |
|
if ($showresponse =~ /[\r\n\f]/) { |
|
my @lines = split(/[\r\n\f]+/,$showresponse); |
|
$showresponse = join('\\n',@lines); |
|
} |
|
&Apache::lonnet::logthis("Stringresponse grading: control characters stripped from submission ".$showresponse." for $sname:$sdomain in $courseid for part: $part response: $id and symb: $symb"); |
|
$Apache::lonhomework::results{"resource.$part.$id.submission"} = $response; |
|
} |
|
if ($error ne '') { |
|
&Apache::lonnet::logthis("Stringresponse grading error: $error for $sname:$sdomain in $courseid for part: $part response: $id and symb: $symb"); |
|
} |
} |
} |
} |
} |
&Apache::lonxml::debug('msgs are'.join(':',@msgs)); |
&Apache::lonxml::debug('msgs are'.join(':',@msgs)); |
Line 1250 sub end_stringresponse {
|
Line 1270 sub end_stringresponse {
|
&Apache::inputtags::finalizeawards(\@final_awards, |
&Apache::inputtags::finalizeawards(\@final_awards, |
\@final_msgs, |
\@final_msgs, |
\@names,1); |
\@names,1); |
|
if (keys(%ansstring) > 0) { |
|
$Apache::lonhomework::results{"resource.$part.$id.answerstring"} = &Apache::lonnet::hash2str(%ansstring); |
|
} |
} |
} |
if (($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' || |
if (($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' || |
$ad eq 'EXACT_ANS')) { |
$ad eq 'EXACT_ANS')) { |
Line 1263 sub end_stringresponse {
|
Line 1286 sub end_stringresponse {
|
$ad='ANONYMOUS_CREDIT'; |
$ad='ANONYMOUS_CREDIT'; |
} |
} |
} |
} |
unless ($env{'request.state'} eq 'construct') { |
unless (($env{'request.state'} eq 'construct') || |
if ($previous{'used'}) { |
($Apache::lonhomework::type eq 'randomizetry')) { |
if ($ad ne $previous{'award'} && $previous{'award'} ne '') { |
if (($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' || $ad eq 'EXACT_ANS')) { |
&stringresponse_gradechange($part,$id,\%previous, |
if ($previous{'used'}) { |
'cs',$response,$ad,$type); |
if ($ad ne $previous{'award'}) { |
} |
if (($previous{'award'} eq 'INCORRECT' || |
} elsif ($previous{'usedci'}) { |
$previous{'award'} eq 'APPROX_ANS' || |
if ($ad ne $previous{'awardci'} && $previous{'awardci'} ne '') { |
$previous{'award'} eq 'EXACT_ANS')) { |
&stringresponse_gradechange($part,$id,\%previous, |
&stringresponse_gradechange($part,$id,\%previous, |
'ci',$response,$ad,$type); |
'cs',$response,$ad,$type); |
|
} |
|
} |
|
} elsif ($previous{'usedci'}) { |
|
if ($ad ne $previous{'awardci'}) { |
|
if (($previous{'awardci'} eq 'INCORRECT' || |
|
$previous{'awardci'} eq 'APPROX_ANS' || |
|
$previous{'awardci'} eq 'EXACT_ANS')) { |
|
&stringresponse_gradechange($part,$id,\%previous, |
|
'ci',$response,$ad,$type); |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
Line 1301 sub end_stringresponse {
|
Line 1335 sub end_stringresponse {
|
if ($target eq 'answer') { |
if ($target eq 'answer') { |
$result.=&Apache::response::answer_part('stringresponse', |
$result.=&Apache::response::answer_part('stringresponse', |
$element); |
$element); |
|
if ($env{'form.grade_retrieveanswers'}) { |
|
$env{'form.grade_answers.resource.'.$part.'.'.$id} = $element; |
|
} |
} elsif ($target eq 'analyze') { |
} elsif ($target eq 'analyze') { |
push (@{ $Apache::lonhomework::analyze{"$part.$id.answer"}{$name}[$i] }, |
push (@{ $Apache::lonhomework::analyze{"$part.$id.answer"}{$name}[$i] }, |
$element); |
$element); |