From: dpvc v. a. <we...@ma...> - 2005-06-06 02:34:17
|
Log Message: ----------- Forgot to check hardcopy mode. Fixed some problems with that. The answer array items have to turn off verbatim mode that is used when answer are included in the hardcopy. This causes paragraph breaks between entries in a singleResult MultiPart that includes ans_arrays, which make the output less pretty, but at least they show up. Modified Files: -------------- pg/lib/Value: AnswerChecker.pm Revision Data ------------- Index: AnswerChecker.pm =================================================================== RCS file: /webwork/cvs/system/pg/lib/Value/AnswerChecker.pm,v retrieving revision 1.45 retrieving revision 1.46 diff -Llib/Value/AnswerChecker.pm -Llib/Value/AnswerChecker.pm -u -r1.45 -r1.46 --- lib/Value/AnswerChecker.pm +++ lib/Value/AnswerChecker.pm @@ -295,14 +295,17 @@ sub format_matrix_tex { my $self = shift; my $array = shift; - my %options = {open=>'',close=>'',sep=>'',@_}; + my %options = (open=>'.',close=>'.',sep=>'',@_); $self->{format_options} = [%options] unless $self->{format_options}; my ($open,$close,$sep) = ($options{open},$options{close},$options{sep}); my ($rows,$cols) = (scalar(@{$array}),scalar(@{$array->[0]})); my $tex = ""; - $tex .= '\left'.$open.'\begin{array}{'.('c'x$cols).'}'; - foreach my $i (0..$rows-1) {$tex .= join('&',@{$array->[$i]}).'\\'."\n"} - $tex .= '\end{array}\right'.$close; + $open = '\\'.$open if $open =~ m/[{}]/; $close = '\\'.$close if $close =~ m/[{}]/; + $tex .= '\(\left'.$open; + $tex .= '\setlength{\arraycolsep}{2pt}', $sep = '\,'.$sep if $sep; + $tex .= '\begin{array}{'.('c'x$cols).'}'; + foreach my $i (0..$rows-1) {$tex .= join($sep.'&',@{$array->[$i]}).'\cr'."\n"} + $tex .= '\end{array}\right'.$close.'\)'; return $tex; } @@ -338,6 +341,13 @@ . '</TABLE>'; } +sub VERBATIM { + my $string = shift; + my $displayMode = Value->getPG('$displayMode'); + $string = '\end{verbatim}'.$string.'\begin{verbatim}' if $displayMode eq 'TeX'; + return $string; +} + # # Create a tall delimiter to match the line height # @@ -589,7 +599,7 @@ sub correct_ans { my $self = shift; return $self->SUPER::correct_ans unless $self->{ans_name}; - return $self->format_matrix([[@{$self->{data}}]],@{$self->{format_options}},tth_delims=>1); + Value::VERBATIM($self->format_matrix([[@{$self->{data}}]],@{$self->{format_options}},tth_delims=>1)); } sub ANS_MATRIX { @@ -656,10 +666,10 @@ sub correct_ans { my $self = shift; return $self->SUPER::correct_ans unless $self->{ans_name}; - return $self->format_matrix([[$self->value]],@{$self->{format_options}},tth_delims=>1) + return Value::VERBATIM($self->format_matrix([[$self->value]],@{$self->{format_options}},tth_delims=>1)) unless $self->{ColumnVector}; my @array = (); foreach my $x ($self->value) {push(@array,[$x])} - return $self->format_matrix([@array],@{$self->{format_options}},tth_delims=>1); + return Value::VERBATIM($self->format_matrix([@array],@{$self->{format_options}},tth_delims=>1)); } sub ANS_MATRIX { @@ -722,7 +732,7 @@ my $self = shift; return $self->SUPER::correct_ans unless $self->{ans_name}; my @array = $self->value; @array = ([@array]) if $self->isRow; - return $self->format_matrix([$self->value],@{$self->{format_options}},tth_delims=>1); + Value::VERBATIM($self->format_matrix([$self->value],@{$self->{format_options}},tth_delims=>1)); } sub ANS_MATRIX { @@ -1199,7 +1209,7 @@ if ($self->{tree}{ColumnVector}) {foreach my $x (@array) {$x = [$x]}} else {@array = [@array]} } - return $self->format_matrix([@array],@{$self->{format_options}},tth_delims=>1); + Value::VERBATIM($self->format_matrix([@array],@{$self->{format_options}},tth_delims=>1)); } # |