Skip to content

Commit 773f35e

Browse files
committed
Remove deprecated attributes in MultiAnswer error message table.
Use styles instead. Also switch to using the `tag` method.
1 parent 82e6346 commit 773f35e

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

macros/parsers/parserMultiAnswer.pl

+26-13
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# Artistic License for more details.
1414
################################################################################
1515

16-
loadMacros("MathObjects.pl");
16+
loadMacros('MathObjects.pl', 'PGbasicmacros.pl');
1717

1818
sub _parserMultiAnswer_init {
1919
main::PG_restricted_eval('sub MultiAnswer {parser::MultiAnswer->new(@_)}');
@@ -175,7 +175,12 @@ sub single_check {
175175
my $i = 0;
176176
my $nonblank = 0;
177177
if ($self->perform_check($ans)) {
178-
push(@errors, '<TR><TD STYLE="text-align:left" COLSPAN="2">' . $self->{ans}[0]{ans_message} . '</TD></TR>');
178+
push(
179+
@errors,
180+
main::tag(
181+
'tr', main::tag('td', style => 'text-align:left', colspan => '2', $self->{ans}[0]{ans_message})
182+
)
183+
);
179184
$self->{ans}[0]{ans_message} = "";
180185
}
181186
foreach my $result (@{ $self->{ans} }) {
@@ -185,26 +190,34 @@ sub single_check {
185190
push(@text, check_string($result->{preview_text_string}, '__'));
186191
push(@student, check_string($result->{student_ans}, '__'));
187192
if ($result->{ans_message}) {
188-
push(@errors,
189-
'<TR VALIGN="TOP"><TD STYLE="text-align:right; border:0px" NOWRAP>'
190-
. "<I>In answer $i</I>:&nbsp;</TD>"
191-
. '<TD STYLE="text-align:left; border:0px">'
192-
. $result->{ans_message}
193-
. '</TD></TR>');
193+
push(
194+
@errors,
195+
main::tag(
196+
'tr',
197+
main::tag(
198+
'td',
199+
style => 'text-align:right',
200+
main::tag('i', "In answer $i") . ':&nbsp;'
201+
)
202+
. main::tag('td', style => 'text-align:left', $result->{ans_message})
203+
)
204+
);
194205
}
195206
$score += $result->{score};
196207
}
197208
$ans->score($score / $self->length);
198209
$ans->{ans_message} = $ans->{error_message} = "";
199210
if (scalar(@errors)) {
200-
$ans->{ans_message} = $ans->{error_message} =
201-
'<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" CLASS="ArrayLayout">'
202-
. join('<TR><TD HEIGHT="4"></TD></TR>', @errors)
203-
. '</TABLE>';
211+
$ans->{ans_message} = $ans->{error_message} = main::tag(
212+
'table',
213+
class => 'ArrayLayout',
214+
style => 'width:100%',
215+
join(main::tag('tr', style => 'height: 4px', main::tag('td')), @errors)
216+
);
204217
}
205218
if (@{ $self->{single_ans_messages} }) {
206219
$ans->{ans_message} = $ans->{error_message} =
207-
'<DIV>' . join('</DIV><DIV>', @{ $self->{single_ans_messages} }) . '</DIV>' . $ans->{ans_message};
220+
join('', map { main::tag('div', $_) } @{ $self->{single_ans_messages} });
208221
}
209222
if ($nonblank) {
210223
$ans->{preview_latex_string} =

0 commit comments

Comments
 (0)