ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
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['ct_recipient']
+ Here is the call graph for this function:

Member Function Documentation

◆ _removeTrackingDataForUser()

static ilSCORM13Package::_removeTrackingDataForUser (   $user_id)
static

Definition at line 1266 of file ilSCORM13Package.php.

References ilSCORM2004DeleteData\removeCMIDataForUser().

Referenced by ilObjUser\delete().

1266  {
1267 
1268  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004DeleteData.php");
1270  //missing updatestatus
1271  }
+ 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 1127 of file ilSCORM13Package.php.

References $ilDB.

1128  {
1129  global $ilDB;
1130 
1131  //$this->packageId = 100;
1132  //return true;
1133  //ilSCORM13DB::getRecord('sahs_lm', array());
1134  // $this->packageId = ilSCORM13DB::getRecord('sahs_lm', array());
1135 /* ilSCORM13DB::setRecord('cp_package', array(
1136  'obj_id' => $this->packageId,
1137  'xmldata' => $x->asXML(),
1138  'jsdata' => json_encode($j),
1139  ), 'obj_id');
1140 */
1141 
1142  $ilDB->insert('cp_package', array(
1143  'obj_id' => array('integer', $this->packageId),
1144  'xmldata' => array('clob', $x->asXML()),
1145  'jsdata' => array('clob', json_encode($j))
1146  ));
1147 
1148  return true;
1149  }
global $ilDB

◆ dbImport()

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

Definition at line 915 of file ilSCORM13Package.php.

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

Referenced by il_import().

