--- loncom/homework/externalresponse.pm 2008/11/10 13:18:19 1.14 +++ loncom/homework/externalresponse.pm 2011/04/29 00:32:08 1.19 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # external style responses # -# $Id: externalresponse.pm,v 1.14 2008/11/10 13:18:19 jms Exp $ +# $Id: externalresponse.pm,v 1.19 2011/04/29 00:32:08 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -26,27 +26,14 @@ # http://www.lon-capa.org/ # -=pod -=head1 NAME - -Apache::externalresponse.pm - -=head1 SYNOPSIS - -Handler to evaluate externally graded responses. - -This is part of the LearningOnline Network with CAPA project -described at http://www.lon-capa.org. - - -=cut package Apache::externalresponse; use strict; use HTTP::Request::Common; use Apache::loncapagrade; use Apache::lonnet; +use Apache::lonlocal; BEGIN { &Apache::lonxml::register('Apache::externalresponse',('externalresponse')); @@ -54,7 +41,7 @@ BEGIN { =pod -=head1 FIXME +=head1 FIXME (start_externalresponse) send of response params and their current values (form good enough? what parameters to send?) Need to get returned message displayed @@ -70,13 +57,14 @@ sub start_externalresponse { if ($target eq 'edit') { $result .=&Apache::edit::tag_start($target,$token); $result .=&Apache::edit::text_arg('URL:','url',$token,60).'
'; - $result .=&Apache::edit::text_arg('Answer:','answer',$token); - $result .=&Apache::edit::text_arg('Form:','form',$token); + $result .=&Apache::edit::text_arg(&mt('Answer:'),'answer',$token); + $result .=&Apache::edit::text_arg(&mt('Form:'),'form',$token).'
'; + $result .=&Apache::edit::text_arg(&mt('Answer display:'),'answerdisplay',$token,80); $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); } elsif ($target eq 'modified') { my $constructtag = &Apache::edit::get_new_args($token,$parstack,$safeeval, - 'answer','form','url'); + 'answerdisplay','answer','form','url'); if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); } @@ -127,8 +115,13 @@ sub end_externalresponse { $Apache::lonhomework::results{"resource.$part.$id.$key"}= $Apache::loncapagrade::results{$key}; } + $Apache::externalresponse::message=$Apache::loncapagrade::results{'message'}; &Apache::response::handle_previous(\%previous, $Apache::loncapagrade::results{'awarddetail'}); + if ($Apache::loncapagrade::results{'awarddetail'} eq 'ASSIGNED_SCORE') { + $Apache::lonhomework::results{"resource.$part.$id.awarded"}= + 1.*$Apache::loncapagrade::results{"awarded"}; + } &Apache::lonxml::debug("response of"); &Apache::lonhomework::showhash(%$res); &Apache::lonxml::debug("capagrade of"); @@ -140,6 +133,16 @@ sub end_externalresponse { } if ($target eq 'web') { &Apache::response::setup_prior_tries_hash(\&format_prior_response); + if (&Apache::response::show_answer()) { + $result.='
'.&mt('Your answer:').'
'.
+                    $Apache::lonhomework::history{"resource.$part.$id.submission"}.
+                    '

'.&Apache::lonxml::get_param('answerdisplay',$parstack,$safeeval). + '
'; + } + if ($Apache::externalresponse::message) { + $result.='
'.$Apache::externalresponse::message.'

'; + } + $Apache::externalresponse::message=''; } if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || @@ -165,3 +168,29 @@ sub format_prior_response { __END__ +=pod + +=head1 NAME + +Apache::externalresponse.pm + +=head1 SYNOPSIS + +Handler to evaluate externally graded responses. + +This is part of the LearningOnline Network with CAPA project +described at http://www.lon-capa.org. + +=head1 SUBROUTINES + +=over + +=item start_externalresponse() + +=item end_externalresponse() + +=item format_prior_response() + +=back + +=cut