--- loncom/homework/caparesponse/caparesponse.pm 2005/01/31 22:00:40 1.162
+++ loncom/homework/caparesponse/caparesponse.pm 2005/04/07 06:56:22 1.166
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# caparesponse definition
#
-# $Id: caparesponse.pm,v 1.162 2005/01/31 22:00:40 albertel Exp $
+# $Id: caparesponse.pm,v 1.166 2005/04/07 06:56:22 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -30,6 +30,7 @@ package Apache::caparesponse;
use strict;
use capa;
use Apache::lonlocal;
+use Apache::lonnet;
BEGIN {
&Apache::lonxml::register('Apache::caparesponse',('caparesponse','numericalresponse','stringresponse','formularesponse'));
@@ -136,15 +137,6 @@ sub end_numericalresponse {
if ($Apache::lonhomework::type eq 'exam' &&
$tag eq 'formularesponse') {
$increment=&Apache::response::scored_response($partid,$id);
- } elsif ($Apache::lonhomework::type eq 'survey') {
- my $response = &Apache::response::getresponse();
- if ( $response =~ /[^\s]/) {
- my %previous=&Apache::response::check_for_previous($response,
- $partid,$id);
- $Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;
- my $ad=$Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}='SUBMITTED';
- &Apache::response::handle_previous(\%previous,$ad);
- }
} else {
my $response = &Apache::response::getresponse();
if ( $response =~ /[^\s]/) {
@@ -213,6 +205,11 @@ sub end_numericalresponse {
$Apache::inputtags::params{'sig'});
}
&Apache::lonxml::debug("\n
result:$result:$Apache::lonxml::curdepth
\n");
+ if ($Apache::lonhomework::type eq 'survey' &&
+ ($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' ||
+ $ad eq 'EXACT_ANS')) {
+ $ad='SUBMITTED';
+ }
&Apache::response::handle_previous(\%previous,$ad);
$Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad;
$Apache::lonhomework::results{"resource.$partid.$id.awardmsg"}=$msg;
@@ -352,7 +349,7 @@ sub end_numericalresponse {
if ($target eq 'answer') {
if ($high && $tag eq 'numericalresponse') { $ans.=' ['.$low.','.$high.']'; }
if (defined($sighigh) && $tag eq 'numericalresponse') {
- if ($ENV{'form.answer_output_mode'} eq 'tex') {
+ if ($env{'form.answer_output_mode'} eq 'tex') {
$ans.= " Sig $siglow - $sighigh";
} else {
$ans.= " Sig $siglow - $sighigh";
@@ -365,12 +362,15 @@ sub end_numericalresponse {
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);
+ }
}
}
if (defined($unit) and ($unit ne '') and
$tag eq 'numericalresponse') {
if ($target eq 'answer') {
- if ($ENV{'form.answer_output_mode'} eq 'tex') {
+ if ($env{'form.answer_output_mode'} eq 'tex') {
$result.=&Apache::response::answer_part($tag,
" Unit: $unit ");
} else {
@@ -416,11 +416,11 @@ sub get_table_sizes {
}
$cell_width+=8;
my $textwidth;
- if ($ENV{'form.textwidth'} ne '') {
- $ENV{'form.textwidth'}=~/(\d*)\.?(\d*)/;
+ if ($env{'form.textwidth'} ne '') {
+ $env{'form.textwidth'}=~/(\d*)\.?(\d*)/;
$textwidth=$1.'.'.$2;
} else {
- $ENV{'textwidth'}=~/(\d+)\.?(\d*)/;
+ $env{'form.textwidth'}=~/(\d+)\.?(\d*)/;
$textwidth=$1.'.'.$2;
}
my $bubbles_per_line=int($textwidth/$cell_width);
@@ -527,8 +527,8 @@ sub get_tolrange {
sub get_sigrange {
my ($sig)=@_;
&Apache::lonxml::debug("Got a sig of :$sig:");
- my $courseid=$ENV{'request.course.id'};
- if (lc($ENV{"course.$courseid.disablesigfigs"}) eq 'yes') {
+ my $courseid=$env{'request.course.id'};
+ if (lc($env{"course.$courseid.disablesigfigs"}) eq 'yes') {
return (15,0);
}
my $sig_lbound;
@@ -548,7 +548,7 @@ sub get_sigrange {
($sig_lbound > 15) ||
($sig =~/(\+|-)/ ) ) {
my $errormsg=&mt("Invalid Significant figures detected")." ($sig)";
- if ($ENV{'request.state'} eq 'construct') {
+ if ($env{'request.state'} eq 'construct') {
$errormsg.=
&Apache::loncommon::help_open_topic('Significant_Figures');
}
@@ -617,16 +617,6 @@ sub end_stringresponse {
if ($Apache::lonhomework::type eq 'exam' ||
&Apache::response::submitted('scantron')) {
$increment=&Apache::response::scored_response($part,$id);
- } elsif ($Apache::lonhomework::type eq 'survey') {
- my $response = &Apache::response::getresponse();
- if ( $response =~ /[^\s]/) {
- my %previous=&Apache::response::check_for_previous($response,
- $part,$id);
- $Apache::lonhomework::results{"resource.$part.$id.submission"}=
- $response;
- my $ad=$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}='SUBMITTED';
- &Apache::response::handle_previous(\%previous,$ad);
- }
} else {
my $response = &Apache::response::getresponse();
if ( $response =~ /[^\s]/) {
@@ -669,6 +659,11 @@ sub end_stringresponse {
($ad,$msg) = &Apache::inputtags::finalizeawards(\@awards,\@msgs);
&Apache::lonxml::debug("\n
result:$result:$Apache::lonxml::curdepth
\n");
}
+ if ($Apache::lonhomework::type eq 'survey' &&
+ ($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' ||
+ $ad eq 'EXACT_ANS')) {
+ $ad='SUBMITTED';
+ }
&Apache::response::handle_previous(\%previous,$ad);
$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
$Apache::lonhomework::results{"resource.$part.$id.awardmsg"}=$msg;
@@ -717,7 +712,7 @@ sub end_stringresponse {
$string='Regular Expression';
}
if ($target eq 'answer') {
- if ($ENV{'form.answer_output_mode'} eq 'tex') {
+ if ($env{'form.answer_output_mode'} eq 'tex') {
$result.=&Apache::response::answer_part('stringresponse',
"$string");
} else {