[LON-CAPA-cvs] cvs: loncom /homework hint.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 19 Nov 2004 22:26:37 -0000
albertel Fri Nov 19 17:26:37 2004 EDT
Modified files:
/loncom/homework hint.pm
Log:
-BUG#3575, you can make negative <stringhint> regexp conditions prepended the re with NOT
i.e. "NOT /right/"
Index: loncom/homework/hint.pm
diff -u loncom/homework/hint.pm:1.56 loncom/homework/hint.pm:1.57
--- loncom/homework/hint.pm:1.56 Tue Aug 24 12:01:18 2004
+++ loncom/homework/hint.pm Fri Nov 19 17:26:37 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# implements the tags that control the hints
#
-# $Id: hint.pm,v 1.56 2004/08/24 16:01:18 albertel Exp $
+# $Id: hint.pm,v 1.57 2004/11/19 22:26:37 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -267,7 +267,14 @@
my ($ad,$msg);
if ($type eq 're' ) {
${$safeeval->varglob('LONCAPA::response')}=$response;
- $result = &Apache::run::run('return $LONCAPA::response=~m'.$answer,$safeeval);
+ my $compare='=';
+ if ($answer=~/^\s*NOT\s*/) {
+ $answer=~s/^\s*NOT\s*//;
+ $compare='!';
+ }
+ my $test='$LONCAPA::response'.$compare.'~m'.$answer;
+ &Apache::lonxml::debug("test $test");
+ $result = &Apache::run::run("return $test",$safeeval);
&Apache::lonxml::debug("current $response");
&Apache::lonxml::debug("current $answer");
$ad = ($result) ? 'APPROX_ANS' : 'INCORRECT';