ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilSCORM13Package Class Reference
+ Collaboration diagram for ilSCORM13Package:

Public Member Functions

 __construct ($packageId=null)
 
 load ($packageId)
 
 rollback ()
 
 exportZIP ()
 
 exportXML ()
 Export as internal XML. More...
 
 il_import ($packageFolder, $packageId, $ilias, $validate, $reimport=false)
 Imports an extracted SCORM 2004 module from ilias-data dir into database. More...
 
 il_importSco ($packageId, $sco_id, $packageFolder)
 Imports an extracted SCORM 2004 module from ilias-data dir into database. More...
 
 il_importAss ($packageId, $sco_id, $packageFolder)
 Imports an extracted SCORM 2004 module from ilias-data dir into database. More...
 
 il_importLM ($slm, $packageFolder, $a_import_sequencing=false)
 
 importGlossary ($slm, $packageFolder)
 
 dbImportLM ($node, $parent_id="", $a_import_sequencing=false)
 
 setSequencingInfo ($a_node, $a_seq_info, $a_import_sequencing, $a_fix_obj_id="")
 Save sequencing ingo. More...
 
 jsonNode ($node, &$sink)
 Helper for UploadAndImport Recursively copies values from XML into PHP array for export as json Elements are translated into sub array, attributes into literals. More...
 
 dbImportSco ($slm, $sco, $asset=false)
 
 dbImport ($node, &$lft=1, $depth=1, $parent=0)
 
 dbAddNew ()
 add new sahs and package record More...
 
 removeCMIData ()
 
 removeCPData ()
 
 dbRemoveAll ()
 
 transform ($inputdoc, $xslfile, $outputpath=null)
 
 validate ($doc, $schema)
 

Static Public Member Functions

static _removeTrackingDataForUser ($user_id)
 

Data Fields

const DB_ENCODE_XSL = './Modules/Scorm2004/templates/xsl/op/op-scorm13.xsl'
 
const CONVERT_XSL = './Modules/Scorm2004/templates/xsl/op/scorm12To2004.xsl'
 
const DB_DECODE_XSL = './Modules/Scorm2004/templates/xsl/op/op-scorm13-revert.xsl'
 
const VALIDATE_XSD = './Modules/Scorm2004/templates/xsd/op/op-scorm13.xsd'
 
const WRAPPER_HTML = './Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/GenericRunTimeWrapper.htm'
 
const WRAPPER_JS = './Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/SCOPlayerWrapper.js'
 
 $imsmanifest
 
 $manifest
 
 $diagnostic
 
 $status
 
 $packageId
 
 $packageName
 
 $packageHash
 
 $userId
 

Private Member Functions

 setProgress ($progress, $msg='')
 

Private Attributes

 $packageFile
 
 $packageFolder
 
 $packagesFolder
 
 $packageData
 
 $slm
 
 $slm_tree
 
 $idmap = array()
 
 $progress = 0.0
 

Static Private Attributes

static $elements
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilSCORM13Package::__construct (   $packageId = null)

Definition at line 74 of file ilSCORM13Package.php.

References $GLOBALS, $packageId, and load().

75  {
76  $this->packagesFolder = IL_OP_PACKAGES_FOLDER;
77  $this->load($packageId);
78  $this->userId = $GLOBALS['USER']['usr_id'];
79  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
+ Here is the call graph for this function:

Member Function Documentation

◆ _removeTrackingDataForUser()

static ilSCORM13Package::_removeTrackingDataForUser (   $user_id)
static

Definition at line 1247 of file ilSCORM13Package.php.

References ilSCORM2004DeleteData\removeCMIDataForUser().

Referenced by ilObjUser\delete().

1247  {
1248 
1249  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004DeleteData.php");
1251  //missing updatestatus
1252  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dbAddNew()

ilSCORM13Package::dbAddNew ( )

add new sahs and package record

Definition at line 1119 of file ilSCORM13Package.php.

References $ilDB, $x, and array.

1120  {
1121  global $ilDB;
1122 
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))
1127  ));
1128 
1129  return true;
1130  }
$x
Definition: example_009.php:98
Create styles array
The data for the language used.
global $ilDB

◆ dbImport()

ilSCORM13Package::dbImport (   $node,
$lft = 1,
  $depth = 1,
  $parent = 0 
)

Definition at line 913 of file ilSCORM13Package.php.

References $ilDB, $names, $packageId, $query, $res, and array.

Referenced by il_import().

914  {
915  global $ilDB;
916 
917  switch ($node->nodeType)
918  {
919  case XML_DOCUMENT_NODE:
920 
921  // insert into cp_package
922 
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)
927  );
928  if($num_rows = $ilDB->numRows($res))
929  {
930  $query = 'UPDATE cp_package '
931  . 'SET persistprevattempts = %s, c_settings = %s '
932  . 'WHERE obj_id = %s AND c_identifier= %s';
933  $ilDB->manipulateF(
934  $query,
935  array('integer', 'text', 'integer', 'text'),
936  array(0, NULL, $this->packageId, $this->packageName)
937  );
938  }
939  else
940  {
941  $query = 'INSERT INTO cp_package (obj_id, c_identifier, persistprevattempts, c_settings) '
942  . 'VALUES (%s, %s, %s, %s)';
943  $ilDB->manipulateF(
944  $query,
945  array('integer','text','integer', 'text'),
946  array($this->packageId, $this->packageName, 0, NULL)
947  );
948  }
949 
950  // run sub nodes
951  $this->dbImport($node->documentElement); // RECURSION
952  break;
953 
954  case XML_ELEMENT_NODE:
955  if ($node->nodeName==='manifest')
956  {
957  if ($node->getAttribute('uri')=="")
958  {
959  // default URI is md5 hash of zip file, i.e. packageHash
960  $node->setAttribute('uri', 'md5:' . $this->packageHash);
961  }
962  }
963 
964  $cp_node_id = $ilDB->nextId('cp_node');
965 
966  $query = 'INSERT INTO cp_node (cp_node_id, slm_id, nodename) '
967  . 'VALUES (%s, %s, %s)';
968  $ilDB->manipulateF(
969  $query,
970  array('integer', 'integer', 'text'),
971  array($cp_node_id, $this->packageId, $node->nodeName)
972  );
973 
974  $query = 'INSERT INTO cp_tree (child, depth, lft, obj_id, parent, rgt) '
975  . 'VALUES (%s, %s, %s, %s, %s, %s)';
976  $ilDB->manipulateF(
977  $query,
978  array('integer', 'integer', 'integer', 'integer', 'integer', 'integer'),
979  array($cp_node_id, $depth, $lft++, $this->packageId, $parent, 0)
980  );
981 
982  // insert into cp_*
983  //$a = array('cp_node_id' => $cp_node_id);
984  $names = array('cp_node_id');
985  $values = array($cp_node_id);
986  $types = array('integer');
987 
988  foreach ($node->attributes as $attr)
989  {
990  switch(strtolower($attr->name))
991  {
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;
1021  }
1022 
1023  if(in_array($names[count($names) - 1],
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')))
1037  {
1038  if($attr->value == 'true')
1039  $values[] = 1;
1040  else if ($attr->value == 'false')
1041  $values[] = 0;
1042  else
1043  $values[] = (int)$attr->value;
1044  }
1045  else
1046  {
1047  $values[] = $attr->value;
1048  }
1049 
1050  if( in_array($names[count($names) - 1],
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';
1066  else if ( in_array($names[count($names) - 1],
1067  array('jsdata', 'xmldata', 'activitytree', 'data')))
1068  $types[] = 'clob';
1069  else if ( in_array($names[count($names) - 1],
1070  array('objectivemeasweight')))
1071  $types[] = 'float';
1072  else
1073  $types[] = 'text';
1074  }
1075 
1076  if($node->nodeName==='datamap')
1077  {
1078  $names[] = 'slm_id';
1079  $values[] = $this->packageId;
1080  $types[] = 'integer';
1081 
1082  $names[] = 'sco_node_id';
1083  $values[] = $parent;
1084  $types[] = 'integer';
1085  }
1086 
1087  // we have to change the insert method because of clob fields ($ilDB->manipulate does not work here)
1088  $insert_data = array();
1089  foreach($names as $key => $db_field)
1090  {
1091  $insert_data[$db_field] = array($types[$key], trim($values[$key]));
1092  }
1093  $ilDB->insert('cp_'.strtolower($node->nodeName), $insert_data);
1094 
1095  $node->setAttribute('foreignId', $cp_node_id);
1096  $this->idmap[$node->getAttribute('id')] = $cp_node_id;
1097 
1098  // run sub nodes
1099  foreach($node->childNodes as $child)
1100  {
1101  $this->dbImport($child, $lft, $depth + 1, $cp_node_id); // RECURSION
1102  }
1103 
1104  // update cp_tree (rgt value for pre order walk in sql tree)
1105  $query = 'UPDATE cp_tree SET rgt = %s WHERE child = %s';
1106  $ilDB->manipulateF(
1107  $query,
1108  array('integer', 'integer'),
1109  array($lft++, $cp_node_id)
1110  );
1111 
1112  break;
1113  }
1114  }
dbImport($node, &$lft=1, $depth=1, $parent=0)
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ dbImportLM()

ilSCORM13Package::dbImportLM (   $node,
  $parent_id = "",
  $a_import_sequencing = false 
)

Definition at line 497 of file ilSCORM13Package.php.

References $l, $r, ilSCORM2004Node\putInTree(), setSequencingInfo(), ilTree\setTreeTablePK(), and ilSaxParser\startParsing().

Referenced by il_importLM().

498  {
499 
500  switch($node->getName())
501  {
502  case "manifest":
503  $this->slm_tree = new ilTree($this->slm->getId());
504  $this->slm_tree->setTreeTablePK("slm_id");
505  $this->slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
506  $this->slm_tree->addTree($this->slm->getId(), 1);
507 
508  //add seqinfo for rootNode
509  include_once ("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
510  $seq_info = new ilSCORM2004Sequencing($this->slm->getId(),true);
511 
512  // get original sequencing information
513  $r = $this->mani_xpath->query("/d:manifest/d:organizations/d:organization/imsss:sequencing");
514  $this->imsmanifest->formatOutput = false;
515  if ($r)
516  {
517  $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing);
518  if ($a_import_sequencing)
519  {
520  $seq_info->initDom();
521  }
522  }
523  $seq_info->insert();
524 
525  if(file_exists($this->packageFolder . '/' . 'index.xml'))
526  {
527  $doc = simplexml_load_file($this->packageFolder . '/' . 'index.xml');
528  $l = $doc->xpath ( "/ContentObject/MetaData" );
529  if($l[0])
530  {
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());
533  $mdxml->startParsing();
534  $mdxml->getMDObject()->update();
535  }
536  }
537  break;
538  case "organization":
539  $this->slm->title=$node->title;
540  break;
541  case "item":
542  $a = $node->attributes();
543  if(preg_match("/il_\d+_chap_\d+/",$a['identifier']))
544  {
545  $chap= new ilSCORM2004Chapter($this->slm);
546  $chap->setTitle($node->title);
547  $chap->setSLMId($this->slm->getId());
548  $chap->create(true);
549 
550  // save sequencing information
551  $r = $this->mani_xpath->query("//d:item[@identifier='".$a['identifier']."']/imsss:sequencing");
552  if ($r)
553  {
554  $seq_info = new ilSCORM2004Sequencing($chap->getId());
555  $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing);
556  $seq_info->initDom();
557  $seq_info->insert();
558  }
559 
560  ilSCORM2004Node::putInTree($chap, $parent_id, "");
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']."']" );
564  if($l[0])
565  {
566  include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
567  $mdxml = new ilMDXMLCopier($l[0]->asXML(),$this->slm->getId(),$chap->getId(),$chap->getType());
568  $mdxml->startParsing();
569  $mdxml->getMDObject()->update();
570  }
571  }
572  if(preg_match("/il_\d+_sco_(\d+)/",$a['identifier'], $match))
573  {
574  $sco = new ilSCORM2004Sco($this->slm);
575  $sco->setTitle($node->title);
576  $sco->setSLMId($this->slm->getId());
577  $sco->create(true);
578 
579  // save sequencing information
580  $r = $this->mani_xpath->query("//d:item[@identifier='".$a['identifier']."']/imsss:sequencing");
581  if ($r)
582  {
583  $seq_info = new ilSCORM2004Sequencing($sco->getId());
584  $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing,
585  "local_obj_".$sco->getID()."_0");
586  $seq_info->initDom();
587  $seq_info->insert();
588  }
589 
590  ilSCORM2004Node::putInTree($sco, $parent_id, "");
591  $newPack = new ilSCORM13Package();
592  $newPack->il_importSco($this->slm->getId(),$sco->getId(),$this->packageFolder."/".$match[1]);
593  $parent_id = $sco->getId();
594  }
595  if(preg_match("/il_\d+_ass_(\d+)/",$a['identifier'], $match))
596  {
597  $ass = new ilSCORM2004Asset($this->slm);
598  $ass->setTitle($node->title);
599  $ass->setSLMId($this->slm->getId());
600  $ass->create(true);
601 
602  // save sequencing information
603  $r = $this->mani_xpath->query("//d:item[@identifier='".$a['identifier']."']/imsss:sequencing");
604  if ($r)
605  {
606  $seq_info = new ilSCORM2004Sequencing($ass->getId());
607  $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing,
608  "local_obj_".$ass->getID()."_0");
609  $seq_info->initDom();
610  $seq_info->insert();
611  }
612 
613  ilSCORM2004Node::putInTree($ass, $parent_id, "");
614  $newPack = new ilSCORM13Package();
615  $newPack->il_importAss($this->slm->getId(),$ass->getId(),$this->packageFolder."/".$match[1]);
616  $parent_id = $ass->getId();
617  }
618 
619  break;
620  }
621  //if($node->nodeType==XML_ELEMENT_NODE)
622  {
623  foreach($node->children() as $child)
624  {
625  $this->dbImportLM($child, $parent_id, $a_import_sequencing);
626  }
627  }
628  }
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
put this object into content object tree
Class ilSCORM2004Sco.
dbImportLM($node, $parent_id="", $a_import_sequencing=false)
startParsing()
stores xml data in array
Class ilSCORM2004Chapter.
setSequencingInfo($a_node, $a_seq_info, $a_import_sequencing, $a_fix_obj_id="")
Save sequencing ingo.
$r
Definition: example_031.php:79
Class ilSCORM2004Sequencing.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
setTreeTablePK($a_column_name)
set column containing primary key in tree table public
global $l
Definition: afr.php:30
Class ilSCORM2004Asset.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dbImportSco()

