5 require_once
"./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php";
30 const CONVERT_XSL =
'./Modules/Scorm2004/templates/xsl/op/scorm12To2004.xsl';
31 const WRAPPER_HTML =
'./Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/GenericRunTimeWrapper.htm';
32 const WRAPPER_JS =
'./Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/SCOPlayerWrapper.js';
40 public function __construct($a_id = 0, $a_call_by_reference =
true)
44 $this->lng = $DIC->language();
45 $this->error = $DIC[
"ilErr"];
46 $this->db = $DIC->database();
47 $this->log = $DIC[
"ilLog"];
48 $this->
user = $DIC->user();
49 $this->tabs = $DIC->tabs();
51 parent::__construct($a_id, $a_call_by_reference);
61 $this->import_sequencing = $a_val;
71 return $this->import_sequencing;
98 if (!function_exists(
'json_encode') || !function_exists(
'json_decode')) {
102 $needs_convert =
false;
109 $check_for_manifest_file = is_file($manifest_file);
114 if (!$check_for_manifest_file) {
115 $ilErr->raiseError($this->lng->txt(
"Manifestfile $manifest_file not found!"),
$ilErr->MESSAGE);
120 if ($check_for_manifest_file) {
121 $manifest_file_array = file($manifest_file);
123 foreach ($manifest_file_array as $mfa) {
125 if (@iconv(
'UTF-8',
'UTF-8', $mfa) != $mfa) {
126 $needs_convert =
true;
134 $estimated_manifest_filesize = filesize($manifest_file) * 2;
138 $check_disc_free = 2;
143 if ($needs_convert) {
145 if ($check_for_manifest_file && ($check_disc_free > 1)) {
148 if (!copy($manifest_file, $manifest_file .
".old")) {
149 echo "Failed to copy $manifest_file...<br>\n";
154 $f_write_handler =
fopen($manifest_file .
".new",
"w");
155 $f_read_handler =
fopen($manifest_file .
".old",
"r");
156 while (!feof($f_read_handler)) {
157 $zeile = fgets($f_read_handler);
159 fputs($f_write_handler, utf8_encode($zeile));
161 fclose($f_read_handler);
162 fclose($f_write_handler);
165 if (!copy($manifest_file .
".new", $manifest_file)) {
166 echo "Failed to copy $manifest_file...<br>\n";
169 if (!@is_file($manifest_file)) {
170 $ilErr->raiseError($this->lng->txt(
"cont_no_manifest"),
$ilErr->WARNING);
175 if (!($check_disc_free > 1)) {
176 $ilErr->raiseError($this->lng->txt(
"Not enough space left on device!"),
$ilErr->MESSAGE);
182 $hmani =
fopen($manifest_file,
"r");
183 $start = fread($hmani, 3);
184 if (strtolower(bin2hex(
$start)) ==
"efbbbf") {
185 $f_write_handler =
fopen($manifest_file .
".new",
"w");
186 while (!feof($hmani)) {
187 $n = fread($hmani, 900);
188 fputs($f_write_handler,
$n);
190 fclose($f_write_handler);
194 if (!copy($manifest_file .
".new", $manifest_file)) {
195 echo "Failed to copy $manifest_file...<br>\n";
203 if (
$_POST[
"validate"] ==
"y") {
217 include_once(
"./Modules/Scorm2004/classes/ilSCORM13Package.php");
220 return $newPack->il_importLM(
233 $out = file_get_contents($this->imsmanifestFile);
234 $check =
'/xmlns="http:\/\/www.imsglobal.org\/xsd\/imscp_v1p1"/';
235 $replace =
"xmlns=\"http://www.imsproject.org/xsd/imscp_rootv1p1p2\"";
236 $out = preg_replace($check, $replace,
$out);
237 file_put_contents($this->imsmanifestFile,
$out);
246 ##check manifest-file for version. Check for schemaversion as this is a required element for SCORM 2004 247 ##accept 2004 3rd Edition an CAM 1.3 as valid schemas 251 $this->imsmanifestFile = $manifest;
252 $doc =
new DomDocument();
256 $doc->load($this->imsmanifestFile);
257 $elements = $doc->getElementsByTagName(
"schemaversion");
258 $schema = $elements->item(0)->nodeValue;
259 if (strtolower(trim($schema)) ==
"cam 1.3" || strtolower(trim($schema)) ==
"2004 3rd edition" || strtolower(trim($schema)) ==
"2004 4th edition") {
261 $this->converted =
false;
264 $this->converted =
true;
271 die(
"organizations missing in manifest");
276 $organization = $doc->getElementsByTagName(
"organization");
277 $ident = $organization->item(0)->getAttribute(
"identifier");
285 $wrapperdir = $this->packageFolder .
"/GenericRunTimeWrapper1.0_aadlc";
287 copy(self::WRAPPER_HTML, $wrapperdir .
"/GenericRunTimeWrapper.htm");
288 copy(self::WRAPPER_JS, $wrapperdir .
"/SCOPlayerWrapper.js");
291 $this->backupManifest = $this->packageFolder .
"/imsmanifest.xml.back";
292 $ret = copy($this->imsmanifestFile, $this->backupManifest);
295 $this->totransform = $doc;
296 $ilLog->write(
"SCORM: about to transform to SCORM 2004");
300 $xsl->load(self::CONVERT_XSL);
301 $prc =
new XSLTProcessor;
302 $r = @$prc->importStyleSheet($xsl);
304 file_put_contents($this->imsmanifestFile, $prc->transformToXML($this->totransform));
306 $ilLog->write(
"SCORM: Transformation completed");
322 $ilDB = $DIC->database();
326 SELECT MAX(c_timestamp) last_access 327 FROM cmi_node, cp_node 328 WHERE cmi_node.cp_node_id = cp_node.cp_node_id 329 AND cp_node.slm_id = %s 331 GROUP BY c_timestamp',
332 array(
'integer',
'integer'),
333 array($a_obj_id, $a_usr_id)
337 return $row[
"last_access"];
396 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004DeleteData.php");
397 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
398 include_once(
"./Services/Tracking/classes/class.ilChangeEvent.php");
401 foreach ($a_users as
$user) {
417 $sco_set =
$ilDB->queryF(
419 SELECT DISTINCT cmi_node.cp_node_id id 420 FROM cp_node, cmi_node 422 AND cp_node.cp_node_id = cmi_node.cp_node_id 423 ORDER BY cmi_node.cp_node_id ',
425 array($this->
getId())
430 while ($sco_rec =
$ilDB->fetchAssoc($sco_set)) {
431 $item[
'id'] = $sco_rec[
"id"];
432 $item[
'title'] = self::_lookupItemTitle($sco_rec[
"id"]);
433 $items[count($items)] = $item;
447 $val_set =
$ilDB->queryF(
448 'SELECT cp_node_id FROM cp_node 450 AND cp_node.slm_id = %s',
451 array(
'text',
'integer'),
452 array(
'item',$this->
getId())
454 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
455 array_push($scos, $val_rec[
'cp_node_id']);
458 foreach ($scos as $sco) {
459 $data_set =
$ilDB->queryF(
461 SELECT c_timestamp last_access, total_time, success_status, completion_status, 462 c_raw, scaled, cp_node_id 464 WHERE cp_node_id = %s 466 array(
'integer',
'integer'),
467 array($sco,$a_user_id)
470 while ($data_rec =
$ilDB->fetchAssoc($data_set)) {
471 if ($data_rec[
"success_status"] !=
"" && $data_rec[
"success_status"] !=
"unknown") {
472 $status = $data_rec[
"success_status"];
474 if ($data_rec[
"completion_status"] ==
"") {
477 $status = $data_rec[
"completion_status"];
483 if ($data_rec[
"c_raw"] != null) {
484 $score = $data_rec[
"c_raw"];
485 if ($data_rec[
"scaled"] != null) {
489 if ($data_rec[
"scaled"] != null) {
490 $score .= ($data_rec[
"scaled"] * 100) .
"%";
492 $title = self::_lookupItemTitle($data_rec[
"cp_node_id"]);
494 $data[] = array(
"sco_id" => $data_rec[
"cp_node_id"],
495 "score" => $score,
"time" =>
$time,
"status" => $status,
"last_access" => $last_access,
"title" =>
$title);
497 $data_rec[
"total_time"] = self::_ISODurationToCentisec($data_rec[
"total_time"]) / 100;
498 $data[$data_rec[
"cp_node_id"]] = $data_rec;
513 $val_set =
$ilDB->queryF(
514 'SELECT package_attempts FROM sahs_user WHERE user_id = %s AND obj_id = %s',
515 array(
'integer',
'integer'),
516 array($a_user_id, $this->
getId())
519 $val_rec =
$ilDB->fetchAssoc($val_set);
521 if ($val_rec[
"package_attempts"] == null) {
522 $val_rec[
"package_attempts"] =
"";
525 return $val_rec[
"package_attempts"];
535 $val_set =
$ilDB->queryF(
536 'SELECT module_version FROM sahs_user WHERE user_id = %s AND obj_id = %s',
537 array(
'integer',
'integer'),
538 array($a_user_id, $this->
getId())
541 $val_rec =
$ilDB->fetchAssoc($val_set);
543 if ($val_rec[
"module_version"] == null) {
544 $val_rec[
"module_version"] =
"";
546 return $val_rec[
"module_version"];
562 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
565 include_once
'./Services/Object/classes/class.ilObjectLP.php';
567 $collection = $olp->getCollectionInstance();
569 $scos = $collection->getItems();
572 $fhandle =
fopen($a_file,
"r");
574 $obj_id = $this->getID();
576 $usersToDelete = array();
577 $fields = fgetcsv($fhandle, 4096,
';');
578 while (($csv_rows = fgetcsv($fhandle, 4096,
";")) !==
false) {
579 $data = array_combine($fields, $csv_rows);
581 if (
$data[
"Login"]) {
584 if (
$data[
"login"]) {
588 if (
$data[
"user"] && is_numeric(
$data[
"user"])) {
589 $user_id =
$data[
"user"];
594 $date_ex = explode(
'.',
$data[
'Date']);
595 $last_access = implode(
'-', array($date_ex[2], $date_ex[1], $date_ex[0]));
597 if (
$data[
'LastAccess']) {
598 $last_access =
$data[
'LastAccess'];
603 if (
$data[
"Status"]) {
604 if (is_numeric(
$data[
"Status"])) {
605 $status =
$data[
"Status"];
615 if (
$data[
"Attempts"]) {
616 $attempts =
$data[
"Attempts"];
619 $percentage_completed = 0;
621 $percentage_completed = 100;
622 } elseif (
$data[
'percentageCompletedSCOs']) {
623 $percentage_completed =
$data[
'percentageCompletedSCOs'];
626 $sco_total_time_sec = null;
627 if (
$data[
'SumTotal_timeSeconds']) {
628 $sco_total_time_sec =
$data[
'SumTotal_timeSeconds'];
632 $usersToDelete[] = $user_id;
634 $this->
importSuccessForSahsUser($user_id, $last_access, $status, $attempts, $percentage_completed, $sco_total_time_sec);
639 foreach ($scos as $sco_id) {
642 SELECT completion_status, success_status, user_id FROM cmi_node WHERE cp_node_id = %s AND user_id = %s',
643 array(
'integer',
'integer'),
644 array($sco_id,$user_id)
648 $nextId =
$ilDB->nextId(
'cmi_node');
649 $val_set =
$ilDB->manipulateF(
650 'INSERT INTO cmi_node 651 (cp_node_id,user_id,completion_status,c_timestamp,cmi_node_id) 652 VALUES(%s,%s,%s,%s,%s)',
653 array(
'integer',
'integer',
'text',
'timestamp',
'integer'),
654 array($sco_id,$user_id,
'completed',$last_access,$nextId)
659 if ((
$row[
"completion_status"] ==
"completed" &&
$row[
"success_status"] !=
"failed") ||
$row[
"success_status"] ==
"passed") {
660 if ($doUpdate !=
true) {
667 if ($doUpdate ==
true) {
671 'completion_status' => array(
'text',
'completed'),
672 'success_status' => array(
'text',
''),
673 'suspend_data' => array(
'text',
''),
674 'c_timestamp' => array(
'timestamp', $last_access)
677 'user_id' => array(
'integer', $user_id),
678 'cp_node_id' => array(
'integer', $sco_id)
690 if (count($usersToDelete) > 0) {
695 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
709 $aV = array(0, 0, 0, 0, 0, 0);
712 if (strpos($str,
"P") != 0) {
716 $aT = array(
"Y",
"M",
"D",
"H",
"M",
"S");
719 $str = substr($str, 1);
720 for (
$i = 0;
$i < count($aT);
$i++) {
721 if (strpos($str,
"T") === 0) {
722 $str = substr($str, 1);
726 $p = strpos($str, $aT[
$i]);
729 if ($i == 1 && strpos($str,
"T") > -1 && strpos($str,
"T") < $p) {
732 if ($aT[$i] ==
"S") {
733 $aV[
$i] = substr($str, 0, $p);
735 $aV[
$i] = intval(substr($str, 0, $p));
737 if (!is_numeric($aV[$i])) {
740 } elseif ($i > 2 && !$bTFound) {
744 $str = substr($str, $p + 1);
747 if (!$bErr && strlen($str) != 0) {
755 return $aV[0] * 3155760000 + $aV[1] * 262980000 + $aV[2] * 8640000 + $aV[3] * 360000 + $aV[4] * 6000 + round($aV[5] * 100);
761 $val_set = $DIC->database()->queryF(
763 SELECT distinct(cp_node.cp_node_id) FROM cp_node,cp_resource,cp_item 764 WHERE cp_item.cp_node_id = cp_node.cp_node_id 765 AND cp_item.resourceid = cp_resource.id 768 AND cp_node.slm_id = %s ',
769 array(
'text',
'text',
'integer'),
770 array(
'sco',
'item',$a_slm_id)
772 return $DIC->database()->numRows($val_set);
783 $val_set =
$ilDB->queryF(
785 SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item 786 WHERE cp_item.cp_node_id = cp_node.cp_node_id 787 AND cp_item.resourceid = cp_resource.id 790 AND cp_node.slm_id = %s ',
791 array(
'text',
'text',
'integer'),
792 array(
'sco',
'item',$this->
getId())
795 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
796 array_push($scos, $val_rec[
'cp_node_id']);
803 for (
$i = 0;
$i < count($scos);
$i++) {
804 $val_set =
$ilDB->queryF(
806 SELECT * FROM cmi_node 809 AND (completion_status=%s OR success_status=%s))',
810 array(
'integer',
'integer',
'text',
'text'),
811 array($a_user,$scos[
$i],
'completed',
'passed')
814 if (
$ilDB->numRows($val_set) > 0) {
816 $key = array_search($scos[$i], $scos_c);
817 unset($scos_c[
$key]);
821 if (count($scos_c) == 0) {
839 $ilDB = $DIC->database();
844 $val_set =
$ilDB->queryF(
846 SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item 847 WHERE cp_item.cp_node_id = cp_node.cp_node_id 848 AND cp_item.resourceid = cp_resource.id 851 AND cp_node.slm_id = %s',
852 array(
'text',
'text',
'integer'),
853 array(
'sco' ,
'item',$a_id)
855 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
856 array_push($scos, $val_rec[
'cp_node_id']);
862 for (
$i = 0;
$i < count($scos);
$i++) {
863 $val_set =
$ilDB->queryF(
865 SELECT * FROM cmi_node 868 AND (completion_status = %s OR success_status = %s))',
869 array(
'integer',
'integer',
'text',
'text'),
870 array($a_user,$scos[
$i],
'completed',
'passed')
873 if (
$ilDB->numRows($val_set) > 0) {
875 $key = array_search($scos[$i], $scos_c);
876 unset($scos_c[
$key]);
880 if (count($scos_c) == 0) {
899 $ilDB = $DIC->database();
903 $val_set =
$ilDB->queryF(
904 "SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item WHERE" .
905 " cp_item.cp_node_id=cp_node.cp_node_id AND cp_item.resourceId = cp_resource.id AND scormType='sco' AND nodeName='item' AND cp_node.slm_id = %s GROUP BY cp_node.cp_node_id",
909 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
910 array_push($scos, $val_rec[
'cp_node_id']);
914 for (
$i = 0;
$i < count($scos);
$i++) {
915 $val_set =
$ilDB->queryF(
916 "SELECT scaled FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)",
917 array(
'integer',
'integer'),
918 array($a_user, $scos[
$i])
920 if ($val_set->numRows() > 0) {
921 $val_rec =
$ilDB->fetchAssoc($val_set);
922 if ($val_rec[
'scaled'] != null) {
924 $scaled = $val_rec[
'scaled'];
928 $retVal = ($set == 1) ? $scaled : null ;
941 $ilDB = $DIC->database();
944 $item_set =
$ilDB->queryF(
946 SELECT cp_item.* FROM cp_node, cp_item WHERE slm_id = %s 947 AND cp_node.cp_node_id = cp_item.cp_node_id 948 ORDER BY cp_node.cp_node_id ',
954 while ($item_rec =
$ilDB->fetchAssoc($item_set)) {
957 SELECT cp_resource.* FROM cp_node, cp_resource 959 AND cp_node.cp_node_id = cp_resource.cp_node_id 960 AND cp_resource.id = %s ',
961 array(
'integer',
'text'),
962 array($a_obj_id,$item_rec[
"resourceid"])
967 if (
$res[
"scormtype"] ==
"sco") {
968 $items[] = array(
"id" => $item_rec[
"cp_node_id"],
969 "title" => $item_rec[
"title"]);
981 $ilDB = $DIC->database();
983 $status_set =
$ilDB->queryF(
985 SELECT * FROM cmi_gobjective 987 AND objective_id = %s 989 array(
'integer',
'text',
'integer'),
990 array($a_obj_id,
'-course_overall_status-',$a_user_id)
993 if ($status_rec =
$ilDB->fetchAssoc($status_set)) {
994 return $status_rec[
"status"];
1004 $ilDB = $DIC->database();
1007 $status_set =
$ilDB->queryF(
1009 SELECT * FROM cmi_gobjective 1011 AND objective_id = %s 1013 array(
'integer',
'text',
'integer'),
1014 array($a_obj_id,
'-course_overall_status-',$a_user_id)
1017 if ($status_rec =
$ilDB->fetchAssoc($status_set)) {
1018 return $status_rec[
"satisfied"];
1028 $ilDB = $DIC->database();
1030 $status_set =
$ilDB->queryF(
1032 SELECT * FROM cmi_gobjective 1034 AND objective_id = %s 1036 array(
'integer',
'text',
'integer'),
1037 array($a_obj_id,
'-course_overall_status-',$a_user_id)
1040 if ($status_rec =
$ilDB->fetchAssoc($status_set)) {
1041 return $status_rec[
"measure"];
1051 $ilDB = $DIC->database();
1055 SELECT * FROM cp_item 1056 WHERE cp_node_id = %s',
1072 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Tree.php");
1078 $this->slm_tree->addTree($this->
getId(), 1);
1081 include_once(
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1083 $seq_info->insert();
1089 $this->slm_tree->setTreeTablePK(
"slm_id");
1090 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1091 return $this->slm_tree;
1097 $ilTabs->setTabActive(
"sequencing");
1099 include_once(
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1102 return $control_settings;
1107 include_once(
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1113 $control_settings->insert();
1129 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1130 $this->slm_tree->setTreeTablePK(
"slm_id");
1132 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
1137 if (!$first_child) {
1140 $target_parent = $this->slm_tree->getParentId(
$target_id);
1144 if ($source_obj->getType() ==
"page") {
1145 if ($this->slm_tree->isInTree($source_obj->getId())) {
1146 $node_data = $this->slm_tree->getNodeData($source_obj->getId());
1149 if ($movecopy ==
"move") {
1150 $parent_id = $this->slm_tree->getParentId($source_obj->getId());
1151 $this->slm_tree->deleteTree($node_data);
1173 if (!$this->slm_tree->isInTree($source_obj->getId())) {
1177 } elseif ($as_subitem) {
1180 $pg_childs = $this->slm_tree->getChildsByType($parent,
"page");
1181 if (count($pg_childs) != 0) {
1182 $target_pos = $pg_childs[count($pg_childs) - 1][
"obj_id"];
1186 $parent = $target_parent;
1190 $this->slm_tree->insertNode(
1191 $source_obj->getId(),
1214 if ($source_obj->getType() ==
"sco" || $source_obj->getType() ==
"ass") {
1216 $source_node = $this->slm_tree->getNodeData($source_id);
1217 $subnodes = $this->slm_tree->getSubtree($source_node);
1220 foreach ($subnodes as $subnode) {
1232 $pg_childs = $this->slm_tree->getChildsByType($target_parent,
"page");
1233 if (count($pg_childs) != 0) {
1234 $target_pos = $pg_childs[count($pg_childs) - 1][
"obj_id"];
1236 } elseif ($as_subitem) {
1239 $childs = $this->slm_tree->getChilds($target_parent);
1240 if (count($childs) != 0) {
1241 $target_pos = $childs[count($childs) - 1][
"obj_id"];
1246 if ($movecopy ==
"move") {
1247 $this->slm_tree->deleteTree($source_node);
1256 if (!$this->slm_tree->isInTree($source_id)) {
1257 $this->slm_tree->insertNode($source_id, $target_parent, $target_pos);
1260 if ($movecopy ==
"move") {
1261 foreach ($subnodes as $node) {
1262 if ($node[
"obj_id"] != $source_id) {
1263 $this->slm_tree->insertNode($node[
"obj_id"], $node[
"parent"]);
1274 if ($source_obj->getType() ==
"chap") {
1276 $source_node = $this->slm_tree->getNodeData($source_id);
1277 $subnodes = $this->slm_tree->getSubtree($source_node);
1280 foreach ($subnodes as $subnode) {
1297 } elseif ($as_subitem) {
1300 $childs = $this->slm_tree->getChilds($target_parent);
1301 if (count($childs) != 0) {
1302 $target_pos = $childs[count($childs) - 1][
"obj_id"];
1307 if ($movecopy ==
"move") {
1308 $this->slm_tree->deleteTree($source_node);
1317 if (!$this->slm_tree->isInTree($source_id)) {
1318 $this->slm_tree->insertNode($source_id, $target_parent, $target_pos);
1321 if ($movecopy ==
"move") {
1322 foreach ($subnodes as $node) {
1323 if ($node[
"obj_id"] != $source_id) {
1324 $this->slm_tree->insertNode($node[
"obj_id"], $node[
"parent"]);
1341 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Export.php");
1343 $export =
new ilSCORM2004Export($this);
1344 foreach ($export->getSupportedExportTypes() as
$type) {
1345 $dir = $export->getExportDirectoryForType(
$type);
1347 if (!@is_dir($dir)
or !is_writeable($dir)) {
1354 while ($entry = $cdir->read()) {
1355 if ($entry !=
"." and 1358 preg_match(
"~^[0-9]{10}_{2}[0-9]+_{2}(" . $this->
getType() .
"_)*[0-9]+\.zip\$~", $entry)
or 1359 preg_match(
"~^[0-9]{10}_{2}[0-9]+_{2}(" . $this->
getType() .
"_)*[0-9]+\.pdf\$~", $entry)
or 1360 preg_match(
"~^[0-9]{10}_{2}[0-9]+_{2}(" . $this->
getType() .
"_)*[0-9]+\.iso\$~", $entry)
1362 $file[$entry .
$type] = array(
"type" =>
$type,
"file" => $entry,
1363 "size" => filesize($dir .
"/" . $entry));
1386 $metadata_xml = $a_xml_writer->xmlDumpMem(
false);
1387 $a_xml_writer->_XmlWriter;
1389 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/metadata.xsl");
1390 $args = array(
'/_xml' => $metadata_xml ,
'/_xsl' => $xsl );
1392 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", null, $args, null);
1394 file_put_contents($a_target_dir .
'/indexMD.xml',
$output);
1399 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1400 include_once(
"./Modules/Glossary/classes/class.ilGlossaryExport.php");
1403 $glo_xml_writer->xmlSetDtdDef(
"<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
1405 $glo_xml_writer->xmlHeader();
1409 $glos->exportXML($glo_xml_writer, $glos_export->getInstId(), $a_target_dir .
"/glossary", $expLog);
1410 $glo_xml_writer->xmlDumpFile($a_target_dir .
"/glossary/glossary.xml");
1411 $glo_xml_writer->_XmlWriter;
1416 $a_xml_writer->
xmlSetDtdDef(
"<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
1419 $a_xml_writer->xmlSetGenCmt(
"Export of ILIAS Content Module " . $this->
getId() .
" of installation " . $a_inst .
".");
1422 $a_xml_writer->xmlHeader();
1424 $a_xml_writer->xmlStartTag(
"ContentObject", array(
"Type" =>
"SCORM2004LearningModule"));
1432 $expLog->write(date(
"[y-m-d H:i:s] ") .
"Start Export Sco Objects");
1434 $expLog->write(date(
"[y-m-d H:i:s] ") .
"Finished Export Sco Objects");
1436 $a_xml_writer->xmlEndTag(
"ContentObject");
1437 $a_xml_writer->xmlDumpFile($a_target_dir .
'/index.xml',
false);
1439 if ($ver ==
"2004 4th") {
1444 if ($ver ==
"2004 3rd") {
1450 $css_dir = $a_target_dir .
"/ilias_css_4_2";
1452 include_once(
"./Modules/Scorm2004/classes/class.ilScormExportUtil.php");
1456 include_once(
"./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php");
1458 $manifestBuilder->buildManifest($ver, $revision);
1459 $manifestBuilder->dump($a_target_dir);
1461 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1462 $args = array(
'/_xml' => file_get_contents($a_target_dir .
"/imsmanifest.xml"),
'/_xsl' => $xsl );
1464 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", null, $args, null);
1466 fputs(
fopen($a_target_dir .
'/index.html',
'w+'),
$output);
1470 if ($revision ==
"3rd") {
1471 ilUtil::rCopy(
'./libs/ilias/Scorm2004/xsd/adlcp_130_export_2004', $a_target_dir,
false);
1474 if ($revision ==
"4th") {
1475 ilUtil::rCopy(
'./libs/ilias/Scorm2004/xsd/adlcp_130_export_2004_4th', $a_target_dir,
false);
1479 ilUtil::rCopy(
'./libs/ilias/Scorm2004/xsd/adlcp_120_export_12', $a_target_dir,
false);
1483 $a_xml_writer->_XmlWriter;
1490 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1491 $tree->setTreeTablePK(
"slm_id");
1492 foreach (
$tree->getSubTree(
$tree->getNodeData(
$tree->getRootId()),
true,
'sco') as $sco) {
1493 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1494 $sco_folder = $a_target_dir .
"/" . $sco[
'obj_id'];
1497 $node->exportHTML4PDF($a_inst, $sco_folder, $expLog);
1504 $a_xml_writer->
xmlStartTag(
"ContentObject", array(
"Type" =>
"SCORM2004SCO"));
1507 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1508 $tree->setTreeTablePK(
"slm_id");
1509 foreach (
$tree->getSubTree(
$tree->getNodeData(
$tree->getRootId()),
true,
'sco') as $sco) {
1510 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1511 $sco_folder = $a_target_dir .
"/" . $sco[
'obj_id'];
1514 $node->exportPDFPrepareXmlNFiles($a_inst, $a_target_dir, $expLog, $a_xml_writer);
1518 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1519 include_once(
"./Modules/Glossary/classes/class.ilGlossaryExport.php");
1522 $glos->exportXML($a_xml_writer, $glos_export->getInstId(), $a_target_dir .
"/glossary", $expLog);
1524 $a_xml_writer->xmlEndTag(
"ContentObject");
1525 include_once
'Services/Transformation/classes/class.ilXML2FO.php';
1527 $xml2FO->setXSLTLocation(
'./Modules/Scorm2004/templates/xsl/contentobject2fo.xsl');
1528 $xml2FO->setXMLString($a_xml_writer->xmlDumpMem());
1529 $xml2FO->setXSLTParams(array(
'target_dir' => $a_target_dir));
1530 $xml2FO->transform();
1531 $fo_string = $xml2FO->getFOString();
1532 $fo_xml = simplexml_load_string($fo_string);
1533 $fo_ext = $fo_xml->xpath(
"//fo:declarations");
1534 $fo_ext = $fo_ext[0];
1536 include_once
"./Services/Utilities/classes/class.ilFileUtils.php";
1540 $e = $fo_ext->addChild(
"fox:embedded-file",
"",
"http://xml.apache.org/fop/extensions");
1541 $e->addAttribute(
"src",
$results[path][
$key] . $value);
1542 $e->addAttribute(
"name", $value);
1543 $e->addAttribute(
"desc",
"");
1546 $fo_string = $fo_xml->asXML();
1547 $a_xml_writer->_XmlWriter;
1553 $one_file =
fopen($a_target_dir .
'/index.html',
'w+');
1554 $this->
exportHTML($a_inst, $a_target_dir, $expLog, $one_file);
1561 public function exportHTML($a_inst, $a_target_dir, &$expLog, $a_one_file =
"")
1589 if ($a_one_file ==
"") {
1590 include_once(
"./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php");
1592 $manifestBuilder->buildManifest(
'12');
1594 include_once(
"Services/Frameset/classes/class.ilFramesetGUI.php");
1596 $fs_gui->setFramesetTitle($this->
getTitle());
1597 $fs_gui->setMainFrameSource(
"");
1598 $fs_gui->setSideFrameSource(
"toc.html");
1599 $fs_gui->setMainFrameName(
"content");
1600 $fs_gui->setSideFrameName(
"toc");
1602 fputs(
fopen($a_target_dir .
'/index.html',
'w+'),
$output);
1604 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1605 $xml = simplexml_load_string($manifestBuilder->writer->xmlDumpMem());
1606 $args = array(
'/_xml' =>
$xml->organizations->organization->asXml(),
'/_xsl' => $xsl );
1608 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", null, $args, null);
1610 fputs(
fopen($a_target_dir .
'/toc.html',
'w+'),
$output);
1623 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
1625 $md2xml->setExportMode(
true);
1626 $md2xml->startExport();
1627 $a_xml_writer->appendXML($md2xml->getXML());
1638 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
1640 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1641 $tree->setTreeTablePK(
"slm_id");
1642 $a_xml_writer->xmlStartTag(
"StructureObject");
1643 foreach (
$tree->getFilteredSubTree(
$tree->getRootId(), array(
'page')) as $obj) {
1644 if ($obj[
'type'] ==
'') {
1649 $md2xml =
new ilMD2XML($this->
getId(), $obj[
'obj_id'], $obj[
'type']);
1650 $md2xml->setExportMode(
true);
1651 $md2xml->startExport();
1652 $a_xml_writer->appendXML($md2xml->getXML());
1654 $a_xml_writer->xmlEndTag(
"StructureObject");
1667 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1668 $tree->setTreeTablePK(
"slm_id");
1669 foreach (
$tree->getSubTree(
$tree->getNodeData(
$tree->getRootId()),
true, array(
'sco',
'ass')) as $sco) {
1670 if ($sco[
'type'] ==
"sco") {
1671 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1672 $sco_folder = $a_target_dir .
"/" . $sco[
'obj_id'];
1675 $node->exportScorm($a_inst, $sco_folder, $ver, $expLog);
1677 if ($sco[
'type'] ==
"ass") {
1678 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php");
1679 $sco_folder = $a_target_dir .
"/" . $sco[
'obj_id'];
1682 $node->exportScorm($a_inst, $sco_folder, $ver, $expLog);
1695 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1696 $tree->setTreeTablePK(
"slm_id");
1699 if ($a_one_file !=
"") {
1703 $sco_tpl =
new ilTemplate(
"tpl.sco.html",
true,
true,
"Modules/Scorm2004");
1704 include_once(
"./Services/COPage/classes/class.ilCOPageHTMLExport.php");
1706 $sco_tpl = $page_html_export->getPreparedMainTemplate($sco_tpl);
1708 $sco_tpl->setCurrentBlock(
"js_file");
1709 $sco_tpl->setVariable(
"JS_FILE",
"./js/pure.js");
1710 $sco_tpl->parseCurrentBlock();
1711 $sco_tpl->setCurrentBlock(
"js_file");
1712 $sco_tpl->setVariable(
"JS_FILE",
"./js/question_handling.js");
1713 $sco_tpl->parseCurrentBlock();
1716 $sco_tpl->setCurrentBlock(
"head");
1717 $sco_tpl->parseCurrentBlock();
1718 fputs($a_one_file, $sco_tpl->get(
"head"));
1721 include_once(
"./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php");
1723 $manifestBuilder->buildManifest(
'12');
1724 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1725 $xml = simplexml_load_string($manifestBuilder->writer->xmlDumpMem());
1726 $args = array(
'/_xml' =>
$xml->organizations->organization->asXml(),
'/_xsl' => $xsl );
1728 $params = array(
"one_page" =>
"y");
1729 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", null, $args,
$params);
1734 foreach (
$tree->getSubTree(
$tree->getNodeData(
$tree->getRootId()),
true,
'sco') as $sco) {
1735 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1736 $sco_folder = $a_target_dir .
"/" . $sco[
'obj_id'];
1740 if ($a_one_file ==
"") {
1741 $node->exportHTML($a_inst, $sco_folder, $expLog, $a_one_file);
1743 $node->exportHTMLPageObjects(
1754 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1761 if ($a_one_file !=
"") {
1763 fputs($a_one_file, $sco_tpl->get(
"tail"));
1776 include_once(
"./Services/Style/System/classes/class.ilSystemStyleHTMLExport.php");
1778 $this->sys_style_html_export->export();
1781 include_once(
"./Services/COPage/classes/class.ilCOPageHTMLExport.php");
1783 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1784 $this->co_page_html_export->setContentStyleId(
1787 $this->co_page_html_export->createDirectories();
1788 $this->co_page_html_export->exportStyles();
1789 $this->co_page_html_export->exportSupportScripts();
1791 include_once(
"./Services/MediaObjects/classes/class.ilPlayerUtil.php");
1799 include_once(
"./Services/MediaObjects/classes/class.ilPlayerUtil.php");
1804 copy(
'./Modules/Scorm2004/scripts/scorm_2004.js', $a_target_dir .
'/js/scorm.js');
1805 copy(
'./Modules/Scorm2004/scripts/pager.js', $a_target_dir .
'/js/pager.js');
1806 copy(
'./Modules/Scorm2004/scripts/questions/pure.js', $a_target_dir .
'/js/pure.js');
1808 './Modules/Scorm2004/scripts/questions/question_handling.js',
1809 $a_target_dir .
'/js/question_handling.js' 1822 return $this->public_export_file[
$a_type];
1831 include_once(
"./Modules/File/classes/class.ilObjFile.php");
1833 foreach ($this->file_ids as $file_id) {
1834 $expLog->write(date(
"[y-m-d H:i:s] ") .
"File Item " . $file_id);
1835 $file_obj =
new ilObjFile($file_id,
false);
1836 $file_obj->export($a_target_dir);
1846 $this->public_export_file[
$a_type] = $a_file;
1863 $ilDB = $DIC->database();
1868 'SELECT cp_node.cp_node_id ' 1869 .
'FROM cp_node, cp_resource, cp_item ' 1870 .
'WHERE cp_item.cp_node_id = cp_node.cp_node_id ' 1871 .
'AND cp_item.resourceId = cp_resource.id ' 1872 .
'AND scormType = ' .
$ilDB->quote(
'sco',
'text') .
' ' 1873 .
'AND nodeName = ' .
$ilDB->quote(
'item',
'text') .
' ' 1874 .
'AND cp_node.slm_id = ' .
$ilDB->quote($a_id,
'integer') .
' ' 1875 .
'GROUP BY cp_node.cp_node_id' 1879 array_push($scos,
$row[
'cp_node_id']);
1884 for (
$i = 0;
$i < count($scos);
$i++) {
1886 'SELECT c_max FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)',
1887 array(
'integer',
'integer'),
1888 array($a_user, $scos[
$i])
1893 if (
$row[
'c_max'] != null) {
1895 $max =
$row[
'c_max'];
1899 $retVal = ($set == 1) ? $max : null;
1908 $ilDB = $DIC->database();
1909 $retAr = array(
"raw" => null,
"max" => null,
"scaled" => null);
1910 $val_set =
$ilDB->queryF(
1911 "SELECT c_raw, c_max, scaled FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)",
1912 array(
'integer',
'integer'),
1913 array($a_user, $a_cp_node_id)
1915 if ($val_set->numRows() > 0) {
1916 $val_rec =
$ilDB->fetchAssoc($val_set);
1917 $retAr[
"raw"] = $val_rec[
'c_raw'];
1918 $retAr[
"max"] = $val_rec[
'c_max'];
1919 $retAr[
"scaled"] = $val_rec[
'scaled'];
1920 if ($val_rec[
'scaled'] == null && $val_rec[
'c_raw'] != null && $val_rec[
'c_max'] != null) {
1921 $retAr[
"scaled"] = ($val_rec[
'c_raw'] / $val_rec[
'c_max']);
1936 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1940 $new_id = $style_obj->ilClone();
1941 $a_new_obj->setStyleSheetId($new_id);
1942 $a_new_obj->update();
1945 $a_new_obj->createScorm2004Tree();
1946 $source_tree = $this->
getTree();
1947 $target_tree_root_id = $a_new_obj->getTree()->readRootId();
1948 $childs = $source_tree->getChilds($source_tree->readRootId());
1949 $a_copied_nodes = array();
1950 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
1951 foreach ($childs as
$c) {
1955 $target_tree_root_id,
const LP_STATUS_COMPLETED_NUM
static _lookupLastAccess($a_obj_id, $a_usr_id)
Return the last access timestamp for a given user.
getStyleSheetId()
get ID of assigned style sheet object
static _getTrackingItems($a_obj_id)
get all tracking items of scorm object
copyAuthoredContent($a_new_obj)
Copy authored content (everything done with the editor.
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
exportHTML4PDF($a_inst, $a_target_dir, &$expLog)
exportHTMLScoObjects($a_inst, $a_target_dir, &$expLog, $a_one_file="")
getTrackingDataAgg($a_user_id, $raw=false)
xmlSetDtdDef($dtdDef)
Sets dtd definition.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
HTML export class for pages.
static exportContentCSS($a_slm_object, $a_target_dir)
Export lm content css to a directory.
const LP_STATUS_NOT_ATTEMPTED
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _getSatisfied($a_obj_id, $a_user_id)
static removeCMIDataForUserAndPackage($user_id, $packageId)
HTML export class for system styles.
const LP_STATUS_IN_PROGRESS_NUM
getAssignedGlossary()
get assigned glossary
getEditable()
Get Editable.
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
prepareHTMLExporter($a_target_dir)
Prepare HTML exporter.
static now()
Return current timestamp in Y-m-d H:i:s format.
static _getScores2004ForUser($a_cp_node_id, $a_user)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
exportXMLStructureObjects(&$a_xml_writer, $a_inst, &$expLog)
export structure objects to xml (see ilias_co.dtd)
if($source===NULL) $organizations
const LP_STATUS_IN_PROGRESS
static _lookupStandard($a_id)
Lookup standard flag.
setImportSequencing($a_val)
Set import sequencing.
getDataDirectory($mode="filesystem")
get data directory of lm
exportHTMLOne($a_inst, $a_target_dir, &$expLog)
exportFileItems($a_target_dir, &$expLog)
export files of file itmes
static secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
foreach($_POST as $key=> $value) $res
getId()
get object id public
static getInstance($a_slm_object, $a_id=0, $a_halt=true)
validate($directory)
Validate all XML-Files in a SCOM-Directory.
deleteTrackingDataOfUsers($a_users)
get all tracked items of current user
getTrackedItems()
get all tracked items of current user
exportXMLMetaData(&$a_xml_writer)
export content objects meta data to xml (see ilias_co.dtd)
static getQuantityOfSCOs(int $a_slm_id)
special template class to simplify handling of ITX/PEAR
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
executeDragDrop($source_id, $target_id, $first_child, $as_subitem=false, $movecopy="move")
Execute Drag Drop Action.
static _getUniqueScaledScoreForUser($a_id, $a_user)
Get the Unique Scaled Score of a course Conditions: Only one SCO may set cmi.score.scaled.
getTitle()
get object title public
static getFlashVideoPlayerDirectory()
Get flash video player directory.
Class ilSCORM2004Sequencing.
getType()
get object type public
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
importSuccessForSahsUser($user_id, $last_access, $status, $attempts=null, $percentage_completed=null, $sco_total_time_sec=null)
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
__construct($a_id=0, $a_call_by_reference=true)
Constructor public.
const LP_STATUS_NOT_ATTEMPTED_NUM
static _getMeasure($a_obj_id, $a_user_id)
getCourseCompletionForUser($a_user)
exportXMLScoObjects($a_inst, $a_target_dir, $ver, &$expLog)
export page objects to xml (see ilias_co.dtd)
getAttemptsForUser($a_user_id)
get number of atttempts for a certain user and package
exportHTML($a_inst, $a_target_dir, &$expLog, $a_one_file="")
Export SCORM package to HTML.
static _deleteReadEventsForUsers($a_obj_id, array $a_user_ids)
Class ilObjSCORM2004LearningModule.
static copyPlayerFilesToTargetDirectory($a_target_dir)
Copy css files to target dir.
static pasteTree( $a_target_slm, $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy=false, $a_from_clipboard=true, $a_source_parent_type="")
Paste item (tree) from clipboard or other learning module to target scorm learning module...
updateSequencingSettings()
createScorm2004Tree()
Create Scorm 2004 Tree used by Editor.
exportPDF($a_inst, $a_target_dir, &$expLog)
static _getMaxScoreForUser($a_id, $a_user)
Returns score.max for the learning module, refered to the last sco where score.max is set...
static _ISODurationToCentisec($str)
convert ISO 8601 Timeperiods to centiseconds ta
static recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
Export class for content objects.
setPublicExportFile($a_type, $a_file)
getPublicExportFile($a_type)
get public export file
static yn2tf($a_yn)
convert "y"/"n" to true/false
static getInstance($a_obj_id)
readObject()
read manifest file public
static _lookupItemTitle($a_node_id)
convert_1_2_to_2004($manifest)
Class ilObjSCORMLearningModule.
static _getCourseCompletionForUser($a_id, $a_user)
Get the completion of a SCORM module for a given user.
Scorm 2004 Content Object Manifest export class.
exportScorm($a_inst, $a_target_dir, $ver, &$expLog)
Export (authoring) scorm package.
const LP_STATUS_FAILED_NUM
getImportSequencing()
Get import sequencing.
getModuleVersionForUser($a_user_id)
get module version that tracking data for a user was recorded on
static _getStatus($a_obj_id, $a_user_id)