916  {
917  global $ilDB;
918 
919  switch ($node->nodeType)
920  {
921  case XML_DOCUMENT_NODE:
922 
923  // insert into cp_package
924  /*ilSCORM13DB::setRecord('cp_package', array(
925  'obj_id' => $this->packageId,
926  'identifier' => $this->packageName,
927  'persistPreviousAttempts' => 0,
928  'settings' => '',
929  ));*/
930 
931  $res = $ilDB->queryF(
932  'SELECT * FROM cp_package WHERE obj_id = %s AND c_identifier = %s',
933  array('integer', 'text'),
934  array($this->packageId, $this->packageName)
935  );
936  if($num_rows = $ilDB->numRows($res))
937  {
938  $query = 'UPDATE cp_package '
939  . 'SET persistprevattempts = %s, c_settings = %s '
940  . 'WHERE obj_id = %s AND c_identifier= %s';
941  $ilDB->manipulateF(
942  $query,
943  array('integer', 'text', 'integer', 'text'),
944  array(0, NULL, $this->packageId, $this->packageName)
945  );
946  }
947  else
948  {
949  $query = 'INSERT INTO cp_package (obj_id, c_identifier, persistprevattempts, c_settings) '
950  . 'VALUES (%s, %s, %s, %s)';
951  $ilDB->manipulateF(
952  $query,
953  array('integer','text','integer', 'text'),
954  array($this->packageId, $this->packageName, 0, NULL)
955  );
956  }
957 
958  // run sub nodes
959  $this->dbImport($node->documentElement); // RECURSION
960  break;
961 
962  case XML_ELEMENT_NODE:
963  if ($node->nodeName==='manifest')
964  {
965  if ($node->getAttribute('uri')=="")
966  {
967  // default URI is md5 hash of zip file, i.e. packageHash
968  $node->setAttribute('uri', 'md5:' . $this->packageHash);
969  }
970  }
971 
972  $cp_node_id = $ilDB->nextId('cp_node');
973 
974  $query = 'INSERT INTO cp_node (cp_node_id, slm_id, nodename) '
975  . 'VALUES (%s, %s, %s)';
976  $ilDB->manipulateF(
977  $query,
978  array('integer', 'integer', 'text'),
979  array($cp_node_id, $this->packageId, $node->nodeName)
980  );
981 
982  $query = 'INSERT INTO cp_tree (child, depth, lft, obj_id, parent, rgt) '
983  . 'VALUES (%s, %s, %s, %s, %s, %s)';
984  $ilDB->manipulateF(
985  $query,
986  array('integer', 'integer', 'integer', 'integer', 'integer', 'integer'),
987  array($cp_node_id, $depth, $lft++, $this->packageId, $parent, 0)
988  );
989 
990  // insert into cp_*
991  //$a = array('cp_node_id' => $cp_node_id);
992  $names = array('cp_node_id');
993  $values = array($cp_node_id);
994  $types = array('integer');
995 
996  foreach ($node->attributes as $attr)
997  {
998  switch(strtolower($attr->name))
999  {
1000  case 'completionsetbycontent': $names[] = 'completionbycontent';break;
1001  case 'objectivesetbycontent': $names[] = 'objectivebycontent';break;
1002  case 'type': $names[] = 'c_type';break;
1003  case 'mode': $names[] = 'c_mode';break;
1004  case 'language': $names[] = 'c_language';break;
1005  case 'condition': $names[] = 'c_condition';break;
1006  case 'operator': $names[] = 'c_operator';break;
1007  case 'condition': $names[] = 'c_condition';break;
1008  case 'readnormalizedmeasure': $names[] = 'readnormalmeasure';break;
1009  case 'writenormalizedmeasure': $names[] = 'writenormalmeasure';break;
1010  case 'minnormalizedmeasure': $names[] = 'minnormalmeasure';break;
1011  case 'primary': $names[] = 'c_primary';break;
1012  case 'minnormalizedmeasure': $names[] = 'minnormalmeasure';break;
1013  case 'persistpreviousattempts': $names[] = 'persistprevattempts';break;
1014  case 'identifier': $names[] = 'c_identifier';break;
1015  case 'settings': $names[] = 'c_settings';break;
1016  case 'activityabsolutedurationlimit': $names[] = 'activityabsdurlimit';break;
1017  case 'activityexperienceddurationlimit': $names[] = 'activityexpdurlimit';break;
1018  case 'attemptabsolutedurationlimit': $names[] = 'attemptabsdurlimit';break;
1019  case 'measuresatisfactionifactive': $names[] = 'measuresatisfactive';break;
1020  case 'objectivemeasureweight': $names[] = 'objectivemeasweight';break;
1021  case 'requiredforcompleted': $names[] = 'requiredcompleted';break;
1022  case 'requiredforincomplete': $names[] = 'requiredincomplete';break;
1023  case 'requiredfornotsatisfied': $names[] = 'requirednotsatisfied';break;
1024  case 'rollupobjectivesatisfied': $names[] = 'rollupobjectivesatis';break;
1025  case 'rollupprogresscompletion': $names[] = 'rollupprogcompletion';break;
1026  case 'usecurrentattemptobjectiveinfo': $names[] = 'usecurattemptobjinfo';break;
1027  case 'usecurrentattemptprogressinfo': $names[] = 'usecurattemptproginfo';break;
1028  default: $names[] = strtolower($attr->name);break;
1029  }
1030 
1031  if(in_array($names[count($names) - 1],
1032  array('flow', 'completionbycontent',
1033  'objectivebycontent', 'rollupobjectivesatis',
1034  'tracked', 'choice',
1035  'choiceexit', 'satisfiedbymeasure',
1036  'c_primary', 'constrainchoice',
1037  'forwardonly', 'global_to_system',
1038  'writenormalmeasure', 'writesatisfiedstatus',
1039  'readnormalmeasure', 'readsatisfiedstatus',
1040  'preventactivation', 'measuresatisfactive',
1041  'reorderchildren', 'usecurattemptproginfo',
1042  'usecurattemptobjinfo', 'rollupprogcompletion',
1043  'read_shared_data', 'write_shared_data',
1044  'shared_data_global_to_system', 'completedbymeasure')))
1045  {
1046  if($attr->value == 'true')
1047  $values[] = 1;
1048  else if ($attr->value == 'false')
1049  $values[] = 0;
1050  else
1051  $values[] = (int)$attr->value;
1052  }
1053  else
1054  {
1055  $values[] = $attr->value;
1056  }
1057 
1058  if( in_array($names[count($names) - 1],
1059  array('objectivesglobtosys', 'attemptlimit',
1060  'flow', 'completionbycontent',
1061  'objectivebycontent', 'rollupobjectivesatis',
1062  'tracked', 'choice',
1063  'choiceexit', 'satisfiedbymeasure',
1064  'c_primary', 'constrainchoice',
1065  'forwardonly', 'global_to_system',
1066  'writenormalmeasure', 'writesatisfiedstatus',
1067  'readnormalmeasure', 'readsatisfiedstatus',
1068  'preventactivation', 'measuresatisfactive',
1069  'reorderchildren', 'usecurattemptproginfo',
1070  'usecurattemptobjinfo', 'rollupprogcompletion',
1071  'read_shared_data', 'write_shared_data',
1072  'shared_data_global_to_system')))
1073  $types[] = 'integer';
1074  else if ( in_array($names[count($names) - 1],
1075  array('jsdata', 'xmldata', 'activitytree', 'data')))
1076  $types[] = 'clob';
1077  else if ( in_array($names[count($names) - 1],
1078  array('objectivemeasweight')))
1079  $types[] = 'float';
1080  else
1081  $types[] = 'text';
1082  }
1083 
1084  if($node->nodeName==='datamap')
1085  {
1086  $names[] = 'slm_id';
1087  $values[] = $this->packageId;
1088  $types[] = 'integer';
1089 
1090  $names[] = 'sco_node_id';
1091  $values[] = $parent;
1092  $types[] = 'integer';
1093  }
1094 
1095  // we have to change the insert method because of clob fields ($ilDB->manipulate does not work here)
1096  $insert_data = array();
1097  foreach($names as $key => $db_field)
1098  {
1099  $insert_data[$db_field] = array($types[$key], trim($values[$key]));
1100  }
1101  $ilDB->insert('cp_'.strtolower($node->nodeName), $insert_data);
1102 
1103  $node->setAttribute('foreignId', $cp_node_id);
1104  $this->idmap[$node->getAttribute('id')] = $cp_node_id;
1105 
1106  // run sub nodes
1107  foreach($node->childNodes as $child)
1108  {
1109  $this->dbImport($child, $lft, $depth + 1, $cp_node_id); // RECURSION
1110  }
1111 
1112  // update cp_tree (rgt value for pre order walk in sql tree)
1113  $query = 'UPDATE cp_tree SET rgt = %s WHERE child = %s';
1114  $ilDB->manipulateF(
1115  $query,
1116  array('integer', 'integer'),
1117  array($lft++, $cp_node_id)
1118  );
1119 
1120  break;
1121  }
1122  }
dbImport($node, &$lft=1, $depth=1, $parent=0)
global $ilDB
+ Here is the caller graph for this function:

◆ dbImportLM()

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

Definition at line 499 of file ilSCORM13Package.php.

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

Referenced by il_importLM().

500  {
501 
502  switch($node->getName())
503  {
504  case "manifest":
505  $this->slm_tree =& new ilTree($this->slm->getId());
506  $this->slm_tree->setTreeTablePK("slm_id");
507  $this->slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
508  $this->slm_tree->addTree($this->slm->getId(), 1);
509 
510  //add seqinfo for rootNode
511  include_once ("./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
512  $seq_info = new ilSCORM2004Sequencing($this->slm->getId(),true);
513 
514  // get original sequencing information
515  $r = $this->mani_xpath->query("/d:manifest/d:organizations/d:organization/imsss:sequencing");
516  $this->imsmanifest->formatOutput = false;
517  if ($r)
518  {
519  $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing);
520  if ($a_import_sequencing)
521  {
522  $seq_info->initDom();
523  }
524  }
525  $seq_info->insert();
526 
527  if(file_exists($this->packageFolder . '/' . 'index.xml'))
528  {
529  $doc = simplexml_load_file($this->packageFolder . '/' . 'index.xml');
530  $l = $doc->xpath ( "/ContentObject/MetaData" );
531  if($l[0])
532  {
533  include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
534  $mdxml =& new ilMDXMLCopier($l[0]->asXML(),$this->slm->getId(),$this->slm->getId(),$this->slm->getType());
535  $mdxml->startParsing();
536  $mdxml->getMDObject()->update();
537  }
538  }
539  break;
540  case "organization":
541  $this->slm->title=$node->title;
542  break;
543  case "item":
544  $a = $node->attributes();
545  if(preg_match("/il_\d+_chap_\d+/",$a['identifier']))
546  {
547  $chap=& new ilSCORM2004Chapter($this->slm);
548  $chap->setTitle($node->title);
549  $chap->setSLMId($this->slm->getId());
550  $chap->create(true);
551 
552  // save sequencing information
553  $r = $this->mani_xpath->query("//d:item[@identifier='".$a['identifier']."']/imsss:sequencing");
554  if ($r)
555  {
556  $seq_info = new ilSCORM2004Sequencing($chap->getId());
557  $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing);
558  $seq_info->initDom();
559  $seq_info->insert();
560  }
561 
562  ilSCORM2004Node::putInTree($chap, $parent_id, "");
563  $parent_id = $chap->getId();
564  $doc = simplexml_load_file($this->packageFolder . '/' . 'index.xml');
565  $l = $doc->xpath ( "/ContentObject/StructureObject/MetaData[General/Identifier/@Entry='".$a['identifier']."']" );
566  if($l[0])
567  {
568  include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
569  $mdxml =& new ilMDXMLCopier($l[0]->asXML(),$this->slm->getId(),$chap->getId(),$chap->getType());
570  $mdxml->startParsing();
571  $mdxml->getMDObject()->update();
572  }
573  }
574  if(preg_match("/il_\d+_sco_(\d+)/",$a['identifier'], $match))
575  {
576  $sco = new ilSCORM2004Sco($this->slm);
577  $sco->setTitle($node->title);
578  $sco->setSLMId($this->slm->getId());
579  $sco->create(true);
580 
581  // save sequencing information
582  $r = $this->mani_xpath->query("//d:item[@identifier='".$a['identifier']."']/imsss:sequencing");
583  if ($r)
584  {
585  $seq_info = new ilSCORM2004Sequencing($sco->getId());
586  $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing,
587  "local_obj_".$sco->getID()."_0");
588  $seq_info->initDom();
589  $seq_info->insert();
590  }
591 
592  ilSCORM2004Node::putInTree($sco, $parent_id, "");
593  $newPack = new ilSCORM13Package();
594  $newPack->il_importSco($this->slm->getId(),$sco->getId(),$this->packageFolder."/".$match[1]);
595  $parent_id = $sco->getId();
596  }
597  if(preg_match("/il_\d+_ass_(\d+)/",$a['identifier'], $match))
598  {
599  $ass = new ilSCORM2004Asset($this->slm);
600  $ass->setTitle($node->title);
601  $ass->setSLMId($this->slm->getId());
602  $ass->create(true);
603 
604  // save sequencing information
605  $r = $this->mani_xpath->query("//d:item[@identifier='".$a['identifier']."']/imsss:sequencing");
606  if ($r)
607  {
608  $seq_info = new ilSCORM2004Sequencing($ass->getId());
609  $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing,
610  "local_obj_".$ass->getID()."_0");
611  $seq_info->initDom();
612  $seq_info->insert();
613  }
614 
615  ilSCORM2004Node::putInTree($ass, $parent_id, "");
616  $newPack = new ilSCORM13Package();
617  $newPack->il_importAss($this->slm->getId(),$ass->getId(),$this->packageFolder."/".$match[1]);
618  $parent_id = $ass->getId();
619  }
620 
621  break;
622  }
623  //if($node->nodeType==XML_ELEMENT_NODE)
624  {
625  foreach($node->children() as $child)
626  {
627  $this->dbImportLM($child, $parent_id, $a_import_sequencing);
628  }
629  }
630  }
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.
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
Class ilSCORM2004Asset.
$r
+ 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 687 of file ilSCORM13Package.php.

