--- loncom/homework/caparesponse/caparesponse.pm 2012/01/16 11:54:37 1.249.4.1 +++ loncom/homework/caparesponse/caparesponse.pm 2012/01/20 10:12:09 1.249.8.1 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.249.4.1 2012/01/16 11:54:37 foxr Exp $ +# $Id: caparesponse.pm,v 1.249.8.1 2012/01/20 10:12:09 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -636,7 +636,8 @@ sub end_numericalresponse { $result.=' \textit{(in} \verb|'.$unit.'|\textit{)} '; } if ($tag eq 'numericalresponse') { - $result .= &make_latex_bubbles($bubble_values, $bubble_display); + $result .= &make_horizontal_latex_bubbles($bubble_values, $bubble_display, + '$\bigcirc$'); } else { $increment = &Apache::response::repetition(); } @@ -1058,18 +1059,22 @@ sub make_numerical_bubbles { } ## -# Produce LaTeX bubbles given a set of bubble values: +# Produce LaTeX bubbles laid out horizontally given a set of bubble values: # # @param bubble_values - reference to an array of bubble 'values' # @param bubble_display - reference to the array of texts to display to the user # for each bubble_value (this is mostly for numerical response # when the displayed value may not be an exact # representation of the bubble value. +# @param bubble_fragment- The LaTeX fragment that will be plugged in to make +# the bubble itself. Note that the code will autonomously +# label each bubble with a lable...and that it's perfectly +# acceptable to use "" for the bubble_fragment. # # @return string - the LaTeX fragment that produces the bubbles. # -sub make_latex_bubbles { - my ($bubble_values, $bubble_display) = @_; +sub make_horizontal_latex_bubbles { + my ($bubble_values, $bubble_display, $bubble_fragment) = @_; my $result; my $number_of_bubbles = scalar(@{$bubble_values}); @@ -1097,8 +1102,12 @@ sub make_latex_bubbles { } $result.='}'; for (my $ind=$cou;$ind<$cou+$table_range[$j];$ind++) { - $result.='\hskip -4 mm {\small \textbf{'.$alphabet[$ind].'}}$\bigcirc$ & \hskip -3 mm {\small '.$bubble_display->[$ind].'} '; - if ($ind != $cou+$table_range[$j]-1) {$result.=' & ';} + $result.='\hskip -4 mm {\small \textbf{'.$alphabet[$ind].'}}' + . $bubble_fragment + . '& \hskip -3 mm {\small '.$bubble_display->[$ind].'} '; + if ($ind != $cou+$table_range[$j]-1) { + $result.=' & '; + } } $cou += $table_range[$j]; $j++;