diff --git a/question/bank/history/history.php b/question/bank/history/history.php index 6e80d200765..65952277ee8 100644 --- a/question/bank/history/history.php +++ b/question/bank/history/history.php @@ -36,7 +36,15 @@ list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) = question_edit_setup('questions', '/question/bank/history/history.php'); $pagevars['entryid'] = $entryid; $pagevars['returnurl'] = $returnurl; -$url = new moodle_url($thispageurl, ['entryid' => $entryid, 'returnurl' => $returnurl]); +$url = new moodle_url( + $thispageurl, + [ + 'entryid' => $entryid, + 'returnurl' => $returnurl, + 'view' => '\qbank_history\question_history_view', + 'extraparams' => json_encode(['entryid' => $entryid, 'returnurl' => $returnurl]), + ], +); $PAGE->set_url($url); // Additional param to differentiate with other question bank view. diff --git a/question/bank/history/tests/behat/question_history_action.feature b/question/bank/history/tests/behat/question_history_action.feature index f9dd7b742b3..4ac983f1467 100644 --- a/question/bank/history/tests/behat/question_history_action.feature +++ b/question/bank/history/tests/behat/question_history_action.feature @@ -86,3 +86,23 @@ Feature: Use the qbank plugin manager page for question history And I click on "Continue" "button" And I should see "Question bank" And I should not see "First question" + + Scenario: Resetting the columns in the question history view will return it to its default setting. + Given the following "user preferences" exist: + | user | preference | value | + | admin | qbank_columnsortorder_hiddencols | qbank_usage\question_last_used_column-question_last_used_column | + And the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | Second question | Answer the second question | + When I am on the "Test quiz" "mod_quiz > question bank" page logged in as "admin" + And "Last used" "qbank_columnsortorder > column header" should not exist + Then I should see "First question" + And I should see "Second question" + And I choose "History" action for "First question" in the question bank + And "First question" "table_row" should exist + And "Second question" "table_row" should not exist + And "Last used" "qbank_columnsortorder > column header" should not exist + And I follow "Reset columns" + And "Last used" "qbank_columnsortorder > column header" should exist + And "First question" "table_row" should exist + And "Second question" "table_row" should not exist diff --git a/question/lib.php b/question/lib.php index 758c642d979..336b0ba97ed 100644 --- a/question/lib.php +++ b/question/lib.php @@ -69,6 +69,12 @@ function core_question_output_fragment_question_data(array $args): string { if (!empty($args['lastchanged'])) { $thispageurl->param('lastchanged', clean_param($args['lastchanged'], PARAM_INT)); } + if (!empty($args['view'])) { + $thispageurl->param('view', clean_param($args['view'], PARAM_NOTAGS)); + } + if (!empty($args['extraparams'])) { + $thispageurl->param('extraparams', clean_param($args['extraparams'], PARAM_RAW)); + } // This is highly suspicious, but it is the same approach taken in /question/edit.php. See MDL-79281. $thispageurl->param('deleteall', 1); $questionbank = new $viewclass($contexts, $thispageurl, $course, $cm, $pagevars, $extraparams);