From 0dd1e51e873958ea7b2def1aab640128aa8d9c37 Mon Sep 17 00:00:00 2001 From: Richard Lobb Date: Fri, 23 Aug 2024 14:41:38 +1200 Subject: [PATCH] Regression: testing_outcome was giving php errors with newer PHP versions. --- classes/testing_outcome.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/classes/testing_outcome.php b/classes/testing_outcome.php index 03cc72c4..51d197e1 100644 --- a/classes/testing_outcome.php +++ b/classes/testing_outcome.php @@ -233,19 +233,23 @@ protected function format_failed_test($rownum, $code, $expected, $got, $sanitise '#id_testcode_' . $rownum, get_string('testcase', 'qtype_coderunner', $rownum + 1) ) . "$nl
$code
"; - $expected = html_writer::link( + $expectedlink = html_writer::link( '#id_expected_' . $rownum, html_writer::tag( 'pre', - $expected, + $expected instanceof qtype_coderunner_html_wrapper ? $expected->value() : $expected, ['id' => 'id_fail_expected_' . $rownum] ) ); - $gotpre = html_writer::tag('pre', $got, ['id' => 'id_got_' . $rownum]); + $gotpre = html_writer::tag( + 'pre', + $got instanceof qtype_coderunner_html_wrapper ? $got->value() : $got, + ['id' => 'id_got_' . $rownum] + ); $button = html_writer::tag('button', '<<', [ 'type' => 'button', // To suppress form submission. 'class' => 'replaceexpectedwithgot']); - return [$testcode, $expected, $gotpre . $button]; + return [$testcode, $expectedlink, $gotpre . $button]; } // Return a message summarising the nature of the error if this outcome