mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-24408 extra_question_fields: separate answer data creation code
Now any question using extra_question_fields can overload make_answer (just as make_hint), instead of overloading whole initialise_question_answers.
This commit is contained in:
parent
f0c6c18189
commit
92e83e2d0e
1 changed files with 12 additions and 2 deletions
|
@ -950,14 +950,24 @@ class question_type {
|
|||
return;
|
||||
}
|
||||
foreach ($questiondata->options->answers as $a) {
|
||||
$question->answers[$a->id] = new question_answer($a->id, $a->answer,
|
||||
$a->fraction, $a->feedback, $a->feedbackformat);
|
||||
$question->answers[$a->id] = $this->make_answer($a);
|
||||
if (!$forceplaintextanswers) {
|
||||
$question->answers[$a->id]->answerformat = $a->answerformat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a question_answer, or an appropriate subclass for this question,
|
||||
* from a row loaded from the database.
|
||||
* @param object $answer the DB row from the question_answers table plus extra answer fields.
|
||||
* @return question_answer
|
||||
*/
|
||||
protected function make_answer($answer) {
|
||||
return new question_answer($answer->id, $answer->answer,
|
||||
$answer->fraction, $answer->feedback, $answer->feedbackformat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the question-type specific data when a question is deleted.
|
||||
* @param int $question the question being deleted.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue