MDL-83832 core_question: Links to question history may show blank page

This commit is contained in:
Khoa Nguyen 2024-12-11 15:45:55 +07:00
parent 04cb4312bc
commit f10a1dba9f
2 changed files with 41 additions and 1 deletions

View File

@ -16,7 +16,9 @@
namespace qbank_history;
use core_question\local\bank\condition;
use core_question\local\bank\question_action_base;
use core_question\local\bank\filter_condition_manager;
/**
* Question bank column for the history action icon.
@ -49,11 +51,29 @@ class history_action extends question_action_base {
}
if (question_has_capability_on($question, 'use')) {
$currentfilter = $this->qbank->base_url()->param('filter');
if ($currentfilter) {
$currentfilter = filter_condition_manager::update_filter_param_to_category(
$currentfilter, $question->categoryid);
} else {
$currentfilter = json_encode([
'category' => [
'jointype' => condition::JOINTYPE_DEFAULT,
'values' => [$question->categoryid],
'filteroptions' => ['includesubcategories' => false],
],
'hidden' => [
'jointype' => condition::JOINTYPE_DEFAULT,
'values' => [0],
],
]);
}
$url = helper::question_history_url(
$question->questionbankentryid,
$this->qbank->returnurl,
$this->qbank->course->id,
$this->qbank->base_url()->param('filter'),
$currentfilter,
);
return [$url, 't/log', $this->strpreview];
}

View File

@ -55,6 +55,26 @@ Feature: Use the qbank plugin manager page for question history
And I should see "Second question"
And "Second question" "table_row" should exist
Scenario: Viewing history for a Question in a Subcategory
Given the following "question categories" exist:
| contextlevel | reference | questioncategory | name |
| Course | C1 | Test questions | Subcategory 1 |
And the following "questions" exist:
| questioncategory | qtype | name | questiontext |
| Subcategory 1 | truefalse | Question (v1) | Question version 1 |
When I am on the "Course 1" "core_question > course question categories" page logged in as "admin"
And I should see "Subcategory 1"
And I click on "Subcategory 1" "link"
Then I should see "Question (v1)"
And I choose "Edit question" action for "Question (v1)" in the question bank
And I set the following fields to these values:
| Question name | Question (v2) |
| Question text | Question version 2 |
And I press "id_submitbutton"
And I choose "History" action for "Question (v2)" in the question bank
And "Question (v1)" "table_row" should exist
And "Question (v2)" "table_row" should exist
@javascript
Scenario: Delete question from the history using Edit question menu
Given I am on the "Test quiz" "mod_quiz > question bank" page logged in as "admin"