Skip to content

Commit

Permalink
Fix quiz header / summary table injection in Moodle 4.4+
Browse files Browse the repository at this point in the history
  • Loading branch information
ngandrass committed May 13, 2024
1 parent c468344 commit f2809b0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions classes/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public function get_attempt_attechments_metadata(int $attemptid): array {
* @throws \moodle_exception
*/
public function generate(int $attemptid, array $sections): string {
global $DB, $PAGE;
global $CFG, $DB, $PAGE;
$ctx = \context_module::instance($this->cm->id);
$renderer = $PAGE->get_renderer('mod_quiz');
$html = '';
Expand Down Expand Up @@ -500,7 +500,15 @@ public function generate(int $attemptid, array $sections): string {
];

// Add summary table to the html
$html .= $renderer->review_summary_table($quiz_header_data, 0);
if ($CFG->branch <= 403) {
// FIXME: Remove after Moodle 4.1 (LTS) support ends on 2025-12-08
$html .= $renderer->review_summary_table($quiz_header_data, 0);
} else {
$html .= $renderer->review_attempt_summary(
\mod_quiz\output\attempt_summary_information::create_from_legacy_array($quiz_header_data),
0
);
}
}

// ##### Section: Quiz questions #####
Expand Down

0 comments on commit f2809b0

Please sign in to comment.