From 4010c792d587801a31c7bea5ba3cc523df5e2f36 Mon Sep 17 00:00:00 2001 From: Richard Lobb Date: Mon, 15 Apr 2024 15:13:44 +1200 Subject: [PATCH] Fix various bugs in new combinator grader. --- classes/combinator_grader_outcome.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/classes/combinator_grader_outcome.php b/classes/combinator_grader_outcome.php index c9c2c224..1f702ae4 100644 --- a/classes/combinator_grader_outcome.php +++ b/classes/combinator_grader_outcome.php @@ -161,7 +161,7 @@ private function insert_file_urls($html, $urls) { } } } - return $html; // return the modified HTML. + return $html; // Return the modified HTML. } @@ -181,12 +181,13 @@ public function set_mark_and_feedback($markfraction, $feedback) { if ($this->valid_table_formats($testresults, $columnformats)) { if ($files) { $urls = $this->save_files($files); - $htmlfields = ['feedbackhtml', 'prologuehtml', 'epiloguehtml', 'instructorhtml']; - foreach ($htmlfields as $field) { - if ($this->$field) { - $this->$field = $this->insert_file_urls($this->$field, $urls); - } - }; + } + foreach ($feedback as $field => $value) { + if ($urls && in_array($field, ['prologuehtml', 'epiloguehtml', 'instructorhtml', 'feedbackhtml'])) { + $this->$field = $this->insert_file_urls($value, $urls); + } else { + $this->$field = $value; + } } $this->format_results_table($testresults, $columnformats, $urls); } @@ -401,8 +402,8 @@ private function format_results_table($testresults, $columnformats, $urls) { } $newtable[] = $newrow; } + $this->testresults = $newtable; } - $this->testresults = $newtable; } public function get_prologue() {