[LON-CAPA-cvs] cvs: loncom /homework default_homework.lcpm /xml lonxml.pm

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 12 Feb 2003 22:45:01 -0000


albertel		Wed Feb 12 17:45:01 2003 EDT

  Modified files:              
    /loncom/homework	default_homework.lcpm 
    /loncom/xml	lonxml.pm 
  Log:
  - explict strings \ and ' now work in string response BUG#1036
  
  
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.56 loncom/homework/default_homework.lcpm:1.57
--- loncom/homework/default_homework.lcpm:1.56	Mon Feb 10 16:41:25 2003
+++ loncom/homework/default_homework.lcpm	Wed Feb 12 17:45:01 2003
@@ -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.56 2003/02/10 21:41:25 albertel Exp $
+# $Id: default_homework.lcpm,v 1.57 2003/02/12 22:45:01 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -152,6 +152,8 @@
 sub caparesponse_check_list {
   my ($response,$expr)=@_;
   my $result;
+  $expr =~ s/\\/\\\\/g;
+  $expr =~ s/\'/\\\'/g;
   my ($result,@list) = &get_array_args($expr,'answer');
   my $aresult='';
   my $current_answer;
@@ -180,12 +182,15 @@
   my $awards='';
   for ($i=0; $i<@list;$i++) {
     $result.="trying answer :$list[$i]:\n";
+    my $thisanswer=$list[$i];
+    $thisanswer=~ s/\\/\\\\/g;
+    $thisanswer =~ s/\'/\\\'/g;
     if ($unit eq '') {
       $aresult=&caparesponse_check($responselist[$i],
-			     $expr.';my $answer=\''.$list[$i].'\';');
+			     $expr.';my $answer=\''.$thisanswer.'\';');
     } else {
       $aresult=&caparesponse_check($responselist[$i]." $unit",
-				   $expr.';my $answer=\''.$list[$i].'\';');
+				   $expr.';my $answer=\''.$thisanswer.'\';');
     }
     my ($temp)=split /:/, $aresult;
     $awards.="$temp,";
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.230 loncom/xml/lonxml.pm:1.231
--- loncom/xml/lonxml.pm:1.230	Wed Feb 12 17:04:34 2003
+++ loncom/xml/lonxml.pm	Wed Feb 12 17:45:01 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.230 2003/02/12 22:04:34 albertel Exp $
+# $Id: lonxml.pm,v 1.231 2003/02/12 22:45:01 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1216,7 +1216,7 @@
   foreach (@{$token->[3]}) {
     unless ($_=~/\W/) {
       my $val=$token->[2]->{$_};
-      $val =~ s/([\%\@\\\"])/\\$1/g;
+      $val =~ s/([\%\@\\\"\'])/\\$1/g;
       #if ($val =~ m/^[\%\@]/) { $val="\\".$val; }
       $temp .= "my \$$_=\"$val\";"
     }