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 if ($validate==
"y") {
180 if (!$this->
validate($this->manifest, self::VALIDATE_XSD))
183 $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,
189 if(file_exists($this->packageFolder .
'/' .
'index.xml'))
191 $doc = simplexml_load_file($this->packageFolder .
'/' .
'index.xml');
192 $l = $doc->xpath (
"/ContentObject/MetaData" );
195 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
197 $mdxml->startParsing();
198 $mdxml->getMDObject()->update();
203 $x = simplexml_load_string($this->manifest->saveXML());
204 $x[
'persistPreviousAttempts'] = $this->packageData[
'persistprevattempts'];
205 $x[
'online'] = $this->packageData[
'c_online'];
207 $x[
'defaultLessonMode'] = $this->packageData[
'default_lesson_mode'];
208 $x[
'credit'] = $this->packageData[
'credit'];
209 $x[
'autoReview'] = $this->packageData[
'auto_review'];
213 foreach ($x->resource as $xe)
215 $r[strval($xe[
'id'])] = $xe;
219 foreach ($x->xpath(
'//*[local-name()="item"]') as $xe)
222 if ($b = $r[strval($xe[
'resourceId'])])
224 $xe[
'href'] = strval($b[
'base']) . strval($b[
'href']);
225 unset($xe[
'resourceId']);
226 if (strval($b[
'scormType'])==
'sco') $xe[
'sco'] =
true;
233 foreach($x->sequencing as $s)
238 $j[
'item'][
'base'] = strval($x[
'base']);
241 $j[
'foreignId'] = floatval($x[
'foreignId']);
242 $j[
'id'] = strval($x[
'id']);
247 $adl_tree = $act->buildNodeSeqTree($this->imsmanifestFile);
248 $ilDB->update(
'cp_package',
250 'xmldata' => array(
'clob', $x->asXML()),
251 'jsdata' => array(
'clob', json_encode($j)),
252 'activitytree' => array(
'clob', json_encode($adl_tree[
'tree'])),
253 'global_to_system' => array(
'integer', (
int)$adl_tree[
'global'])
256 'obj_id' => array(
'integer', (
int)$this->packageId)
260 return $j[
'item'][
'title'];
277 $this->imsmanifestFile = $this->packageFolder .
'/' .
'index.xml';
278 $this->imsmanifest =
new DOMDocument;
279 $this->imsmanifest->async =
false;
281 if (!@$this->imsmanifest->load($this->imsmanifestFile))
283 $this->diagnostic[] =
'XML not wellformed';
292 $sco_xml_file = $this->packageFolder .
'/sco.xml';
293 if (is_file($sco_xml_file))
295 $scodoc =
new DOMDocument;
296 $scodoc->async =
false;
297 if (!@$scodoc->load($sco_xml_file))
299 $this->diagnostic[] =
'XML of sco.xml not wellformed';
304 $xpath =
new DOMXPath($scodoc);
305 $nodes = $xpath->query(
"/sco/objective");
306 foreach($nodes as $node)
308 $t_node = $node->firstChild;
309 if (is_object($t_node))
311 $objective_text = $t_node->textContent;
312 if (trim($objective_text) !=
"")
314 $objs = $sco->getObjectives();
315 foreach ($objs as $o)
317 $mappings = $o->getMappings();
318 if ($mappings == null)
320 $ob =
new ilScorm2004Objective($sco->getId(), $o->getId());
321 $ob->setObjectiveID($objective_text);
322 $ob->updateObjective();
337 $this->packageId=
$slm->getId();
338 $this->imsmanifestFile = $this->packageFolder .
'/' .
'imsmanifest.xml';
339 $this->imsmanifest =
new DOMDocument;
340 $this->imsmanifest->async =
false;
342 if (!@$this->imsmanifest->load($this->imsmanifestFile))
344 $this->diagnostic[] =
'XML not wellformed';
347 $this->
dbImportLM(simplexml_import_dom($this->imsmanifest->documentElement),$this->slm);
360 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
362 $newObj->setType(
'glo');
363 $newObj->setTitle(
'');
364 $newObj->create(
true);
365 $newObj->createReference();
366 $newObj->putInTree(
$_GET[
"ref_id"]);
367 $newObj->setPermissions(
$_GET[
"ref_id"]);
368 $newObj->notify(
"new",
$_GET[
"ref_id"],
$_GET[
"parent_non_rbac_id"],
$_GET[
"ref_id"],$newObj->getRefId());
373 if (!is_file($xml_file))
378 include_once (
"./Modules/LearningModule/classes/class.ilContObjParser.php");
380 $contParser->startParsing();
383 $slm->setAssignedGlossary($newObj->getId());
390 switch($node->getName())
393 $this->slm_tree =&
new ilTree($this->slm->getId());
395 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
396 $this->slm_tree->addTree($this->slm->getId(), 1);
398 include_once (
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
402 if(file_exists($this->packageFolder .
'/' .
'index.xml'))
404 $doc = simplexml_load_file($this->packageFolder .
'/' .
'index.xml');
405 $l = $doc->xpath (
"/ContentObject/MetaData" );
408 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
409 $mdxml =&
new ilMDXMLCopier(
$l[0]->asXML(),$this->slm->getId(),$this->slm->getId(),$this->slm->getType());
411 $mdxml->getMDObject()->update();
416 $this->slm->title=$node->title;
419 $a = $node->attributes();
420 if(preg_match(
"/il_\d+_chap_\d+/",$a[
'identifier']))
423 $chap->setTitle($node->title);
424 $chap->setSLMId($this->slm->getId());
427 $parent_id=$chap->getId();
428 $doc = simplexml_load_file($this->packageFolder .
'/' .
'index.xml');
429 $l = $doc->xpath (
"/ContentObject/StructureObject/MetaData[General/Identifier/@Entry='".$a[
'identifier'].
"']" );
432 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
433 $mdxml =&
new ilMDXMLCopier(
$l[0]->asXML(),$this->slm->getId(),$chap->getId(),$chap->getType());
435 $mdxml->getMDObject()->update();
438 if(preg_match(
"/il_\d+_sco_(\d+)/",$a[
'identifier'], $match))
441 $sco->setTitle($node->title);
442 $sco->setSLMId($this->slm->getId());
446 $newPack->il_importSco($this->slm->getId(),$sco->getId(),$this->packageFolder.
"/".$match[1]);
447 $parent_id = $sco->getId();
454 foreach($node->children() as $child)
464 $this->diagnostic[] = $msg;
477 foreach ($node->attributes() as $k => $v)
481 if ($v===
"true") $v =
true;
482 else if ($v===
"false") $v =
false;
483 else if (is_numeric($v)) $v = (float) $v;
486 foreach ($node->children() as
$name => $child)
496 foreach (
$d as
$f ) {
498 if ($f [type] ==
'file' && substr ( $f [entry], 0, 4 ) ==
'qti_') {
499 include_once
"./Services/QTI/classes/class.ilQTIParser.php";
500 include_once
"./Modules/Test/classes/class.ilObjTest.php";
504 $result = $qtiParser->startParsing ();
505 $founditems = & $qtiParser->getFoundItems ();
507 foreach ( $founditems as $qp ) {
522 $qtiParser->setTestObject ( $newObj );
523 $result = $qtiParser->startParsing ();
525 $qtis = array_merge($qtis, $qtiParser->getImportMapping());
531 include_once
'class.ilSCORM2004Page.php';
532 $doc =
new SimpleXMLElement($this->imsmanifest->saveXml());
533 $l = $doc->xpath (
"/ContentObject/MetaData" );
536 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
537 $mdxml =&
new ilMDXMLCopier($l[0]->asXML(),
$slm->getId(),$sco->getId(),$sco->getType());
539 $mdxml->getMDObject()->update();
541 $l = $doc->xpath(
"/ContentObject/PageObject");
542 foreach ( $l as $page_xml )
544 $tnode = $page_xml->xpath (
'MetaData/General/Title' );
546 $page->setTitle ( $tnode [0] );
547 $page->setSLMId (
$slm->getId () );
548 $page->create (
true);
550 $pmd = $page_xml->xpath (
"MetaData");
553 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
554 $mdxml =&
new ilMDXMLCopier($pmd[0]->asXML(),
$slm->getId(),$page->getId(),$page->getType());
556 $mdxml->getMDObject()->update();
558 $tnode = $page_xml->xpath(
"//MediaObject/MediaAlias");
559 foreach($tnode as $ttnode)
561 include_once
'./Services/MediaObjects/classes/class.ilObjMediaObject.php';
562 $OriginId = $ttnode[OriginId];
563 $medianodes = $doc->xpath(
"//MediaObject[MetaData/General/Identifier/@Entry='".$OriginId .
"']");
564 $medianode = $medianodes[0];
568 $media_object->setTitle ($medianode->MetaData->General->Title);
569 $media_object->setDescription ($medianode->MetaData->General->Description);
570 $media_object->create (
false);
571 $mmd = $medianode->xpath (
"MetaData");
574 include_once
'Services/MetaData/classes/class.ilMDXMLCopier.php';
575 $mdxml =&
new ilMDXMLCopier($mmd[0]->asXML(),0,$media_object->getId(),$media_object->getType());
577 $mdxml->getMDObject()->update();
580 $media_object->createDirectory ();
582 foreach ( $medianode->MediaItem as $xMediaItem )
585 $media_object->addMediaItem ( $media_item );
586 $media_item->setPurpose($xMediaItem[Purpose]);
587 $media_item->setFormat($xMediaItem->Format );
588 $media_item->setLocation($xMediaItem->Location);
589 $media_item->setLocationType($xMediaItem->Location[Type]);
590 $media_item->setWidth ( $xMediaItem->Layout[Width]);
591 $media_item->setHeight ( $xMediaItem->Layout[Height]);
592 $media_item->setHAlign($xMediaItem->Layout[HorizontalAlign]);
593 if($media_item->getLocationType()==
"LocalFile")
595 $tmp_name = $this->packageFolder.
"/objects/".$OriginId.
"/".$xMediaItem->Location;
596 copy($tmp_name, $mob_dir.
"/".$xMediaItem->Location);
604 $media_object->update(
true);
605 $ttnode [OriginId] =
"il__mob_" . $media_object->getId ();
608 include_once(
"./Modules/File/classes/class.ilObjFile.php");
609 include_once(
"./Services/Utilities/classes/class.ilFileUtils.php");
610 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
612 $intlinks = $page_xml->xpath(
"//IntLink");
616 foreach ( $intlinks as $intlink )
618 if($intlink[Type]!=
"File")
continue;
619 $path = $this->packageFolder.
"/objects/".str_replace(
'dfile',
'file',$intlink[Target]);
620 if(!is_dir(
$path ))
continue;
625 $fileObj->setType(
"file");
634 $fileObj->createReference();
637 $fileObj->createDirectory();
639 $intlink[Target]=
"il__dfile_".$fileObj->getId();
643 $fileitems = $page_xml->xpath(
"//FileItem/Identifier");
646 foreach ( $fileitems as $fileitem )
648 $path = $this->packageFolder.
"/objects/".$fileitem[Entry];
649 if(!is_dir(
$path ))
continue;
654 $fileObj->setType(
"file");
663 $fileObj->createReference();
666 $fileObj->createDirectory();
668 $fileitem[Entry]=
"il__file_".$fileObj->getId();
674 $ddoc =
new DOMDocument();
675 $ddoc->async =
false;
676 $ddoc->preserveWhiteSpace =
false;
677 $ddoc->formatOutput =
false;
678 $ddoc->loadXML($page_xml->asXML());
679 $xpath =
new DOMXPath($ddoc);
680 $tnode = $xpath->query(
'PageContent');
682 foreach($tnode as $ttnode)
683 $t .= $ddoc->saveXML($ttnode);
684 $t .=
"</PageObject>";
685 foreach ($qtis as $old=>$q)
686 $t = str_replace($old,
'il__qst_'.$q[
'pool'],
$t);
687 $pagex->setXMLContent(
$t);
688 $pagex->updateFromXML();
692 public function dbImport($node, &$lft=1, $depth=1, $parent=0)
696 switch ($node->nodeType)
698 case XML_DOCUMENT_NODE:
708 $res = $ilDB->queryF(
709 'SELECT * FROM cp_package WHERE obj_id = %s AND c_identifier = %s',
710 array(
'integer',
'text'),
711 array($this->packageId, $this->packageName)
713 if($num_rows = $ilDB->numRows(
$res))
715 $query =
'UPDATE cp_package '
716 .
'SET persistprevattempts = %s, c_settings = %s '
717 .
'WHERE obj_id = %s AND c_identifier= %s';
720 array(
'integer',
'text',
'integer',
'text'),
721 array(0, NULL, $this->packageId, $this->packageName)
726 $query =
'INSERT INTO cp_package (obj_id, c_identifier, persistprevattempts, c_settings) '
727 .
'VALUES (%s, %s, %s, %s)';
730 array(
'integer',
'text',
'integer',
'text'),
731 array($this->packageId, $this->packageName, 0, NULL)
736 $this->
dbImport($node->documentElement);
739 case XML_ELEMENT_NODE:
740 if ($node->nodeName===
'manifest')
742 if ($node->getAttribute(
'uri')==
"")
745 $node->setAttribute(
'uri',
'md5:' . $this->packageHash);
749 $cp_node_id = $ilDB->nextId(
'cp_node');
751 $query =
'INSERT INTO cp_node (cp_node_id, slm_id, nodename) '
752 .
'VALUES (%s, %s, %s)';
755 array(
'integer',
'integer',
'text'),
756 array($cp_node_id, $this->packageId, $node->nodeName)
759 $query =
'INSERT INTO cp_tree (child, depth, lft, obj_id, parent, rgt) '
760 .
'VALUES (%s, %s, %s, %s, %s, %s)';
763 array(
'integer',
'integer',
'integer',
'integer',
'integer',
'integer'),
764 array($cp_node_id, $depth, $lft++, $this->packageId, $parent, 0)
769 $names = array(
'cp_node_id');
770 $values = array($cp_node_id);
771 $types = array(
'integer');
773 foreach ($node->attributes as $attr)
775 switch(strtolower($attr->name))
777 case 'completionsetbycontent': $names[] =
'completionbycontent';
break;
778 case 'objectivesetbycontent': $names[] =
'objectivebycontent';
break;
779 case 'type': $names[] =
'c_type';
break;
780 case 'mode': $names[] =
'c_mode';
break;
781 case 'language': $names[] =
'c_language';
break;
782 case 'condition': $names[] =
'c_condition';
break;
783 case 'operator': $names[] =
'c_operator';
break;
784 case 'condition': $names[] =
'c_condition';
break;
785 case 'readnormalizedmeasure': $names[] =
'readnormalmeasure';
break;
786 case 'writenormalizedmeasure': $names[] =
'writenormalmeasure';
break;
787 case 'minnormalizedmeasure': $names[] =
'minnormalmeasure';
break;
788 case 'primary': $names[] =
'c_primary';
break;
789 case 'minnormalizedmeasure': $names[] =
'minnormalmeasure';
break;
790 case 'persistpreviousattempts': $names[] =
'persistprevattempts';
break;
791 case 'identifier': $names[] =
'c_identifier';
break;
792 case 'settings': $names[] =
'c_settings';
break;
793 case 'activityabsolutedurationlimit': $names[] =
'activityabsdurlimit';
break;
794 case 'activityexperienceddurationlimit': $names[] =
'activityexpdurlimit';
break;
795 case 'attemptabsolutedurationlimit': $names[] =
'attemptabsdurlimit';
break;
796 case 'measuresatisfactionifactive': $names[] =
'measuresatisfactive';
break;
797 case 'objectivemeasureweight': $names[] =
'objectivemeasweight';
break;
798 case 'requiredforcompleted': $names[] =
'requiredcompleted';
break;
799 case 'requiredforincomplete': $names[] =
'requiredincomplete';
break;
800 case 'requiredfornotsatisfied': $names[] =
'requirednotsatisfied';
break;
801 case 'rollupobjectivesatisfied': $names[] =
'rollupobjectivesatis';
break;
802 case 'rollupprogresscompletion': $names[] =
'rollupprogcompletion';
break;
803 case 'usecurrentattemptobjectiveinfo': $names[] =
'usecurattemptobjinfo';
break;
804 case 'usecurrentattemptprogressinfo': $names[] =
'usecurattemptproginfo';
break;
805 default: $names[] = strtolower($attr->name);
break;
808 if(in_array($names[count($names) - 1],
809 array(
'flow',
'completionbycontent',
810 'objectivebycontent',
'rollupobjectivesatis',
812 'choiceexit',
'satisfiedbymeasure',
813 'c_primary',
'constrainchoice',
814 'forwardonly',
'global_to_system',
815 'writenormalmeasure',
'writesatisfiedstatus',
816 'readnormalmeasure',
'readsatisfiedstatus',
817 'preventactivation',
'measuresatisfactive',
818 'reorderchildren',
'usecurattemptproginfo',
819 'usecurattemptobjinfo',
'rollupprogcompletion')))
821 if($attr->value ==
'true')
823 else if ($attr->value ==
'false')
826 $values[] = (int)$attr->value;
830 $values[] = $attr->value;
833 if( in_array($names[count($names) - 1],
834 array(
'objectivesglobtosys',
'attemptlimit',
835 'flow',
'completionbycontent',
836 'objectivebycontent',
'rollupobjectivesatis',
838 'choiceexit',
'satisfiedbymeasure',
839 'c_primary',
'constrainchoice',
840 'forwardonly',
'global_to_system',
841 'writenormalmeasure',
'writesatisfiedstatus',
842 'readnormalmeasure',
'readsatisfiedstatus',
843 'preventactivation',
'measuresatisfactive',
844 'reorderchildren',
'usecurattemptproginfo',
845 'usecurattemptobjinfo',
'rollupprogcompletion')))
846 $types[] =
'integer';
847 else if ( in_array($names[count($names) - 1],
848 array(
'jsdata',
'xmldata',
'activitytree',
'data')))
850 else if ( in_array($names[count($names) - 1],
851 array(
'objectivemeasweight')))
858 $insert_data = array();
859 foreach($names as $key => $db_field)
861 $insert_data[$db_field] = array($types[$key], trim($values[$key]));
863 $ilDB->insert(
'cp_'.strtolower($node->nodeName), $insert_data);
865 $node->setAttribute(
'foreignId', $cp_node_id);
866 $this->idmap[$node->getAttribute(
'id')] = $cp_node_id;
869 foreach($node->childNodes as $child)
871 $this->
dbImport($child, $lft, $depth + 1, $cp_node_id);
875 $query =
'UPDATE cp_tree SET rgt = %s WHERE child = %s';
878 array(
'integer',
'integer'),
879 array($lft++, $cp_node_id)
904 $ilDB->insert(
'cp_package', array(
905 'obj_id' => array(
'integer', $this->packageId),
906 'xmldata' => array(
'clob',
$x->asXML()),
907 'jsdata' => array(
'clob', json_encode($j))
919 $cmi_nodes = array();
921 $res = $ilDB->queryF(
'
922 SELECT cmi_node.cmi_node_id
923 FROM cmi_node, cp_node
924 WHERE cp_node.slm_id = %s AND cmi_node.cp_node_id = cp_node.cp_node_id',
926 array($this->packageId)
930 $cmi_node_values[] =
$data[
'cmi_node_id'];
934 $cmi_inodes = array();
936 $res = $ilDB->queryF(
'
937 SELECT cmi_interaction.cmi_interaction_id
938 FROM cmi_interaction, cmi_node, cp_node
939 WHERE (cp_node.slm_id = %s
940 AND cmi_node.cp_node_id = cp_node.cp_node_id
941 AND cmi_node.cmi_node_id = cmi_interaction.cmi_node_id)',
943 array($this->packageId)
947 $cmi_inode_values[] =
$data[
'cmi_interaction_id'];
951 $query =
'DELETE FROM cmi_correct_response WHERE '
952 . $ilDB->in(
'cmi_correct_response.cmi_interaction_id', $cmi_inode_values,
false,
'integer');
953 $ilDB->manipulate(
$query);
956 $query =
'DELETE FROM cmi_objective WHERE '
957 . $ilDB->in(
'cmi_objective.cmi_interaction_id', $cmi_inode_values,
false,
'integer');
958 $ilDB->manipulate(
$query);
961 $query =
'DELETE FROM cmi_objective WHERE '
962 . $ilDB->in(
'cmi_objective.cmi_node_id', $cmi_node_values,
false,
'integer');
963 $ilDB->manipulate(
$query);
966 $query =
'DELETE FROM cmi_interaction WHERE '
967 . $ilDB->in(
'cmi_interaction.cmi_node_id', $cmi_node_values,
false,
'integer');
968 $ilDB->manipulate(
$query);
971 $query =
'DELETE FROM cmi_comment WHERE '
972 . $ilDB->in(
'cmi_comment.cmi_node_id', $cmi_node_values,
false,
'integer');
973 $ilDB->manipulate(
$query);
976 $query =
'DELETE FROM cmi_node WHERE '
977 . $ilDB->in(
'cmi_node.cmi_node_id', $cmi_node_values,
false,
'integer');
978 $ilDB->manipulate(
$query);
980 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
992 $res = $ilDB->queryF(
993 'SELECT cp_node.cp_node_id FROM cp_node WHERE cp_node.slm_id = %s',
995 array($this->packageId)
999 $cp_nodes[] =
$data[
'cp_node_id'];
1003 foreach(self::$elements[
'cp'] as
$t)
1007 $in = $ilDB->in(strtolower($t).
'.cp_node_id', $cp_nodes,
false,
'integer');
1008 $ilDB->manipulate(
'DELETE FROM '.strtolower($t).
' WHERE '.
$in);
1013 'DELETE FROM cp_tree WHERE cp_tree.obj_id = %s',
1015 array($this->packageId)
1019 'DELETE FROM cp_node WHERE cp_node.slm_id = %s',
1021 array($this->packageId)
1026 'DELETE FROM cp_package WHERE cp_package.obj_id = %s',
1028 array($this->packageId)
1039 public function transform($inputdoc, $xslfile, $outputpath = null)
1041 $xsl =
new DOMDocument;
1042 $xsl->async =
false;
1043 if (!@$xsl->load($xslfile))
1045 die(
'ERROR: load StyleSheet ' . $xslfile);
1047 $prc =
new XSLTProcessor;
1048 $r = @$prc->importStyleSheet($xsl);
1049 if (
false===@$prc->importStyleSheet($xsl))
1051 die(
'ERROR: importStyleSheet ' . $xslfile);
1055 file_put_contents($outputpath, $prc->transformToXML($inputdoc));
1059 return $prc->transformToDoc($inputdoc);
1065 libxml_use_internal_errors(
true);
1066 $return = @$doc->schemaValidate($schema);
1070 LIBXML_ERR_ERROR =>
'Error',
1071 LIBXML_ERR_FATAL =>
'Fatal Error'
1073 foreach (libxml_get_errors() as
$error)
1075 $level = $levels[$error->level];
1078 $message = trim($error->message);
1079 $this->diagnostic[] =
"XSLT $level (Line $error->line) $message";
1082 libxml_clear_errors();
1084 libxml_use_internal_errors(
false);
1093 $res = $ilDB->queryF(
'
1094 SELECT cmi_node.cmi_node_id
1095 FROM cmi_node, cp_node
1096 WHERE cmi_node.cp_node_id = cp_node.cp_node_id AND cmi_node.user_id = %s',
1101 $cmi_nodes = array();
1104 $cmi_node_values[] =
$data[
'cmi_node_id'];
1108 $res = $ilDB->queryF(
'
1109 SELECT cmi_interaction.cmi_interaction_id
1110 FROM cmi_interaction, cmi_node, cp_node
1111 WHERE (cmi_node.user_id = %s
1112 AND cmi_node.cp_node_id = cp_node.cp_node_id
1113 AND cmi_node.cmi_node_id = cmi_interaction.cmi_node_id)',
1118 $cmi_inodes = array();
1122 $cmi_inode_values[] =
$data[
'cmi_interaction_id'];
1128 $query =
'DELETE FROM cmi_correct_response WHERE '
1129 . $ilDB->in(
'cmi_correct_response.cmi_interaction_id', $cmi_inode_values,
false,
'integer');
1130 $ilDB->manipulate(
$query);
1133 $query =
'DELETE FROM cmi_objective WHERE '
1134 . $ilDB->in(
'cmi_objective.cmi_interaction_id', $cmi_inode_values,
false,
'integer');
1135 $ilDB->manipulate(
$query);
1138 $query =
'DELETE FROM cmi_objective WHERE '
1139 . $ilDB->in(
'cmi_objective.cmi_node_id', $cmi_node_values,
false,
'integer');
1140 $ilDB->manipulate(
$query);
1143 $query =
'DELETE FROM cmi_interaction WHERE '
1144 . $ilDB->in(
'cmi_interaction.cmi_node_id', $cmi_node_values,
false,
'integer');
1145 $ilDB->manipulate(
$query);
1148 $query =
'DELETE FROM cmi_comment WHERE '
1149 . $ilDB->in(
'cmi_comment.cmi_node_id', $cmi_node_values,
false,
'integer');
1150 $ilDB->manipulate(
$query);
1153 $query =
'DELETE FROM cmi_node WHERE '
1154 . $ilDB->in(
'cmi_node.cmi_node_id', $cmi_node_values,
false,
'integer');
1155 $ilDB->manipulate(
$query);
1159 'DELETE FROM cmi_gobjective WHERE user_id = %s',