public function get_choices(ImsQtiReader $reader) { $result = array(); $choices = $reader->query('.//def:simpleAssociableChoice'); foreach ($choices as $choice) { $id = $choice->identifier; $text = $this->to_text($choice); $max = $choice->matchMax; // not handled by moodle $result[$id] = $this->create_choice($id, $text, $max); } 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; }