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'];
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"');
131 $res = $ilDB->queryF(
132 'SELECT xmldata FROM cp_package WHERE obj_id = %s',
134 array($this->packageId)
138 print(
$row[
'xmldata']);
153 if ($reimport ===
true) {
160 $this->imsmanifestFile = $this->packageFolder .
'/' .
'imsmanifest.xml';
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 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM13MDImporter.php");
220 $title = $importer->getTitle();
221 $description = $importer->getDescription();
222 if ($description !=
"") {
228 $x = simplexml_load_string($this->manifest->saveXML());
229 $x[
'persistPreviousAttempts'] = $this->packageData[
'persistprevattempts'];
230 $x[
'online'] = $this->packageData[
'c_online'];
232 $x[
'defaultLessonMode'] = $this->packageData[
'default_lesson_mode'];
233 $x[
'credit'] = $this->packageData[
'credit'];
234 $x[
'autoReview'] = $this->packageData[
'auto_review'];
238 foreach ($x->resource as $xe)
240 $r[strval($xe[
'id'])] = $xe;
244 foreach ($x->xpath(
'//*[local-name()="item"]') as $xe)
247 if ($b =
$r[strval($xe[
'resourceId'])])
249 $xe[
'href'] = strval($b[
'base']) . strval($b[
'href']);
250 unset($xe[
'resourceId']);
251 if (strval($b[
'scormType'])==
'sco') $xe[
'sco'] =
true;
257 self::jsonNode($x->organization, $j[
'item']);
258 foreach($x->sequencing as $s)
260 self::jsonNode($s, $j[
'sequencing'][]);
263 $j[
'item'][
'base'] = strval($x[
'base']);
266 $j[
'foreignId'] = floatval($x[
'foreignId']);
267 $j[
'id'] = strval($x[
'id']);
272 $adl_tree = $act->buildNodeSeqTree($this->imsmanifestFile);
273 $ilDB->update(
'cp_package',
275 'xmldata' =>
array(
'clob', $x->asXML()),
276 'jsdata' =>
array(
'clob', json_encode($j)),
277 'activitytree' =>
array(
'clob', json_encode($adl_tree[
'tree'])),
278 'global_to_system' =>
array(
'integer', (
int)$adl_tree[
'global']),
279 'shared_data_global_to_system' =>
array(
'integer', (
int)$adl_tree[
'dataglobal'])
282 'obj_id' =>
array(
'integer', (
int)$this->packageId)
291 return $j[
'item'][
'title'];
307 $this->imsmanifestFile = $this->packageFolder .
'/' .
'index.xml';
309 $this->imsmanifest->async =
false;
311 if (!@$this->imsmanifest->load($this->imsmanifestFile))
313 $this->diagnostic[] =
'XML not wellformed';
322 $sco_xml_file = $this->packageFolder .
'/sco.xml';
323 if (is_file($sco_xml_file))
326 $scodoc->async =
false;
327 if (!@$scodoc->load($sco_xml_file))
329 $this->diagnostic[] =
'XML of sco.xml not wellformed';
334 $xpath =
new DOMXPath($scodoc);
335 $nodes = $xpath->query(
"/sco/objective");
336 foreach($nodes as $node)
338 $t_node = $node->firstChild;
339 if (is_object($t_node))
341 $objective_text = $t_node->textContent;
342 if (trim($objective_text) !=
"")
344 $objs = $sco->getObjectives();
345 foreach ($objs as $o)
347 $mappings = $o->getMappings();
348 if ($mappings == null)
350 $ob =
new ilScorm2004Objective($sco->getId(), $o->getId());
351 $ob->setObjectiveID($objective_text);
352 $ob->updateObjective();
374 $this->imsmanifestFile = $this->packageFolder .
'/' .
'index.xml';
376 $this->imsmanifest->async =
false;
378 if (!@$this->imsmanifest->load($this->imsmanifestFile))
380 $this->diagnostic[] =
'XML not wellformed';
436 $this->packageId=
$slm->getId();
437 $this->imsmanifestFile = $this->packageFolder .
'/' .
'imsmanifest.xml';
439 $this->imsmanifest->async =
false;
440 $this->imsmanifest->formatOutput =
false;
441 $this->imsmanifest->preserveWhiteSpace =
false;
443 if (!@$this->imsmanifest->load($this->imsmanifestFile))
445 $this->diagnostic[] =
'XML not wellformed';
449 $this->mani_xpath =
new DOMXPath($this->imsmanifest);
450 $this->mani_xpath->registerNamespace(
"d",
"http://www.imsproject.org/xsd/imscp_rootv1p1p2");
451 $this->mani_xpath->registerNamespace(
"imscp",
"http://www.imsglobal.org/xsd/imscp_v1p1");
452 $this->mani_xpath->registerNamespace(
"imsss",
"http://www.imsglobal.org/xsd/imsss");
455 $this->
dbImportLM(simplexml_import_dom($this->imsmanifest->documentElement),
"",
456 $a_import_sequencing);
471 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
473 $newObj->setType(
'glo');
474 $newObj->setTitle(
'');
475 $newObj->create(
true);
476 $newObj->createReference();
477 $newObj->putInTree(
$_GET[
"ref_id"]);
478 $newObj->setPermissions(
$_GET[
"ref_id"]);
483 if (!is_file($xml_file))
488 include_once (
"./Modules/LearningModule/classes/class.ilContObjParser.php");
490 $contParser->startParsing();
493 $slm->setAssignedGlossary($newObj->getId());
497 function dbImportLM($node, $parent_id =
"", $a_import_sequencing =
false)
500 switch($node->getName())
503 $this->slm_tree =
new ilTree($this->slm->getId());
505 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
506 $this->slm_tree->addTree($this->slm->getId(), 1);
509 include_once (
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
513 $r = $this->mani_xpath->query(
"/d:manifest/d:organizations/d:organization/imsss:sequencing");
514 $this->imsmanifest->formatOutput =
false;
518 if ($a_import_sequencing)
520 $seq_info->initDom();
525 if(file_exists($this->packageFolder .
'/' .
'index.xml'))
527 $doc = simplexml_load_file($this->packageFolder .
'/' .
'index.xml');
528 $l = $doc->xpath (
"/ContentObject/MetaData" );
531 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
532 $mdxml =
new ilMDXMLCopier(
$l[0]->asXML(),$this->slm->getId(),$this->slm->getId(),$this->slm->getType());
534 $mdxml->getMDObject()->update();
539 $this->slm->title=$node->title;
542 $a = $node->attributes();
543 if(preg_match(
"/il_\d+_chap_\d+/",$a[
'identifier']))
546 $chap->setTitle($node->title);
547 $chap->setSLMId($this->slm->getId());
551 $r = $this->mani_xpath->query(
"//d:item[@identifier='".$a[
'identifier'].
"']/imsss:sequencing");
556 $seq_info->initDom();
561 $parent_id = $chap->getId();
562 $doc = simplexml_load_file($this->packageFolder .
'/' .
'index.xml');
563 $l = $doc->xpath (
"/ContentObject/StructureObject/MetaData[General/Identifier/@Entry='".$a[
'identifier'].
"']" );
566 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
567 $mdxml =
new ilMDXMLCopier(
$l[0]->asXML(),$this->slm->getId(),$chap->getId(),$chap->getType());
569 $mdxml->getMDObject()->update();
572 if(preg_match(
"/il_\d+_sco_(\d+)/",$a[
'identifier'], $match))
575 $sco->setTitle($node->title);
576 $sco->setSLMId($this->slm->getId());
580 $r = $this->mani_xpath->query(
"//d:item[@identifier='".$a[
'identifier'].
"']/imsss:sequencing");
585 "local_obj_".$sco->getID().
"_0");
586 $seq_info->initDom();
592 $newPack->il_importSco($this->slm->getId(),$sco->getId(),$this->packageFolder.
"/".$match[1]);
593 $parent_id = $sco->getId();
595 if(preg_match(
"/il_\d+_ass_(\d+)/",$a[
'identifier'], $match))
598 $ass->setTitle($node->title);
599 $ass->setSLMId($this->slm->getId());
603 $r = $this->mani_xpath->query(
"//d:item[@identifier='".$a[
'identifier'].
"']/imsss:sequencing");
608 "local_obj_".$ass->getID().
"_0");
609 $seq_info->initDom();
615 $newPack->il_importAss($this->slm->getId(),$ass->getId(),$this->packageFolder.
"/".$match[1]);
616 $parent_id = $ass->getId();
623 foreach($node->children() as $child)
625 $this->
dbImportLM($child, $parent_id, $a_import_sequencing);
638 $seq_xml = trim(str_replace(
"imsss:",
"", $this->imsmanifest->saveXML($a_node)));
641 $a_seq_info->setImportSeqXml(
'<?xml version="1.0"?>'.$seq_xml);
643 if ($a_import_sequencing)
645 if ($a_fix_obj_id !=
"")
647 $seq_xml = preg_replace(
"/local_obj_[0-9]*_0/", $a_fix_obj_id, $seq_xml);
649 $a_seq_info->setSeqXml(
'<?xml version="1.0"?>'.$seq_xml);
657 $this->diagnostic[] = $msg;
670 foreach ($node->attributes() as $k => $v)
674 if ($v===
"true") $v =
true;
675 else if ($v===
"false") $v =
false;
676 else if (is_numeric($v)) $v = (float) $v;
679 foreach ($node->children() as $name => $child)
681 self::jsonNode($child, $sink[$name][]);
689 foreach (
$d as $f ) {
691 if ($f [type] ==
'file' && substr ( $f [entry], 0, 4 ) ==
'qti_') {
692 include_once
"./Services/QTI/classes/class.ilQTIParser.php";
693 include_once
"./Modules/Test/classes/class.ilObjTest.php";
697 $result = $qtiParser->startParsing ();
698 $founditems = & $qtiParser->getFoundItems ();
700 foreach ( $founditems as $qp ) {
715 $qtiParser->setTestObject ( $newObj );
716 $result = $qtiParser->startParsing ();
718 $qtis = array_merge($qtis, $qtiParser->getImportMapping());
724 include_once
'Modules/Scorm2004/classes/class.ilSCORM2004Page.php';
726 $l = $doc->xpath (
"/ContentObject/MetaData" );
729 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
730 $mdxml =
new ilMDXMLCopier($l[0]->asXML(),
$slm->getId(),$sco->getId(),$sco->getType());
732 $mdxml->getMDObject()->update();
734 $l = $doc->xpath(
"/ContentObject/PageObject");
735 foreach ( $l as $page_xml )
737 $tnode = $page_xml->xpath (
'MetaData/General/Title' );
739 $page->setTitle ( $tnode [0] );
740 $page->setSLMId (
$slm->getId () );
741 $page->create (
true);
743 $pmd = $page_xml->xpath (
"MetaData");
746 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
747 $mdxml =
new ilMDXMLCopier($pmd[0]->asXML(),
$slm->getId(),$page->getId(),$page->getType());
749 $mdxml->getMDObject()->update();
751 $tnode = $page_xml->xpath(
"//MediaObject/MediaAlias | //InteractiveImage/MediaAlias");
752 foreach($tnode as $ttnode)
754 include_once
'./Services/MediaObjects/classes/class.ilObjMediaObject.php';
755 $OriginId = $ttnode[OriginId];
756 $medianodes = $doc->xpath(
"//MediaObject[MetaData/General/Identifier/@Entry='".$OriginId .
"']");
757 $medianode = $medianodes[0];
761 $media_object->setTitle ($medianode->MetaData->General->Title);
762 $media_object->setDescription ($medianode->MetaData->General->Description);
763 $media_object->create (
false);
764 $mmd = $medianode->xpath (
"MetaData");
767 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
768 $mdxml =
new ilMDXMLCopier($mmd[0]->asXML(),0,$media_object->getId(),$media_object->getType());
770 $mdxml->getMDObject()->update();
773 $media_object->createDirectory ();
775 foreach ( $medianode->MediaItem as $xMediaItem )
778 $media_object->addMediaItem ( $media_item );
779 $media_item->setPurpose($xMediaItem[Purpose]);
780 $media_item->setFormat($xMediaItem->Format );
781 $media_item->setLocation($xMediaItem->Location);
782 $media_item->setLocationType($xMediaItem->Location[Type]);
783 $media_item->setWidth ( $xMediaItem->Layout[Width]);
784 $media_item->setHeight ( $xMediaItem->Layout[Height]);
785 $media_item->setHAlign($xMediaItem->Layout[HorizontalAlign]);
786 $media_item->setCaption($xMediaItem->Caption);
787 $media_item->setTextRepresentation($xMediaItem->TextRepresentation);
791 foreach ($xMediaItem->MapArea as
$n => $v)
794 if ($v->ExtLink[Href] !=
"")
796 include_once(
"./Services/MediaObjects/classes/class.ilMapArea.php");
800 $map_area->setShape($v[Shape]);
801 $map_area->setCoords($v[Coords]);
803 $map_area->setTitle($v->ExtLink);
804 $map_area->setHref($v->ExtLink[Href]);
806 $media_item->addMapArea($map_area);
810 if($media_item->getLocationType()==
"LocalFile")
818 ilUtil::rCopy($this->packageFolder.
"/objects/".$OriginId, $mob_dir);
825 $media_object->update(
true);
826 $ttnode [OriginId] =
"il__mob_" . $media_object->getId ();
829 include_once(
"./Modules/File/classes/class.ilObjFile.php");
830 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
831 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
833 $intlinks = $page_xml->xpath(
"//IntLink");
837 foreach ( $intlinks as $intlink )
839 if($intlink[Type]!=
"File")
continue;
840 $path = $this->packageFolder.
"/objects/".str_replace(
'dfile',
'file',$intlink[Target]);
841 if(!is_dir(
$path ))
continue;
846 $fileObj->setType(
"file");
855 $fileObj->createReference();
858 $fileObj->createDirectory();
860 $intlink[Target]=
"il__dfile_".$fileObj->getId();
864 $fileitems = $page_xml->xpath(
"//FileItem/Identifier");
867 foreach ( $fileitems as $fileitem )
869 $path = $this->packageFolder.
"/objects/".$fileitem[
Entry];
870 if(!is_dir(
$path ))
continue;
875 $fileObj->setType(
"file");
884 $fileObj->createReference();
887 $fileObj->createDirectory();
889 $fileitem[
Entry]=
"il__file_".$fileObj->getId();
896 $ddoc->async =
false;
897 $ddoc->preserveWhiteSpace =
false;
898 $ddoc->formatOutput =
false;
899 $ddoc->loadXML($page_xml->asXML());
900 $xpath =
new DOMXPath($ddoc);
901 $tnode = $xpath->query(
'PageContent');
903 foreach($tnode as $ttnode)
904 $t .= $ddoc->saveXML($ttnode);
905 $t .=
"</PageObject>";
906 foreach ($qtis as
$old=>$q)
907 $t = str_replace(
$old,
'il__qst_'.$q[
'pool'],
$t);
908 $pagex->setXMLContent(
$t);
909 $pagex->updateFromXML();
913 public function dbImport($node, &$lft=1, $depth=1, $parent=0)
917 switch ($node->nodeType)
919 case XML_DOCUMENT_NODE:
923 $res = $ilDB->queryF(
924 'SELECT * FROM cp_package WHERE obj_id = %s AND c_identifier = %s',
925 array(
'integer',
'text'),
926 array($this->packageId, $this->packageName)
928 if($num_rows = $ilDB->numRows(
$res))
930 $query =
'UPDATE cp_package ' 931 .
'SET persistprevattempts = %s, c_settings = %s ' 932 .
'WHERE obj_id = %s AND c_identifier= %s';
935 array(
'integer',
'text',
'integer',
'text'),
936 array(0, NULL, $this->packageId, $this->packageName)
941 $query =
'INSERT INTO cp_package (obj_id, c_identifier, persistprevattempts, c_settings) ' 942 .
'VALUES (%s, %s, %s, %s)';
945 array(
'integer',
'text',
'integer',
'text'),
946 array($this->packageId, $this->packageName, 0, NULL)
951 $this->
dbImport($node->documentElement);
954 case XML_ELEMENT_NODE:
955 if ($node->nodeName===
'manifest')
957 if ($node->getAttribute(
'uri')==
"")
960 $node->setAttribute(
'uri',
'md5:' . $this->packageHash);
964 $cp_node_id = $ilDB->nextId(
'cp_node');
966 $query =
'INSERT INTO cp_node (cp_node_id, slm_id, nodename) ' 967 .
'VALUES (%s, %s, %s)';
970 array(
'integer',
'integer',
'text'),
971 array($cp_node_id, $this->packageId, $node->nodeName)
974 $query =
'INSERT INTO cp_tree (child, depth, lft, obj_id, parent, rgt) ' 975 .
'VALUES (%s, %s, %s, %s, %s, %s)';
978 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
979 array($cp_node_id, $depth, $lft++, $this->packageId, $parent, 0)
985 $values =
array($cp_node_id);
986 $types =
array(
'integer');
988 foreach ($node->attributes as $attr)
990 switch(strtolower($attr->name))
992 case 'completionsetbycontent':
$names[] =
'completionbycontent';
break;
993 case 'objectivesetbycontent':
$names[] =
'objectivebycontent';
break;
994 case 'type':
$names[] =
'c_type';
break;
995 case 'mode':
$names[] =
'c_mode';
break;
996 case 'language':
$names[] =
'c_language';
break;
997 case 'condition':
$names[] =
'c_condition';
break;
998 case 'operator':
$names[] =
'c_operator';
break;
999 case 'condition':
$names[] =
'c_condition';
break;
1000 case 'readnormalizedmeasure':
$names[] =
'readnormalmeasure';
break;
1001 case 'writenormalizedmeasure':
$names[] =
'writenormalmeasure';
break;
1002 case 'minnormalizedmeasure':
$names[] =
'minnormalmeasure';
break;
1003 case 'primary':
$names[] =
'c_primary';
break;
1004 case 'minnormalizedmeasure':
$names[] =
'minnormalmeasure';
break;
1005 case 'persistpreviousattempts':
$names[] =
'persistprevattempts';
break;
1006 case 'identifier':
$names[] =
'c_identifier';
break;
1007 case 'settings':
$names[] =
'c_settings';
break;
1008 case 'activityabsolutedurationlimit':
$names[] =
'activityabsdurlimit';
break;
1009 case 'activityexperienceddurationlimit':
$names[] =
'activityexpdurlimit';
break;
1010 case 'attemptabsolutedurationlimit':
$names[] =
'attemptabsdurlimit';
break;
1011 case 'measuresatisfactionifactive':
$names[] =
'measuresatisfactive';
break;
1012 case 'objectivemeasureweight':
$names[] =
'objectivemeasweight';
break;
1013 case 'requiredforcompleted':
$names[] =
'requiredcompleted';
break;
1014 case 'requiredforincomplete':
$names[] =
'requiredincomplete';
break;
1015 case 'requiredfornotsatisfied':
$names[] =
'requirednotsatisfied';
break;
1016 case 'rollupobjectivesatisfied':
$names[] =
'rollupobjectivesatis';
break;
1017 case 'rollupprogresscompletion':
$names[] =
'rollupprogcompletion';
break;
1018 case 'usecurrentattemptobjectiveinfo':
$names[] =
'usecurattemptobjinfo';
break;
1019 case 'usecurrentattemptprogressinfo':
$names[] =
'usecurattemptproginfo';
break;
1020 default:
$names[] = strtolower($attr->name);
break;
1024 array(
'flow',
'completionbycontent',
1025 'objectivebycontent',
'rollupobjectivesatis',
1026 'tracked',
'choice',
1027 'choiceexit',
'satisfiedbymeasure',
1028 'c_primary',
'constrainchoice',
1029 'forwardonly',
'global_to_system',
1030 'writenormalmeasure',
'writesatisfiedstatus',
1031 'readnormalmeasure',
'readsatisfiedstatus',
1032 'preventactivation',
'measuresatisfactive',
1033 'reorderchildren',
'usecurattemptproginfo',
1034 'usecurattemptobjinfo',
'rollupprogcompletion',
1035 'read_shared_data',
'write_shared_data',
1036 'shared_data_global_to_system',
'completedbymeasure')))
1038 if($attr->value ==
'true')
1040 else if ($attr->value ==
'false')
1043 $values[] = (int)$attr->value;
1047 $values[] = $attr->value;
1051 array(
'objectivesglobtosys',
'attemptlimit',
1052 'flow',
'completionbycontent',
1053 'objectivebycontent',
'rollupobjectivesatis',
1054 'tracked',
'choice',
1055 'choiceexit',
'satisfiedbymeasure',
1056 'c_primary',
'constrainchoice',
1057 'forwardonly',
'global_to_system',
1058 'writenormalmeasure',
'writesatisfiedstatus',
1059 'readnormalmeasure',
'readsatisfiedstatus',
1060 'preventactivation',
'measuresatisfactive',
1061 'reorderchildren',
'usecurattemptproginfo',
1062 'usecurattemptobjinfo',
'rollupprogcompletion',
1063 'read_shared_data',
'write_shared_data',
1064 'shared_data_global_to_system')))
1065 $types[] =
'integer';
1067 array(
'jsdata',
'xmldata',
'activitytree',
'data')))
1070 array(
'objectivemeasweight')))
1076 if($node->nodeName===
'datamap')
1080 $types[] =
'integer';
1082 $names[] =
'sco_node_id';
1083 $values[] = $parent;
1084 $types[] =
'integer';
1088 $insert_data =
array();
1089 foreach(
$names as $key => $db_field)
1091 $insert_data[$db_field] =
array($types[$key], trim($values[$key]));
1093 $ilDB->insert(
'cp_'.strtolower($node->nodeName), $insert_data);
1095 $node->setAttribute(
'foreignId', $cp_node_id);
1096 $this->idmap[$node->getAttribute(
'id')] = $cp_node_id;
1099 foreach($node->childNodes as $child)
1101 $this->
dbImport($child, $lft, $depth + 1, $cp_node_id);
1105 $query =
'UPDATE cp_tree SET rgt = %s WHERE child = %s';
1108 array(
'integer',
'integer'),
1109 array($lft++, $cp_node_id)
1123 $ilDB->insert(
'cp_package',
array(
1124 'obj_id' =>
array(
'integer', $this->packageId),
1125 'xmldata' =>
array(
'clob',
$x->asXML()),
1126 'jsdata' =>
array(
'clob', json_encode($j))
1135 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004DeleteData.php");
1138 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
1147 $cp_nodes =
array();
1149 $res = $ilDB->queryF(
1150 'SELECT cp_node.cp_node_id FROM cp_node WHERE cp_node.slm_id = %s',
1152 array($this->packageId)
1156 $cp_nodes[] =
$data[
'cp_node_id'];
1160 foreach(self::$elements[
'cp'] as
$t)
1164 $in = $ilDB->in(strtolower($t).
'.cp_node_id', $cp_nodes,
false,
'integer');
1165 $ilDB->manipulate(
'DELETE FROM '.strtolower($t).
' WHERE '.
$in);
1170 'DELETE FROM cp_tree WHERE cp_tree.obj_id = %s',
1172 array($this->packageId)
1176 'DELETE FROM cp_node WHERE cp_node.slm_id = %s',
1178 array($this->packageId)
1183 'DELETE FROM cp_package WHERE cp_package.obj_id = %s',
1185 array($this->packageId)
1196 public function transform($inputdoc, $xslfile, $outputpath = null)
1199 $xsl->async =
false;
1200 if (!@$xsl->load($xslfile))
1202 die(
'ERROR: load StyleSheet ' . $xslfile);
1204 $prc =
new XSLTProcessor;
1205 $prc->registerPHPFunctions();
1206 $r = @$prc->importStyleSheet($xsl);
1207 if (
false===@$prc->importStyleSheet($xsl))
1209 die(
'ERROR: importStyleSheet ' . $xslfile);
1213 file_put_contents($outputpath, $prc->transformToXML($inputdoc));
1217 return $prc->transformToDoc($inputdoc);
1223 libxml_use_internal_errors(
true);
1224 $return = @$doc->schemaValidate(
$schema);
1228 LIBXML_ERR_ERROR =>
'Error',
1229 LIBXML_ERR_FATAL =>
'Fatal Error' 1231 foreach (libxml_get_errors() as
$error)
1233 $level = $levels[$error->level];
1236 $message = trim($error->message);
1237 $this->diagnostic[] =
"XSLT $level (Line $error->line) $message";
1240 libxml_clear_errors();
1242 libxml_use_internal_errors(
false);
1249 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004DeleteData.php");
Class ilSCORM2004PageNode.
dbImportSco($slm, $sco, $asset=false)
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
put this object into content object tree
dbImportLM($node, $parent_id="", $a_import_sequencing=false)
transform($inputdoc, $xslfile, $outputpath=null)
jsonNode($node, &$sink)
Helper for UploadAndImport Recursively copies values from XML into PHP array for export as json Eleme...
dbImport($node, &$lft=1, $depth=1, $parent=0)
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
startParsing()
stores xml data in array
il_import($packageFolder, $packageId, $ilias, $validate, $reimport=false)
Imports an extracted SCORM 2004 module from ilias-data dir into database.
SCORM 13 Metadata importer.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
Class ilSCORM2004Chapter.
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
dbAddNew()
add new sahs and package record
for($col=0; $col< 50; $col++) $d
setSequencingInfo($a_node, $a_seq_info, $a_import_sequencing, $a_fix_obj_id="")
Save sequencing ingo.
exportXML()
Export as internal XML.
il_importAss($packageId, $sco_id, $packageFolder)
Imports an extracted SCORM 2004 module from ilias-data dir into database.
setProgress($progress, $msg='')
static removeCMIDataForUser($user_id)
Reload workbook from saved file
static _removeTrackingDataForUser($user_id)
Add a drawing to the header
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
il_importLM($slm, $packageFolder, $a_import_sequencing=false)
Class ilSCORM2004Sequencing.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
setTreeTablePK($a_column_name)
set column containing primary key in tree table public
static _writeDescription($a_obj_id, $a_desc)
write description to db (static)
if(php_sapi_name() !='cli') $in
static utf8_encode($string)
utf8-encodes string if it is not a valid utf8-string.
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
Class ilObjSCORM2004LearningModule.
__construct($packageId=null)
il_importSco($packageId, $sco_id, $packageFolder)
Imports an extracted SCORM 2004 module from ilias-data dir into database.
static recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
static removeCMIDataForPackage($packageId)
importGlossary($slm, $packageFolder)