mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-66378 behat: Fix use of before/after selectors
This commit is contained in:
parent
989f380089
commit
221bfed37b
3 changed files with 20 additions and 12 deletions
|
@ -102,7 +102,7 @@ class core_question_generator extends component_generator_base {
|
|||
* @param array|stdClass $overrides any fields that should be different from the base example.
|
||||
*/
|
||||
public function update_question($question, $which = null, $overrides = null) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
|
||||
$qtype = $question->qtype;
|
||||
|
@ -113,7 +113,16 @@ class core_question_generator extends component_generator_base {
|
|||
$fromform = (object) $this->datagenerator->combine_defaults_and_record(
|
||||
(array) $fromform, $overrides);
|
||||
|
||||
return question_bank::get_qtype($qtype)->save_question($question, $fromform);
|
||||
$question = question_bank::get_qtype($qtype)->save_question($question, $fromform);
|
||||
|
||||
if ($overrides && array_key_exists('createdby', $overrides)) {
|
||||
// Manually update the createdby because questiontypebase forces current user and some tests require a
|
||||
// specific user.
|
||||
$question->createdby = $overrides['createdby'];
|
||||
$DB->update_record('question', $question);
|
||||
}
|
||||
|
||||
return $question;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue