66        libxml_use_internal_errors(
true);
 
   67        $root = simplexml_load_string(trim($this->xml));
 
   68        if (!$root instanceof SimpleXMLElement) {
 
   69            $GLOBALS[
'ilLog']->write(__METHOD__ . 
': XML is: ' . $this->xml . (
string) $root);
 
   73        $GLOBALS[
'ilLog']->write(__METHOD__ . 
': Handling element: ' . (
string) $root->getName());
 
   83        libxml_use_internal_errors(
true);
 
   84        $root = simplexml_load_string(trim($this->xml));
 
   85        if (!$root instanceof SimpleXMLElement) {
 
   86            $GLOBALS[
'ilLog']->write(__METHOD__ . 
': XML is: ' . $this->xml . (
string) $root);
 
   91        foreach ($root->Objective as $obj) {
 
   92            $mapped_objective_id = $this->
getMapping()->getMapping(
'Modules/Course', 
'objectives', (
string) $obj->attributes()->id);
 
   93            if ($mapped_objective_id) {
 
  106        include_once 
'./Modules/Course/classes/Objectives/class.ilLOSettings.php';
 
  108        $GLOBALS[
'ilLog']->write(__METHOD__ . 
': Handling element: ' . (
string) $root->Settings->getName());
 
  109        foreach ($root->Settings as $set) {
 
  110            $GLOBALS[
'ilLog']->write(__METHOD__ . 
': Handling element: ' . (
string) $set->getName());
 
  111            $settings->setInitialTestType((
int) (
string) $set->attributes()->initialTestType);
 
  112            $settings->setInitialTestAsStart((
bool) (
string) $set->attributes()->initialTestStart);
 
  113            $settings->setQualifyingTestType((
int) (
string) $set->attributes()->qualifyingTestType);
 
  114            $settings->setQualifyingTestAsStart((
bool) (
string) $set->attributes()->qualifyingTestStart);
 
  115            $settings->resetResults((
bool) (
string) $set->attributes()->resetResults);
 
  116            $settings->setPassedObjectiveMode((
int) (
string) $set->attributes()->passedObjectivesMode);
 
  120            $settings->setInitialTest($itest);
 
  124            $settings->setQualifiedTest($qtest);
 
  136        foreach ($root->Objective as $obj) {
 
  137            include_once 
'./Modules/Course/classes/class.ilCourseObjective.php';
 
  139            $new_obj->setActive((
bool) (
string) $obj->attributes()->online);
 
  140            $new_obj->setTitle((
string) $obj->Title);
 
  141            $new_obj->setDescription((
string) $obj->Description);
 
  142            $new_obj->setPosition((
int) (
string) $obj->attributes()->position);
 
  143            $new_objective_id = $new_obj->add();
 
  145            $this->
getMapping()->addMapping(
'Modules/Course', 
'objectives', (
string) $obj->attributes()->id, $new_objective_id);
 
  146            $this->
getMapping()->addMapping(
'Services/COPage', 
'pg', 
'lobj:' . (
string) $obj->attributes()->id, 
'lobj:' . $new_objective_id);
 
  160        foreach ($obj->Material as $mat) {
 
  161            $mat_ref_id = (string) $mat->attributes()->refId;
 
  164            if ($mapping_ref_id) {
 
  165                include_once 
'./Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
 
  167                $new_mat->setLMRefId($mapping_ref_id);
 
  169                $mat_type = (string) $mat->attributes()->type;
 
  173                        $mapped_chapter = $this->
getMapping()->getMapping(
 
  174                            'Modules/LearningModule',
 
  176                            (
int) (
string) $mat->attributes()->objId
 
  178                        if ($mapped_chapter) {
 
  179                            $obj_id = $mapped_chapter;
 
  184                        $mapped_page = $this->
getMapping()->getMapping(
 
  185                            'Modules/LearningModule',
 
  187                            (
int) (
string) $mat->attributes()->objId
 
  190                            $obj_id = $mapped_page;
 
  199                    $new_mat->setLMObjId($obj_id);
 
  200                    $new_mat->setType((
string) $mat->attributes()->type);
 
  201                    $new_id  = $new_mat->add();
 
  202                    $new_mat->writePosition($new_id, (
int) (
string) $mat->attributes()->position);
 
  213    protected function parseTests(SimpleXMLElement $obj, $a_objective_id)
 
  215        $GLOBALS[
'ilLog']->write(__METHOD__ . 
': Parsing ' . (
string) $obj->getName());
 
  217        foreach ($obj->Test as $tst) {
 
  218            $type = (int) (
string) $tst->attributes()->type;
 
  221            if (
$type == self::TYPE_TST_PO) {
 
  222                $tst_ref_id = (string) $tst->attributes()->refId;
 
  224                $GLOBALS[
'ilLog']->write(__METHOD__ . 
': Found test ref id ' . (
string) $tst_ref_id);
 
  225                if (!$mapping_ref_id) {
 
  228                include_once 
'./Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
 
  230                $assignment->setContainerId($this->
getCourse()->getId());
 
  231                $assignment->setTestRefId($mapping_ref_id);
 
  232                $assignment->setObjectiveId($a_objective_id);
 
  233                $assignment->setAssignmentType((
int) (
string) $tst->attributes()->testType);
 
  235            } elseif (
$type == self::TYPE_TST_RND) {
 
  236                $tst_obj_id = (int) (
string) $tst->attributes()->objId;
 
  242                $new_qpl_id = $this->
getMappingForQpls((
int) (
string) $tst->attributes()->poolId);
 
  250                    (
int) (
string) $tst->attributes()->testType,
 
  253                $rnd->setTestId($mapping_id);
 
  254                $rnd->setLimit((
string) $tst->attributes()->limit);
 
  257                $tst_ref_id = (string) $tst->attributes()->refId;
 
  259                if (!$mapping_ref_id) {
 
  262                include_once 
'./Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
 
  264                $quest->setTestRefId($mapping_ref_id);
 
  266                $quest->setTestStatus((
string) $tst->attributes()->testType);
 
  267                $quest->setTestSuggestedLimit((
string) $tst->attributes()->limit);
 
  269                foreach ($tst->Question as $qst) {
 
  270                    $qid = (string) $qst->attributes()->id;
 
  273                        $quest->setQuestionId($mapping_qid);
 
  289        $new_ref_id = $this->
getMapping()->getMapping(
'Services/Container', 
'refs', $a_ref_id);
 
  290        $GLOBALS[
'ilLog']->write(__METHOD__ . 
': Found new ref_id: ' . $new_ref_id . 
' for ' . $a_ref_id);
 
  291        return (
int) $new_ref_id;
 
  301        $new_obj_id = $this->
getMapping()->getMapping(
'Services/Container', 
'objs', $a_obj_id);
 
  302        $GLOBALS[
'ilLog']->write(__METHOD__ . 
': Found new ref_id: ' . $new_obj_id . 
' for ' . $a_obj_id);
 
  303        return (
int) $new_obj_id;
 
  308        $new_qid = $this->
getMapping()->getMapping(
'Modules/Test', 
'quest', $qid);
 
  309        $GLOBALS[
'ilLog']->write(__METHOD__ . 
': Found new question_id: ' . $new_qid . 
' for ' . $qid);
 
  315        $new_id = $this->
getMapping()->getMapping(
'Modules/Test', 
'rnd_src_pool_def', $a_id);
 
  337        foreach (libxml_get_errors() as $err) {
 
  338            $errors .= $err->code . 
'<br/>';
 
An exception for terminatinating execution or to throw for unit testing.
class ilCourseObjectiveMaterials
class ilcourseobjectiveQuestion
static getInstanceByObjId($a_obj_id)
get singleton instance
getMappingForQuestion($qid)
parseObjectDependencies()
Parse object dependencies (assigned strucure objects, page objects, fixed questions)
getMappingInfoForItem($a_ref_id)
Get mapping info.
parseXmlErrors()
Parse xml errors from libxml_get_errors.
parseObjectives(SimpleXMLElement $root)
Parse objective.
setMapping(ilImportMapping $mapping)
Set import mapping.
parseSettings(SimpleXMLElement $root)
__construct(ilObjCourse $course, $a_xml)
Constructor.
getMappingInfoForItemObject($a_obj_id)
Get obj_id mapping.
parseTests(SimpleXMLElement $obj, $a_objective_id)
Parse tests of objective.
parseMaterials(SimpleXMLElement $obj, $a_objective_id)
Parse assigned materials.
getMapping()
Get import mapping.
static _lookupObjId($a_id)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.