MDL-76843 quiz: fix statistics questions for missing questions

This commit is contained in:
Tim Hunt
2023-02-22 15:07:40 +00:00
parent d6f0ad4980
commit 291d241981
7 changed files with 85 additions and 30 deletions
+11 -8
View File
@@ -940,23 +940,18 @@ function question_load_questions($questionids, $extrafields = '', $join = '') {
* @param stdClass[]|null $filtercourses The courses to filter the course tags by.
*/
function _tidy_question($question, $category, array $tagobjects = null, array $filtercourses = null): void {
// Load question-type specific fields.
if (!question_bank::is_qtype_installed($question->qtype)) {
$question->questiontext = html_writer::tag('p', get_string('warningmissingtype',
'qtype_missingtype')) . $question->questiontext;
}
// Convert numeric fields to float (Prevents these being displayed as 1.0000000.).
// Convert numeric fields to float. This prevents these being displayed as 1.0000000.
$question->defaultmark += 0;
$question->penalty += 0;
// Indicate the question is now fully initialised.
if (isset($question->_partiallyloaded)) {
unset($question->_partiallyloaded);
}
$question->categoryobject = $category;
question_bank::get_qtype($question->qtype)->get_question_options($question);
// Add any tags we have been passed.
if (!is_null($tagobjects)) {
$categorycontext = context::instance_by_id($category->contextid);
$sortedtagobjects = question_sort_tags($tagobjects, $categorycontext, $filtercourses);
@@ -965,6 +960,14 @@ function _tidy_question($question, $category, array $tagobjects = null, array $f
$question->tagobjects = $sortedtagobjects->tagobjects;
$question->tags = $sortedtagobjects->tags;
}
// Load question-type specific fields.
if (question_bank::is_qtype_installed($question->qtype)) {
question_bank::get_qtype($question->qtype)->get_question_options($question);
} else {
$question->questiontext = html_writer::tag('p', get_string('warningmissingtype',
'qtype_missingtype')) . $question->questiontext;
}
}
/**