protected function add_answer_feedback(ImsQtiWriter $item, $question)
 {
     foreach ($question->options->answers as $answer) {
         $identifier = $answer->answer;
         if ($has_feeback = !empty($answer->feedback)) {
             $text = $this->translate_feedback_text($answer->feedback, self::FORMAT_HTML, $question);
             $item->add_modalFeedback(ImsQtiWriter::FEEDBACK, $identifier, 'show')->add_flow($text);
         }
     }
 }
 /**
  * Serialize additional information not or not well supported by QTI.
  * Used for reimport.
  */
 protected function add_question_data(ImsQtiWriter $item, $question)
 {
     $id = self::MOODLE_QUESTION_DATA;
     $value = 'true';
     $q = clone $question;
     $q = $this->get_question_data($q);
     $text = serialize($q);
     $result = $item->add_modalFeedback($id, $value, 'show')->add_text($text);
     return $result;
 }
 protected function add_overall_feedback(ImsQtiWriter $item, $question)
 {
     if (!isset($question->options) || !isset($question->options->incorrectfeedback)) {
         return false;
     }
     $text = $this->translate_feedback_text($question->options->incorrectfeedback, self::FORMAT_HTML, $question);
     $item->add_modalFeedback(self::OVERALL_FEEDBACK, self::FEEDBACK_INCORRECT, 'show')->add_flow($text);
     $text = $this->translate_feedback_text($question->options->correctfeedback, self::FORMAT_HTML, $question);
     $item->add_modalFeedback(self::OVERALL_FEEDBACK, self::FEEDBACK_CORRECT, 'show')->add_flow($text);
     $text = $this->translate_feedback_text($question->options->partiallycorrectfeedback, self::FORMAT_HTML, $question);
     $item->add_modalFeedback(self::OVERALL_FEEDBACK, self::FEEDBACK_PARTIALY_CORRECT, 'show')->add_flow($text);
 }
 public function add_feedback(ImsQtiWriter $item, $question)
 {
     $feedback_id = $this->feedback_id($question);
     foreach ($question->options->answers as $answer) {
         $answer_id = $this->answer_id($answer);
         if ($has_feeback = !empty($answer->feedback)) {
             $text = $this->translate_feedback_text($answer->feedback, self::FORMAT_HTML, $question);
             $item->add_modalFeedback($feedback_id, $answer_id, 'show')->add_flow($text);
         }
     }
 }