Skip to content

Commit 6a4dd45

Browse files
committed
Fix invalid html for ans_array answers.
The `format_matrix_HTML` method uses `span` tags to format the html output for matrices. This is a problem when that is used to format the output for an `ans_array` answer because the answer inputs inside now are wrapped in `div` tags (so that the feedback button works in a valid html way). So this just switches to using `div`s instead. This doesn't change the result at all since the containg array layout div already has `display:inline-block` set. There is one minor tweak to the style. I added `text-align:center;` to the cells. This just looks better in about all of the cases that I have observed. Note that this is also consistent with when these objects are displayed in math mode via MathJax or as an image with the image display mode. Note that method is used ans_array matrix, vector, and point answer rules, as well as the "Entered" feedback preview of the student answer for those answers. It also affects the "textual" correct answer, but that actually isn't used for anything anymore.
1 parent ce1f03b commit 6a4dd45

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lib/Value/AnswerChecker.pm

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -555,57 +555,57 @@ sub format_matrix_HTML {
555555
my ($rows, $cols) = (scalar(@{$array}), scalar(@{ $array->[0] }));
556556
my $HTML = "";
557557
my $class = 'class="ans_array_cell"';
558-
my $cell = "display:table-cell;vertical-align:middle;";
558+
my $cell = "display:table-cell;vertical-align:middle;text-align:center;";
559559
my $pad = "padding:4px 0;";
560-
if ($sep) { $sep = '<span class="ans_array_sep" style="' . $cell . 'padding:0 2px">' . $sep . '</span>' }
561-
else { $sep = '<span class="ans_array_sep" style="' . $cell . 'width:8px"></span>' }
562-
$sep = '</span>' . $sep . '<span ' . $class . ' style="' . $cell . $pad . '">';
560+
if ($sep) { $sep = '<div class="ans_array_sep" style="' . $cell . 'padding:0 2px">' . $sep . '</div>' }
561+
else { $sep = '<div class="ans_array_sep" style="' . $cell . 'width:8px"></div>' }
562+
$sep = '</div>' . $sep . '<div ' . $class . ' style="' . $cell . $pad . '">';
563563

564564
if ($options{top_labels}) {
565565
$HTML .=
566-
'<span style="display:table-row"><span '
566+
'<div style="display:table-row"><div '
567567
. $class
568568
. ' style="'
569569
. $cell
570570
. $pad . '">'
571571
. join($sep, @{ $options{top_labels} })
572-
. '</span></span>';
572+
. '</div></div>';
573573
}
574574
foreach my $i (0 .. $rows - 1) {
575575
$HTML .=
576-
'<span style="display:table-row"><span '
576+
'<div style="display:table-row"><div '
577577
. $class
578578
. ' style="'
579579
. $cell
580580
. $pad . '">'
581581
. join($sep, EVALUATE(@{ $array->[$i] }))
582-
. '</span></span>';
582+
. '</div></div>';
583583
}
584-
$HTML = '<span class="ans_array_table" style="display:inline-table; vertical-align:middle">' . $HTML . '</span>';
584+
$HTML = '<div class="ans_array_table" style="display:inline-table; vertical-align:middle">' . $HTML . '</div>';
585585
$open = $self->format_delimiter($open, $rows, $options{tth_delims});
586586
$close = $self->format_delimiter($close, $rows, $options{tth_delims});
587587
if ($open ne '' || $close ne '') {
588588
my $delim = "display:inline-block; vertical-align:middle;";
589589
$HTML =
590-
'<span class="ans_array_open" style="'
590+
'<div class="ans_array_open" style="'
591591
. $delim
592592
. ' margin-right:4px">'
593593
. $open
594-
. '</span>'
594+
. '</div>'
595595
. $HTML
596-
. '<span class="ans_array_close" style="'
596+
. '<div class="ans_array_close" style="'
597597
. $delim
598598
. ' margin-left:4px">'
599599
. $close
600-
. '</span>';
600+
. '</div>';
601601
}
602-
return '<span class="ans_array" style="display:inline-block;vertical-align:.5ex"'
602+
return '<div class="ans_array" style="display:inline-block;vertical-align:.5ex"'
603603
. ($options{ans_last_name}
604604
? qq{ data-feedback-insert-element="$options{ans_last_name}" data-feedback-insert-method="append_content"}
605605
: '')
606606
. '>'
607607
. $HTML
608-
. '</span>';
608+
. '</div>';
609609
}
610610

611611
sub EVALUATE {

0 commit comments

Comments
 (0)