11 require_once
"./Modules/Scorm2004/classes/ilSCORM13Package.php";
12 require_once
"./Modules/Scorm2004/classes/class.ilSCORM2004Chapter.php";
13 require_once
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php";
14 require_once
"./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php";
15 require_once
"./Modules/Scorm2004/classes/adlparser/SeqTreeBuilder.php";
16 require_once(
"./Modules/ScormAicc/classes/SCORM/class.ilSCORMTree.php");
21 const DB_ENCODE_XSL =
'./Modules/Scorm2004/templates/xsl/op/op-scorm13.xsl';
22 const CONVERT_XSL =
'./Modules/Scorm2004/templates/xsl/op/scorm12To2004.xsl';
23 const DB_DECODE_XSL =
'./Modules/Scorm2004/templates/xsl/op/op-scorm13-revert.xsl';
24 const VALIDATE_XSD =
'./Modules/Scorm2004/templates/xsd/op/op-scorm13.xsd';
26 const WRAPPER_HTML =
'./Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/GenericRunTimeWrapper.htm';
27 const WRAPPER_JS =
'./Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/SCOPlayerWrapper.js';
76 $this->packagesFolder = IL_OP_PACKAGES_FOLDER;
78 $this->userId =
$GLOBALS[
'USER'][
'usr_id'];
90 $lm_set = $ilDB->queryF(
'SELECT * FROM sahs_lm WHERE id = %s', array(
'integer'), array(
$packageId));
91 $lm_data = $ilDB->fetchAssoc($lm_set);
92 $pg_set = $ilDB->queryF(
'SELECT * FROM cp_package WHERE obj_id = %s', array(
'integer'), array(
$packageId));
93 $pg_data = $ilDB->fetchAssoc($lm_set);
95 $this->packageData = array_merge($lm_data, $pg_data);
97 $this->packageFolder = $this->packagesFolder .
'/' .
$packageId;
98 $this->packageFile = $this->packageFolder .
'.zip';
99 $this->imsmanifestFile = $this->packageFolder .
'/' .
'imsmanifest.xml';
107 if (is_dir($this->packageFolder))
108 dir_delete($this->packageFolder);
109 if (is_file($this->packageFile))
110 @unlink($this->packageFile);
116 header(
'content-type: application/zip');
117 header(
'content-disposition: attachment; filename="' . basename($this->packageFile) .
'"');
118 readfile($this->packageFile);
128 header(
'content-type: text/xml');
129 header(
'content-disposition: attachment; filename="manifest.xml"');
132 $res = $ilDB->queryF(
133 'SELECT xmldata FROM cp_package WHERE obj_id = %s',
135 array($this->packageId)
139 print(
$row[
'xmldata']);
153 if ($reimport ===
true) {
160 $this->imsmanifestFile = $this->packageFolder .
'/' .
'imsmanifest.xml';
162 $this->imsmanifest =
new DOMDocument;
163 $this->imsmanifest->async =
false;
164 if (!@$this->imsmanifest->load($this->imsmanifestFile))
166 $this->diagnostic[] =
'XML not wellformed';
171 $this->manifest = $this->
transform($this->imsmanifest, self::DB_ENCODE_XSL);
173 if (!$this->manifest)
175 $this->diagnostic[] =
'Cannot transform into normalized manifest';
179 $path =
new DOMXpath($this->manifest);
180 $path->registerNamespace(
"scorm",
"http://www.openpalms.net/scorm/scorm13");
181 $items =
$path->query(
"//scorm:item");
182 if($items->length == 1){
183 $n = $items->item(0);
184 $resource =
$path->query(
"//scorm:resource");
185 foreach($resource as
$res){
186 if($res->getAttribute(
'id') ==
$n->getAttribute(
"resourceId")){
187 $res->setAttribute(
'scormType',
'sco');
193 if ($validate==
"y") {
194 if (!$this->
validate($this->manifest, self::VALIDATE_XSD))
197 $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,
203 if(file_exists($this->packageFolder .
'/' .
'index.xml'))
205 $doc = simplexml_load_file($this->packageFolder .
'/' .
'index.xml');
206 $l = $doc->xpath (
"/ContentObject/MetaData" );
209 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
211 $mdxml->startParsing();
212 $mdxml->getMDObject()->update();
217 $x = simplexml_load_string($this->manifest->saveXML());
218 $x[
'persistPreviousAttempts'] = $this->packageData[
'persistprevattempts'];
219 $x[
'online'] = $this->packageData[
'c_online'];
221 $x[
'defaultLessonMode'] = $this->packageData[
'default_lesson_mode'];
222 $x[
'credit'] = $this->packageData[
'credit'];
223 $x[
'autoReview'] = $this->packageData[
'auto_review'];
227 foreach ($x->resource as $xe)
229 $r[strval($xe[
'id'])] = $xe;
233 foreach ($x->xpath(
'//*[local-name()="item"]') as $xe)
236 if ($b = $r[strval($xe[
'resourceId'])])
238 $xe[
'href'] = strval($b[
'base']) . strval($b[
'href']);
239 unset($xe[
'resourceId']);
240 if (strval($b[
'scormType'])==
'sco') $xe[
'sco'] =
true;
247 foreach($x->sequencing as $s)
252 $j[
'item'][
'base'] = strval($x[
'base']);
255 $j[
'foreignId'] = floatval($x[
'foreignId']);
256 $j[
'id'] = strval($x[
'id']);
261 $adl_tree = $act->buildNodeSeqTree($this->imsmanifestFile);
262 $ilDB->update(
'cp_package',
264 'xmldata' => array(
'clob', $x->asXML()),
265 'jsdata' => array(
'clob', json_encode($j)),
266 'activitytree' => array(
'clob', json_encode($adl_tree[
'tree'])),
267 'global_to_system' => array(
'integer', (
int)$adl_tree[
'global']),
268 'shared_data_global_to_system' => array(
'integer', (
int)$adl_tree[
'dataglobal'])
271 'obj_id' => array(
'integer', (
int)$this->packageId)
275 return $j[
'item'][
'title'];
291 $this->imsmanifestFile = $this->packageFolder .
'/' .
'index.xml';
292 $this->imsmanifest =
new DOMDocument;
293 $this->imsmanifest->async =
false;
295 if (!@$this->imsmanifest->load($this->imsmanifestFile))
297 $this->diagnostic[] =
'XML not wellformed';
306 $sco_xml_file = $this->packageFolder .
'/sco.xml';
307 if (is_file($sco_xml_file))
309 $scodoc =
new DOMDocument;
310 $scodoc->async =
false;
311 if (!@$scodoc->load($sco_xml_file))
313 $this->diagnostic[] =
'XML of sco.xml not wellformed';
318 $xpath =
new DOMXPath($scodoc);
319 $nodes = $xpath->query(
"/sco/objective");
320 foreach($nodes as $node)
322 $t_node = $node->firstChild;
323 if (is_object($t_node))
325 $objective_text = $t_node->textContent;
326 if (trim($objective_text) !=
"")
328 $objs = $sco->getObjectives();
329 foreach ($objs as $o)
331 $mappings = $o->getMappings();
332 if ($mappings == null)
334 $ob =
new ilScorm2004Objective($sco->getId(), $o->getId());
335 $ob->setObjectiveID($objective_text);
336 $ob->updateObjective();
358 $this->imsmanifestFile = $this->packageFolder .
'/' .
'index.xml';
359 $this->imsmanifest =
new DOMDocument;
360 $this->imsmanifest->async =
false;
362 if (!@$this->imsmanifest->load($this->imsmanifestFile))
364 $this->diagnostic[] =
'XML not wellformed';
420 $this->packageId=
$slm->getId();
421 $this->imsmanifestFile = $this->packageFolder .
'/' .
'imsmanifest.xml';
422 $this->imsmanifest =
new DOMDocument;
423 $this->imsmanifest->async =
false;
424 $this->imsmanifest->formatOutput =
false;
425 $this->imsmanifest->preserveWhiteSpace =
false;
427 if (!@$this->imsmanifest->load($this->imsmanifestFile))
429 $this->diagnostic[] =
'XML not wellformed';
433 $this->mani_xpath =
new DOMXPath($this->imsmanifest);
434 $this->mani_xpath->registerNamespace(
"d",
"http://www.imsproject.org/xsd/imscp_rootv1p1p2");
435 $this->mani_xpath->registerNamespace(
"imscp",
"http://www.imsglobal.org/xsd/imscp_v1p1");
436 $this->mani_xpath->registerNamespace(
"imsss",
"http://www.imsglobal.org/xsd/imsss");
439 $this->
dbImportLM(simplexml_import_dom($this->imsmanifest->documentElement),
"",
440 $a_import_sequencing);
455 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
457 $newObj->setType(
'glo');
458 $newObj->setTitle(
'');
459 $newObj->create(
true);
460 $newObj->createReference();
461 $newObj->putInTree(
$_GET[
"ref_id"]);
462 $newObj->setPermissions(
$_GET[
"ref_id"]);
463 $newObj->notify(
"new",
$_GET[
"ref_id"],
$_GET[
"parent_non_rbac_id"],
$_GET[
"ref_id"],$newObj->getRefId());
468 if (!is_file($xml_file))
473 include_once (
"./Modules/LearningModule/classes/class.ilContObjParser.php");
475 $contParser->startParsing();
478 $slm->setAssignedGlossary($newObj->getId());
482 function dbImportLM($node, $parent_id =
"", $a_import_sequencing =
false)
485 switch($node->getName())
488 $this->slm_tree =&
new ilTree($this->slm->getId());
490 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
491 $this->slm_tree->addTree($this->slm->getId(), 1);
494 include_once (
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
498 $r = $this->mani_xpath->query(
"/d:manifest/d:organizations/d:organization/imsss:sequencing");
499 $this->imsmanifest->formatOutput =
false;
503 if ($a_import_sequencing)
505 $seq_info->initDom();
510 if(file_exists($this->packageFolder .
'/' .
'index.xml'))
512 $doc = simplexml_load_file($this->packageFolder .
'/' .
'index.xml');
513 $l = $doc->xpath (
"/ContentObject/MetaData" );
516 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
517 $mdxml =&
new ilMDXMLCopier($l[0]->asXML(),$this->slm->getId(),$this->slm->getId(),$this->slm->getType());
519 $mdxml->getMDObject()->update();
524 $this->slm->title=$node->title;
527 $a = $node->attributes();
528 if(preg_match(
"/il_\d+_chap_\d+/",$a[
'identifier']))
531 $chap->setTitle($node->title);
532 $chap->setSLMId($this->slm->getId());
536 $r = $this->mani_xpath->query(
"//d:item[@identifier='".$a[
'identifier'].
"']/imsss:sequencing");
541 $seq_info->initDom();
546 $parent_id = $chap->getId();
547 $doc = simplexml_load_file($this->packageFolder .
'/' .
'index.xml');
548 $l = $doc->xpath (
"/ContentObject/StructureObject/MetaData[General/Identifier/@Entry='".$a[
'identifier'].
"']" );
551 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
552 $mdxml =&
new ilMDXMLCopier($l[0]->asXML(),$this->slm->getId(),$chap->getId(),$chap->getType());
554 $mdxml->getMDObject()->update();
557 if(preg_match(
"/il_\d+_sco_(\d+)/",$a[
'identifier'], $match))
560 $sco->setTitle($node->title);
561 $sco->setSLMId($this->slm->getId());
565 $r = $this->mani_xpath->query(
"//d:item[@identifier='".$a[
'identifier'].
"']/imsss:sequencing");
570 "local_obj_".$sco->getID().
"_0");
571 $seq_info->initDom();
577 $newPack->il_importSco($this->slm->getId(),$sco->getId(),$this->packageFolder.
"/".$match[1]);
578 $parent_id = $sco->getId();
580 if(preg_match(
"/il_\d+_ass_(\d+)/",$a[
'identifier'], $match))
583 $ass->setTitle($node->title);
584 $ass->setSLMId($this->slm->getId());
588 $r = $this->mani_xpath->query(
"//d:item[@identifier='".$a[
'identifier'].
"']/imsss:sequencing");
593 "local_obj_".$ass->getID().
"_0");
594 $seq_info->initDom();
600 $newPack->il_importAss($this->slm->getId(),$ass->getId(),$this->packageFolder.
"/".$match[1]);
601 $parent_id = $ass->getId();
608 foreach($node->children() as $child)
610 $this->
dbImportLM($child, $parent_id, $a_import_sequencing);
623 $seq_xml = trim(str_replace(
"imsss:",
"", $this->imsmanifest->saveXML($a_node)));
626 $a_seq_info->setImportSeqXml(
'<?xml version="1.0"?>'.$seq_xml);
628 if ($a_import_sequencing)
630 if ($a_fix_obj_id !=
"")
632 $seq_xml = preg_replace(
"/local_obj_[0-9]*_0/", $a_fix_obj_id, $seq_xml);
634 $a_seq_info->setSeqXml(
'<?xml version="1.0"?>'.$seq_xml);
642 $this->diagnostic[] = $msg;
655 foreach ($node->attributes() as $k => $v)
659 if ($v===
"true") $v =
true;
660 else if ($v===
"false") $v =
false;
661 else if (is_numeric($v)) $v = (float) $v;
664 foreach ($node->children() as $name => $child)
674 foreach (
$d as $f ) {
676 if ($f [type] ==
'file' && substr ( $f [entry], 0, 4 ) ==
'qti_') {
677 include_once
"./Services/QTI/classes/class.ilQTIParser.php";
678 include_once
"./Modules/Test/classes/class.ilObjTest.php";
682 $result = $qtiParser->startParsing ();
683 $founditems = & $qtiParser->getFoundItems ();
685 foreach ( $founditems as $qp ) {
700 $qtiParser->setTestObject ( $newObj );
701 $result = $qtiParser->startParsing ();
703 $qtis = array_merge($qtis, $qtiParser->getImportMapping());
709 include_once
'Modules/Scorm2004/classes/class.ilSCORM2004Page.php';
710 $doc =
new SimpleXMLElement($this->imsmanifest->saveXml());
711 $l = $doc->xpath (
"/ContentObject/MetaData" );
714 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
715 $mdxml =&
new ilMDXMLCopier($l[0]->asXML(),
$slm->getId(),$sco->getId(),$sco->getType());
717 $mdxml->getMDObject()->update();
719 $l = $doc->xpath(
"/ContentObject/PageObject");
720 foreach ( $l as $page_xml )
722 $tnode = $page_xml->xpath (
'MetaData/General/Title' );
724 $page->setTitle ( $tnode [0] );
725 $page->setSLMId (
$slm->getId () );
726 $page->create (
true);
728 $pmd = $page_xml->xpath (
"MetaData");
731 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
732 $mdxml =&
new ilMDXMLCopier($pmd[0]->asXML(),
$slm->getId(),$page->getId(),$page->getType());
734 $mdxml->getMDObject()->update();
736 $tnode = $page_xml->xpath(
"//MediaObject/MediaAlias | //InteractiveImage/MediaAlias");
737 foreach($tnode as $ttnode)
739 include_once
'./Services/MediaObjects/classes/class.ilObjMediaObject.php';
740 $OriginId = $ttnode[OriginId];
741 $medianodes = $doc->xpath(
"//MediaObject[MetaData/General/Identifier/@Entry='".$OriginId .
"']");
742 $medianode = $medianodes[0];
746 $media_object->setTitle ($medianode->MetaData->General->Title);
747 $media_object->setDescription ($medianode->MetaData->General->Description);
748 $media_object->create (
false);
749 $mmd = $medianode->xpath (
"MetaData");
752 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
753 $mdxml =&
new ilMDXMLCopier($mmd[0]->asXML(),0,$media_object->getId(),$media_object->getType());
755 $mdxml->getMDObject()->update();
758 $media_object->createDirectory ();
760 foreach ( $medianode->MediaItem as $xMediaItem )
763 $media_object->addMediaItem ( $media_item );
764 $media_item->setPurpose($xMediaItem[Purpose]);
765 $media_item->setFormat($xMediaItem->Format );
766 $media_item->setLocation($xMediaItem->Location);
767 $media_item->setLocationType($xMediaItem->Location[Type]);
768 $media_item->setWidth ( $xMediaItem->Layout[Width]);
769 $media_item->setHeight ( $xMediaItem->Layout[Height]);
770 $media_item->setHAlign($xMediaItem->Layout[HorizontalAlign]);
771 $media_item->setCaption($xMediaItem->Caption);
772 $media_item->setTextRepresentation($xMediaItem->TextRepresentation);
776 foreach ($xMediaItem->MapArea as
$n => $v)
779 if ($v->ExtLink[Href] !=
"")
781 include_once(
"./Services/MediaObjects/classes/class.ilMapArea.php");
785 $map_area->setShape($v[Shape]);
786 $map_area->setCoords($v[Coords]);
788 $map_area->setTitle($v->ExtLink);
789 $map_area->setHref($v->ExtLink[Href]);
791 $media_item->addMapArea($map_area);
795 if($media_item->getLocationType()==
"LocalFile")
803 ilUtil::rCopy($this->packageFolder.
"/objects/".$OriginId, $mob_dir);
810 $media_object->update(
true);
811 $ttnode [OriginId] =
"il__mob_" . $media_object->getId ();
814 include_once(
"./Modules/File/classes/class.ilObjFile.php");
815 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
816 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
818 $intlinks = $page_xml->xpath(
"//IntLink");
822 foreach ( $intlinks as $intlink )
824 if($intlink[Type]!=
"File")
continue;
825 $path = $this->packageFolder.
"/objects/".str_replace(
'dfile',
'file',$intlink[Target]);
826 if(!is_dir(
$path ))
continue;
831 $fileObj->setType(
"file");
840 $fileObj->createReference();
843 $fileObj->createDirectory();
845 $intlink[Target]=
"il__dfile_".$fileObj->getId();
849 $fileitems = $page_xml->xpath(
"//FileItem/Identifier");
852 foreach ( $fileitems as $fileitem )
854 $path = $this->packageFolder.
"/objects/".$fileitem[Entry];
855 if(!is_dir(
$path ))
continue;
860 $fileObj->setType(
"file");
869 $fileObj->createReference();
872 $fileObj->createDirectory();
874 $fileitem[Entry]=
"il__file_".$fileObj->getId();
880 $ddoc =
new DOMDocument();
881 $ddoc->async =
false;
882 $ddoc->preserveWhiteSpace =
false;
883 $ddoc->formatOutput =
false;
884 $ddoc->loadXML($page_xml->asXML());
885 $xpath =
new DOMXPath($ddoc);
886 $tnode = $xpath->query(
'PageContent');
888 foreach($tnode as $ttnode)
889 $t .= $ddoc->saveXML($ttnode);
890 $t .=
"</PageObject>";
891 foreach ($qtis as $old=>$q)
892 $t = str_replace($old,
'il__qst_'.$q[
'pool'],
$t);
893 $pagex->setXMLContent(
$t);
894 $pagex->updateFromXML();
898 public function dbImport($node, &$lft=1, $depth=1, $parent=0)
902 switch ($node->nodeType)
904 case XML_DOCUMENT_NODE:
914 $res = $ilDB->queryF(
915 'SELECT * FROM cp_package WHERE obj_id = %s AND c_identifier = %s',
916 array(
'integer',
'text'),
917 array($this->packageId, $this->packageName)
919 if($num_rows = $ilDB->numRows(
$res))
921 $query =
'UPDATE cp_package '
922 .
'SET persistprevattempts = %s, c_settings = %s '
923 .
'WHERE obj_id = %s AND c_identifier= %s';
926 array(
'integer',
'text',
'integer',
'text'),
927 array(0, NULL, $this->packageId, $this->packageName)
932 $query =
'INSERT INTO cp_package (obj_id, c_identifier, persistprevattempts, c_settings) '
933 .
'VALUES (%s, %s, %s, %s)';
936 array(
'integer',
'text',
'integer',
'text'),
937 array($this->packageId, $this->packageName, 0, NULL)
942 $this->
dbImport($node->documentElement);
945 case XML_ELEMENT_NODE:
946 if ($node->nodeName===
'manifest')
948 if ($node->getAttribute(
'uri')==
"")
951 $node->setAttribute(
'uri',
'md5:' . $this->packageHash);
955 $cp_node_id = $ilDB->nextId(
'cp_node');
957 $query =
'INSERT INTO cp_node (cp_node_id, slm_id, nodename) '
958 .
'VALUES (%s, %s, %s)';
961 array(
'integer',
'integer',
'text'),
962 array($cp_node_id, $this->packageId, $node->nodeName)
965 $query =
'INSERT INTO cp_tree (child, depth, lft, obj_id, parent, rgt) '
966 .
'VALUES (%s, %s, %s, %s, %s, %s)';
969 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
970 array($cp_node_id, $depth, $lft++, $this->packageId, $parent, 0)
975 $names = array(
'cp_node_id');
976 $values = array($cp_node_id);
977 $types = array(
'integer');
979 foreach ($node->attributes as $attr)
981 switch(strtolower($attr->name))
983 case 'completionsetbycontent': $names[] =
'completionbycontent';
break;
984 case 'objectivesetbycontent': $names[] =
'objectivebycontent';
break;
985 case 'type': $names[] =
'c_type';
break;
986 case 'mode': $names[] =
'c_mode';
break;
987 case 'language': $names[] =
'c_language';
break;
988 case 'condition': $names[] =
'c_condition';
break;
989 case 'operator': $names[] =
'c_operator';
break;
990 case 'condition': $names[] =
'c_condition';
break;
991 case 'readnormalizedmeasure': $names[] =
'readnormalmeasure';
break;
992 case 'writenormalizedmeasure': $names[] =
'writenormalmeasure';
break;
993 case 'minnormalizedmeasure': $names[] =
'minnormalmeasure';
break;
994 case 'primary': $names[] =
'c_primary';
break;
995 case 'minnormalizedmeasure': $names[] =
'minnormalmeasure';
break;
996 case 'persistpreviousattempts': $names[] =
'persistprevattempts';
break;
997 case 'identifier': $names[] =
'c_identifier';
break;
998 case 'settings': $names[] =
'c_settings';
break;
999 case 'activityabsolutedurationlimit': $names[] =
'activityabsdurlimit';
break;
1000 case 'activityexperienceddurationlimit': $names[] =
'activityexpdurlimit';
break;
1001 case 'attemptabsolutedurationlimit': $names[] =
'attemptabsdurlimit';
break;
1002 case 'measuresatisfactionifactive': $names[] =
'measuresatisfactive';
break;
1003 case 'objectivemeasureweight': $names[] =
'objectivemeasweight';
break;
1004 case 'requiredforcompleted': $names[] =
'requiredcompleted';
break;
1005 case 'requiredforincomplete': $names[] =
'requiredincomplete';
break;
1006 case 'requiredfornotsatisfied': $names[] =
'requirednotsatisfied';
break;
1007 case 'rollupobjectivesatisfied': $names[] =
'rollupobjectivesatis';
break;
1008 case 'rollupprogresscompletion': $names[] =
'rollupprogcompletion';
break;
1009 case 'usecurrentattemptobjectiveinfo': $names[] =
'usecurattemptobjinfo';
break;
1010 case 'usecurrentattemptprogressinfo': $names[] =
'usecurattemptproginfo';
break;
1011 default: $names[] = strtolower($attr->name);
break;
1014 if(in_array($names[count($names) - 1],
1015 array(
'flow',
'completionbycontent',
1016 'objectivebycontent',
'rollupobjectivesatis',
1017 'tracked',
'choice',
1018 'choiceexit',
'satisfiedbymeasure',
1019 'c_primary',
'constrainchoice',
1020 'forwardonly',
'global_to_system',
1021 'writenormalmeasure',
'writesatisfiedstatus',
1022 'readnormalmeasure',
'readsatisfiedstatus',
1023 'preventactivation',
'measuresatisfactive',
1024 'reorderchildren',
'usecurattemptproginfo',
1025 'usecurattemptobjinfo',
'rollupprogcompletion',
1026 'read_shared_data',
'write_shared_data',
1027 'shared_data_global_to_system',
'completedbymeasure')))
1029 if($attr->value ==
'true')
1031 else if ($attr->value ==
'false')
1034 $values[] = (int)$attr->value;
1038 $values[] = $attr->value;
1041 if( in_array($names[count($names) - 1],
1042 array(
'objectivesglobtosys',
'attemptlimit',
1043 'flow',
'completionbycontent',
1044 'objectivebycontent',
'rollupobjectivesatis',
1045 'tracked',
'choice',
1046 'choiceexit',
'satisfiedbymeasure',
1047 'c_primary',
'constrainchoice',
1048 'forwardonly',
'global_to_system',
1049 'writenormalmeasure',
'writesatisfiedstatus',
1050 'readnormalmeasure',
'readsatisfiedstatus',
1051 'preventactivation',
'measuresatisfactive',
1052 'reorderchildren',
'usecurattemptproginfo',
1053 'usecurattemptobjinfo',
'rollupprogcompletion',
1054 'read_shared_data',
'write_shared_data',
1055 'shared_data_global_to_system')))
1056 $types[] =
'integer';
1057 else if ( in_array($names[count($names) - 1],
1058 array(
'jsdata',
'xmldata',
'activitytree',
'data')))
1060 else if ( in_array($names[count($names) - 1],
1061 array(
'objectivemeasweight')))
1067 if($node->nodeName===
'datamap')
1069 $names[] =
'slm_id';
1071 $types[] =
'integer';
1073 $names[] =
'sco_node_id';
1074 $values[] = $parent;
1075 $types[] =
'integer';
1079 $insert_data = array();
1080 foreach($names as $key => $db_field)
1082 $insert_data[$db_field] = array($types[$key], trim($values[$key]));
1084 $ilDB->insert(
'cp_'.strtolower($node->nodeName), $insert_data);
1086 $node->setAttribute(
'foreignId', $cp_node_id);
1087 $this->idmap[$node->getAttribute(
'id')] = $cp_node_id;
1090 foreach($node->childNodes as $child)
1092 $this->
dbImport($child, $lft, $depth + 1, $cp_node_id);
1096 $query =
'UPDATE cp_tree SET rgt = %s WHERE child = %s';
1099 array(
'integer',
'integer'),
1100 array($lft++, $cp_node_id)
1125 $ilDB->insert(
'cp_package', array(
1126 'obj_id' => array(
'integer', $this->packageId),
1127 'xmldata' => array(
'clob', $x->asXML()),
1128 'jsdata' => array(
'clob', json_encode($j))
1137 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004DeleteData.php");
1140 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
1150 $cp_nodes = array();
1152 $res = $ilDB->queryF(
1153 'SELECT cp_node.cp_node_id FROM cp_node WHERE cp_node.slm_id = %s',
1155 array($this->packageId)
1159 $cp_nodes[] =
$data[
'cp_node_id'];
1163 foreach(self::$elements[
'cp'] as
$t)
1167 $in = $ilDB->in(strtolower($t).
'.cp_node_id', $cp_nodes,
false,
'integer');
1168 $ilDB->manipulate(
'DELETE FROM '.strtolower($t).
' WHERE '.
$in);
1173 'DELETE FROM cp_tree WHERE cp_tree.obj_id = %s',
1175 array($this->packageId)
1179 'DELETE FROM cp_node WHERE cp_node.slm_id = %s',
1181 array($this->packageId)
1186 'DELETE FROM cp_package WHERE cp_package.obj_id = %s',
1188 array($this->packageId)
1199 public function transform($inputdoc, $xslfile, $outputpath = null)
1201 $xsl =
new DOMDocument;
1202 $xsl->async =
false;
1203 if (!@$xsl->load($xslfile))
1205 die(
'ERROR: load StyleSheet ' . $xslfile);
1207 $prc =
new XSLTProcessor;
1208 $prc->registerPHPFunctions();
1209 $r = @$prc->importStyleSheet($xsl);
1210 if (
false===@$prc->importStyleSheet($xsl))
1212 die(
'ERROR: importStyleSheet ' . $xslfile);
1216 file_put_contents($outputpath, $prc->transformToXML($inputdoc));
1220 return $prc->transformToDoc($inputdoc);
1226 libxml_use_internal_errors(
true);
1227 $return = @$doc->schemaValidate($schema);
1231 LIBXML_ERR_ERROR =>
'Error',
1232 LIBXML_ERR_FATAL =>
'Fatal Error'
1234 foreach (libxml_get_errors() as $error)
1236 $level = $levels[$error->level];
1239 $message = trim($error->message);
1240 $this->diagnostic[] =
"XSLT $level (Line $error->line) $message";
1243 libxml_clear_errors();
1245 libxml_use_internal_errors(
false);
1252 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004DeleteData.php");