MDL-82237 mod_quiz: Include all filters in "See questions" link
The "See questions" link for random questions was still using the old format the filter conditions, so was only applying the category filter on the list of questions displayed. This means that if a tag filter (or any other filter) was set on the random question set, it was not applied when viewing the list of questions. This change takes all the filter conditions applied in random question's slot and passes them to the question bank in the "See questions" link.
This commit is contained in:
@@ -1076,19 +1076,10 @@ class edit_renderer extends \plugin_renderer_base {
|
||||
|
||||
$editicon = $this->pix_icon('t/edit', $configuretitle, 'moodle', ['title' => '']);
|
||||
$qbankurlparams = [
|
||||
'cmid' => $structure->get_cmid(),
|
||||
'cat' => $slot->category . ',' . $slot->contextid,
|
||||
'courseid' => $structure->get_courseid(),
|
||||
'filter' => json_encode($slot->filtercondition['filter']),
|
||||
];
|
||||
|
||||
$slottags = [];
|
||||
if (isset($slot->randomtags)) {
|
||||
$slottags = $slot->randomtags;
|
||||
}
|
||||
foreach ($slottags as $index => $slottag) {
|
||||
$slottag = explode(',', $slottag);
|
||||
$qbankurlparams["qtagids[{$index}]"] = $slottag[0];
|
||||
}
|
||||
|
||||
// If this is a random question, display a link to show the questions
|
||||
// selected from in the question bank.
|
||||
$qbankurl = new \moodle_url('/question/edit.php', $qbankurlparams);
|
||||
|
||||
@@ -267,3 +267,27 @@ Feature: Adding random questions to a quiz based on category and tags
|
||||
And I should see "Random (New Random category) based on filter condition" on quiz page "1"
|
||||
And I click on "Configure question" "link" in the "Random (New Random category) based on filter condition" "list_item"
|
||||
Then I should see "New Random category"
|
||||
|
||||
Scenario: See questions link applies all random question filters
|
||||
Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
||||
And I open the "last" add to quiz menu
|
||||
And I follow "a random question"
|
||||
And I apply question bank filter "Tag" with value "foo"
|
||||
And I select "1" from the "randomcount" singleselect
|
||||
And I press "Add random question"
|
||||
And I should see "Random (Questions Category 1) based on filter condition with tags: foo" on quiz page "1"
|
||||
And I click on "Configure question" "link" in the "Random (Questions Category 1) based on filter condition with tags: foo" "list_item"
|
||||
And I should see "Questions Category 1"
|
||||
And I should see "foo"
|
||||
And I should see "question 1 name"
|
||||
And I should see "\"listen\" & \"answer\""
|
||||
And I should not see "bar"
|
||||
And I should not see "question 2 name"
|
||||
When I am on the "Quiz 1" "mod_quiz > Edit" page
|
||||
And I click on "(See questions)" "link" in the "Random (Questions Category 1) based on filter condition with tags: foo" "list_item"
|
||||
Then I should see "Questions Category 1"
|
||||
And I should see "foo"
|
||||
And I should see "question 1 name"
|
||||
And I should see "\"listen\" & \"answer\""
|
||||
And I should not see "bar"
|
||||
And I should not see "question 2 name"
|
||||
|
||||
Reference in New Issue
Block a user