MDL-72553 qbank_customfields: Add custom fields for question types
Custom fields can now be added to question types. Site administrators can configure the custom fields and filed types available. Teachers and question creators can then use these fields for extra question metadata when creating questions. Question creators can control if the fields are displayed to students when they are taking a quiz or not. This features uses the core Moodle custom field API. Co-Authored-By: Matt Porritt <[email protected]> Co-Authored-By: Safat Shahin <[email protected]> Co-Authored-By: Marc-Alexandre Ghaly <[email protected]>
This commit is contained in:
committed by
Safat Shahin
co-authored by
Safat Shahin
Marc-Alexandre Ghaly
parent
51149a78cc
commit
556e2f1aec
@@ -964,6 +964,9 @@ class question_type {
|
||||
}
|
||||
|
||||
$this->initialise_question_hints($question, $questiondata);
|
||||
|
||||
// Add the custom fields.
|
||||
$this->initialise_custom_fields($question, $questiondata);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -990,6 +993,17 @@ class question_type {
|
||||
return question_hint::load_from_record($hint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise question custom fields.
|
||||
* @param question_definition $question the question_definition we are creating.
|
||||
* @param object $questiondata the question data loaded from the database.
|
||||
*/
|
||||
protected function initialise_custom_fields(question_definition $question, $questiondata) {
|
||||
if (!empty($questiondata->customfields)) {
|
||||
$question->customfields = $questiondata->customfields;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise the combined feedback fields.
|
||||
* @param question_definition $question the question_definition we are creating.
|
||||
|
||||
Reference in New Issue
Block a user