ilSCORM13Package::dbImportSco (   $slm,
  $sco,
  $asset = false 
)

Definition at line 685 of file ilSCORM13Package.php.

References $d, $filename, $l, $n, $old, $path, $result, $slm, $t, $target, ilObjMediaObject\_getDirectory(), array, file, ilUtil\getDir(), ilObjMediaObject\getMimeType(), IL_EXT_LINK, IL_MO_PARSE_QTI, IL_MO_VERIFY_QTI, ilSCORM2004Node\putInTree(), ilUtil\rCopy(), ilFileUtils\recursive_dirscan(), ilUtil\renameExecutables(), ilSaxParser\startParsing(), ilUtil\stripSlashes(), and ilFileUtils\utf8_encode().

Referenced by il_importAss(), and il_importSco().

686  {
687  $qtis = array();
688  $d = ilUtil::getDir ( $this->packageFolder );
689  foreach ( $d as $f ) {
690  //continue;
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";
694 
695 
696  $qtiParser = new ilQTIParser ( $this->packageFolder . "/" . $f [entry], IL_MO_VERIFY_QTI, 0, "" );
697  $result = $qtiParser->startParsing ();
698  $founditems = & $qtiParser->getFoundItems ();
699  // die(print_r($founditems));
700  foreach ( $founditems as $qp ) {
701  $newObj = new ilObjTest ( 0, true );
702 
703  // This creates a lot of invalid repository objects for each question
704  // question are not repository objects (see e.g. table object_data), alex 29 Sep 2009
705 
706 // $newObj->setType ( $qp ['type'] );
707 // $newObj->setTitle ( $qp ['title'] );
708 // $newObj->create ( true );
709 // $newObj->createReference ();
710 // $newObj->putInTree ($_GET ["ref_id"]);
711 // $newObj->setPermissions ( $sco->getId ());
712 // $newObj->notify ("new", $_GET["ref_id"], $sco->getId (), $_GET["ref_id"], $newObj->getRefId () );
713 // $newObj->mark_schema->flush ();
714  $qtiParser = new ilQTIParser ( $this->packageFolder . "/" . $f [entry], IL_MO_PARSE_QTI, 0, "" );
715  $qtiParser->setTestObject ( $newObj );
716  $result = $qtiParser->startParsing ();
717 // $newObj->saveToDb ();
718  $qtis = array_merge($qtis, $qtiParser->getImportMapping());
719 
720  }
721  }
722  }
723 //exit;
724  include_once 'Modules/Scorm2004/classes/class.ilSCORM2004Page.php';
725  $doc = new SimpleXMLElement($this->imsmanifest->saveXml());
726  $l = $doc->xpath ( "/ContentObject/MetaData" );
727  if($l[0])
728  {
729  include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
730  $mdxml = new ilMDXMLCopier($l[0]->asXML(),$slm->getId(),$sco->getId(),$sco->getType());
731  $mdxml->startParsing();
732  $mdxml->getMDObject()->update();
733  }
734  $l = $doc->xpath("/ContentObject/PageObject");
735  foreach ( $l as $page_xml )
736  {
737  $tnode = $page_xml->xpath ( 'MetaData/General/Title' );
738  $page = new ilSCORM2004PageNode ( $slm );
739  $page->setTitle ( $tnode [0] );
740  $page->setSLMId ( $slm->getId () );
741  $page->create (true);
742  ilSCORM2004Node::putInTree ( $page, $sco->getId (), $target );
743  $pmd = $page_xml->xpath ("MetaData");
744  if($pmd[0])
745  {
746  include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
747  $mdxml = new ilMDXMLCopier($pmd[0]->asXML(),$slm->getId(),$page->getId(),$page->getType());
748  $mdxml->startParsing();
749  $mdxml->getMDObject()->update();
750  }
751  $tnode = $page_xml->xpath("//MediaObject/MediaAlias | //InteractiveImage/MediaAlias");
752  foreach($tnode as $ttnode)
753  {
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];
758  if($medianode)
759  {
760  $media_object = new ilObjMediaObject ( );
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");
765  if($mmd[0])
766  {
767  include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
768  $mdxml = new ilMDXMLCopier($mmd[0]->asXML(),0,$media_object->getId(),$media_object->getType());
769  $mdxml->startParsing();
770  $mdxml->getMDObject()->update();
771  }
772  // determine and create mob directory, move uploaded file to directory
773  $media_object->createDirectory ();
774  $mob_dir = ilObjMediaObject::_getDirectory ( $media_object->getId () );
775  foreach ( $medianode->MediaItem as $xMediaItem )
776  {
777  $media_item = new ilMediaItem ( );
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);
788  $nr = 0;
789 
790  // add map areas (external links only)
791  foreach ($xMediaItem->MapArea as $n => $v)
792  {
793 
794  if ($v->ExtLink[Href] != "")
795  {
796  include_once("./Services/MediaObjects/classes/class.ilMapArea.php");
797  $ma = new ilMapArea();
798 
799  $map_area = new ilMapArea();
800  $map_area->setShape($v[Shape]);
801  $map_area->setCoords($v[Coords]);
802  $map_area->setLinkType(IL_EXT_LINK);
803  $map_area->setTitle($v->ExtLink);
804  $map_area->setHref($v->ExtLink[Href]);
805 
806  $media_item->addMapArea($map_area);
807  }
808  }
809 
810  if($media_item->getLocationType()=="LocalFile")
811  {
812 // $tmp_name = $this->packageFolder."/objects/".$OriginId."/".$xMediaItem->Location;
813 // copy($tmp_name, $mob_dir."/".$xMediaItem->Location);
814  }
815  }
816 
817  // copy whole directory
818  ilUtil::rCopy($this->packageFolder."/objects/".$OriginId, $mob_dir);
819 
820 
821  // alex: fixed media import: these lines have been
822  // behind the next curly bracket which makes it fail
823  // when no medianode is given. (id=0 -> fatal error)
824  ilUtil::renameExecutables ( $mob_dir );
825  $media_object->update(true);
826  $ttnode [OriginId] = "il__mob_" . $media_object->getId ();
827  }
828  }
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");
832 
833  $intlinks = $page_xml->xpath("//IntLink");
834  //die($intlinks);
835  //if($intlinks )
836  {
837  foreach ( $intlinks as $intlink )
838  {
839  if($intlink[Type]!="File") continue;
840  $path = $this->packageFolder."/objects/".str_replace('dfile','file',$intlink[Target]);
841  if(!is_dir($path )) continue;
842  $ffiles = array();
844  $filename = $ffiles[file][0];
845  $fileObj = new ilObjFile();
846  $fileObj->setType("file");
849 
850  // better use this, mime_content_type is deprecated
851  $fileObj->setFileType(ilObjMediaObject::getMimeType($path. "/" . $filename));
852 
853  $fileObj->setFileSize(filesize($path. "/" . $filename));
854  $fileObj->create();
855  $fileObj->createReference();
856  //$fileObj->putInTree($_GET["ref_id"]);
857  //$fileObj->setPermissions($slm->getId ());
858  $fileObj->createDirectory();
859  $fileObj->storeUnzipedFile($path."/" .$filename,ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
860  $intlink[Target]="il__dfile_".$fileObj->getId();
861 
862  }
863  }
864  $fileitems = $page_xml->xpath("//FileItem/Identifier");
865  //if($intlinks )
866  {
867  foreach ( $fileitems as $fileitem )
868  {
869  $path = $this->packageFolder."/objects/".$fileitem[Entry];
870  if(!is_dir($path )) continue;
871  $ffiles = array();
873  $filename = $ffiles[file][0];
874  $fileObj = new ilObjFile();
875  $fileObj->setType("file");
878 
879  // better use this, mime_content_type is deprecated
880  $fileObj->setFileType(ilObjMediaObject::getMimeType($path. "/" . $filename));
881 
882  $fileObj->setFileSize(filesize($path. "/" . $filename));
883  $fileObj->create();
884  $fileObj->createReference();
885  //$fileObj->putInTree($_GET["ref_id"]);
886  //$fileObj->setPermissions($slm->getId ());
887  $fileObj->createDirectory();
888  $fileObj->storeUnzipedFile($path."/" .$filename,ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
889  $fileitem[Entry]="il__file_".$fileObj->getId();
890 
891  }
892  }
893  $pagex = new ilSCORM2004Page($page->getId());
894 
895  $ddoc = new DOMDocument();
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');
902  $t = "<PageObject>";
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();
910  }
911  }
Class ilSCORM2004PageNode.
$path
Definition: aliased.php:25
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
put this object into content object tree
$result
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
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
for($col=0; $col< 50; $col++) $d
static _getDirectory($a_mob_id)
get directory for files of media object (static)
const IL_MO_PARSE_QTI
Class ilSCORM2004Page.
Class ilObjFile.
Class ilMediaItem.
Reload workbook from saved file
Class ilObjMediaObject.
$n
Definition: RandomTest.php:80
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$old
Create styles array
The data for the language used.
const IL_EXT_LINK
static utf8_encode($string)
utf8-encodes string if it is not a valid utf8-string.
Class ilMapArea.
static getMimeType($a_file, $a_external=false)
get mime type for file
global $l
Definition: afr.php:30
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
static recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
const IL_MO_VERIFY_QTI
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dbRemoveAll()

ilSCORM13Package::dbRemoveAll ( )

Definition at line 1189 of file ilSCORM13Package.php.

References removeCMIData(), and removeCPData().

Referenced by il_import(), and rollback().

1190  {
1191  //dont change order of calls
1192  $this->removeCMIData();
1193  $this->removeCPData();
1194  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exportXML()

ilSCORM13Package::exportXML ( )

Export as internal XML.

Definition at line 124 of file ilSCORM13Package.php.

References $ilDB, $res, $row, array, and header.

125  {
126  global $ilDB;
127 
128  header('content-type: text/xml');
129  header('content-disposition: attachment; filename="manifest.xml"');
130 
131  $res = $ilDB->queryF(
132  'SELECT xmldata FROM cp_package WHERE obj_id = %s',
133  array('integer'),
134  array($this->packageId)
135  );
136  $row = $ilDB->fetchAssoc($res);
137 
138  print($row['xmldata']);
139  }
Add a drawing to the header
Definition: 04printing.php:69
Create styles array
The data for the language used.
global $ilDB

◆ exportZIP()

ilSCORM13Package::exportZIP ( )

Definition at line 114 of file ilSCORM13Package.php.

References header.

115  {
116  header('content-type: application/zip');
117  header('content-disposition: attachment; filename="' . basename($this->packageFile) . '"');
118  readfile($this->packageFile);
119  }
Add a drawing to the header
Definition: 04printing.php:69

◆ il_import()

ilSCORM13Package::il_import (   $packageFolder,
  $packageId,
  $ilias,
  $validate,
  $reimport = false 
)

Imports an extracted SCORM 2004 module from ilias-data dir into database.

public

Returns
string title of package

Definition at line 148 of file ilSCORM13Package.php.

References $ilDB, $ilErr, $ilLog, $l, $n, $packageFolder, $packageId, $path, $r, $res, $title, $x, ilObject\_lookupType(), ilObject\_writeDescription(), array, dbImport(), dbRemoveAll(), transform(), and validate().

148  {
149  global $ilDB, $ilLog, $ilErr;
150 
151  $title = "";
152 
153  if ($reimport === true) {
154  $this->packageId = $packageId;
155  $this->dbRemoveAll();
156  }
157 
158  $this->packageFolder=$packageFolder;
159  $this->packageId=$packageId;
160  $this->imsmanifestFile = $this->packageFolder . '/' . 'imsmanifest.xml';
161  //step 1 - parse Manifest-File and validate
162  $this->imsmanifest = new DOMDocument;
163  $this->imsmanifest->async = false;
164  if (!@$this->imsmanifest->load($this->imsmanifestFile))
165  {
166  $this->diagnostic[] = 'XML not wellformed';
167  return false;
168  }
169 
170  //step 2 tranform
171  $this->manifest = $this->transform($this->imsmanifest, self::DB_ENCODE_XSL);
172 
173  if (!$this->manifest)
174  {
175  $this->diagnostic[] = 'Cannot transform into normalized manifest';
176  return false;
177  }
178  //setp 2.5 if only a single item, make sure the scormType of it's linked resource is SCO
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");//[&id='"+$n->getAttribute("resourceId")+"']");
185  foreach($resource as $res){
186  if($res->getAttribute('id') == $n->getAttribute("resourceId")){
187  $res->setAttribute('scormType','sco');
188  }
189  }
190  }
191  //$this->manifest->save("C:\Users\gratat\after.xml");
192  //step 3 validation -just for normalized XML
193  if ($validate=="y") {
194  if (!$this->validate($this->manifest, self::VALIDATE_XSD))
195  {
196 
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,
198  $ilErr->MESSAGE);
199  }
200  }
201  $this->dbImport($this->manifest);
202 
203  if(file_exists($this->packageFolder . '/' . 'index.xml'))
204  {
205  $doc = simplexml_load_file($this->packageFolder . '/' . 'index.xml');
206  $l = $doc->xpath ("/ContentObject/MetaData" );
207  if($l[0])
208  {
209  include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
211  $mdxml->startParsing();
212  $mdxml->getMDObject()->update();
213  }
214  }
215  else
216  {
217  include_once("./Modules/Scorm2004/classes/class.ilSCORM13MDImporter.php");
218  $importer = new ilSCORM13MDImporter($this->imsmanifest, $packageId);
219  $importer->import();
220  $title = $importer->getTitle();
221  $description = $importer->getDescription();
222  if ($description != "") {
224  }
225  }
226 
227  //step 5
228  $x = simplexml_load_string($this->manifest->saveXML());
229  $x['persistPreviousAttempts'] = $this->packageData['persistprevattempts'];
230  $x['online'] = $this->packageData['c_online'];
231 
232  $x['defaultLessonMode'] = $this->packageData['default_lesson_mode'];
233  $x['credit'] = $this->packageData['credit'];
234  $x['autoReview'] = $this->packageData['auto_review'];
235  $j = array();
236  // first read resources into flat array to resolve item/identifierref later
237  $r = array();
238  foreach ($x->resource as $xe)
239  {
240  $r[strval($xe['id'])] = $xe;
241  unset($xe);
242  }
243  // iterate through items and set href and scoType as activity attributes
244  foreach ($x->xpath('//*[local-name()="item"]') as $xe)
245  {
246  // get reference to resource and set href accordingly
247  if ($b = $r[strval($xe['resourceId'])])
248  {
249  $xe['href'] = strval($b['base']) . strval($b['href']);
250  unset($xe['resourceId']);
251  if (strval($b['scormType'])=='sco') $xe['sco'] = true;
252  }
253  }
254  // iterate recursivly through activities and build up simple php object
255  // with items and associated sequencings
256  // top node is the default organization which is handled as an item
257  self::jsonNode($x->organization, $j['item']);
258  foreach($x->sequencing as $s)
259  {
260  self::jsonNode($s, $j['sequencing'][]);
261  }
262  // combined manifest+resources xml:base is set as organization base
263  $j['item']['base'] = strval($x['base']);
264  // package folder is base to whole playing process
265  $j['base'] = $packageFolder . '/';
266  $j['foreignId'] = floatval($x['foreignId']); // manifest cp_node_id for associating global (package wide) objectives
267  $j['id'] = strval($x['id']); // manifest id for associating global (package wide) objectives
268 
269 
270  //last step - build ADL Activity tree
271  $act = new SeqTreeBuilder();
272  $adl_tree = $act->buildNodeSeqTree($this->imsmanifestFile);
273  $ilDB->update('cp_package',
274  array(
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'])
280  ),
281  array(
282  'obj_id' => array('integer', (int)$this->packageId)
283  )
284  );
285 
286  // title retrieved by importer
287  if ($title != "") {
288  return $title;
289  }
290 
291  return $j['item']['title'];
292  }
global $ilErr
Definition: raiseError.php:16
$path
Definition: aliased.php:25
transform($inputdoc, $xslfile, $outputpath=null)
dbImport($node, &$lft=1, $depth=1, $parent=0)
$x
Definition: example_009.php:98
SCORM 13 Metadata importer.
$r
Definition: example_031.php:79
$n
Definition: RandomTest.php:80
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _writeDescription($a_obj_id, $a_desc)
write description to db (static)
validate($doc, $schema)
global $l
Definition: afr.php:30
global $ilDB
+ Here is the call graph for this function:

◆ il_importAss()

ilSCORM13Package::il_importAss (   $packageId,
  $sco_id,
  $packageFolder 
)

Imports an extracted SCORM 2004 module from ilias-data dir into database.

public

Returns
string title of package

Definition at line 368 of file ilSCORM13Package.php.

References $ilDB, $ilLog, $packageFolder, $packageId, $slm, and dbImportSco().

369  {
370  global $ilDB, $ilLog;
371 
372  $this->packageFolder=$packageFolder;
373  $this->packageId=$packageId;
374  $this->imsmanifestFile = $this->packageFolder . '/' . 'index.xml';
375  $this->imsmanifest = new DOMDocument;
376  $this->imsmanifest->async = false;
377 
378  if (!@$this->imsmanifest->load($this->imsmanifestFile))
379  {
380  $this->diagnostic[] = 'XML not wellformed';
381  return false;
382  }
383 
385  $sco = new ilSCORM2004Asset($slm,$sco_id);
386  $this->dbImportSco($slm,$sco, true);
387 
388  // import sco.xml
389 /*
390  $sco_xml_file = $this->packageFolder . '/sco.xml';
391  if (is_file($sco_xml_file))
392  {
393  $scodoc = new DOMDocument;
394  $scodoc->async = false;
395  if (!@$scodoc->load($sco_xml_file))
396  {
397  $this->diagnostic[] = 'XML of sco.xml not wellformed';
398  return false;
399  }
400  //$doc = new SimpleXMLElement($scodoc->saveXml());
401  //$l = $doc->xpath("/sco/objective");
402  $xpath = new DOMXPath($scodoc);
403  $nodes = $xpath->query("/sco/objective");
404  foreach($nodes as $node)
405  {
406  $t_node = $node->firstChild;
407  if (is_object($t_node))
408  {
409  $objective_text = $t_node->textContent;
410  if (trim($objective_text) != "")
411  {
412  $objs = $sco->getObjectives();
413  foreach ($objs as $o)
414  {
415  $mappings = $o->getMappings();
416  if ($mappings == null)
417  {
418  $ob = new ilScorm2004Objective($sco->getId(), $o->getId());
419  $ob->setObjectiveID($objective_text);
420  $ob->updateObjective();
421  }
422  }
423  }
424  }
425  }
426  }
427 */
428  return "";
429  }
dbImportSco($slm, $sco, $asset=false)
Class ilObjSCORM2004LearningModule.
global $ilDB
Class ilSCORM2004Asset.
+ Here is the call graph for this function:

◆ il_importLM()

ilSCORM13Package::il_importLM (   $slm,
  $packageFolder,
  $a_import_sequencing = false 
)

Definition at line 431 of file ilSCORM13Package.php.

References $ilDB, $ilLog, $packageFolder, $slm, dbImportLM(), and importGlossary().

432  {
433  global $ilDB, $ilLog;
434 
435  $this->packageFolder=$packageFolder;
436  $this->packageId=$slm->getId();
437  $this->imsmanifestFile = $this->packageFolder . '/' . 'imsmanifest.xml';
438  $this->imsmanifest = new DOMDocument;
439  $this->imsmanifest->async = false;
440  $this->imsmanifest->formatOutput = false;
441  $this->imsmanifest->preserveWhiteSpace = false;
442  $this->slm = $slm;
443  if (!@$this->imsmanifest->load($this->imsmanifestFile))
444  {
445  $this->diagnostic[] = 'XML not wellformed';
446  return false;
447  }
448 
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");
453 
454 
455  $this->dbImportLM(simplexml_import_dom($this->imsmanifest->documentElement), "",
456  $a_import_sequencing);
457 
458  if(is_dir($packageFolder."/glossary"))
459  {
460  $this->importGlossary($slm,$packageFolder."/glossary");
461  }
462  //die($slm->title);
463 
464  return $slm->title;
465  }
dbImportLM($node, $parent_id="", $a_import_sequencing=false)
global $ilDB
importGlossary($slm, $packageFolder)
+ Here is the call graph for this function:

◆ il_importSco()

ilSCORM13Package::il_importSco (   $packageId,
  $sco_id,
  $packageFolder 
)

Imports an extracted SCORM 2004 module from ilias-data dir into database.

public

Returns
string title of package

Definition at line 301 of file ilSCORM13Package.php.

References $ilDB, $ilLog, $packageFolder, $packageId, $slm, and dbImportSco().

302  {
303  global $ilDB, $ilLog;
304 
305  $this->packageFolder=$packageFolder;
306  $this->packageId=$packageId;
307  $this->imsmanifestFile = $this->packageFolder . '/' . 'index.xml';
308  $this->imsmanifest = new DOMDocument;
309  $this->imsmanifest->async = false;
310 
311  if (!@$this->imsmanifest->load($this->imsmanifestFile))
312  {
313  $this->diagnostic[] = 'XML not wellformed';
314  return false;
315  }
316 
318  $sco = new ilSCORM2004Sco($slm,$sco_id);
319  $this->dbImportSco($slm,$sco);
320 
321  // import sco.xml
322  $sco_xml_file = $this->packageFolder . '/sco.xml';
323  if (is_file($sco_xml_file))
324  {
325  $scodoc = new DOMDocument;
326  $scodoc->async = false;
327  if (!@$scodoc->load($sco_xml_file))
328  {
329  $this->diagnostic[] = 'XML of sco.xml not wellformed';
330  return false;
331  }
332  //$doc = new SimpleXMLElement($scodoc->saveXml());
333  //$l = $doc->xpath("/sco/objective");
334  $xpath = new DOMXPath($scodoc);
335  $nodes = $xpath->query("/sco/objective");
336  foreach($nodes as $node)
337  {
338  $t_node = $node->firstChild;
339  if (is_object($t_node))
340  {
341  $objective_text = $t_node->textContent;
342  if (trim($objective_text) != "")
343  {
344  $objs = $sco->getObjectives();
345  foreach ($objs as $o)
346  {
347  $mappings = $o->getMappings();
348  if ($mappings == null)
349  {
350  $ob = new ilScorm2004Objective($sco->getId(), $o->getId());
351  $ob->setObjectiveID($objective_text);
352  $ob->updateObjective();
353  }
354  }
355  }
356  }
357  }
358  }
359  return "";
360  }
dbImportSco($slm, $sco, $asset=false)
Class ilSCORM2004Sco.
Class ilObjSCORM2004LearningModule.
global $ilDB
+ Here is the call graph for this function:

◆ importGlossary()

