/** * Constructor * * @param ilExercise $exercise existing exercise object * @param string $a_xml_file xml data * @param int $obj_id obj id of exercise which is to be updated * @access public */ function ilExerciseXMLParser(&$exercise, $a_xml_data, $obj_id = -1) { // @todo: needs to be revised for multiple assignments per exercise parent::ilSaxParser(); $this->exercise = $exercise; // get all assignments and choose first one if exists, otherwise create $assignments = ilExAssignment::getAssignmentDataOfExercise($exercise->getId()); if (count($assignments) > 0) { $this->assignment = new ilExAssignment($assignments[0]["id"]); } else { $this->assignment = new ilExAssignment(); $this->assignment->setExerciseId($exercise->getId()); $this->assignment->save(); } include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php"; $this->storage = new ilFSStorageExercise($this->exercise->getId(), $this->assignment->getId()); $this->storage->create(); $this->storage->init(); $this->setXMLContent($a_xml_data); $this->obj_id = $obj_id; $this->result = false; }