--- loncom/homework/caparesponse/caparesponse.pm 2003/09/22 20:49:01 1.114
+++ loncom/homework/caparesponse/caparesponse.pm 2003/10/23 07:54:55 1.118
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# caparesponse definition
#
-# $Id: caparesponse.pm,v 1.114 2003/09/22 20:49:01 albertel Exp $
+# $Id: caparesponse.pm,v 1.118 2003/10/23 07:54:55 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -41,6 +41,8 @@ sub start_numericalresponse {
if ($target eq 'edit') {
$result.=&Apache::edit::tag_start($target,$token);
$result.=&Apache::edit::text_arg('Answer:','answer',$token);
+ $result.=&Apache::edit::text_arg('Incorrect Answers:','incorrect',
+ $token);
if ($token->[1] eq 'numericalresponse') {
$result.=&Apache::edit::text_arg('Unit:','unit',$token,5).
&Apache::loncommon::help_open_topic('Physical_Units');
@@ -61,7 +63,8 @@ sub start_numericalresponse {
if ($token->[1] eq 'numericalresponse') {
$constructtag=&Apache::edit::get_new_args($token,$parstack,
$safeeval,'answer',
- 'unit','format');
+ 'incorrect','unit',
+ 'format');
} elsif ($token->[1] eq 'stringresponse') {
$constructtag=&Apache::edit::get_new_args($token,$parstack,
$safeeval,'answer',
@@ -114,23 +117,22 @@ sub end_numericalresponse {
if ( $response =~ /[^\s]/) {
my $ad;
my %previous = &Apache::response::check_for_previous($response,$partid,$id);
- $Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;
&Apache::lonxml::debug("submitted a $response
\n");
&Apache::lonxml::debug($$parstack[-1] . "\n
");
if ($ENV{'form.submitted'} eq 'scantron') {
- my $number_of_bubbles = 8;#default values for number of bubbles
- my (@formats)=&Apache::lonxml::get_param_var('format',
- $parstack,$safeeval);
- my (@answers)=&Apache::lonxml::get_param_var('answer',
- $parstack,$safeeval);
- my @values=&make_numerical_bubbles($number_of_bubbles,$target,
- $answers[0],$formats[0]);
+ my $number_of_bubbles = &Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.numbubbles');
+ if (!$number_of_bubbles) { $number_of_bubbles=8; }
+ my (@formats)=&Apache::lonxml::get_param_var('format',$parstack,$safeeval);
+ my (@answers)=&Apache::lonxml::get_param_var('answer',$parstack,$safeeval);
+ my (@incorrect)=&Apache::lonxml::get_param_var('incorrect',$parstack,$safeeval);
+ my @values=&make_numerical_bubbles($number_of_bubbles,$target,$answers[0],$formats[0],\@incorrect);
$response=$values[$response];
} else {
$response =~ s/\\/\\\\/g;
$response =~ s/\'/\\\'/g;
}
+ $Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;
&Apache::lonxml::debug("current $response");
my $expression="&caparesponse_check_list('".$response."','".
$$parstack[-1];
@@ -206,25 +208,33 @@ sub end_numericalresponse {
}
}
if ($Apache::lonhomework::type eq 'exam') {
- my $number_of_bubbles = 8; #default values for number of bubbles
+ my $partid=$Apache::inputtags::part;
+ my $id=$Apache::inputtags::response[-1];
+ my $number_of_bubbles = &Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.numbubbles');
+ if (!$number_of_bubbles) { $number_of_bubbles=8; }
my (@formats)=&Apache::lonxml::get_param_var('format',$parstack,
$safeeval);
my $unit=&Apache::lonxml::get_param_var('unit',$parstack,
$safeeval);
+ my (@incorrect)=&Apache::lonxml::get_param_var('incorrect',$parstack,$safeeval);
my @bubble_values=&make_numerical_bubbles($number_of_bubbles,
$target,$answers[0],
- $formats[0]);
+ $formats[0],\@incorrect);
my @alphabet=('A'..'Z');
- my $id=$Apache::inputtags::response[-1];
if ($target eq 'web') {
if ($$tagstack[-1] eq 'numericalresponse') {
if ($unit=~/\S/) {$result.=' (in '.$unit.')
';}
$result.= '
'. - $alphabet[$ind].': '. - $bubble_values[$ind].' | '; + '" value="'.$bubble_values[$ind].'" '.$checked + .' />'.$alphabet[$ind].': '. + $bubble_values[$ind].''; } $result.='