version 1.212, 2009/03/13 00:34:20
|
version 1.220, 2010/11/24 00:10:06
|
Line 30
|
Line 30
|
|
|
=head1 NAME |
=head1 NAME |
|
|
Apache::resonse.pm |
Apache::response.pm |
|
|
=head1 SYNOPSIS |
=head1 SYNOPSIS |
|
|
Line 54 use strict;
|
Line 54 use strict;
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::lonmaxima(); |
use Apache::lonmaxima(); |
|
use Apache::lonr(); |
|
|
BEGIN { |
BEGIN { |
&Apache::lonxml::register('Apache::response',('responseparam','parameter','dataresponse','customresponse','mathresponse')); |
&Apache::lonxml::register('Apache::response',('responseparam','parameter','dataresponse','customresponse','mathresponse')); |
Line 279 sub meta_response_order {
|
Line 280 sub meta_response_order {
|
} |
} |
|
|
sub check_for_previous { |
sub check_for_previous { |
my ($curresponse,$partid,$id,$last) = @_; |
my ($curresponse,$partid,$id,$last,$type) = @_; |
my %previous; |
my %previous; |
$previous{'used'} = 0; |
$previous{'used'} = 0; |
foreach my $key (sort(keys(%Apache::lonhomework::history))) { |
foreach my $key (sort(keys(%Apache::lonhomework::history))) { |
Line 304 sub check_for_previous {
|
Line 305 sub check_for_previous {
|
if (! $previous{'award'} ) { $previous{'award'} = 'UNKNOWN'; } |
if (! $previous{'award'} ) { $previous{'award'} = 'UNKNOWN'; } |
if ($previous{'award'} eq 'INTERNAL_ERROR') { $previous{'used'}=0; } |
if ($previous{'award'} eq 'INTERNAL_ERROR') { $previous{'used'}=0; } |
&Apache::lonxml::debug("got a match :$previous{'award'}:$previous{'used'}:"); |
&Apache::lonxml::debug("got a match :$previous{'award'}:$previous{'used'}:"); |
} |
} elsif ($type eq 'ci') { |
|
if (lc($pastresponse) eq lc($curresponse)) { |
|
if ($key =~ /^(\d+):/) { |
|
push (@{$previous{'versionci'}},$1); |
|
$previous{'awardci'} = $Apache::lonhomework::history{"resource.$partid.$id.awarddetail"}; |
|
$previous{'usedci'} = 1; |
|
} |
|
} |
|
} |
} |
} |
} |
} |
&Apache::lonhomework::showhash(%previous); |
&Apache::lonhomework::showhash(%previous); |
Line 317 sub handle_previous {
|
Line 326 sub handle_previous {
|
if ($$previous{'last'}) { |
if ($$previous{'last'}) { |
push(@Apache::inputtags::previous,'PREVIOUSLY_LAST'); |
push(@Apache::inputtags::previous,'PREVIOUSLY_LAST'); |
push(@Apache::inputtags::previous_version,$$previous{'version'}); |
push(@Apache::inputtags::previous_version,$$previous{'version'}); |
} elsif ($Apache::lonhomework::type ne 'survey') { |
} elsif (($Apache::lonhomework::type ne 'survey') && |
|
($Apache::lonhomework::type ne 'surveycred') && |
|
($Apache::lonhomework::type ne 'anonsurvey') && |
|
($Apache::lonhomework::type ne 'anonsurveycred')) { |
push(@Apache::inputtags::previous,'PREVIOUSLY_USED'); |
push(@Apache::inputtags::previous,'PREVIOUSLY_USED'); |
push(@Apache::inputtags::previous_version,$$previous{'version'}); |
push(@Apache::inputtags::previous_version,$$previous{'version'}); |
} |
} |
Line 398 sub start_customresponse {
|
Line 410 sub start_customresponse {
|
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
$result.=&Apache::edit::tag_start($target,$token); |
$result.=&Apache::edit::tag_start($target,$token); |
$result.=&Apache::edit::text_arg('String to display for answer:', |
$result.=&Apache::edit::text_arg('String to display for answer:', |
'answerdisplay',$token); |
'answerdisplay',$token,'50'); |
$result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); |
$result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); |
} elsif ($target eq 'modified') { |
} elsif ($target eq 'modified') { |
my $constructtag; |
my $constructtag; |
Line 438 sub end_customresponse {
|
Line 450 sub end_customresponse {
|
${$safeeval->varglob('LONCAPA::customresponse_submission')}= |
${$safeeval->varglob('LONCAPA::customresponse_submission')}= |
$response; |
$response; |
|
|
my $award = &Apache::run::run('{ my $submission=$LONCAPA::customresponse_submission;'.$Apache::response::custom_answer[-1].'}',$safeeval); |
my ($award,$score) = &Apache::run::run('{ my $submission=$LONCAPA::customresponse_submission;'.$Apache::response::custom_answer[-1].'}',$safeeval); |
if (!&Apache::inputtags::valid_award($award)) { |
if (!&Apache::inputtags::valid_award($award)) { |
$error = $award; |
$error = $award; |
$award = 'ERROR'; |
$award = 'ERROR'; |
Line 446 sub end_customresponse {
|
Line 458 sub end_customresponse {
|
&Apache::response::handle_previous(\%previous,$award); |
&Apache::response::handle_previous(\%previous,$award); |
$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}= |
$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}= |
$award; |
$award; |
|
if ($award eq 'ASSIGNED_SCORE') { |
|
$Apache::lonhomework::results{"resource.$part.$id.awarded"}=1.0*$score; |
|
} |
if ($error) { |
if ($error) { |
$Apache::lonhomework::results{"resource.$part.$id.awardmsg"}= |
$Apache::lonhomework::results{"resource.$part.$id.awardmsg"}= |
$error; |
$error; |
Line 505 sub start_mathresponse {
|
Line 520 sub start_mathresponse {
|
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
$result.=&Apache::edit::tag_start($target,$token); |
$result.=&Apache::edit::tag_start($target,$token); |
$result.=&Apache::edit::text_arg('String to display for answer:', |
$result.=&Apache::edit::text_arg('String to display for answer:', |
'answerdisplay',$token); |
'answerdisplay',$token,'50'); |
$result.=&Apache::edit::select_arg('Algebra System:', |
$result.=&Apache::edit::select_arg('Algebra System:', |
'cas', |
'cas', |
['maxima'], |
['maxima','R'], |
$token); |
$token); |
$result.=&Apache::edit::text_arg('Argument Array:', |
$result.=&Apache::edit::text_arg('Argument Array:', |
'args',$token). |
'args',$token). |
Line 538 sub edit_mathresponse_button {
|
Line 553 sub edit_mathresponse_button {
|
# my $helplink=&Apache::loncommon::help_open_topic('Formula_Editor'); |
# my $helplink=&Apache::loncommon::help_open_topic('Formula_Editor'); |
my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'}; |
my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'}; |
return(<<ENDFORMULABUTTON); |
return(<<ENDFORMULABUTTON); |
<script language="JavaScript"> |
<script type="text/javascript" language="JavaScript"> |
function edit_${id}_${field} (textarea) { |
function edit_${id}_${field} (textarea) { |
thenumber = textarea; |
thenumber = textarea; |
thedata = document.forms['lonhomework'].elements[textarea].value; |
thedata = document.forms['lonhomework'].elements[textarea].value; |
newwin = window.open("/adm/dragmath/applet/MaximaPopup.html","","width=565,height=400,resizable"); |
newwin = window.open("/adm/dragmath/applet/MaximaPopup.html","","width=565,height=400,resizable"); |
} |
} |
</script> |
</script> |
<a href="javascript:edit_${id}_${field}('${field}');void(0);"><img class="stift" src='$iconpath/stift.gif' alt='$button' title='$button'/></a> |
<a href="javascript:edit_${id}_${field}('${field}');void(0);"><img class="stift" src="$iconpath/stift.gif" alt="$button" title="$button" /></a> |
ENDFORMULABUTTON |
ENDFORMULABUTTON |
} |
} |
|
|
Line 572 sub end_mathresponse {
|
Line 587 sub end_mathresponse {
|
$award=&Apache::lonmaxima::maxima_run($Apache::response::custom_answer[-1],$response,$args, |
$award=&Apache::lonmaxima::maxima_run($Apache::response::custom_answer[-1],$response,$args, |
&Apache::lonxml::get_param('libraries',$parstack,$safeeval)); |
&Apache::lonxml::get_param('libraries',$parstack,$safeeval)); |
} |
} |
|
if ($cas eq 'R') { |
|
my $args = [&Apache::lonxml::get_param_var('args',$parstack,$safeeval)]; |
|
$award=&Apache::lonr::r_run($Apache::response::custom_answer[-1],$response,$args, |
|
&Apache::lonxml::get_param('libraries',$parstack,$safeeval)); |
|
} |
|
|
if (!&Apache::inputtags::valid_award($award)) { |
if (!&Apache::inputtags::valid_award($award)) { |
$error = $award; |
$error = $award; |
$award = 'ERROR'; |
$award = 'ERROR'; |
Line 897 sub showallfoils {
|
Line 918 sub showallfoils {
|
} |
} |
} |
} |
if ($Apache::lonhomework::type eq 'survey') { return 1; } |
if ($Apache::lonhomework::type eq 'survey') { return 1; } |
|
if ($Apache::lonhomework::type eq 'surveycred') { return 1; } |
|
if ($Apache::lonhomework::type eq 'anonsurvey') { return 1; } |
|
if ($Apache::lonhomework::type eq 'anonsurveycred') { return 1; } |
|
|
return 0; |
return 0; |
} |
} |
|
|