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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 07 Jun 2005 01:33:21 -0000


albertel		Mon Jun  6 21:33:21 2005 EDT

  Modified files:              
    /loncom/homework	edit.pm optionresponse.pm 
  Log:
  - BUG#4065 make it so html entities work inside of <oprtionresponse> values
  (for instance &ne;)
  
  
Index: loncom/homework/edit.pm
diff -u loncom/homework/edit.pm:1.92 loncom/homework/edit.pm:1.93
--- loncom/homework/edit.pm:1.92	Thu Apr  7 02:56:21 2005
+++ loncom/homework/edit.pm	Mon Jun  6 21:33:19 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # edit mode helpers
 #
-# $Id: edit.pm,v 1.92 2005/04/07 06:56:21 albertel Exp $
+# $Id: edit.pm,v 1.93 2005/06/07 01:33:19 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -654,12 +654,12 @@
     foreach my $option (@$list) {
 	my ($text,$value);
 	if ( ref($option) eq 'ARRAY') {
-	    $value='value="'.$$option[0].'"';
+	    $value='value="'.&HTML::Entities::encode($$option[0]).'"';
 	    $text=$$option[1];
 	    $option=$$option[0];
 	} else {
 	    $text=$option;
-	    $value='value="'.$option.'"';
+	    $value='value="'.&HTML::Entities::encode($option,'\'"&<>').'"';
 	}
 	if ( $selected eq $option ) {
 	    $optionlist.="<option $value selected=\"selected\">$text</option>\n";
@@ -683,12 +683,12 @@
     foreach my $option (@$list) {
 	my ($text,$value);
 	if ( ref($option) eq 'ARRAY') {
-	    $value='value="'.$$option[0].'"';
+	    $value='value="'.&HTML::Entities::encode($$option[0]).'"';
 	    $text=$$option[1];
 	    $option=$$option[0];
 	} else {
 	    $text=$option;
-	    $value='value="'.$option.'"';
+	    $value='value="'.&HTML::Entities::encode($option,'\'"&<>').'"';
 	}
 	if ( $selected eq $option ) {
 	    $optionlist.="<option $value selected=\"selected\">$text</option>\n";
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.125 loncom/homework/optionresponse.pm:1.126
--- loncom/homework/optionresponse.pm:1.125	Thu Apr  7 02:56:22 2005
+++ loncom/homework/optionresponse.pm	Mon Jun  6 21:33:19 2005
@@ -1,7 +1,7 @@
 # LearningOnline Network with CAPA
 # option list style responses
 #
-# $Id: optionresponse.pm,v 1.125 2005/04/07 06:56:22 albertel Exp $
+# $Id: optionresponse.pm,v 1.126 2005/06/07 01:33:19 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -165,6 +165,8 @@
     my $name;
     my @opt;
     eval '@opt ='.&Apache::lonxml::get_param('options',$parstack,$safeeval);
+    &Apache::lonxml::debug("options:".join(':',@opt));
+
     my $TeXlayout=&Apache::lonxml::get_param('TeXlayout',$parstack,$safeeval,
 					     -2,0);
     if ($target eq 'tex' && $tex_option_switch eq 'nochoice') {@opt=();}
@@ -385,13 +387,13 @@
       }
       my $lastopt=$lastresponse{$name};
       my $optionlist="<option></option>\n";
-      my $option;
-      foreach $option (@opt) {
-	if ($option eq $lastopt) {
-	  $optionlist.="<option selected=\"on\">$option</option>\n";
-	} else {
-	  $optionlist.="<option>$option</option>\n";
-	}
+      foreach my $option (@opt) {
+	  my $escopt=&HTML::Entities::encode($option,'\'"&<>');
+	  if ($option eq $lastopt) {
+	      $optionlist.="<option value='".$escopt."' selected=\"on\">$option</option>\n";
+	  } else {
+	      $optionlist.="<option value='".$escopt."'>$option</option>\n";
+	  }
       }
       if ($target ne 'tex') {
 	  if ($Apache::lonhomework::type ne 'exam') {