References $d, $filename, $n, $path, $result, $slm, $t, ilObjMediaObject\_getDirectory(), 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().

688  {
689  $qtis = array();
690  $d = ilUtil::getDir ( $this->packageFolder );
691  foreach ( $d as $f ) {
692  //continue;
693  if ($f [type] == 'file' && substr ( $f [entry], 0, 4 ) == 'qti_') {
694  include_once "./Services/QTI/classes/class.ilQTIParser.php";
695  include_once "./Modules/Test/classes/class.ilObjTest.php";
696 
697 
698  $qtiParser = new ilQTIParser ( $this->packageFolder . "/" . $f [entry], IL_MO_VERIFY_QTI, 0, "" );
699  $result = $qtiParser->startParsing ();
700  $founditems = & $qtiParser->getFoundItems ();
701  // die(print_r($founditems));
702  foreach ( $founditems as $qp ) {
703  $newObj = new ilObjTest ( 0, true );
704 
705  // This creates a lot of invalid repository objects for each question
706  // question are not repository objects (see e.g. table object_data), alex 29 Sep 2009
707 
708 // $newObj->setType ( $qp ['type'] );
709 // $newObj->setTitle ( $qp ['title'] );
710 // $newObj->create ( true );
711 // $newObj->createReference ();
712 // $newObj->putInTree ($_GET ["ref_id"]);
713 // $newObj->setPermissions ( $sco->getId ());
714 // $newObj->notify ("new", $_GET["ref_id"], $sco->getId (), $_GET["ref_id"], $newObj->getRefId () );
715 // $newObj->mark_schema->flush ();
716  $qtiParser = new ilQTIParser ( $this->packageFolder . "/" . $f [entry], IL_MO_PARSE_QTI, 0, "" );
717  $qtiParser->setTestObject ( $newObj );
718  $result = $qtiParser->startParsing ();
719 // $newObj->saveToDb ();
720  $qtis = array_merge($qtis, $qtiParser->getImportMapping());
721 
722  }
723  }
724  }
725 //exit;
726  include_once 'Modules/Scorm2004/classes/class.ilSCORM2004Page.php';
727  $doc = new SimpleXMLElement($this->imsmanifest->saveXml());
728  $l = $doc->xpath ( "/ContentObject/MetaData" );
729  if($l[0])
730  {
731  include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
732  $mdxml =& new ilMDXMLCopier($l[0]->asXML(),$slm->getId(),$sco->getId(),$sco->getType());
733  $mdxml->startParsing();
734  $mdxml->getMDObject()->update();
735  }
736  $l = $doc->xpath("/ContentObject/PageObject");
737  foreach ( $l as $page_xml )
738  {
739  $tnode = $page_xml->xpath ( 'MetaData/General/Title' );
740  $page = new ilSCORM2004PageNode ( $slm );
741  $page->setTitle ( $tnode [0] );
742  $page->setSLMId ( $slm->getId () );
743  $page->create (true);
744  ilSCORM2004Node::putInTree ( $page, $sco->getId (), $target );
745  $pmd = $page_xml->xpath ("MetaData");
746  if($pmd[0])
747  {
748  include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
749  $mdxml =& new ilMDXMLCopier($pmd[0]->asXML(),$slm->getId(),$page->getId(),$page->getType());
750  $mdxml->startParsing();
751  $mdxml->getMDObject()->update();
752  }
753  $tnode = $page_xml->xpath("//MediaObject/MediaAlias | //InteractiveImage/MediaAlias");
754  foreach($tnode as $ttnode)
755  {
756  include_once './Services/MediaObjects/classes/class.ilObjMediaObject.php';
757  $OriginId = $ttnode[OriginId];
758  $medianodes = $doc->xpath("//MediaObject[MetaData/General/Identifier/@Entry='".$OriginId ."']");
759  $medianode = $medianodes[0];
760  if($medianode)
761  {
762  $media_object = new ilObjMediaObject ( );
763  $media_object->setTitle ($medianode->MetaData->General->Title);
764  $media_object->setDescription ($medianode->MetaData->General->Description);
765  $media_object->create (false);
766  $mmd = $medianode->xpath ("MetaData");
767  if($mmd[0])
768  {
769  include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php';
770  $mdxml =& new ilMDXMLCopier($mmd[0]->asXML(),0,$media_object->getId(),$media_object->getType());
771  $mdxml->startParsing();
772  $mdxml->getMDObject()->update();
773  }
774  // determine and create mob directory, move uploaded file to directory
775  $media_object->createDirectory ();
776  $mob_dir = ilObjMediaObject::_getDirectory ( $media_object->getId () );
777  foreach ( $medianode->MediaItem as $xMediaItem )
778  {
779  $media_item = & new ilMediaItem ( );
780  $media_object->addMediaItem ( $media_item );
781  $media_item->setPurpose($xMediaItem[Purpose]);
782  $media_item->setFormat($xMediaItem->Format );
783  $media_item->setLocation($xMediaItem->Location);
784  $media_item->setLocationType($xMediaItem->Location[Type]);
785  $media_item->setWidth ( $xMediaItem->Layout[Width]);
786  $media_item->setHeight ( $xMediaItem->Layout[Height]);
787  $media_item->setHAlign($xMediaItem->Layout[HorizontalAlign]);
788  $media_item->setCaption($xMediaItem->Caption);
789  $media_item->setTextRepresentation($xMediaItem->TextRepresentation);
790  $nr = 0;
791 
792  // add map areas (external links only)
793  foreach ($xMediaItem->MapArea as $n => $v)
794  {
795 
796  if ($v->ExtLink[Href] != "")
797  {
798  include_once("./Services/MediaObjects/classes/class.ilMapArea.php");
799  $ma = new ilMapArea();
800 
801  $map_area = new ilMapArea();
802  $map_area->setShape($v[Shape]);
803  $map_area->setCoords($v[Coords]);
804  $map_area->setLinkType(IL_EXT_LINK);
805  $map_area->setTitle($v->ExtLink);
806  $map_area->setHref($v->ExtLink[Href]);
807 
808  $media_item->addMapArea($map_area);
809  }
810  }
811 
812  if($media_item->getLocationType()=="LocalFile")
813  {
814 // $tmp_name = $this->packageFolder."/objects/".$OriginId."/".$xMediaItem->Location;
815 // copy($tmp_name, $mob_dir."/".$xMediaItem->Location);
816  }
817  }
818 
819  // copy whole directory
820  ilUtil::rCopy($this->packageFolder."/objects/".$OriginId, $mob_dir);
821 
822 
823  // alex: fixed media import: these lines have been
824  // behind the next curly bracket which makes it fail
825  // when no medianode is given. (id=0 -> fatal error)
826  ilUtil::renameExecutables ( $mob_dir );
827  $media_object->update(true);
828  $ttnode [OriginId] = "il__mob_" . $media_object->getId ();
829  }
830  }
831  include_once("./Modules/File/classes/class.ilObjFile.php");
832  include_once("./Services/Utilities/classes/class.ilFileUtils.php");
833  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
834 
835  $intlinks = $page_xml->xpath("//IntLink");
836  //die($intlinks);
837  //if($intlinks )
838  {
839  foreach ( $intlinks as $intlink )
840  {
841  if($intlink[Type]!="File") continue;
842  $path = $this->packageFolder."/objects/".str_replace('dfile','file',$intlink[Target]);
843  if(!is_dir($path )) continue;
844  $ffiles = array();
846  $filename = $ffiles[file][0];
847  $fileObj = new ilObjFile();
848  $fileObj->setType("file");
851 
852  // better use this, mime_content_type is deprecated
853  $fileObj->setFileType(ilObjMediaObject::getMimeType($path. "/" . $filename));
854 
855  $fileObj->setFileSize(filesize($path. "/" . $filename));
856  $fileObj->create();
857  $fileObj->createReference();
858  //$fileObj->putInTree($_GET["ref_id"]);
859  //$fileObj->setPermissions($slm->getId ());
860  $fileObj->createDirectory();
861  $fileObj->storeUnzipedFile($path."/" .$filename,ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
862  $intlink[Target]="il__dfile_".$fileObj->getId();
863 
864  }
865  }
866  $fileitems = $page_xml->xpath("//FileItem/Identifier");
867  //if($intlinks )
868  {
869  foreach ( $fileitems as $fileitem )
870  {
871  $path = $this->packageFolder."/objects/".$fileitem[Entry];
872  if(!is_dir($path )) continue;
873  $ffiles = array();
875  $filename = $ffiles[file][0];
876  $fileObj = new ilObjFile();
877  $fileObj->setType("file");
880 
881  // better use this, mime_content_type is deprecated
882  $fileObj->setFileType(ilObjMediaObject::getMimeType($path. "/" . $filename));
883 
884  $fileObj->setFileSize(filesize($path. "/" . $filename));
885  $fileObj->create();
886  $fileObj->createReference();
887  //$fileObj->putInTree($_GET["ref_id"]);
888  //$fileObj->setPermissions($slm->getId ());
889  $fileObj->createDirectory();
890  $fileObj->storeUnzipedFile($path."/" .$filename,ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename)));
891  $fileitem[Entry]="il__file_".$fileObj->getId();
892 
893  }
894  }
895  $pagex = new ilSCORM2004Page($page->getId());
896 
897  $ddoc = new DOMDocument();
898  $ddoc->async = false;
899  $ddoc->preserveWhiteSpace = false;
900  $ddoc->formatOutput = false;
901  $ddoc->loadXML($page_xml->asXML());
902  $xpath = new DOMXPath($ddoc);
903  $tnode = $xpath->query('PageContent');
904  $t = "<PageObject>";
905  foreach($tnode as $ttnode)
906  $t .= $ddoc->saveXML($ttnode);
907  $t .="</PageObject>";
908  foreach ($qtis as $old=>$q)
909  $t = str_replace($old,'il__qst_'.$q['pool'], $t);
910  $pagex->setXMLContent($t);
911  $pagex->updateFromXML();
912  }
913  }
Class ilSCORM2004PageNode.
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
static getMimeType($a_file)
get mime type for file
const IL_MO_PARSE_QTI
utf8_encode($string)
utf8-encodes string if it is not a valid utf8-string.
Class ilSCORM2004Page.
Class ilObjFile.
Class ilMediaItem.
Class ilObjMediaObject.
$n
Definition: RandomTest.php:80
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$filename
Definition: buildRTE.php:89
const IL_EXT_LINK
Class ilMapArea.
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
$path
Definition: index.php:22
const IL_MO_VERIFY_QTI
_getDirectory($a_mob_id)
get directory for files of media object (static)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dbRemoveAll()

ilSCORM13Package::dbRemoveAll ( )

Definition at line 1208 of file ilSCORM13Package.php.

References removeCMIData(), and removeCPData().

Referenced by il_import(), and rollback().

1209  {
1210  //dont change order of calls
1211  $this->removeCMIData();
1212  $this->removeCPData();
1213  }
+ 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, and $row.

125  {
126  global $ilDB;
127 
128  header('content-type: text/xml');
129  header('content-disposition: attachment; filename="manifest.xml"');
130 
131  //$row = ilSCORM13DB::getRecord("cp_package", "obj_id",$this->packageId);
132  $res = $ilDB->queryF(
133  'SELECT xmldata FROM cp_package WHERE obj_id = %s',
134  array('integer'),
135  array($this->packageId)
136  );
137  $row = $ilDB->fetchAssoc($res);
138 
139  print($row['xmldata']);
140  }
global $ilDB

◆ exportZIP()

ilSCORM13Package::exportZIP ( )

Definition at line 114 of file ilSCORM13Package.php.

115  {
116  header('content-type: application/zip');
117  header('content-disposition: attachment; filename="' . basename($this->packageFile) . '"');
118  readfile($this->packageFile);
119  }

◆ 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 149 of file ilSCORM13Package.php.

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

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

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

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

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

433  {
434  global $ilDB, $ilLog;
435 
436  $this->packageFolder=$packageFolder;
437  $this->packageId=$slm->getId();
438  $this->imsmanifestFile = $this->packageFolder . '/' . 'imsmanifest.xml';
439  $this->imsmanifest = new DOMDocument;
440  $this->imsmanifest->async = false;
441  $this->imsmanifest->formatOutput = false;
442  $this->imsmanifest->preserveWhiteSpace = false;
443  $this->slm = $slm;
444  if (!@$this->imsmanifest->load($this->imsmanifestFile))
445  {
446  $this->diagnostic[] = 'XML not wellformed';
447  return false;
448  }
449 
450  $this->mani_xpath = new DOMXPath($this->imsmanifest);
451  $this->mani_xpath->registerNamespace("d", "http://www.imsproject.org/xsd/imscp_rootv1p1p2");
452  $this->mani_xpath->registerNamespace("imscp", "http://www.imsglobal.org/xsd/imscp_v1p1");
453  $this->mani_xpath->registerNamespace("imsss", "http://www.imsglobal.org/xsd/imsss");
454 
455 
456  $this->dbImportLM(simplexml_import_dom($this->imsmanifest->documentElement), "",
457  $a_import_sequencing);
458 
459  if(is_dir($packageFolder."/glossary"))
460  {
461  $this->importGlossary($slm,$packageFolder."/glossary");
462  }
463  //die($slm->title);
464 
465  return $slm->title;
466  }
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 302 of file ilSCORM13Package.php.

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

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

References $_GET, $packageFolder, and $slm.

Referenced by il_importLM().

469  {
470  global $ilias;
471  // create and insert object in objecttree
472  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
473  $newObj = new ilObjGlossary();
474  $newObj->setType('glo');
475  $newObj->setTitle('');
476  $newObj->create(true);
477  $newObj->createReference();
478  $newObj->putInTree($_GET["ref_id"]);
479  $newObj->setPermissions($_GET["ref_id"]);
480  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
481 
482  $xml_file = $packageFolder."/glossary.xml";
483 
484  // check whether xml file exists within zip file
485  if (!is_file($xml_file))
486  {
487  return;
488  }
489 
490  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
491  $contParser = new ilContObjParser($newObj, $xml_file, $packageFolder);
492  $contParser->startParsing();
493  $newObj->update();
494  //ilObject::_writeImportId($newObj->getId(), $newObj->getImportId());
495  $slm->setAssignedGlossary($newObj->getId());
496  $slm->update();
497  }
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 670 of file ilSCORM13Package.php.

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

◆ load()

ilSCORM13Package::load (   $packageId)

Definition at line 81 of file ilSCORM13Package.php.

References $ilDB, $lm_set, and $packageId.

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  }
$lm_set
global $ilDB
+ Here is the caller graph for this function:

◆ removeCMIData()

ilSCORM13Package::removeCMIData ( )

Definition at line 1152 of file ilSCORM13Package.php.

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

Referenced by dbRemoveAll().

1153  {
1154  include_once("./Modules/Scorm2004/classes/class.ilSCORM2004DeleteData.php");
1156 
1157  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
1158  ilLPStatusWrapper::_refreshStatus($this->packageId);
1159  }
_refreshStatus($a_obj_id, $a_users=null)
Set dirty.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeCPData()

ilSCORM13Package::removeCPData ( )

Definition at line 1161 of file ilSCORM13Package.php.

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

Referenced by dbRemoveAll().

1162  {
1163  global $ilDB, $ilLog;
1164 
1165  //get relevant nodes
1166  $cp_nodes = array();
1167 
1168  $res = $ilDB->queryF(
1169  'SELECT cp_node.cp_node_id FROM cp_node WHERE cp_node.slm_id = %s',
1170  array('integer'),
1171  array($this->packageId)
1172  );
1173  while($data = $ilDB->fetchAssoc($res))
1174  {
1175  $cp_nodes[] = $data['cp_node_id'];
1176  }
1177 
1178  //remove package data
1179  foreach(self::$elements['cp'] as $t)
1180  {
1181  $t = 'cp_' . $t;
1182 
1183  $in = $ilDB->in(strtolower($t).'.cp_node_id', $cp_nodes, false, 'integer');
1184  $ilDB->manipulate('DELETE FROM '.strtolower($t).' WHERE '.$in);
1185  }
1186 
1187  // remove CP structure entries in tree and node
1188  $ilDB->manipulateF(
1189  'DELETE FROM cp_tree WHERE cp_tree.obj_id = %s',
1190  array('integer'),
1191  array($this->packageId)
1192  );
1193 
1194  $ilDB->manipulateF(
1195  'DELETE FROM cp_node WHERE cp_node.slm_id = %s',
1196  array('integer'),
1197  array($this->packageId)
1198  );
1199 
1200  // remove general package entry
1201  $ilDB->manipulateF(
1202  'DELETE FROM cp_package WHERE cp_package.obj_id = %s',
1203  array('integer'),
1204  array($this->packageId)
1205  );
1206  }
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 656 of file ilSCORM13Package.php.

References $progress.

Referenced by rollback().

657  {
658  $this->progress = $progress;
659  $this->diagnostic[] = $msg;
660  }
+ 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 638 of file ilSCORM13Package.php.

Referenced by dbImportLM().

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

◆ transform()

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

Definition at line 1215 of file ilSCORM13Package.php.

References $r.

Referenced by il_import().

1216  {
1217  $xsl = new DOMDocument;
1218  $xsl->async = false;
1219  if (!@$xsl->load($xslfile))
1220  {
1221  die('ERROR: load StyleSheet ' . $xslfile);
1222  }
1223  $prc = new XSLTProcessor;
1224  $prc->registerPHPFunctions();
1225  $r = @$prc->importStyleSheet($xsl);
1226  if (false===@$prc->importStyleSheet($xsl))
1227  {
1228  die('ERROR: importStyleSheet ' . $xslfile);
1229  }
1230  if ($outputpath)
1231  {
1232  file_put_contents($outputpath, $prc->transformToXML($inputdoc));
1233  }
1234  else
1235  {
1236  return $prc->transformToDoc($inputdoc);
1237  }
1238  }
$r
+ Here is the caller graph for this function:

◆ validate()

ilSCORM13Package::validate (   $doc,
  $schema 
)

Definition at line 1240 of file ilSCORM13Package.php.

Referenced by il_import().

1241  {
1242  libxml_use_internal_errors(true);
1243  $return = @$doc->schemaValidate($schema);
1244  if (!$return)
1245  {
1246  $levels = array(
1247  LIBXML_ERR_ERROR => 'Error',
1248  LIBXML_ERR_FATAL => 'Fatal Error'
1249  );
1250  foreach (libxml_get_errors() as $error)
1251  {
1252  $level = $levels[$error->level];
1253  if (isset($level))
1254  {
1255  $message = trim($error->message);
1256  $this->diagnostic[] = "XSLT $level (Line $error->line) $message";
1257  }
1258  }
1259  libxml_clear_errors();
1260  }
1261  libxml_use_internal_errors(false);
1262  return $return;
1263  }
+ 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:
= array(
'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: