66 libxml_use_internal_errors(
true);
67 $root = simplexml_load_string(trim($this->xml));
70 $GLOBALS[
'ilLog']->write(__METHOD__.
': XML is: '. $this->xml. (
string) $root);
71 $GLOBALS[
'ilLog']->write(__METHOD__.
': Error parsing objective xml: '.$this->parseXmlErrors());
74 $GLOBALS[
'ilLog']->write(__METHOD__.
': Handling element: '. (
string) $root->getName());
84 libxml_use_internal_errors(
true);
85 $root = simplexml_load_string(trim($this->xml));
88 $GLOBALS[
'ilLog']->write(__METHOD__.
': XML is: '. $this->xml. (
string) $root);
89 $GLOBALS[
'ilLog']->write(__METHOD__.
': Error parsing objective xml: '.$this->parseXmlErrors());
93 foreach($root->Objective as $obj)
95 $mapped_objective_id = $this->
getMapping()->getMapping(
'Modules/Course',
'objectives', (
string) $obj->attributes()->id);
96 if($mapped_objective_id)
110 include_once
'./Modules/Course/classes/Objectives/class.ilLOSettings.php';
112 $GLOBALS[
'ilLog']->write(__METHOD__.
': Handling element: '. (
string) $root->Settings->getName());
113 foreach($root->Settings as $set)
115 $GLOBALS[
'ilLog']->write(__METHOD__.
': Handling element: '. (
string) $set->getName());
116 $settings->setInitialTestType((
int) (
string) $set->attributes()->initialTestType);
117 $settings->setInitialTestAsStart((
bool) (
string) $set->attributes()->initialTestStart);
118 $settings->setQualifyingTestType((
int) (
string) $set->attributes()->qualifyingTestType);
119 $settings->setQualifyingTestAsStart((
bool) (
string) $set->attributes()->qualifyingTestStart);
120 $settings->resetResults((
bool) (
string) $set->attributes()->resetResults);
121 $settings->setPassedObjectiveMode((
int) (
string) $set->attributes()->passedObjectivesMode);
125 $settings->setInitialTest($itest);
129 $settings->setQualifiedTest($qtest);
141 foreach($root->Objective as $obj)
143 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
145 $new_obj->setActive((
bool) (
string) $obj->attributes()->online);
146 $new_obj->setTitle((
string) $obj->Title);
147 $new_obj->setDescription((
string) $obj->Description);
148 $new_obj->setPosition((
int) (
string) $obj->attributes()->position);
149 $new_objective_id = $new_obj->add();
151 $this->
getMapping()->addMapping(
'Modules/Course',
'objectives', (
string) $obj->attributes()->id, $new_objective_id);
152 $this->
getMapping()->addMapping(
'Services/COPage',
'pg',
'lobj:'.(
string) $obj->attributes()->id,
'lobj:'.$new_objective_id);
167 foreach($obj->Material as $mat)
169 $mat_ref_id = (
string) $mat->attributes()->refId;
174 include_once
'./Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
176 $new_mat->setLMRefId($mapping_ref_id);
178 $mat_type = (
string) $mat->attributes()->type;
183 $mapped_chapter = $this->
getMapping()->getMapping(
184 'Modules/LearningModule',
186 (
int) (
string) $mat->attributes()->objId
190 $obj_id = $mapped_chapter;
195 $mapped_page = $this->
getMapping()->getMapping(
196 'Modules/LearningModule',
198 (
int) (
string) $mat->attributes()->objId
202 $obj_id = $mapped_page;
212 $new_mat->setLMObjId($obj_id);
213 $new_mat->setType((
string) $mat->attributes()->type);
214 $new_id = $new_mat->add();
215 $new_mat->writePosition($new_id, (
int) (
string) $mat->attributes()->position);
228 $GLOBALS[
'ilLog']->write(__METHOD__.
': Parsing ' . (
string) $obj->getName());
230 foreach($obj->Test as $tst)
232 $type = (int) (
string) $tst->attributes()->type;
235 if($type == self::TYPE_TST_PO)
237 $tst_ref_id = (
string) $tst->attributes()->refId;
239 $GLOBALS[
'ilLog']->write(__METHOD__.
': Found test ref id ' . (
string) $tst_ref_id);
244 include_once
'./Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
246 $assignment->setContainerId($this->
getCourse()->getId());
247 $assignment->setTestRefId($mapping_ref_id);
248 $assignment->setObjectiveId($a_objective_id);
249 $assignment->setAssignmentType((
int) (
string) $tst->attributes()->testType);
252 elseif($type == self::TYPE_TST_RND)
254 $tst_obj_id = (int) (
string) $tst->attributes()->objId;
261 $new_qpl_id = $this->
getMappingForQpls((
int) (
string) $tst->attributes()->poolId);
267 include_once
'./Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
271 (
int) (
string) $tst->attributes()->testType
274 $rnd->setLimit((
string) $tst->attributes()->limit);
275 $rnd->setQplSequence($new_qpl_id);
280 $tst_ref_id = (
string) $tst->attributes()->refId;
286 include_once
'./Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
288 $quest->setTestRefId($mapping_ref_id);
290 $quest->setTestStatus((
string) $tst->attributes()->testType);
291 $quest->setTestSuggestedLimit((
string) $tst->attributes()->limit);
293 foreach($tst->Question as $qst)
295 $qid = (
string) $qst->attributes()->id;
299 $quest->setQuestionId($mapping_qid);
315 $new_ref_id = $this->
getMapping()->getMapping(
'Services/Container',
'refs', $a_ref_id);
316 $GLOBALS[
'ilLog']->write(__METHOD__.
': Found new ref_id: ' .$new_ref_id.
' for '. $a_ref_id);
317 return (
int) $new_ref_id;
327 $new_obj_id = $this->
getMapping()->getMapping(
'Services/Container',
'objs', $a_obj_id);
328 $GLOBALS[
'ilLog']->write(__METHOD__.
': Found new ref_id: ' .$new_obj_id.
' for '. $a_obj_id);
329 return (
int) $new_obj_id;
334 $new_qid = $this->
getMapping()->getMapping(
'Modules/Test',
'quest', $qid);
335 $GLOBALS[
'ilLog']->write(__METHOD__.
': Found new question_id: ' .$new_qid.
' for '. $qid);
341 $new_id = $this->
getMapping()->getMapping(
'Modules/Test',
'rnd_src_pool_def', $a_id);
364 foreach(libxml_get_errors() as $err)
parseObjectives(SimpleXMLElement $root)
Parse objective.
parseSettings(SimpleXMLElement $root)
static getInstanceByObjId($a_obj_id)
get singleton instance
parseObjectDependencies()
Parse object dependencies (assigned strucure objects, page objects, fixed questions) ...
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
getMapping()
Get import mapping.
Add rich text string
The name of the decorator.
getMappingInfoForItemObject($a_obj_id)
Get obj_id mapping.
parseXmlErrors()
Parse xml errors from libxml_get_errors.
getMappingInfoForItem($a_ref_id)
Get mapping info.
class ilCourseObjectiveMaterials
setMapping(ilImportMapping $mapping)
Set import mapping.
static _lookupObjId($a_id)
parseMaterials(SimpleXMLElement $obj, $a_objective_id)
Parse assigned materials.
__construct(ilObjCourse $course, $a_xml)
Constructor.
getMappingForQuestion($qid)
class ilcourseobjectiveQuestion
parseTests(SimpleXMLElement $obj, $a_objective_id)
Parse tests of objective.