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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Fri, 12 Sep 2008 09:56:14 -0000


raeburn		Fri Sep 12 05:56:14 2008 EDT

  Modified files:              
    /loncom/homework	default_homework.lcpm hint.pm 
    /loncom/homework/caparesponse	caparesponse.pm 
  Log:
  - Bug 5531 (although should really be a separate bug).
  RegExp used to separate units from numerical part of an answer can truncate responses to stringresponse items for which the type has not been explicitly set (as ci, cs, mc or re).
  
  - Include the tagname of the response item in calls to caparesponse_check_list(), so that if the type attribute is unspecified, stringresponse submissions are not subjected to the unit extractor.
  
  Perhaps there is a reason why this ambiguity has not been eliminated previously by passing the tagname to caparesponse_check_list() - run in the safe space?
  Testing needed.
  
  
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.138 loncom/homework/default_homework.lcpm:1.139
--- loncom/homework/default_homework.lcpm:1.138	Sat Sep  6 17:39:15 2008
+++ loncom/homework/default_homework.lcpm	Fri Sep 12 05:56:09 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run()
 #
-# $Id: default_homework.lcpm,v 1.138 2008/09/06 21:39:15 raeburn Exp $
+# $Id: default_homework.lcpm,v 1.139 2008/09/12 09:56:09 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -254,11 +254,12 @@
 
     &LONCAPA_INTERNAL_DEBUG("RetError $reterror: Answer $answer: Response $response:  type-$type|$tol|$tol_type|$sig:$sig_lbound:$sig_ubound|$unit|");
     &LONCAPA_INTERNAL_DEBUG(" $answer $response $result ");
-    return ($result,$reterror)
+    return ($result,$reterror);
 }
 
 
 sub caparesponse_check_list {
+    my ($tag) = @_;
     my $responses=$LONCAPA::CAPAresponse_args{'response'};
     &LONCAPA_INTERNAL_DEBUG("args ".join(':',%LONCAPA::CAPAresponse_args));
     my $type = $LONCAPA::CAPAresponse_args{'type'};
@@ -303,7 +304,7 @@
 
     &LONCAPA_INTERNAL_DEBUG("Initial final response :$responses->[0][-1]:");
     my $unit;
-    if ($type eq '' || $type eq 'float') {
+    if (($type eq 'float') || (($type eq '') && (($tag ne 'stringresponse') && ($tag ne 'stringhint')) ) ) {
 	#for numerical problems split off the unit
 #	if ( $responses->[0][-1]=~ /(.*[^\s])\s+([^\s]+)/ ) {
         if ( $responses->[0][-1]=~ /^([\d\.\,\s\$]*(?:(?:[xX\*]10[\^\*]*|[eE]*)[\+\-]*\d*)*(?:^|\S)\d+)([\$\s\w\^\*\/\(\)\+\-]*[^\d\.\s\,][\$\s\w\^\*\/\(\)\+\-]*)$/ ) {
Index: loncom/homework/hint.pm
diff -u loncom/homework/hint.pm:1.69 loncom/homework/hint.pm:1.70
--- loncom/homework/hint.pm:1.69	Thu Sep 11 10:47:17 2008
+++ loncom/homework/hint.pm	Fri Sep 12 05:56:09 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # implements the tags that control the hints
 #
-# $Id: hint.pm,v 1.69 2008/09/11 14:47:17 bisitz Exp $
+# $Id: hint.pm,v 1.70 2008/09/12 09:56:09 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -194,7 +194,7 @@
 		dclone($answer{$ans_name});
 	    &Apache::caparesponse::setup_capa_response($args_ref,$response);
 	    my ($result,@msgs) = 
-		&Apache::run::run("&caparesponse_check_list()",$safeeval);
+		&Apache::run::run("&caparesponse_check_list($$tagstack[-1])",$safeeval);
 	    &Apache::lonxml::debug("checking $ans_name $result with $response");
 	    &Apache::lonxml::debug('msgs are '.join(':',@msgs));
 	    my ($awards)=split(/:/,$result);
@@ -428,7 +428,7 @@
 	    foreach my $ans_name (keys(%answer)) {
 		&Apache::lonxml::debug(" doing $ans_name with ".join(':',@{ $answer{$ans_name}{'answers'} }));
 		${$safeeval->varglob('LONCAPA::CAPAresponse_answer')}=dclone($answer{$ans_name});
-		my ($result, @msgs)=&Apache::run::run("&caparesponse_check_list()",$safeeval);
+		my ($result, @msgs)=&Apache::run::run("&caparesponse_check_list($$tagstack[-1])",$safeeval);
 		&Apache::lonxml::debug('msgs are'.join(':',@msgs));
 		my ($awards) = split(/:/,$result);
 		my (@awards) = split(/,/,$awards);
Index: loncom/homework/caparesponse/caparesponse.pm
diff -u loncom/homework/caparesponse/caparesponse.pm:1.231 loncom/homework/caparesponse/caparesponse.pm:1.232
--- loncom/homework/caparesponse/caparesponse.pm:1.231	Tue Sep  9 09:56:49 2008
+++ loncom/homework/caparesponse/caparesponse.pm	Fri Sep 12 05:56:10 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # caparesponse definition
 #
-# $Id: caparesponse.pm,v 1.231 2008/09/09 13:56:49 riegler Exp $
+# $Id: caparesponse.pm,v 1.232 2008/09/12 09:56:10 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -447,7 +447,7 @@
 	use Time::HiRes;
 	my $t0 = [Time::HiRes::gettimeofday()];
 	my ($result,@msgs) = 
-	    &Apache::run::run("&caparesponse_check_list()",$safeeval);
+	    &Apache::run::run("&caparesponse_check_list($tag)",$safeeval);
 	&Apache::lonxml::debug("checking $name $result with $response took ".&Time::HiRes::tv_interval($t0));
 	&Apache::lonxml::debug('msgs are '.join(':',@msgs));
 	my ($awards)=split(/:/,$result);
@@ -1167,7 +1167,7 @@
 		    foreach my $name (keys(%answer)) {
 			&Apache::lonxml::debug(" doing $name with ".join(':',@{ $answer{$name}{'answers'} }));
 			${$safeeval->varglob('LONCAPA::CAPAresponse_answer')}=dclone($answer{$name});
-			my ($result, @msgs)=&Apache::run::run("&caparesponse_check_list()",$safeeval);
+			my ($result, @msgs)=&Apache::run::run("&caparesponse_check_list($$tagstack[-1])",$safeeval);
 			&Apache::lonxml::debug('msgs are'.join(':',@msgs));
 			my ($awards)=split(/:/,$result);
 			my (@awards) = split(/,/,$awards);