version 1.198, 2006/12/04 23:56:20
|
version 1.198.2.3, 2007/01/25 21:03:45
|
Line 40 BEGIN {
|
Line 40 BEGIN {
|
} |
} |
|
|
my %answer; |
my %answer; |
|
my @answers; |
|
sub get_answer { return %answer; }; |
|
sub push_answer{ push(@answers,dclone(\%answer)); undef(%answer) } |
|
sub pop_answer { %answer = %{pop(@answers)}; }; |
|
|
my $cur_name; |
my $cur_name; |
my $tag_internal_answer_name = 'INTERNAL'; |
my $tag_internal_answer_name = 'INTERNAL'; |
|
|
Line 400 sub end_numericalresponse {
|
Line 405 sub end_numericalresponse {
|
&Apache::lonxml::debug($$parstack[-1] . "\n<br>"); |
&Apache::lonxml::debug($$parstack[-1] . "\n<br>"); |
|
|
if ( &Apache::response::submitted('scantron')) { |
if ( &Apache::response::submitted('scantron')) { |
|
&add_in_tag_answer($parstack,$safeeval); |
my ($values,$display)=&make_numerical_bubbles($partid,$id, |
my ($values,$display)=&make_numerical_bubbles($partid,$id, |
$target,$parstack,$safeeval); |
$target,$parstack,$safeeval); |
$response=$values->[$response]; |
$response=$values->[$response]; |
Line 524 sub end_numericalresponse {
|
Line 530 sub end_numericalresponse {
|
} |
} |
foreach my $name (sort(keys(%answer))) { |
foreach my $name (sort(keys(%answer))) { |
my @answers = @{ $answer{$name}{'answers'} }; |
my @answers = @{ $answer{$name}{'answers'} }; |
|
if ($target eq 'analyze') { |
|
foreach my $info ('answer','ans_high','ans_low','format') { |
|
$Apache::lonhomework::analyze{"$part_id.$info"}{$name}=[]; |
|
} |
|
} |
my ($sigline,$tolline); |
my ($sigline,$tolline); |
if ($name ne $tag_internal_answer_name |
if ($name ne $tag_internal_answer_name |
|| scalar(keys(%answer)) > 1) { |
|| scalar(keys(%answer)) > 1) { |
Line 543 sub end_numericalresponse {
|
Line 554 sub end_numericalresponse {
|
} else { |
} else { |
@vector = ($ans); |
@vector = ($ans); |
} |
} |
if ($target eq 'answer') { |
my @all_answer_info; |
my @all_answer_info; |
foreach my $element (@vector) { |
foreach my $element (@vector) { |
my ($high,$low); |
my ($high,$low); |
if ($Apache::inputtags::params{'tol'}) { |
if ($Apache::inputtags::params{'tol'}) { |
($high,$low)=&get_tolrange($element,$Apache::inputtags::params{'tol'}); |
($high,$low)=&get_tolrange($element,$Apache::inputtags::params{'tol'}); |
} |
} |
if ($target eq 'answer') { |
if ($fmt && $tag eq 'numericalresponse') { |
if ($fmt && $tag eq 'numericalresponse') { |
$fmt=~s/e/E/g; |
$fmt=~s/e/E/g; |
if ($unit=~/\$/) { $fmt="\$".$fmt; $unit=~s/\$//g; } |
if ($unit=~/\$/) { $fmt="\$".$fmt; $unit=~s/\$//g; } |
Line 573 sub end_numericalresponse {
|
Line 584 sub end_numericalresponse {
|
} |
} |
} |
} |
push(@all_answer_info,$element); |
push(@all_answer_info,$element); |
|
|
|
} elsif ($target eq 'analyze') { |
|
push (@{ $Apache::lonhomework::analyze{"$part_id.answer"}{$name}[$i] }, $element); |
|
if ($high) { |
|
push (@{ $Apache::lonhomework::analyze{"$part_id.ans_high"}{$name}[$i] }, $high); |
|
push (@{ $Apache::lonhomework::analyze{"$part_id.ans_low"}{$name}[$i] }, $low); |
|
} |
|
if ($fmt) { |
|
push (@{ $Apache::lonhomework::analyze{"$part_id.format"}{$name}[$i] }, $fmt); |
|
} |
} |
} |
|
} |
|
if ($target eq 'answer') { |
$result.= &Apache::response::answer_part($tag,join(', ',@all_answer_info)); |
$result.= &Apache::response::answer_part($tag,join(', ',@all_answer_info)); |
} elsif ($target eq 'analyze') { |
|
my ($high,$low); |
|
if ($Apache::inputtags::params{'tol'}) { |
|
($high,$low)=&get_tolrange($ans,$Apache::inputtags::params{'tol'}); |
|
} |
|
push (@{ $Apache::lonhomework::analyze{"$part_id.answer"} }, $ans); |
|
if ($high) { |
|
push (@{ $Apache::lonhomework::analyze{"$part_id.ans_high"} }, $high); |
|
push (@{ $Apache::lonhomework::analyze{"$part_id.ans_low"} }, $low); |
|
} |
|
if ($fmt) { |
|
push (@{ $Apache::lonhomework::analyze{"$part_id.format"} }, $fmt); |
|
} |
|
} |
} |
} |
} |
|
|
Line 772 sub make_numerical_bubbles {
|
Line 782 sub make_numerical_bubbles {
|
&Apache::response::get_response_param($part.'_'.$id,'numbubbles',8); |
&Apache::response::get_response_param($part.'_'.$id,'numbubbles',8); |
|
|
my ($format)=&Apache::lonxml::get_param_var('format',$parstack,$safeeval); |
my ($format)=&Apache::lonxml::get_param_var('format',$parstack,$safeeval); |
my ($answer)=&Apache::lonxml::get_param_var('answer',$parstack,$safeeval); |
my $name = (exists($answer{$tag_internal_answer_name}) |
|
? $tag_internal_answer_name |
|
: (sort(keys(%answer)))[0]); |
|
|
|
if ( scalar(@{$answer{$name}{'answers'}}) > 1) { |
|
&Apache::lonxml::error("Only answers with 1 component are supported in exam mode"); |
|
} |
|
if (scalar(@{$answer{$name}{'answers'}[0]}) > 1) { |
|
&Apache::lonxml::error("Vector answers are unsupported in exam mode."); |
|
} |
|
|
|
my $answer = $answer{$name}{'answers'}[0][0]; |
my (@incorrect)=&Apache::lonxml::get_param_var('incorrect',$parstack, |
my (@incorrect)=&Apache::lonxml::get_param_var('incorrect',$parstack, |
$safeeval); |
$safeeval); |
if ($#incorrect eq 0) { @incorrect=(split(/,/,$incorrect[0])); } |
if ($#incorrect eq 0) { @incorrect=(split(/,/,$incorrect[0])); } |
Line 1005 sub end_stringresponse {
|
Line 1026 sub end_stringresponse {
|
} |
} |
} |
} |
} elsif ($target eq 'answer' || $target eq 'analyze') { |
} elsif ($target eq 'answer' || $target eq 'analyze') { |
|
&add_in_tag_answer($parstack,$safeeval); |
if ($target eq 'analyze') { |
if ($target eq 'analyze') { |
push (@{ $Apache::lonhomework::analyze{"parts"} },"$part.$id"); |
push (@{ $Apache::lonhomework::analyze{"parts"} },"$part.$id"); |
$Apache::lonhomework::analyze{"$part.$id.type"} = 'stringresponse'; |
$Apache::lonhomework::analyze{"$part.$id.type"} = 'stringresponse'; |
Line 1015 sub end_stringresponse {
|
Line 1037 sub end_stringresponse {
|
if ($target eq 'answer') { |
if ($target eq 'answer') { |
$result.=&Apache::response::answer_header('stringresponse'); |
$result.=&Apache::response::answer_header('stringresponse'); |
} |
} |
# foreach my $ans (@answers) { |
foreach my $name (keys(%answer)) { |
if ($target eq 'answer') { |
my @answers = @{ $answer{$name}{'answers'} }; |
$result.=&Apache::response::answer_part('stringresponse',$answer); |
for (my $i=0;$i<=$#answers;$i++) { |
if ($type eq 're') { |
my $answer_part = $answers[$i]; |
|
foreach my $element (@{$answer_part}) { |
|
if ($target eq 'answer') { |
|
$result.=&Apache::response::answer_part('stringresponse', |
|
$element); |
|
} elsif ($target eq 'analyze') { |
|
push (@{ $Apache::lonhomework::analyze{"$part.$id.answer"}{$name}[$i] }, |
|
$element); |
|
} |
|
} |
|
if ($target eq 'answer' && $type eq 're') { |
$result.=&Apache::response::answer_part('stringresponse', |
$result.=&Apache::response::answer_part('stringresponse', |
$answerdisplay); |
$answerdisplay); |
} |
} |
} elsif ($target eq 'analyze') { |
|
push (@{ $Apache::lonhomework::analyze{"$part.$id.answer"} }, |
|
$answer); |
|
} |
} |
# } |
} |
my $string='Case Insensitive'; |
my $string='Case Insensitive'; |
if ($type eq 'mc') { |
if ($type eq 'mc') { |
$string='Multiple Choice'; |
$string='Multiple Choice'; |