public function start_attempt(question_attempt_step $step, $variant) { parent::start_attempt($step, $variant); $choiceorder = array_keys($this->choices); $step->set_qt_var('_choiceorder', implode(',', $choiceorder)); $this->set_choiceorder($choiceorder); }
public function start_attempt(question_attempt_step $step, $variant) { $saquestions = $this->questionsloader->load_questions(); foreach ($saquestions as $wrappedquestion) { // Store and save stem text and format. $this->stems[$wrappedquestion->id] = $wrappedquestion->questiontext; $this->stemformat[$wrappedquestion->id] = $wrappedquestion->questiontextformat; $step->set_qt_var('_stem_' . $wrappedquestion->id, $this->stems[$wrappedquestion->id]); $step->set_qt_var('_stemformat_' . $wrappedquestion->id, $this->stemformat[$wrappedquestion->id]); // Find, store and save right choice id. $key = $this->find_right_answer($wrappedquestion); $this->right[$wrappedquestion->id] = $key; $step->set_qt_var('_right_' . $wrappedquestion->id, $key); // No need to save saquestions, it will be saved by parent class in _stemorder. } // Save all the choices. foreach ($this->choices as $key => $answer) { $step->set_qt_var('_choice_' . $key, $answer); } parent::start_attempt($step, $variant); }