mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Merge branch 'MDL-76766-master' of https://github.com/aanabit/moodle
This commit is contained in:
commit
89b722402e
5 changed files with 14 additions and 11 deletions
|
@ -32,7 +32,6 @@ namespace mod_quiz\event;
|
||||||
*
|
*
|
||||||
* - int quizid: the id of the quiz.
|
* - int quizid: the id of the quiz.
|
||||||
* - bool shuffle: shuffle option value.
|
* - 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.
|
* - 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() {
|
public function get_description() {
|
||||||
return "The user with id '$this->userid' updated the section with id '{$this->objectid}' " .
|
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'. " .
|
"belonging to the quiz with course module id '$this->contextinstanceid'. " .
|
||||||
"Its shuffle option was set to '{$this->other['shuffle']}'.";
|
"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.');
|
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'])) {
|
if (!isset($this->other['firstslotnumber'])) {
|
||||||
throw new \coding_exception('The \'firstslotnumber\' value must be set in other.');
|
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() {
|
public static function get_other_mapping() {
|
||||||
$othermapped = [];
|
$othermapped = [];
|
||||||
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
$othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
|
||||||
$othermapped['firstslotid'] = ['db' => 'quiz_slots', 'restore' => 'quiz_question_instance'];
|
|
||||||
|
|
||||||
return $othermapped;
|
return $othermapped;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1339,14 +1339,12 @@ class structure {
|
||||||
$DB->update_record('quiz_sections', $section);
|
$DB->update_record('quiz_sections', $section);
|
||||||
|
|
||||||
// Log section shuffle updated event.
|
// 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([
|
$event = \mod_quiz\event\section_shuffle_updated::create([
|
||||||
'context' => $this->quizobj->get_context(),
|
'context' => $this->quizobj->get_context(),
|
||||||
'objectid' => $id,
|
'objectid' => $id,
|
||||||
'other' => [
|
'other' => [
|
||||||
'quizid' => $this->get_quizid(),
|
'quizid' => $this->get_quizid(),
|
||||||
'firstslotid' => $firstslot->id,
|
'firstslotnumber' => $section->firstslot,
|
||||||
'firstslotnumber' => $firstslot->slot,
|
|
||||||
'shuffle' => $shuffle
|
'shuffle' => $shuffle
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -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"
|
Then "question 01 name" "text" should appear before "question 03 name" "text"
|
||||||
And I follow "Sort by Question type descending"
|
And I follow "Sort by Question type descending"
|
||||||
Then "question 03 name" "text" should appear before "question 01 name" "text"
|
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"
|
||||||
|
|
|
@ -1131,7 +1131,6 @@ class events_test extends \advanced_testcase {
|
||||||
'context' => context_module::instance($quizobj->get_cmid()),
|
'context' => context_module::instance($quizobj->get_cmid()),
|
||||||
'other' => [
|
'other' => [
|
||||||
'quizid' => $quizobj->get_quizid(),
|
'quizid' => $quizobj->get_quizid(),
|
||||||
'firstslotid' => 1,
|
|
||||||
'firstslotnumber' => 2,
|
'firstslotnumber' => 2,
|
||||||
'shuffle' => true
|
'shuffle' => true
|
||||||
]
|
]
|
||||||
|
|
|
@ -6,6 +6,7 @@ This files describes API changes in the quiz code.
|
||||||
some returns a moodle_url and others aa string.
|
some returns a moodle_url and others aa string.
|
||||||
* The method quiz_settings::confirm_start_attempt_message, which was deprecated in Moodle 3.1, is now completely removed.
|
* The method quiz_settings::confirm_start_attempt_message, which was deprecated in Moodle 3.1, is now completely removed.
|
||||||
* The field view_page::$startattemptwarning, which was deprecated in Moodle 3.1, is now completely removed.
|
* The field view_page::$startattemptwarning, which was deprecated in Moodle 3.1, is now completely removed.
|
||||||
|
* 'firstslotid' value is not used in section_shuffle_updated event anymore.
|
||||||
* The quiz has a lot of old classes in lib.php files. These have now been moved into the classes folder,
|
* The quiz has a lot of old classes in lib.php files. These have now been moved into the classes folder,
|
||||||
and so are now in namespaces. Because of Moodle's class renaming support, your code should continue
|
and so are now in namespaces. Because of Moodle's class renaming support, your code should continue
|
||||||
working, but output deprecated warnings, so you probably want to update. This should mostly be
|
working, but output deprecated warnings, so you probably want to update. This should mostly be
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue