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

foxr lon-capa-cvs@mail.lon-capa.org
Tue, 19 Dec 2006 11:05:24 -0000


foxr		Tue Dec 19 06:05:24 2006 EDT

  Modified files:              
    /loncom/homework	radiobuttonresponse.pm 
  Log:
  BUG 4795 - Survey printing fails 'cause displayallfoils has no
  conditional branches for $target eq 'tex'.  Put in a first crack at this.
  NOTE: are the opportunities for a refactoriziation of the display of a single
  foil between displayallfoils and display foil?
  
  
Index: loncom/homework/radiobuttonresponse.pm
diff -u loncom/homework/radiobuttonresponse.pm:1.109 loncom/homework/radiobuttonresponse.pm:1.110
--- loncom/homework/radiobuttonresponse.pm:1.109	Fri Dec  8 12:38:35 2006
+++ loncom/homework/radiobuttonresponse.pm	Tue Dec 19 06:05:21 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # mutliple choice style responses
 #
-# $Id: radiobuttonresponse.pm,v 1.109 2006/12/08 17:38:35 albertel Exp $
+# $Id: radiobuttonresponse.pm,v 1.110 2006/12/19 11:05:21 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -179,7 +179,7 @@
 						   $safeeval,'-2');
 	if ( $style eq 'survey'  && $target ne 'analyze') {
 	    if ($target eq 'web' || $target eq 'tex') {
-		$result=&displayallfoils($direction);
+		$result=&displayallfoils($direction, $target);
 	    } elsif ( $target eq 'answer' ) {
 		$result=&displayallanswers();
 	    } elsif ( $target eq 'grade' ) {
@@ -231,7 +231,7 @@
 }
 
 sub displayallfoils {
-    my ($direction)=@_;
+    my ($direction, $target)=@_;
     my $result;
     &Apache::lonxml::debug("survey style display");
     my @names;
@@ -239,6 +239,7 @@
 	@names= @{ $Apache::response::foilgroup{'names'} };
     }
     my $temp=0;
+    my $i   =0;
     my $id=$Apache::inputtags::response['-1'];
     my $part=$Apache::inputtags::part;
     my $lastresponse=
@@ -248,19 +249,27 @@
     if (&Apache::response::show_answer() ) {
 	foreach my $name (@names) {
 	    if ($Apache::response::foilgroup{$name.'.value'} ne 'unused') {
-		if ($direction eq 'horizontal') {
+		if (($direction eq 'horizontal') && ($target ne 'tex')) {
 		    $result.="<td>";
 		} else {
-		    $result.="<br />";
+		    if ($target eq 'tex') {
+			$result .= '\item \vskip -2mm ';
+		    } else {
+			$result.="<br />";
+		    }
 		}
 		if (defined($lastresponse{$name})) {
-		    $result.='<b>';
+		    if ($target eq 'tex') {
+			$result .= '}';
+		    } else {
+			$result.='<b>';
+		    }
 		}
 		$result .= $Apache::response::foilgroup{$name.'.text'};
-		if (defined($lastresponse{$name})) {
+		if (defined($lastresponse{$name}) && ($target ne 'tex')) {
 		    $result.='</b>';
 		}
-		if ($direction eq 'horizontal') { $result.="</td>"; }
+		if (($direction eq 'horizontal') && ($target ne 'tex')) { $result.="</td>"; }
 	    }
 	}
     } else {
@@ -269,19 +278,32 @@
 		if ($direction eq 'horizontal') {
 		    $result.="<td>";
 		} else {
-		    $result.="<br />";
+		    if ($target eq 'tex') {
+			$result .= '\item \vskip -2mm ';
+		    } else {
+			$result.="<br />";
+		    }
+		}
+		if ($target eq 'tex') {
+		    $result .= '$\bigcirc$'.$Apache::response::foilgroup{$name.'.text'}.'\\\\';  #' stupid emacs
+		    $i++;
+		} else {
+		    $result .= '<label>';
+		    $result.="<input type=\"radio\" name=\"HWVAL_$Apache::inputtags::response['-1']\" value=\"$temp\" ";
+		    if (defined($lastresponse{$name})) { $result .= 'checked="on"'; }
+		    $result .= ' />'.$Apache::response::foilgroup{$name.'.text'}.
+			'</label>';
 		}
-                $result .= '<label>';
-		$result.="<input type=\"radio\" name=\"HWVAL_$Apache::inputtags::response['-1']\" value=\"$temp\" ";
-		if (defined($lastresponse{$name})) { $result .= 'checked="on"'; }
-		$result .= ' />'.$Apache::response::foilgroup{$name.'.text'}.
-                    '</label>';
 		$temp++;
-		if ($direction eq 'horizontal') { $result.="</td>"; }
+		if ($target ne 'tex') {
+		    if (($direction eq 'horizontal') && ($target ne 'tex')) { $result.="</td>"; }
+		} else {
+		    $result.='\vskip 0 mm ';
+		}
 	    }
 	}
     }
-    if ($direction eq 'horizontal') { $result.='</tr></table>'; }
+    if (($direction eq 'horizontal') && ($target ne 'tex')) { $result.='</tr></table>'; }
     return $result;
 }