protected function add_interaction(ImsQtiWriter $body, $question) { $result = $body->add_choiceInteraction(); foreach ($question->options->answers as $answer) { $identifier = $answer->answer; $choice = $result->add_simpleChoice($identifier); $choice->add_flow($answer->answer); } return $result; }
protected function add_unit(ImsQtiWriter $body, $question) { switch ($question->options->showunits) { case self::UNIT_TEXTBOX: //Edit unit Editable text input element $expected_length = 1; foreach ($question->options->units as $unit) { $expected_length = max($expected_length, strlen($unit->unit)); } return $body->add_extendedTextInteraction(self::UNIT, $expected_length, 1, 1); case self::UNIT_RADIO: //Select units Choice radio element of 2 Units minimum $result = $body->add_choiceInteraction(self::UNIT, 1, false); foreach ($question->options->units as $unit) { $choice = $result->add_simpleChoice($unit->unit); $choice->add_span($unit->unit); } return $result; case self::UNIT_READONLY: //Display unit NON editable text of Unit No1 if (isset($question->options->units[0])) { $result = $body->add_span($question->options->units[0]->unit); } else { $result = null; } return $result; case self::UNIT_HIDE: //No unit display Only numerical answer will be graded //do nothing return null; } }
protected function add_interaction(ImsQtiWriter $body, $question) { $max_choices = $question->options->single ? 1 : 0; $shuffle = $question->options->shuffleanswers; $result = $body->add_choiceInteraction(ImsQtiWriter::RESPONSE, $max_choices, $shuffle); foreach ($question->options->answers as $answer) { $identifier = 'ID_' . $answer->id; $result->add_simpleChoice($identifier)->add_flow($answer->answer); } return $result; }
protected function add_interaction(ImsQtiWriter $body, $question) { $max_choices = $question->options->single ? 1 : 0; $shuffle = $question->options->shuffleanswers; $result = $body->add_choiceInteraction(ImsQtiWriter::RESPONSE, $max_choices, $shuffle); $count = 0; foreach ($question->options->answers as $answer) { $identifier = 'ID_' . ++$count; $choice = $result->add_simpleChoice($identifier); $text = $this->translate_question_text($answer->answer, self::FORMAT_HTML, $question); $choice->add_flow($text); } return $result; }