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

foxr foxr at source.lon-capa.org
Wed Jan 25 06:37:32 EST 2012


foxr		Wed Jan 25 11:37:32 2012 EDT

  Modified files:              (Branch: BZ4492)
    /loncom/homework	radiobuttonresponse.pm 
  Log:
  BZ4492 - Get regular problems to honor 'direction' in 'tex' mode.
  
  
Index: loncom/homework/radiobuttonresponse.pm
diff -u loncom/homework/radiobuttonresponse.pm:1.153.6.5 loncom/homework/radiobuttonresponse.pm:1.153.6.6
--- loncom/homework/radiobuttonresponse.pm:1.153.6.5	Tue Jan 24 12:05:12 2012
+++ loncom/homework/radiobuttonresponse.pm	Wed Jan 25 11:37:32 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # mutliple choice style responses
 #
-# $Id: radiobuttonresponse.pm,v 1.153.6.5 2012/01/24 12:05:12 foxr Exp $
+# $Id: radiobuttonresponse.pm,v 1.153.6.6 2012/01/25 11:37:32 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -571,6 +571,8 @@
     return $result;
 }
 
+
+
 sub whichfoils {
     my ( $max, $randomize ) = @_;
 
@@ -787,6 +789,25 @@
     &Apache::lonxml::debug("Answer is $answer");
     return ( $answer, @whichfalse );
 }
+
+## 
+#  Return a list  of foil texts given foil names.
+#  
+# @param $whichfoils - Reference to a list of foil names.
+#
+# @return array
+# @retval foil texts
+#
+sub get_foil_texts {
+    my ($whichfoils) = @_;
+    my @foil_texts;
+
+    foreach my $name (@{$whichfoils}) {
+	push(@foil_texts, $Apache::response::foilgroup{$name . '.text'});
+    }
+    return @foil_texts;
+}
+
 ##
 # Generate the HTML for a single html foil.
 # @param $part           - The part for which the response is being generated.
@@ -984,17 +1005,13 @@
     my $line          = 0;
     my $i             = 0;
 
-    &Apache::lonnet::logthis("LaTeX exam:  $direction  $vbegin $vend");
 
     if ($direction eq  'horizontal') {
 
 	# Marshall the display text for each foil and turn things over to
 	# Apache::response::make_horizontal_bubbles:
 
-	my @foil_texts;
-	foreach my $name (@{$whichfoils}) {
-	    push(@foil_texts, $Apache::response::foilgroup{$name . '.text'});
-	}
+	my @foil_texts = &get_foil_texts($whichfoils);
 	$result .= &Apache::caparesponse::make_horizontal_latex_bubbles(
 	    $whichfoils, \@foil_texts, '$\bigcirc$');
 
@@ -1077,14 +1094,25 @@
     my ($whichfoils, $direction, $vbegin, $vend) = @_;
     my $result;
 
-    $result .= $vbegin;
-    foreach my $name (@{$whichfoils}) {
-	$result .=  '\vspace*{-2 mm}\item '
-	    . $Apache::response::foilgroup{ $name . '.text' };
-    }
+    # how we render depends on the direction.
+    # Vertical is some kind of list environment determined by vbegin/vend.
+    # Horizontal is a table that is generated by 
+    # Apache::caparesponse::make_horizontal_latex_bubbles with an empty string
+    # for the actual bubble text.
 
-    $result .= $vend;
+    if ($direction eq 'horizontal') {
+	my @foil_texts = &get_foil_texts($whichfoils);
+	$result .= &Apache::caparesponse::make_horizontal_latex_bubbles(
+	    $whichfoils, \@foil_texts, '');
+    } else {
+	$result .= $vbegin;
+	foreach my $name (@{$whichfoils}) {
+	    $result .=  '\vspace*{-2 mm}\item '
+		. $Apache::response::foilgroup{ $name . '.text' };
+	}
 	
+	$result .= $vend;
+    }
     return $result;
 }
 




More information about the LON-CAPA-cvs mailing list