/** * Gets a activequiz_question object with the slot set * * @param int $slotnum The index of the slot we want, i.e. the question number * @param \mod_activequiz\activequiz_attempt $attempt The current attempt * * @return \mod_activequiz\activequiz_question */ public function get_question_with_slot($slotnum, $attempt) { $slots = $attempt->getSlots(); $quba = $attempt->get_quba(); // first check if this is the last question if (empty($slots[$slotnum])) { $attempt->islastquestion(true); } else { $attempt->islastquestion(false); } // since arrays are indexed starting at 0 and we reference questions starting with 1, we subtract 1 $slotnum = $slotnum - 1; // get the first question $qubaQuestion = $quba->get_question($slots[$slotnum]); foreach ($this->qbankOrderedQuestions as $qbankQuestion) { /** @var \mod_activequiz\activequiz_question $qbankQuestion */ if ($qbankQuestion->getQuestion()->id == $qubaQuestion->id) { // set the slot on the qbank question as this is the actual id we're using for question number $qbankQuestion->set_slot($slots[$slotnum]); return $qbankQuestion; } } // if we get here return null due to no question return null; }