public function apply_attempt_state(question_attempt_step $step) { $saquestions = explode(',', $step->get_qt_var('_stemorder')); foreach ($saquestions as $questionid) { $this->stems[$questionid] = $step->get_qt_var('_stem_' . $questionid); $this->stemformat[$questionid] = $step->get_qt_var('_stemformat_' . $questionid); $key = $step->get_qt_var('_right_' . $questionid); $this->right[$questionid] = $key; $this->choices[$key] = $step->get_qt_var('_choice_' . $key); } parent::apply_attempt_state($step); }
public function test_set_var() { $step = new question_attempt_step(); $step->set_qt_var('_x', 1); $step->set_behaviour_var('_x', 2); $this->assertEquals('1', $step->get_qt_var('_x')); $this->assertEquals('2', $step->get_behaviour_var('_x')); }
public function apply_attempt_state(question_attempt_step $step) { $this->stemorder = explode(',', $step->get_qt_var('_stemorder')); $this->set_choiceorder(explode(',', $step->get_qt_var('_choiceorder'))); // Add any missing subquestions. Sometimes people edit questions after they // have been attempted which breaks things. foreach ($this->stemorder as $stemid) { if (!isset($this->stems[$stemid])) { $this->stems[$stemid] = html_writer::span(get_string('deletedsubquestion', 'qtype_match'), 'notifyproblem'); $this->stemformat[$stemid] = FORMAT_HTML; $this->right[$stemid] = 0; } } // Add any missing choices. Sometimes people edit questions after they // have been attempted which breaks things. foreach ($this->choiceorder as $choiceid) { if (!isset($this->choices[$choiceid])) { $this->choices[$choiceid] = get_string('deletedchoice', 'qtype_match'); } } }
public function apply_attempt_state(question_attempt_step $step) { $this->order = explode(',', $step->get_qt_var('_order')); // Add any missing answers. Sometimes people edit questions after they // have been attempted which breaks things. foreach ($this->order as $ansid) { if (isset($this->answers[$ansid])) { continue; } $a = new stdClass(); $a->id = 0; $a->answer = html_writer::span(get_string('deletedchoice', 'qtype_multichoice'), 'notifyproblem'); $a->answerformat = FORMAT_HTML; $a->fraction = 0; $a->feedback = ''; $a->feedbackformat = FORMAT_HTML; $this->answers[$ansid] = $this->qtype->make_answer($a); $this->answers[$ansid]->answerformat = FORMAT_HTML; } }
public function apply_attempt_state(question_attempt_step $step) { foreach ($this->choices as $group => $choices) { $this->set_choiceorder($group, explode(',', $step->get_qt_var('_choiceorder' . $group))); } }
public function apply_attempt_state(question_attempt_step $step) { $this->answers = $this->get_ordering_answers(); $this->options = $this->get_ordering_options(); $this->currentresponse = array_filter(explode(',', $step->get_qt_var('_currentresponse'))); $this->correctresponse = array_filter(explode(',', $step->get_qt_var('_correctresponse'))); }
protected function prepare_response_for_editing($name, question_attempt_step $step, $context) { return $step->prepare_response_files_draft_itemid_with_text($name, $context->id, $step->get_qt_var($name)); }
public function apply_attempt_state(question_attempt_step $step) { list($point, $separator) = explode('$', $step->get_qt_var('_separators')); $this->ap->set_characters($point, $separator); }
public function apply_attempt_state(question_attempt_step $step) { $this->stemorder = explode(',', $step->get_qt_var('_stemorder')); $this->set_choiceorder(explode(',', $step->get_qt_var('_choiceorder'))); }
public function apply_attempt_state(question_attempt_step $step) { $this->order = explode(',', $step->get_qt_var('_order')); }
public function apply_attempt_state(question_attempt_step $step) { $this->seed = (int) $step->get_qt_var('_seed'); $this->initialise_question_from_seed(); }
public function response_area_input($name, question_attempt $qa, question_attempt_step $step, $lines, $context) { $response = $step->get_qt_var($name); $inputname = $qa->get_qt_field_name($name); $textarea = $this->textarea($response, $lines, array('name' => $inputname)); $formattag = $this->get_format_tag($inputname); $countarea = $this->get_count_area_input($qa, $response); return $textarea.$formattag.$countarea; }