Merge branch 'MDL-76766-401' of https://github.com/aanabit/moodle into MOODLE_401_STABLE

This commit is contained in:
Ilya Tregubov 2023-01-19 11:04:23 +08:00
commit 69fbf97923
5 changed files with 16 additions and 12 deletions

View File

@ -32,7 +32,6 @@ namespace mod_quiz\event;
*
* - int quizid: the id of the quiz.
* - bool shuffle: shuffle option value.
* - int firstslotid: id of the slot which is right after the section break.
* - int firstslotnumber: slot number of the slot which is right after the section break.
* }
*
@ -53,7 +52,7 @@ class section_shuffle_updated extends \core\event\base {
public function get_description() {
return "The user with id '$this->userid' updated the section with id '{$this->objectid}' " .
"before the slot with id '{$this->other['firstslotid']}' and slot number '{$this->other['firstslotnumber']}' " .
"before the slot number '{$this->other['firstslotnumber']}' " .
"belonging to the quiz with course module id '$this->contextinstanceid'. " .
"Its shuffle option was set to '{$this->other['shuffle']}'.";
}
@ -79,10 +78,6 @@ class section_shuffle_updated extends \core\event\base {
throw new \coding_exception('The \'quizid\' value must be set in other.');
}
if (!isset($this->other['firstslotid'])) {
throw new \coding_exception('The \'firstslotid\' value must be set in other.');
}
if (!isset($this->other['firstslotnumber'])) {
throw new \coding_exception('The \'firstslotnumber\' value must be set in other.');
}
@ -100,7 +95,6 @@ class section_shuffle_updated extends \core\event\base {
public static function get_other_mapping() {
$othermapped = [];
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
$othermapped['firstslotid'] = ['db' => 'quiz_slots', 'restore' => 'quiz_question_instance'];
return $othermapped;
}

View File

@ -1205,14 +1205,12 @@ class structure {
$DB->update_record('quiz_sections', $section);
// Log section shuffle updated event.
$firstslot = $DB->get_record('quiz_slots', array('quizid' => $this->get_quizid(), 'slot' => $section->firstslot));
$event = \mod_quiz\event\section_shuffle_updated::create([
'context' => $this->quizobj->get_context(),
'objectid' => $id,
'other' => [
'quizid' => $this->get_quizid(),
'firstslotid' => $firstslot->id,
'firstslotnumber' => $firstslot->slot,
'firstslotnumber' => $section->firstslot,
'shuffle' => $shuffle
]
]);

View File

@ -126,3 +126,14 @@ Feature: Adding questions to a quiz from the question bank
Then "question 01 name" "text" should appear before "question 03 name" "text"
And I follow "Sort by Question type descending"
Then "question 03 name" "text" should appear before "question 01 name" "text"
Scenario: Shuffle option could be set before adding any question to the quiz
Given the following "questions" exist:
| questioncategory | qtype | name | questiontext |
| Test questions | essay | question 03 name | question 03 text |
And I log in as "teacher1"
And I am on the "Quiz 1" "mod_quiz > Edit" page
When I set the field "Shuffle" to "1"
And I open the "last" add to quiz menu
And I follow "from question bank"
Then I should see "question 01 name"

View File

@ -1136,7 +1136,6 @@ class events_test extends \advanced_testcase {
'context' => context_module::instance($quizobj->get_cmid()),
'other' => [
'quizid' => $quizobj->get_quizid(),
'firstslotid' => 1,
'firstslotnumber' => 2,
'shuffle' => true
]

View File

@ -1,10 +1,12 @@
This files describes API changes in the quiz code.
=== 4.1.1 ===
* 'firstslotid' value is not used in section_shuffle_updated event anymore.
=== 4.1 ===
* quiz_has_question_use is now deprecated. Use mod_quiz\structure::has_use_capability istead.
=== 4.0.3, 4.1 ===
* If a quiz is sequential the external functions mod_quiz_external::get_attempt_data, mod_quiz_external::get_attempt_summary will not return any data