--- loncom/homework/optionresponse.pm	2005/12/06 10:03:57	1.130
+++ loncom/homework/optionresponse.pm	2007/02/22 01:25:31	1.137
@@ -1,7 +1,7 @@
 # LearningOnline Network with CAPA
 # option list style responses
 #
-# $Id: optionresponse.pm,v 1.130 2005/12/06 10:03:57 albertel Exp $
+# $Id: optionresponse.pm,v 1.137 2007/02/22 01:25:31 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -114,6 +114,9 @@ sub start_foilgroup {
         <td>Delete an Option:
 	  <select name="$Apache::lonxml::curdepth.deleteopt">$optionlist</select>
 ENDTABLE
+    $result.= &Apache::edit::checked_arg('Print options:','texoptions',
+					 [ ['nochoice','Don\'t show option list'] ]
+					 ,$token);
     $result.= &Apache::edit::end_row();
     $result.= &Apache::edit::start_spanning_row();
     $result.= $insertlist.'<br />';
@@ -137,7 +140,9 @@ ENDTABLE
       }
       $optchanged=1;
     }
-    if ($optchanged) {
+    my $rebuildtag = &Apache::edit::get_new_args($token,$parstack,$safeeval,
+						 ('texoptions'));
+    if ($optchanged || $rebuildtag ) {
       $result = "<foilgroup options=\"(";
       foreach my $option (@options) {
 	$option=~s/\'/\\\'/g;
@@ -145,7 +150,9 @@ ENDTABLE
 	$result .="'".$option."',";
       }
       chop $result;
-      $result.=')">';
+      $result.=')" ';
+      $result .= 'texoptions="'.$token->[2]{'texoptions'}.'" ';
+      $result .= '>';
     } # else nothing changed so just use the default mechanism
   }
   if ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') {
@@ -176,8 +183,10 @@ sub end_foilgroup {
 					       $safeeval,'-2');
     if ($target eq 'web' || $target eq 'tex') {
       $result.=&displayfoils($target,$max,$randomize,$TeXlayout,@opt);
+      $Apache::lonxml::post_evaluate=0;
     } elsif ( $target eq 'answer') {
       $result.=&displayanswers($max,$randomize,@opt);
+      
     } elsif ( $target eq 'analyze') {
 	my @shown = &whichfoils($max,$randomize);
 	&Apache::response::analyze_store_foilgroup(\@shown,
@@ -407,7 +416,7 @@ sub displayfoils {
       foreach my $option (@opt) {
 	  my $escopt=&HTML::Entities::encode($option,'\'"&<>');
 	  if ($option eq $lastopt) {
-	      $optionlist.="<option value='".$escopt."' selected=\"on\">$option</option>\n";
+	      $optionlist.="<option value='".$escopt."' selected=\"selected\">$option</option>\n";
 	  } else {
 	      $optionlist.="<option value='".$escopt."'>$option</option>\n";
 	  }
@@ -441,7 +450,7 @@ sub displayfoils {
 	      $texoptionlist = &optionlist_correction($TeXlayout,@opt);
 	  }
 	  if ($text=~/<drawoptionlist\s*\/>/) {
-	      $text=~s|<drawoptionlist\s*/>| \\makebox\[0\.3in\]\[b\]\{\\hrulefill\} |;
+	      $text=~s|<drawoptionlist\s*\/>| \\makebox\[0\.3in\]\[b\]\{\\hrulefill\} |g;
 	  }
 
 	  if ($text=~m/\\item /) {
@@ -549,7 +558,7 @@ sub bubbles {
 	    $head.='lr';
 	} else {
 	    $line=~s/\&\s*$//;
-	    $result.='\vskip -2 mm\noindent\begin{tabular}{'.$head.'}'.$line.'\\\\\end{tabular}\vskip 0 mm';
+	    $result.='\vskip -2 mm\noindent\setlength{\tabcolsep}{2 mm}\begin{tabular}{'.$head.'}'.$line.'\\\\\end{tabular}\vskip 0 mm';
 	    $line = '\hskip -1 mm {\small \textbf{'.$alphabet[$ind].'}}$\bigcirc$\hskip -1 mm & \hskip -3 mm {\small '.$opt[$ind].'} & ';;
 	    $head ='lr';
 	    $current_length = (length($opt[$ind])+length($alphabet[$ind]))*2;
@@ -681,14 +690,14 @@ sub end_foil {
 
 sub start_drawoptionlist {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
-    if ($target ne 'meta') {
+    if (($target ne 'meta')  && ($target ne 'answer')) {
 	return $token->[4];
     }
 }
 
 sub end_drawoptionlist {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
-    if ($target ne 'meta') {
+    if (($target ne 'meta') && ($target ne 'answer')) {
 	return $token->[2];
     }
 }