[LON-CAPA-cvs] cvs: loncom /homework/caparesponse caparesponse.pm

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 07 Apr 2003 23:14:52 -0000


albertel		Mon Apr  7 19:14:52 2003 EDT

  Modified files:              
    /loncom/homework/caparesponse	caparesponse.pm 
  Log:
  - this one doesn't bomb, but isn't correct yet about scantron and online submission
  
  
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.87 loncom/homework/caparesponse/caparesponse.pm:1.88
--- loncom/homework/caparesponse/caparesponse.pm:1.87	Mon Apr  7 18:44:32 2003
+++ loncom/homework/caparesponse/caparesponse.pm	Mon Apr  7 19:14:52 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # caparesponse definition
 #
-# $Id: caparesponse.pm,v 1.87 2003/04/07 22:44:32 albertel Exp $
+# $Id: caparesponse.pm,v 1.88 2003/04/07 23:14:52 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -133,14 +133,20 @@
       &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 = &Apache::response::getresponse();
       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<br>\n");
 	&Apache::lonxml::debug($$parstack[$#$parstack] . "\n<br>");
-	if ($Apache::lonhomework::type eq 'exam') {
-	    
+	if ($Apache::lonhomework::type eq 'exam' &&
+	   ($$tagstack[-1] eq 'numericalresponse')) {
+	    &Apache::response::setrandomnumber();
+	    #FIXME the 8 here is based off of number of powers need a parameter
+	    my $ind=&Math::Random::random_uniform_integer(1,0,8);
+	    if ($ind eq $response) { $ad='CORRECT'; } else { $ad='INCORRECT'; }
 	} else {
 	    $response =~ s/\\/\\\\/g;
 	    $response =~ s/\'/\\\'/g;
@@ -159,12 +165,12 @@
 	    $expression.="');";
 	    $result = &Apache::run::run($expression,$safeeval);
 	    my ($awards) = split /:/ , $result;
-	    my ($ad) = &Apache::inputtags::finalizeawards(split /,/ , $awards);
+	    ($ad) = &Apache::inputtags::finalizeawards(split /,/ , $awards);
+	    &Apache::lonxml::debug("$expression");
+	    &Apache::lonxml::debug("\n<br>result:$result:$Apache::lonxml::curdepth<br>\n");
 	}
 	&Apache::response::handle_previous(\%previous,$ad);
 	$Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad;
-	&Apache::lonxml::debug("$expression");
-	&Apache::lonxml::debug("\n<br>result:$result:$Apache::lonxml::curdepth<br>\n");
 	$result='';
       }
     }
@@ -222,9 +228,6 @@
 	my @bubbles_values = (); 
 	my @factors = (1.13,1.17,1.25,1.33,1.45); #default values of factors
 	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
-
 	&Apache::response::setrandomnumber();
 	my $ind=&Math::Random::random_uniform_integer(1,0,$#powers);
 	my $power = $powers[$ind];