From 6719a4fd84b8042e9a6e2f0539e70845275367f2 Mon Sep 17 00:00:00 2001 From: hieuvu Date: Tue, 17 Dec 2024 16:48:09 +0700 Subject: [PATCH] StudentQuiz: Make show all link working with pagination --- classes/question/bank/studentquiz_bank_view.php | 10 ++++++++++ tests/behat/pagination.feature | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/classes/question/bank/studentquiz_bank_view.php b/classes/question/bank/studentquiz_bank_view.php index f4102fa4..50de3642 100755 --- a/classes/question/bank/studentquiz_bank_view.php +++ b/classes/question/bank/studentquiz_bank_view.php @@ -579,6 +579,16 @@ public function load_questions() { return $questions; } + #[\Override] + protected function load_page_questions(): \moodle_recordset { + global $DB; + if (!$this->pagevars['showall']) { + return parent::load_page_questions(); + } else { + return $DB->get_recordset_sql($this->loadsql, $this->sqlparams); + } + } + /** * TODO: rename function and apply (there is duplicate method) * @return bool studentquiz is set to anoymize ranking. diff --git a/tests/behat/pagination.feature b/tests/behat/pagination.feature index 1d53b6d8..78163478 100644 --- a/tests/behat/pagination.feature +++ b/tests/behat/pagination.feature @@ -67,6 +67,11 @@ Feature: Test pagination for StudentQuiz # Verify that the first question and the last question are displayed, ensuring all essential questions are visible. And I should see "TF 01" And I should see "Test question 9" + And I click on "Show 20 per page" "link" + # Verify that the first question and the last question are displayed, ensuring all essential questions are visible when click show all. + And I click on "Show all 25" "link" + And I should see "TF 01" + And I should see "Test question 24" @javascript Scenario: Users using filter should keep the same pagination.