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

albertel lon-capa-cvs@mail.lon-capa.org
Sun, 26 Jun 2005 22:30:05 -0000


albertel		Sun Jun 26 18:30:05 2005 EDT

  Modified files:              
    /loncom/homework/caparesponse	caparesponse.pm 
  Log:
  - Better fix for 4158
     - if the answer is wrong it throws an erro
     - if it just is a sig failure it throws a warnign
  
  
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.170 loncom/homework/caparesponse/caparesponse.pm:1.171
--- loncom/homework/caparesponse/caparesponse.pm:1.170	Sun Jun 26 18:21:06 2005
+++ loncom/homework/caparesponse/caparesponse.pm	Sun Jun 26 18:30:05 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # caparesponse definition
 #
-# $Id: caparesponse.pm,v 1.170 2005/06/26 22:21:06 albertel Exp $
+# $Id: caparesponse.pm,v 1.171 2005/06/26 22:30:05 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -121,7 +121,7 @@
 }
 
 sub check_submission {
-    my ($response,$partid,$id,$tag,$parstack,$safeeval)=@_;
+    my ($response,$partid,$id,$tag,$parstack,$safeeval,$ignore_sig)=@_;
     my $args_ref= \%{$safeeval->varglob('LONCAPA::CAPAresponse_args')};
     $$args_ref{'response'}=$response;
     my $hideunit=&Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.turnoffunit');
@@ -142,7 +142,8 @@
     }
     #sig fig don't make much sense either
     if (($Apache::lonhomework::type eq 'exam' ||
-	 &Apache::response::submitted('scantron')) &&
+	 &Apache::response::submitted('scantron') ||
+	 $ignore_sig) &&
 	$tag eq 'numericalresponse') {
 	delete($$args_ref{'sig'});
     }
@@ -381,7 +382,19 @@
 						 $parstack,$safeeval);
 	    my ($ad,$msg) =&Apache::inputtags::finalizeawards($awards,$msgs);
 	    if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') {
-		&Apache::lonxml::warning(&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range ("[_2]" to "[_3]") or significant figures ("[_4]" to "[_5]") needs to be adjusted',$response,$low,$high,$siglow,$sighigh));
+		# answer failed check if it is sig figs that is failing
+		my ($awards,$msgs)=&check_submission($response,$partid,$id,
+						     $tag,$parstack,$safeeval,
+						     1);
+		my ($ad,$msg)=&Apache::inputtags::finalizeawards($awards,
+								 $msgs);
+
+		my $msg=&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range ("[_2]" to "[_3]") or significant figures ("[_4]" to "[_5]") needs to be adjusted',$response,$low,$high,$siglow,$sighigh);
+		if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') {
+		    &Apache::lonxml::error($msg);
+		} else {
+		    &Apache::lonxml::warning($msg);
+		}
 	    }
 	}
 	if (defined($unit) and ($unit ne '') and