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

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 17 Aug 2005 16:52:40 -0000


albertel		Wed Aug 17 12:52:40 2005 EDT

  Modified files:              
    /loncom/homework	response.pm 
  Log:
  - bug#4279 | could show up as a valid character in an answer, now we search for a nonexistant char in the string and use taht one
  
  
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.123 loncom/homework/response.pm:1.124
--- loncom/homework/response.pm:1.123	Tue Aug  2 14:05:25 2005
+++ loncom/homework/response.pm	Wed Aug 17 12:52:37 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.123 2005/08/02 18:05:25 albertel Exp $
+# $Id: response.pm,v 1.124 2005/08/17 16:52:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -505,7 +505,15 @@
     my ($type,$answer) = @_;
     my $result;
     if ($env{'form.answer_output_mode'} eq 'tex') {
-	$result = ' \verb|'.$answer.'|\\\\ \hline ';
+	my $to_use='|';
+	foreach my $value (32..126) {
+	    my $char=pack('c',$value);
+	    if ($answer !~ /\Q$char\E/) {
+		$to_use=$char;
+		last;
+	    }
+	}
+	$result = '\verb'.$to_use.$answer.$to_use.'\\\\ \hline ';
     } else {
 	$result = '<td>'.$answer.'</td>';
     }