MDL-61380 Quiz: Re-attempting the same "random" question by tag
Some question behaviours allow the same question to be re-attempted several times during a quiz attempt. This commit takes care of the case where a "random" question is re-attempted during a quiz attempt.
This commit is contained in:
@@ -568,7 +568,7 @@ class quiz_attempt {
|
||||
$this->quba = question_engine::load_questions_usage_by_activity($this->attempt->uniqueid);
|
||||
$this->slots = $DB->get_records('quiz_slots',
|
||||
array('quizid' => $this->get_quizid()), 'slot',
|
||||
'slot, requireprevious, questionid');
|
||||
'slot, requireprevious, questionid, includingsubcategories, tags');
|
||||
$this->sections = array_values($DB->get_records('quiz_sections',
|
||||
array('quizid' => $this->get_quizid()), 'firstslot'));
|
||||
|
||||
@@ -1873,9 +1873,11 @@ class quiz_attempt {
|
||||
if ($questiondata->qtype != 'random') {
|
||||
$newqusetionid = $questiondata->id;
|
||||
} else {
|
||||
$tagids = quiz_extract_random_question_tag_ids($this->slots[$slot]->tags);
|
||||
|
||||
$randomloader = new \core_question\bank\random_question_loader($qubaids, array());
|
||||
$newqusetionid = $randomloader->get_next_question_id($questiondata->category,
|
||||
(bool) $questiondata->questiontext);
|
||||
(bool) $questiondata->questiontext, $tagids);
|
||||
if ($newqusetionid === null) {
|
||||
throw new moodle_exception('notenoughrandomquestions', 'quiz',
|
||||
$this->quizobj->view_url(), $questiondata);
|
||||
|
||||
Reference in New Issue
Block a user