Skip to content

Commit 46f11d3

Browse files
committed
Exercise: Refactor answer handling in exercise_show_functions.lib.php for oral expression questions - refs BT#22308
1 parent 7638f49 commit 46f11d3

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

main/inc/lib/exercise_show_functions.lib.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,19 @@ public static function display_oral_expression_answer(
221221
echo '<tr><td>&nbsp;</td></tr>';
222222
}
223223
} else {
224-
echo '<tr>';
225-
echo '<td>';
226-
if (!empty($answer)) {
227-
echo Security::remove_XSS($answer);
224+
$text = '';
225+
226+
if (is_array($answer) && !empty($answer['answer'])) {
227+
$text = $answer['answer'];
228+
} elseif (!is_array($answer)) {
229+
$text = $answer;
230+
}
231+
232+
if (!empty($text)) {
233+
echo '<tr><td>';
234+
echo Security::remove_XSS($text);
235+
echo '</td></tr>';
228236
}
229-
echo '</td>';
230-
echo '</tr>';
231237
}
232238
}
233239

0 commit comments

Comments
 (0)