final function _writeDescription($a_obj_id, $a_desc) { return parent::_writeDescription($a_obj_id, $a_desc); }
/** * Meta data update listener * * Important note: Do never call create() or update() * method of ilObject here. It would result in an * endless loop: update object -> update meta -> update * object -> ... * Use static _writeTitle() ... methods instead. * * @param string $a_element */ function MDUpdateListener($a_element) { include_once 'Services/MetaData/classes/class.ilMD.php'; switch ($a_element) { case 'General': // Update Title and description $md = new ilMD(0, $this->getId(), $this->getType()); $md_gen = $md->getGeneral(); if (is_object($md_gen)) { ilObject::_writeTitle($this->getId(), $md_gen->getTitle()); $this->setTitle($md_gen->getTitle()); foreach ($md_gen->getDescriptionIds() as $id) { $md_des = $md_gen->getDescription($id); ilObject::_writeDescription($this->getId(), $md_des->getDescription()); $this->setDescription($md_des->getDescription()); break; } } break; default: } return true; }
/** * Imports an extracted SCORM 2004 module from ilias-data dir into database * * @access public * @return string title of package */ public function il_import($packageFolder, $packageId, $ilias, $validate, $reimport = false) { global $ilDB, $ilLog, $ilErr; $title = ""; if ($reimport === true) { $this->packageId = $packageId; $this->dbRemoveAll(); } $this->packageFolder = $packageFolder; $this->packageId = $packageId; $this->imsmanifestFile = $this->packageFolder . '/' . 'imsmanifest.xml'; //step 1 - parse Manifest-File and validate $this->imsmanifest = new DOMDocument(); $this->imsmanifest->async = false; if (!@$this->imsmanifest->load($this->imsmanifestFile)) { $this->diagnostic[] = 'XML not wellformed'; return false; } //step 2 tranform $this->manifest = $this->transform($this->imsmanifest, self::DB_ENCODE_XSL); if (!$this->manifest) { $this->diagnostic[] = 'Cannot transform into normalized manifest'; return false; } //setp 2.5 if only a single item, make sure the scormType of it's linked resource is SCO $path = new DOMXpath($this->manifest); $path->registerNamespace("scorm", "http://www.openpalms.net/scorm/scorm13"); $items = $path->query("//scorm:item"); if ($items->length == 1) { $n = $items->item(0); $resource = $path->query("//scorm:resource"); //[&id='"+$n->getAttribute("resourceId")+"']"); foreach ($resource as $res) { if ($res->getAttribute('id') == $n->getAttribute("resourceId")) { $res->setAttribute('scormType', 'sco'); } } } //$this->manifest->save("C:\Users\gratat\after.xml"); //step 3 validation -just for normalized XML if ($validate == "y") { if (!$this->validate($this->manifest, self::VALIDATE_XSD)) { $ilErr->raiseError("<b>The uploaded SCORM 1.2 / SCORM 2004 is not valid. You can try to import the package without the validation option checked on your own risk. </b><br><br>Validation Error(s):</b><br> Normalized XML is not conform to " . self::VALIDATE_XSD, $ilErr->MESSAGE); } } $this->dbImport($this->manifest); if (file_exists($this->packageFolder . '/' . 'index.xml')) { $doc = simplexml_load_file($this->packageFolder . '/' . 'index.xml'); $l = $doc->xpath("/ContentObject/MetaData"); if ($l[0]) { include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php'; $mdxml =& new ilMDXMLCopier($l[0]->asXML(), $packageId, $packageId, ilObject::_lookupType($packageId)); $mdxml->startParsing(); $mdxml->getMDObject()->update(); } } else { include_once "./Modules/Scorm2004/classes/class.ilSCORM13MDImporter.php"; $importer = new ilSCORM13MDImporter($this->imsmanifest, $packageId); $importer->import(); $title = $importer->getTitle(); $description = $importer->getDescription(); if ($description != "") { ilObject::_writeDescription($packageId, $description); } } //step 5 $x = simplexml_load_string($this->manifest->saveXML()); $x['persistPreviousAttempts'] = $this->packageData['persistprevattempts']; $x['online'] = $this->packageData['c_online']; $x['defaultLessonMode'] = $this->packageData['default_lesson_mode']; $x['credit'] = $this->packageData['credit']; $x['autoReview'] = $this->packageData['auto_review']; $j = array(); // first read resources into flat array to resolve item/identifierref later $r = array(); foreach ($x->resource as $xe) { $r[strval($xe['id'])] = $xe; unset($xe); } // iterate through items and set href and scoType as activity attributes foreach ($x->xpath('//*[local-name()="item"]') as $xe) { // get reference to resource and set href accordingly if ($b = $r[strval($xe['resourceId'])]) { $xe['href'] = strval($b['base']) . strval($b['href']); unset($xe['resourceId']); if (strval($b['scormType']) == 'sco') { $xe['sco'] = true; } } } // iterate recursivly through activities and build up simple php object // with items and associated sequencings // top node is the default organization which is handled as an item self::jsonNode($x->organization, $j['item']); foreach ($x->sequencing as $s) { self::jsonNode($s, $j['sequencing'][]); } // combined manifest+resources xml:base is set as organization base $j['item']['base'] = strval($x['base']); // package folder is base to whole playing process $j['base'] = $packageFolder . '/'; $j['foreignId'] = floatval($x['foreignId']); // manifest cp_node_id for associating global (package wide) objectives $j['id'] = strval($x['id']); // manifest id for associating global (package wide) objectives //last step - build ADL Activity tree $act = new SeqTreeBuilder(); $adl_tree = $act->buildNodeSeqTree($this->imsmanifestFile); $ilDB->update('cp_package', array('xmldata' => array('clob', $x->asXML()), 'jsdata' => array('clob', json_encode($j)), 'activitytree' => array('clob', json_encode($adl_tree['tree'])), 'global_to_system' => array('integer', (int) $adl_tree['global']), 'shared_data_global_to_system' => array('integer', (int) $adl_tree['dataglobal'])), array('obj_id' => array('integer', (int) $this->packageId))); // title retrieved by importer if ($title != "") { return $title; } return $j['item']['title']; }