MDL-80682 core_question: Question version information should be clearer

This commit is contained in:
DangHieu1407
2025-02-17 15:04:38 +07:00
committed by hieuvu
parent 77a7d81290
commit 013a3085b0
7 changed files with 63 additions and 18 deletions
@@ -7,14 +7,19 @@ Feature: Use the qbank plugin manager page for question history
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "activities" exist:
| activity | name | course | idnumber |
| quiz | Test quiz | C1 | quiz1 |
| activity | name | intro | course | idnumber |
| quiz | Test quiz | | C1 | quiz1 |
| qbank | Qbank 1 | Question bank 1 | C1 | qbank1 |
| qbank | Qbank 2 | Question bank 2 | C1 | qbank2 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Activity module | quiz1 | Test questions |
| contextlevel | reference | name |
| Activity module | quiz1 | Test questions |
| Activity module | qbank1 | Share questions |
| Activity module | qbank2 | Share questions 2 |
And the following "questions" exist:
| questioncategory | qtype | name | questiontext |
| Test questions | truefalse | First question | Answer the first question |
| questioncategory | qtype | name | questiontext |
| Test questions | truefalse | First question | Answer the first question |
| Share questions | essay | Test question to be edited | Write about whatever you want |
Scenario: Enable/disable question history column from the base view
Given I log in as "admin"
@@ -43,7 +48,7 @@ Feature: Use the qbank plugin manager page for question history
Scenario: Viewing history for a question in a non-default category
Given the following "question categories" exist:
| contextlevel | reference | name |
| Activity module | quiz1 | Test questions 2 |
| Activity module | quiz1 | Test questions 2 |
And the following "questions" exist:
| questioncategory | qtype | name | questiontext |
| Test questions 2 | truefalse | Second question | Answer the second question |
@@ -109,3 +114,12 @@ Feature: Use the qbank plugin manager page for question history
And "Last used" "qbank_columnsortorder > column header" should exist
And "First question" "table_row" should exist
And "Second question" "table_row" should not exist
Scenario: Go History page in edit question page.
Given I am on the "Test quiz" "mod_quiz > question bank" page logged in as "admin"
When I choose "Edit question" action for "First question" in the question bank
And I click on "History" "link"
Then I should see "First question"
And I follow "Close"
And the following fields match these values:
| Question text | Answer the first question |
+1
View File
@@ -0,0 +1 @@
version,qbank_viewcreator
@@ -23,8 +23,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['history'] = 'History';
$string['modifiedby'] = 'Modified by';
$string['timemodified'] = 'Time modified';
$string['pluginname'] = 'View creator';
$string['privacy:metadata'] = 'The View creator question bank plugin does not store any personal data.';
// Deprecated since Moodle 4.5.
$string['version'] = 'Version {$a}';
+28 -3
View File
@@ -30,10 +30,35 @@
* @return string
*/
function qbank_viewcreator_edit_form_display($question): string {
global $DB, $PAGE;
global $DB, $PAGE, $OUTPUT;
$question = question_bank::load_question($question->id);
$versiondata = [];
$questionversion = $DB->get_record('question_versions', ['questionid' => $question->id])->version;
$versiondata['versionnumber'] = $questionversion;
$versioninfo = new \core_question\output\question_version_info($question, true);
$versiondata['versionnumber'] = $versioninfo->export_for_template($OUTPUT)['versioninfo'];
// Currently the history only display the question versions for just only default category.
// To display question in the other category.
// So we need to add filter param so that we can display the question in different category.
$filterparam = json_encode([
'category' => [
'jointype' => 1,
'values' => [$question->category],
'filteroptions' => ['includesubcategories' => false],
],
]);
// We need a return url param so that click close button on history page should redirect back to edit question page.
// Set params filter to returnurl so that when we use the move feature It will not cause any error.
$returnurl = $PAGE->url;
$returnurl->param('filter', $filterparam);
$versiondata['historyurl'] = new moodle_url('/question/bank/history/history.php', [
'entryid' => $question->questionbankentryid,
'returnurl' => $returnurl,
'courseid' => $PAGE->course->id,
'filter' => $filterparam,
'cmid' => $PAGE->url->param('cmid'),
]);
if (!empty($question->createdby)) {
$a = new stdClass();
$a->time = userdate($question->timecreated);
@@ -22,16 +22,17 @@
"addquestiondata": [
{
"versionnumber": 1,
"historyurl": "www.example.com/question/bank/history/history.php",
"createdby": "Admin User on Wednesday, 20 October 2021, 5:33 AM"
}
]
}
}}
<div class="question-version-number">
<a><u>{{#str}} version, qbank_viewcreator, {{versionnumber}} {{/str}}</u></a>
<span> {{versionnumber}}. </span> <a href="{{{historyurl}}}"> {{#pix}} t/log, core {{/pix}} {{#str}}history, qbank_viewcreator{{/str}} </a>
</div>
{{#createdby}}
<div class="question-creator-info">
<a>{{{createdby}}}</a>
<span>{{{createdby}}}</span>
</div>
{{/createdby}}
@@ -54,7 +54,8 @@ Feature: Question bank Modified by column
And I press "Apply filters"
And I should see "First question"
And I choose "Edit question" action for "First question" in the question bank
And I should see "Version 1"
And "History" "link" should exist
And I should see "v1 (latest)"
And I set the field "id_name" to "Renamed question v2"
And I set the field "id_questiontext" to "edited question"
And I press "id_submitbutton"
@@ -65,7 +66,7 @@ Feature: Question bank Modified by column
And I set the field "Category" to "Test questions"
And I press "Apply filters"
And I choose "Edit question" action for "Renamed question v2" in the question bank
Then I should see "Version 2"
Then I should see "v2 (latest)"
And I set the field "id_name" to "Renamed question v3"
And I set the field "id_questiontext" to "edited question v3"
And I press "id_submitbutton"
@@ -31,18 +31,18 @@ Feature: Questions in the question bank have versions
Scenario: Question version is displayed
Given I am on the "Quiz 1" "mod_quiz > question bank" page logged in as "teacher1"
When I choose "Edit question" action for "First question" in the question bank
Then I should see "Version 1"
Then I should see "v1 (latest)"
@javascript
Scenario: Question version change when question is altered
Given I am on the "Quiz 1" "mod_quiz > question bank" page logged in as "teacher1"
When I choose "Edit question" action for "First question" in the question bank
And I should see "Version 1"
And I should see "v1 (latest)"
When I set the field "id_name" to "Renamed question v2"
And I set the field "id_questiontext" to "edited question"
And I press "id_submitbutton"
Then I should not see "First question"
And I should see "Renamed question v2"
When I choose "Edit question" action for "Renamed question v2" in the question bank
Then I should see "Version 2"
And I should not see "Version 1"
Then I should see "v2 (latest)"
And I should not see "v1 (latest)"