--- loncom/homework/caparesponse/caparesponse.pm 2010/10/14 19:55:04 1.241 +++ loncom/homework/caparesponse/caparesponse.pm 2010/10/18 19:47:39 1.242 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.241 2010/10/14 19:55:04 raeburn Exp $ +# $Id: caparesponse.pm,v 1.242 2010/10/18 19:47:39 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1229,11 +1229,27 @@ sub end_stringresponse { ${$safeeval->varglob('LONCAPA::CAPAresponse_answer')}=dclone($answer{$name}); my ($result, @msgs)=&Apache::run::run("&caparesponse_check_list()",$safeeval); if ($$args_ref{'type'} =~ /^c[si]$/) { + my $control_chars_removed = pop(@msgs); my $error = pop(@msgs); - if ($error ne '') { + if (($error ne '') || + ($control_chars_removed ne '')) { my ($symb,$courseid,$domain,$name) = &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 $name:$domain 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 $name:$domain in $courseid for part: $part response: $id and symb: $symb"); + } } } &Apache::lonxml::debug('msgs are'.join(':',@msgs));