ilSCORM13Package::importGlossary (   $slm,
  $packageFolder 
)

Definition at line 467 of file ilSCORM13Package.php.

References $_GET, $packageFolder, and $slm.

Referenced by il_importLM().

468  {
469  global $ilias;
470  // create and insert object in objecttree
471  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
472  $newObj = new ilObjGlossary();
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"]);
479 
480  $xml_file = $packageFolder."/glossary.xml";
481 
482  // check whether xml file exists within zip file
483  if (!is_file($xml_file))
484  {
485  return;
486  }
487 
488  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
489  $contParser = new ilContObjParser($newObj, $xml_file, $packageFolder);
490  $contParser->startParsing();
491  $newObj->update();
492  //ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
493  $slm->setAssignedGlossary($newObj->getId());
494  $slm->update();
495  }
Content Object Parser.
$_GET["client_id"]
Class ilObjGlossary.
+ Here is the caller graph for this function:

◆ jsonNode()

ilSCORM13Package::jsonNode (   $node,
$sink 
)

Helper for UploadAndImport Recursively copies values from XML into PHP array for export as json Elements are translated into sub array, attributes into literals.

Parameters
xmlelement to process
referenceto array object where to copy values
Returns
void

Definition at line 668 of file ilSCORM13Package.php.

669  {
670  foreach ($node->attributes() as $k => $v)
671  {
672  // cast to boolean and number if possible
673  $v = strval($v);
674  if ($v==="true") $v = true;
675  else if ($v==="false") $v = false;
676  else if (is_numeric($v)) $v = (float) $v;
677  $sink[$k] = $v;
678  }
679  foreach ($node->children() as $name => $child)
680  {
681  self::jsonNode($child, $sink[$name][]); // RECURSION
682  }
683  }

◆ load()

ilSCORM13Package::load (   $packageId)

Definition at line 81 of file ilSCORM13Package.php.

References $ilDB, $lm_set, $packageId, and array.

Referenced by __construct().

82  {
83  global $ilDB;
84 
85  if (!is_numeric($packageId))
86  {
87  return false;
88  }
89 
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);
94 
95  $this->packageData = array_merge($lm_data, $pg_data);
96  $this->packageId = $packageId;
97  $this->packageFolder = $this->packagesFolder . '/' . $packageId;
98  $this->packageFile = $this->packageFolder . '.zip';
99  $this->imsmanifestFile = $this->packageFolder . '/' . 'imsmanifest.xml';
100  return true;
101  }
Create styles array
The data for the language used.
$lm_set
global $ilDB
+ Here is the caller graph for this function:

◆ removeCMIData()

ilSCORM13Package::removeCMIData ( )

Definition at line 1133 of file ilSCORM13Package.php.

References ilLPStatusWrapper\_refreshStatus(), and ilSCORM2004DeleteData\removeCMIDataForPackage().

Referenced by dbRemoveAll().

1134  {
1135  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004DeleteData.php");
1137 
1138  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
1139  ilLPStatusWrapper::_refreshStatus($this->packageId);
1140  }
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
static removeCMIDataForPackage($packageId)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeCPData()

ilSCORM13Package::removeCPData ( )

Definition at line 1142 of file ilSCORM13Package.php.

References $data, $ilDB, $ilLog, $in, $res, $t, and array.

Referenced by dbRemoveAll().

1143  {
1144  global $ilDB, $ilLog;
1145 
1146  //get relevant nodes
1147  $cp_nodes = array();
1148 
1149  $res = $ilDB->queryF(
1150  'SELECT cp_node.cp_node_id FROM cp_node WHERE cp_node.slm_id = %s',
1151  array('integer'),
1152  array($this->packageId)
1153  );
1154  while($data = $ilDB->fetchAssoc($res))
1155  {
1156  $cp_nodes[] = $data['cp_node_id'];
1157  }
1158 
1159  //remove package data
1160  foreach(self::$elements['cp'] as $t)
1161  {
1162  $t = 'cp_' . $t;
1163 
1164  $in = $ilDB->in(strtolower($t).'.cp_node_id', $cp_nodes, false, 'integer');
1165  $ilDB->manipulate('DELETE FROM '.strtolower($t).' WHERE '.$in);
1166  }
1167 
1168  // remove CP structure entries in tree and node
1169  $ilDB->manipulateF(
1170  'DELETE FROM cp_tree WHERE cp_tree.obj_id = %s',
1171  array('integer'),
1172  array($this->packageId)
1173  );
1174 
1175  $ilDB->manipulateF(
1176  'DELETE FROM cp_node WHERE cp_node.slm_id = %s',
1177  array('integer'),
1178  array($this->packageId)
1179  );
1180 
1181  // remove general package entry
1182  $ilDB->manipulateF(
1183  'DELETE FROM cp_package WHERE cp_package.obj_id = %s',
1184  array('integer'),
1185  array($this->packageId)
1186  );
1187  }
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
global $ilDB
+ Here is the caller graph for this function:

◆ rollback()

ilSCORM13Package::rollback ( )

Definition at line 103 of file ilSCORM13Package.php.

References dbRemoveAll(), and setProgress().

104  {
105  $this->setProgress(0, 'Rolling back...');
106  $this->dbRemoveAll();
107  if (is_dir($this->packageFolder))
108  dir_delete($this->packageFolder);
109  if (is_file($this->packageFile))
110  @unlink($this->packageFile);
111  $this->setProgress(0, 'Roll back finished: Ok. ');
112  }
setProgress($progress, $msg='')
+ Here is the call graph for this function:

◆ setProgress()

ilSCORM13Package::setProgress (   $progress,
  $msg = '' 
)
private

Definition at line 654 of file ilSCORM13Package.php.

References $progress.

Referenced by rollback().

655  {
656  $this->progress = $progress;
657  $this->diagnostic[] = $msg;
658  }
+ Here is the caller graph for this function:

◆ setSequencingInfo()

ilSCORM13Package::setSequencingInfo (   $a_node,
  $a_seq_info,
  $a_import_sequencing,
  $a_fix_obj_id = "" 
)

Save sequencing ingo.

Parameters

Definition at line 636 of file ilSCORM13Package.php.

Referenced by dbImportLM().

637  {
638  $seq_xml = trim(str_replace("imsss:", "", $this->imsmanifest->saveXML($a_node)));
639  if ($seq_xml != "")
640  {
641  $a_seq_info->setImportSeqXml('<?xml version="1.0"?>'.$seq_xml);
642  }
643  if ($a_import_sequencing)
644  {
645  if ($a_fix_obj_id != "")
646  {
647  $seq_xml = preg_replace("/local_obj_[0-9]*_0/", $a_fix_obj_id, $seq_xml);
648  }
649  $a_seq_info->setSeqXml('<?xml version="1.0"?>'.$seq_xml);
650  }
651  }
+ Here is the caller graph for this function:

◆ transform()

ilSCORM13Package::transform (   $inputdoc,
  $xslfile,
  $outputpath = null 
)

Definition at line 1196 of file ilSCORM13Package.php.

References $r.

Referenced by il_import().

1197  {
1198  $xsl = new DOMDocument;
1199  $xsl->async = false;
1200  if (!@$xsl->load($xslfile))
1201  {
1202  die('ERROR: load StyleSheet ' . $xslfile);
1203  }
1204  $prc = new XSLTProcessor;
1205  $prc->registerPHPFunctions();
1206  $r = @$prc->importStyleSheet($xsl);
1207  if (false===@$prc->importStyleSheet($xsl))
1208  {
1209  die('ERROR: importStyleSheet ' . $xslfile);
1210  }
1211  if ($outputpath)
1212  {
1213  file_put_contents($outputpath, $prc->transformToXML($inputdoc));
1214  }
1215  else
1216  {
1217  return $prc->transformToDoc($inputdoc);
1218  }
1219  }
$r
Definition: example_031.php:79
+ Here is the caller graph for this function:

◆ validate()

ilSCORM13Package::validate (   $doc,
  $schema 
)

Definition at line 1221 of file ilSCORM13Package.php.

References $error, $schema, and array.

Referenced by il_import().

1222  {
1223  libxml_use_internal_errors(true);
1224  $return = @$doc->schemaValidate($schema);
1225  if (!$return)
1226  {
1227  $levels = array(
1228  LIBXML_ERR_ERROR => 'Error',
1229  LIBXML_ERR_FATAL => 'Fatal Error'
1230  );
1231  foreach (libxml_get_errors() as $error)
1232  {
1233  $level = $levels[$error->level];
1234  if (isset($level))
1235  {
1236  $message = trim($error->message);
1237  $this->diagnostic[] = "XSLT $level (Line $error->line) $message";
1238  }
1239  }
1240  libxml_clear_errors();
1241  }
1242  libxml_use_internal_errors(false);
1243  return $return;
1244  }
$error
Definition: Error.php:17
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

Field Documentation

◆ $diagnostic

ilSCORM13Package::$diagnostic

Definition at line 39 of file ilSCORM13Package.php.

◆ $elements

ilSCORM13Package::$elements
staticprivate
Initial value:
'cp' => array(
'manifest',
'organization',
'item',
'hideLMSUI',
'resource',
'file',
'dependency',
'sequencing',
'rule',
'auxilaryResource',
'condition',
'mapinfo',
'objective',
),
'cmi' => array(
'comment',
'correct_response',
'interaction',
'node',
'objective',
),
)

Definition at line 49 of file ilSCORM13Package.php.

◆ $idmap

ilSCORM13Package::$idmap = array()
private

Definition at line 46 of file ilSCORM13Package.php.

◆ $imsmanifest

ilSCORM13Package::$imsmanifest

Definition at line 37 of file ilSCORM13Package.php.

◆ $manifest

ilSCORM13Package::$manifest

Definition at line 38 of file ilSCORM13Package.php.

◆ $packageData

ilSCORM13Package::$packageData
private

Definition at line 33 of file ilSCORM13Package.php.

◆ $packageFile

ilSCORM13Package::$packageFile
private

Definition at line 30 of file ilSCORM13Package.php.

◆ $packageFolder

ilSCORM13Package::$packageFolder
private

◆ $packageHash

ilSCORM13Package::$packageHash

Definition at line 43 of file ilSCORM13Package.php.

◆ $packageId

ilSCORM13Package::$packageId

Definition at line 41 of file ilSCORM13Package.php.

Referenced by __construct(), dbImport(), il_import(), il_importAss(), il_importSco(), and load().

◆ $packageName

ilSCORM13Package::$packageName

Definition at line 42 of file ilSCORM13Package.php.

◆ $packagesFolder

ilSCORM13Package::$packagesFolder
private

Definition at line 32 of file ilSCORM13Package.php.

◆ $progress

ilSCORM13Package::$progress = 0.0
private

Definition at line 47 of file ilSCORM13Package.php.

Referenced by setProgress().

◆ $slm

ilSCORM13Package::$slm
private

◆ $slm_tree

ilSCORM13Package::$slm_tree
private

Definition at line 35 of file ilSCORM13Package.php.

◆ $status

ilSCORM13Package::$status

Definition at line 40 of file ilSCORM13Package.php.

◆ $userId

ilSCORM13Package::$userId

Definition at line 44 of file ilSCORM13Package.php.

◆ CONVERT_XSL

const ilSCORM13Package::CONVERT_XSL = './Modules/Scorm2004/templates/xsl/op/scorm12To2004.xsl'

Definition at line 22 of file ilSCORM13Package.php.

◆ DB_DECODE_XSL

const ilSCORM13Package::DB_DECODE_XSL = './Modules/Scorm2004/templates/xsl/op/op-scorm13-revert.xsl'

Definition at line 23 of file ilSCORM13Package.php.

◆ DB_ENCODE_XSL

const ilSCORM13Package::DB_ENCODE_XSL = './Modules/Scorm2004/templates/xsl/op/op-scorm13.xsl'

Definition at line 21 of file ilSCORM13Package.php.

◆ VALIDATE_XSD

const ilSCORM13Package::VALIDATE_XSD = './Modules/Scorm2004/templates/xsd/op/op-scorm13.xsd'

Definition at line 24 of file ilSCORM13Package.php.

◆ WRAPPER_HTML

const ilSCORM13Package::WRAPPER_HTML = './Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/GenericRunTimeWrapper.htm'

Definition at line 26 of file ilSCORM13Package.php.

◆ WRAPPER_JS

const ilSCORM13Package::WRAPPER_JS = './Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/SCOPlayerWrapper.js'

Definition at line 27 of file ilSCORM13Package.php.


The documentation for this class was generated from the following file: