version 1.151, 2006/12/04 21:12:57
|
version 1.154, 2006/12/11 22:02:13
|
Line 30 package Apache::response;
|
Line 30 package Apache::response;
|
use strict; |
use strict; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonnet; |
use Apache::lonnet; |
|
use Apache::lonmaxima(); |
|
|
BEGIN { |
BEGIN { |
&Apache::lonxml::register('Apache::response',('responseparam','parameter','dataresponse','customresponse','mathresponse')); |
&Apache::lonxml::register('Apache::response',('responseparam','parameter','dataresponse','customresponse','mathresponse')); |
Line 373 sub start_customresponse {
|
Line 374 sub start_customresponse {
|
if ( &Apache::response::show_answer() ) { |
if ( &Apache::response::show_answer() ) { |
my $answer = &Apache::lonxml::get_param('answerdisplay',$parstack, |
my $answer = &Apache::lonxml::get_param('answerdisplay',$parstack, |
$safeeval); |
$safeeval); |
$Apache::inputtags::answertxt{$id}=$answer; |
$Apache::inputtags::answertxt{$id}=[$answer]; |
} |
} |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
$result.=&Apache::edit::tag_start($target,$token); |
$result.=&Apache::edit::tag_start($target,$token); |
Line 464 sub start_mathresponse {
|
Line 465 sub start_mathresponse {
|
if ( &Apache::response::show_answer() ) { |
if ( &Apache::response::show_answer() ) { |
my $answer = &Apache::lonxml::get_param('answerdisplay',$parstack, |
my $answer = &Apache::lonxml::get_param('answerdisplay',$parstack, |
$safeeval); |
$safeeval); |
$Apache::inputtags::answertxt{$id}=$answer; |
$Apache::inputtags::answertxt{$id}=[$answer]; |
} |
} |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
$result.=&Apache::edit::tag_start($target,$token); |
$result.=&Apache::edit::tag_start($target,$token); |
Line 474 sub start_mathresponse {
|
Line 475 sub start_mathresponse {
|
'cas', |
'cas', |
['maxima'], |
['maxima'], |
$token); |
$token); |
$result.=&Apache::edit::text_arg('Algebra System:', |
|
'cas',$token); |
|
$result.=&Apache::edit::text_arg('Argument Array:', |
$result.=&Apache::edit::text_arg('Argument Array:', |
'args',$token); |
'args',$token); |
$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; |
$constructtag=&Apache::edit::get_new_args($token,$parstack, |
$constructtag=&Apache::edit::get_new_args($token,$parstack, |
$safeeval,'answerdisplay'); |
$safeeval,'answerdisplay','cas','args'); |
if ($constructtag) { |
if ($constructtag) { |
$result = &Apache::edit::rebuild_tag($token); |
$result = &Apache::edit::rebuild_tag($token); |
$result.=&Apache::edit::handle_insert(); |
$result.=&Apache::edit::handle_insert(); |
} |
} |
} elsif ($target eq 'answer' || $target eq 'grade') { |
} elsif ($target eq 'answer' || $target eq 'grade') { |
&Apache::response::reset_params(); |
&Apache::response::reset_params(); |
|
my $args_ref= \%{$safeeval->varglob('LONCAPA::mathresponse_args')}; |
|
undef(%{ $args_ref }); |
|
$$args_ref{'cas'}=$token->[2]{'cas'}; |
|
if ($token->[2]{'args'}=~/\$/) { |
|
$$args_ref{'args'}=&Apache::run::run($token->[2]{'args'},$safeeval); |
|
} elsif ($token->[2]{'args'}=~/\@/) { |
|
$$args_ref{'args'}=&Apache::run::run('join(",",'.$token->[2]{'args'}.')',$safeeval); |
|
} else { |
|
$$args_ref{'args'}=$token->[2]{'args'}; |
|
} |
} elsif ($target eq 'meta') { |
} elsif ($target eq 'meta') { |
$result .= &Apache::response::meta_package_write('mathresponse'); |
$result .= &Apache::response::meta_package_write('mathresponse'); |
} |
} |
Line 511 sub end_mathresponse {
|
Line 520 sub end_mathresponse {
|
$Apache::lonhomework::results{"resource.$part.$id.submission"}= |
$Apache::lonhomework::results{"resource.$part.$id.submission"}= |
$response; |
$response; |
my $error; |
my $error; |
${$safeeval->varglob('LONCAPA::mathresponse_submission')}= |
my $args_ref= \%{$safeeval->varglob('LONCAPA::mathresponse_args')}; |
$response; |
my $award; |
|
if ($$args_ref{'cas'} eq 'maxima') { |
my $award = &Apache::run::run('{ my $submission=$LONCAPA::mathresponse_submission;'.$Apache::response::custom_answer.'}',$safeeval); |
$award=&Apache::lonmaxima::maxima_run($Apache::response::custom_answer,$response,$$args_ref{'args'}); |
|
} |
if (!&Apache::inputtags::valid_award($award)) { |
if (!&Apache::inputtags::valid_award($award)) { |
$error = $award; |
$error = $award; |
$award = 'ERROR'; |
$award = 'ERROR'; |