version 1.29, 2001/03/21 18:25:14
|
version 1.35, 2001/07/19 21:26:22
|
Line 6 use strict;
|
Line 6 use strict;
|
use capa; |
use capa; |
|
|
sub BEGIN { |
sub BEGIN { |
&Apache::lonxml::register('Apache::caparesponse',('caparesponse','numericalresponse')); |
&Apache::lonxml::register('Apache::caparesponse',('caparesponse','numericalresponse','stringresponse')); |
} |
} |
|
|
sub start_caparesponse { |
sub start_caparesponse { |
my ($target,$token,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my $id = &Apache::response::start_response($parstack,$safeeval); |
my $id = &Apache::response::start_response($parstack,$safeeval); |
return ''; |
return ''; |
} |
} |
|
|
sub end_caparesponse { |
sub end_caparesponse { |
my ($target,$token,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $result = ''; |
my $result = ''; |
if ( $target eq 'grade' ) { |
if ( $target eq 'grade' ) { |
if ( defined $ENV{'form.submitted'}) { |
if ( defined $ENV{'form.submitted'}) { |
Line 44 sub end_caparesponse {
|
Line 44 sub end_caparesponse {
|
} |
} |
} |
} |
} |
} |
} else { |
} elsif ($target eq 'web') { |
#$result .= "The correct answer is ".&Apache::run::run("{$$parstack['-1'];".'return $answer}',$safeeval)."\n"; |
#$result .= "The correct answer is ".&Apache::run::run("{$$parstack['-1'];".'return $answer}',$safeeval)."\n"; |
} |
} |
#Apache::lonxml::debug("\n<br>\nreal end caparesponse<br>\n"); |
#Apache::lonxml::debug("\n<br>\nreal end caparesponse<br>\n"); |
Line 53 sub end_caparesponse {
|
Line 53 sub end_caparesponse {
|
} |
} |
|
|
sub start_numericalresponse { |
sub start_numericalresponse { |
my ($target,$token,$parstack,$parser,$safeeval)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; |
my $id = &Apache::response::start_response($parstack,$safeeval); |
my $id = &Apache::response::start_response($parstack,$safeeval); |
return ''; |
my $result; |
|
if ($target eq 'edit') { |
|
$result.=&Apache::edit::tag_start($target,$token,&Apache::lonxml::description($token)); |
|
$result.=&Apache::edit::text_arg('Answer:','answer',$token); |
|
if ($token->[1] eq 'numericalresponse') { |
|
$result.=&Apache::edit::text_arg('Unit:','unit',$token) |
|
} else { |
|
$result.=&Apache::edit::select_arg('Type:','type', |
|
['cs','ci','mc'],$token) |
|
} |
|
$result.='</td></tr><tr><td colspan="3">'; |
|
} elsif ($target eq 'modified') { |
|
my $constructtag; |
|
if ($token->[1] eq 'numericalresponse') { |
|
$constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval, |
|
'answer','unit'); |
|
} else { |
|
$constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval, |
|
'answer','type'); |
|
} |
|
if ($constructtag) { |
|
$result = &Apache::edit::rebuild_tag($token); |
|
$result.=&Apache::edit::handle_insert(); |
|
} |
|
} |
|
return $result; |
} |
} |
|
|
sub end_numericalresponse { |
sub end_numericalresponse { |
my ($target,$token,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $result = ''; |
my $result = ''; |
if ( $target eq 'grade' ) { |
if ( $target eq 'grade' ) { |
if ( defined $ENV{'form.submitted'}) { |
if ( defined $ENV{'form.submitted'}) { |
Line 106 sub end_numericalresponse {
|
Line 131 sub end_numericalresponse {
|
chop $result; |
chop $result; |
$result.=" $unit.<br></br>"; |
$result.=" $unit.<br></br>"; |
} |
} |
|
} elsif ($target eq 'edit') { |
|
$result.='</td></tr>'.&Apache::edit::end_table; |
} |
} |
&Apache::response::end_response; |
&Apache::response::end_response; |
return $result; |
return $result; |
} |
} |
|
|
|
sub start_stringresponse { |
|
return start_numericalresponse(@_); |
|
} |
|
|
|
sub end_stringresponse { |
|
return end_numericalresponse(@_); |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |
|
|