[LON-CAPA-cvs] cvs: loncom /homework/caparesponse caparesponse.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 07 Apr 2003 22:44:32 -0000
albertel Mon Apr 7 18:44:32 2003 EDT
Modified files:
/loncom/homework/caparesponse caparesponse.pm
Log:
- switch to general getresponse routine
- prepped for exam bubble submission
- removing useless code
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.86 loncom/homework/caparesponse/caparesponse.pm:1.87
--- loncom/homework/caparesponse/caparesponse.pm:1.86 Wed Mar 26 13:44:13 2003
+++ loncom/homework/caparesponse/caparesponse.pm Mon Apr 7 18:44:32 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# caparesponse definition
#
-# $Id: caparesponse.pm,v 1.86 2003/03/26 18:44:13 sakharuk Exp $
+# $Id: caparesponse.pm,v 1.87 2003/04/07 22:44:32 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -46,7 +46,7 @@
if ( $target eq 'grade' ) {
if ( defined $ENV{'form.submitted'}) {
$safeeval->share_from('capa',['&caparesponse_capa_check_answer']);
- my $response = $ENV{'form.HWVAL'.$Apache::inputtags::response['-1']};
+ my $response = $ENV{'form.HWVAL_'.$Apache::inputtags::response['-1']};
if ( $response =~ /[^\s]/) {
my $id = $Apache::inputtags::response['-1'];
my $previous= &Apache::response::check_for_previous($response,$id,$response);
@@ -133,31 +133,34 @@
&Apache::response::setup_params($$tagstack[-1]);
$safeeval->share_from('capa',['&caparesponse_capa_check_answer']);
my $partid = $Apache::inputtags::part;
- my $id = $Apache::inputtags::response['-1'];
- my $response = $ENV{'form.HWVAL'.$id};
+ 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;
&Apache::lonxml::debug("submitted a $response<br>\n");
&Apache::lonxml::debug($$parstack[$#$parstack] . "\n<br>");
- $response =~ s/\\/\\\\/g;
- $response =~ s/\'/\\\'/g;
- &Apache::lonxml::debug("current $response");
- my $expression="&caparesponse_check_list('".$response."','".
- $$parstack[-1];
- foreach my $key (keys(%Apache::inputtags::params)) {
- $expression.= ';my $'. #'
- $key.'="'.$Apache::inputtags::params{$key}.'"';
- }
- if ($$tagstack[-1] eq 'formularesponse') {
- $expression.=';my $type="fml";';
- } elsif ($$tagstack[-1] eq 'numericalresponse') {
- $expression.=';my $type="float";';
+ if ($Apache::lonhomework::type eq 'exam') {
+
+ } else {
+ $response =~ s/\\/\\\\/g;
+ $response =~ s/\'/\\\'/g;
+ &Apache::lonxml::debug("current $response");
+ my $expression="&caparesponse_check_list('".$response."','".
+ $$parstack[-1];
+ foreach my $key (keys(%Apache::inputtags::params)) {
+ $expression.= ';my $'. #'
+ $key.'="'.$Apache::inputtags::params{$key}.'"';
+ }
+ if ($$tagstack[-1] eq 'formularesponse') {
+ $expression.=';my $type="fml";';
+ } elsif ($$tagstack[-1] eq 'numericalresponse') {
+ $expression.=';my $type="float";';
+ }
+ $expression.="');";
+ $result = &Apache::run::run($expression,$safeeval);
+ my ($awards) = split /:/ , $result;
+ my ($ad) = &Apache::inputtags::finalizeawards(split /,/ , $awards);
}
- $expression.="');";
- $result = &Apache::run::run($expression,$safeeval);
- my ($awards) = split /:/ , $result;
- my ($ad) = &Apache::inputtags::finalizeawards(split /,/ , $awards);
&Apache::response::handle_previous(\%previous,$ad);
$Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad;
&Apache::lonxml::debug("$expression");
@@ -221,8 +224,6 @@
my @powers = (1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0); #default values for powers
my $factors_number = 5; #default values for number of factors
my $powers_number = 8; #default values for number of powers
- my $symb;
- if ($ENV{'form.symb'}=~/___\d+___/) {$symb=$ENV{'form.symb'};} else {$symb=$ENV{'request.symb'};}
&Apache::response::setrandomnumber();
my $ind=&Math::Random::random_uniform_integer(1,0,$#powers);
@@ -255,7 +256,7 @@
}
$ans = sprintf('%.'.$format,$bubbles_values[$ind]);
}
- $result.='<td><input type="radio" name="HWVAL'.$id.'" value="'.$ans.'"><b>'.$alphabet[$ind].'</b>: '.$ans.'</td>';
+ $result.='<td><input type="radio" name="HWVAL_'.$id.'" value="'.$ans.'"><b>'.$alphabet[$ind].'</b>: '.$ans.'</td>';
}
$result.='</tr></table>';
} elsif ($$tagstack[-1] eq 'formularesponse') {