From 1912982e95361e874f65421b3ecfaa5d3f0e68c8 Mon Sep 17 00:00:00 2001 From: hieuvu Date: Fri, 27 Jan 2023 15:10:50 +0700 Subject: [PATCH] MDL-76904 question: Keep question highlight in url --- question/edit.php | 7 ++-- .../tests/behat/question_highlight.feature | 35 +++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 question/tests/behat/question_highlight.feature diff --git a/question/edit.php b/question/edit.php index 1e0026a184c..d9d694ba5cb 100644 --- a/question/edit.php +++ b/question/edit.php @@ -29,11 +29,10 @@ require_once($CFG->dirroot . '/question/editlib.php'); list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) = question_edit_setup('questions', '/question/edit.php'); -$url = new moodle_url($thispageurl); if (($lastchanged = optional_param('lastchanged', 0, PARAM_INT)) !== 0) { - $url->param('lastchanged', $lastchanged); + $thispageurl->param('lastchanged', $lastchanged); } -$PAGE->set_url($url); +$PAGE->set_url($thispageurl); if ($PAGE->course->id == $SITE->id) { $PAGE->set_primary_active_tab('home'); @@ -53,7 +52,7 @@ echo $OUTPUT->header(); $renderer = $PAGE->get_renderer('core_question', 'bank'); // Render the selection action. -$qbankaction = new \core_question\output\qbank_action_menu($url); +$qbankaction = new \core_question\output\qbank_action_menu($thispageurl); echo $renderer->render($qbankaction); // Print the question area. diff --git a/question/tests/behat/question_highlight.feature b/question/tests/behat/question_highlight.feature new file mode 100644 index 00000000000..46d67734637 --- /dev/null +++ b/question/tests/behat/question_highlight.feature @@ -0,0 +1,35 @@ +@core @core_question +Feature: A teacher can see highlighted questions in the question bank + In order to see my edited questions + As a teacher + I need to be able see the highlight of my edited question. + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | format | + | Course 1 | C1 | weeks | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + And the following "question categories" exist: + | contextlevel | reference | name | + | Course | C1 | Test questions | + And 101 "questions" exist with the following data: + | questioncategory | Test questions | + | qtype | essay | + | name | essay [count] | + | questiontext | Write about whatever you want | + + Scenario: Edited question highlight is retained when go to multiple pages. + Given I am on the "Course 1" "core_question > course question bank" page logged in as "teacher1" + And I am on the "essay 1" "core_question > edit" page logged in as "teacher1" + And I set the following fields to these values: + | Question name | essay 1 edited | + And I press "id_submitbutton" + And I should see "essay 1 edited" + And ".highlight" "css_element" should exist in the "#categoryquestions" "css_element" + When I click on "Show all 101" "link" + Then ".highlight" "css_element" should exist in the "#categoryquestions" "css_element"