diff --git a/CHANGES.md b/CHANGES.md index a73f4e3..e594b36 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,8 +4,9 @@ moodle-quiz_archive Changes ------- -### Unreleased +### Release v4.4-r1 +* 2024-04-21 - Assure PHP 8.3 compatibility. * 2023-11-29 - Behat step for the quiz_archive plugin instead of re-defining ### Release v4.3-r3 diff --git a/README.md b/README.md index eb13ea2..93711c5 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ moodle-quiz_archive ========================= [![Latest Release](https://img.shields.io/github/v/release/bfh/moodle-quiz_archive?sort=semver&color=orange)](https://github.com/bfh/moodle-quiz_archive/releases) [![Build Status](https://github.com/bfh/moodle-quiz_archive/workflows/Moodle%20Plugin%20CI/badge.svg?branch=main)](https://github.com/bfh/moodle-quiz_archive/actions?query=workflow%3A%22Moodle+Plugin+CI%22+branch%3Amain) -[![PHP Support](https://img.shields.io/badge/php-7.2--8.2-blue)](https://github.com/bfh/moodle-quiz_archive/actions) -[![Moodle Support](https://img.shields.io/badge/Moodle-3.9--4.3+-orange)](https://github.com/bfh/moodle-quiz_archive/actions) +[![PHP Support](https://img.shields.io/badge/php-7.2--8.3-blue)](https://github.com/bfh/moodle-quiz_archive/actions) +[![Moodle Support](https://img.shields.io/badge/Moodle-3.9--4.4+-orange)](https://github.com/bfh/moodle-quiz_archive/actions) [![License GPL-3.0](https://img.shields.io/github/license/bfh/moodle-quiz_archive?color=lightgrey)](https://github.com/bfh/moodle-quiz_archive/blob/main/LICENSE) [![GitHub contributors](https://img.shields.io/github/contributors/bfh/moodle-quiz_archive)](https://github.com/bfh/moodle-quiz_archive/graphs/contributors) @@ -13,7 +13,7 @@ Moodle quiz report plugin to achieve archiving your test, by printing out all at Requirements ------------ -This plugin requires Moodle 3.4. +This plugin requires Moodle 3.9. Motivation for this report diff --git a/lang/en/quiz_archive.php b/lang/en/quiz_archive.php index 7fafe60..68c7d29 100644 --- a/lang/en/quiz_archive.php +++ b/lang/en/quiz_archive.php @@ -23,12 +23,8 @@ */ $string['archive'] = 'Archive'; +$string['includecorrectanswer'] = 'Include correct answer banner'; +$string['includehistory'] = 'Include response history table'; $string['pluginname'] = 'Archive'; -$string['unknownquestion'] = 'Unknown question'; - -// PRIVACY. $string['privacy:metadata'] = 'The quiz archive plugin does not store any personal data about any user.'; - -// OPTIONS. -$string['includehistory'] = 'Include response history table'; -$string['includecorrectanswer'] = 'Include correct answer banner'; +$string['unknownquestion'] = 'Unknown question'; diff --git a/report.php b/report.php index 41faea7..241cacd 100644 --- a/report.php +++ b/report.php @@ -23,6 +23,7 @@ */ use mod_quiz\local\reports\report_base; +use mod_quiz\output\attempt_summary_information; use mod_quiz\quiz_attempt; use mod_quiz\question\display_options; use mod_quiz\local\reports\attempts_report; @@ -47,6 +48,7 @@ class_alias('\mod_quiz_display_options', '\quiz_archive_mod_quiz_display_options require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php'); require_once($CFG->dirroot . '/mod/quiz/locallib.php'); require_once($CFG->libdir . '/pagelib.php'); +require_once($CFG->libdir . '/environmentlib.php'); /** * Quiz report subclass for the archive report. @@ -174,7 +176,7 @@ protected function quizreportgetstudentandattempts($quiz) { * @param int $userid the user id. */ protected function quiz_report_get_student_attempt($attemptid, $userid) { - global $DB, $PAGE; + global $DB, $PAGE, $CFG; $attemptobj = quiz_create_attempt_handling_errors($attemptid, $this->cm->id); // Summary table start. @@ -230,10 +232,14 @@ protected function quiz_report_get_student_attempt($attemptid, $userid) { 'title' => get_string('completedon', 'quiz'), 'content' => userdate($attempt->timefinish), ]; - $summarydata['timetaken'] = [ - 'title' => get_string('timetaken', 'quiz'), - 'content' => $timetaken, - ]; + $currentversion = normalize_version($CFG->release); + if (version_compare($currentversion, '4.4', "<")) { + // Beginning Moodle 4.4, the string 'timetaken' is deprecated and not used anymore. + $summarydata['timetaken'] = [ + 'title' => get_string('timetaken', 'quiz'), + 'content' => $timetaken, + ]; + } } if (!empty($overtime)) { @@ -315,7 +321,15 @@ protected function quiz_report_get_student_attempt($attemptid, $userid) { $renderer = $PAGE->get_renderer('mod_quiz'); $string = ''; - $string .= $renderer->review_summary_table($summarydata, 0); + + if (method_exists($renderer, 'review_attempt_summary')) { + $displayoptions = $attemptobj->get_display_options(true); + $summarydata = attempt_summary_information::create_for_attempt( + $attemptobj, $displayoptions); + $string .= $renderer->review_attempt_summary($summarydata, 0); + } else { + $string .= $renderer->review_summary_table($summarydata, 0); + } // Display the questions. The overall goal is to have question_display_options from question/engine/lib.php // set so they would show what we wand and not show what we don't want. diff --git a/tests/behat/behat_quiz_archive.php b/tests/behat/behat_quiz_archive.php index cba7e70..c565ef0 100644 --- a/tests/behat/behat_quiz_archive.php +++ b/tests/behat/behat_quiz_archive.php @@ -62,7 +62,6 @@ protected function resolve_page_url(string $page): moodle_url { * @throws Exception with a meaningful error message if the specified page cannot be found. */ protected function resolve_page_instance_url(string $type, string $identifier): moodle_url { - global $DB; switch ($type) { case 'Archive': @@ -106,7 +105,7 @@ public function i_confirm_the_quiz_submission_in_the_modal_dialog_for_the_quiz_a global $CFG; require_once($CFG->libdir . '/environmentlib.php'); require($CFG->dirroot . '/version.php'); - $currentversion = normalize_version($release); + $currentversion = normalize_version($CFG->release); if (version_compare($currentversion, '4.1', ">=")) { $xpath = "//div[contains(@class, 'modal-dialog')]/*/*/button[contains(@class, 'btn-primary')]"; } else if (version_compare($currentversion, '3.9', ">=")) { diff --git a/version.php b/version.php index 2a5f0e7..5e1cc37 100644 --- a/version.php +++ b/version.php @@ -28,5 +28,5 @@ $plugin->requires = 2017110800; $plugin->component = 'quiz_archive'; $plugin->maturity = MATURITY_STABLE; -$plugin->release = 'v4.3-r3'; -$plugin->supported = [39, 403]; +$plugin->release = 'v4.4-r1'; +$plugin->supported = [39, 404];