protected function to_html(ImsXmlReader $item)
 {
     $xml = $item->get_xml();
     $variables = $item->all_printedVariable();
     foreach ($variables as $var) {
         $var_xml = $var->get_xml();
         $name = '{' . $var->identifier . '}';
         $xml = str_replace($var_xml, $name, $xml);
     }
     $xml = '<?xml version="1.0" encoding="UTF-8" ?>' . $xml;
     $item = new ImsQtiReader();
     $item->load_xml($xml);
     $result = parent::to_html($item);
     return $result;
 }
 public function get_entries(ImsQtiReader $item, ImsQtiReader $interaction)
 {
     $result = array();
     $sets = $interaction->list_simpleMatchSet();
     if (count($sets) == 0) {
         //associateInteraction
         $questions = $this->get_choices($interaction);
         $answers = array_merge($questions);
     } else {
         if (count($sets) == 1) {
             //should not be the case
             $questions = $this->get_choices($sets[0]);
             $answers = array_merge($questions);
         } else {
             //matchInteraction
             $questions = $this->get_choices($sets[0]);
             $answers = $this->get_choices($sets[1]);
         }
     }
     $done = array();
     $responses = $this->get_correct_responses($item, $interaction);
     foreach ($responses as $response) {
         $pair = explode(' ', $response);
         $question = isset($questions[$pair[0]]) ? $questions[$pair[0]] : null;
         $answer = isset($answers[$pair[1]]) ? $answers[$pair[1]] : null;
         if (!empty($question)) {
             $result[] = $this->create_entry($question, $answer);
             $done[$pair[1]] = $pair[1];
         }
     }
     foreach ($answers as $key => $answer) {
         if (!isset($done[$key])) {
             $result[] = $this->create_entry(null, $answer);
         }
     }
     return $result;
 }
 protected function is_question_file($path)
 {
     $name = basename($path);
     $ext = pathinfo($path, PATHINFO_EXTENSION);
     if (empty($ext) || $ext != 'xml' || self::IMS_MANIFEST_NAME == $name) {
         return false;
     }
     $reader = new ImsQtiReader();
     $reader->load($path);
     return count($reader->query('/def:assessmentItem')) > 0;
 }