5require_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;
97 if (!function_exists(
'json_encode') || !function_exists(
'json_decode')) {
101 $needs_convert =
false;
108 $check_for_manifest_file = is_file($manifest_file);
113 if (!$check_for_manifest_file) {
114 $ilErr->raiseError($this->lng->txt(
"Manifestfile $manifest_file not found!"),
$ilErr->MESSAGE);
119 if ($check_for_manifest_file) {
120 $manifest_file_array = file($manifest_file);
122 foreach ($manifest_file_array as $mfa) {
124 if (@iconv(
'UTF-8',
'UTF-8', $mfa) != $mfa) {
125 $needs_convert =
true;
133 $estimated_manifest_filesize = filesize($manifest_file) * 2;
137 $check_disc_free = 2;
142 if ($needs_convert) {
144 if ($check_for_manifest_file && ($check_disc_free > 1)) {
147 if (!copy($manifest_file, $manifest_file .
".old")) {
148 echo
"Failed to copy $manifest_file...<br>\n";
153 $f_write_handler = fopen($manifest_file .
".new",
"w");
154 $f_read_handler = fopen($manifest_file .
".old",
"r");
155 while (!feof($f_read_handler)) {
156 $zeile = fgets($f_read_handler);
158 fputs($f_write_handler, utf8_encode($zeile));
160 fclose($f_read_handler);
161 fclose($f_write_handler);
164 if (!copy($manifest_file .
".new", $manifest_file)) {
165 echo
"Failed to copy $manifest_file...<br>\n";
168 if (!@is_file($manifest_file)) {
169 $ilErr->raiseError($this->lng->txt(
"cont_no_manifest"),
$ilErr->WARNING);
174 if (!($check_disc_free > 1)) {
175 $ilErr->raiseError($this->lng->txt(
"Not enough space left on device!"),
$ilErr->MESSAGE);
181 $hmani = fopen($manifest_file,
"r");
182 $start = fread($hmani, 3);
183 if (strtolower(bin2hex($start)) ==
"efbbbf") {
184 $f_write_handler = fopen($manifest_file .
".new",
"w");
185 while (!feof($hmani)) {
186 $n = fread($hmani, 900);
187 fputs($f_write_handler,
$n);
189 fclose($f_write_handler);
193 if (!copy($manifest_file .
".new", $manifest_file)) {
194 echo
"Failed to copy $manifest_file...<br>\n";
202 if (
$_POST[
"validate"] ==
"y") {
216 include_once(
"./Modules/Scorm2004/classes/ilSCORM13Package.php");
219 return $newPack->il_importLM(
232 $out = file_get_contents($this->imsmanifestFile);
233 $check =
'/xmlns="http:\/\/www.imsglobal.org\/xsd\/imscp_v1p1"/';
234 $replace=
"xmlns=\"http://www.imsproject.org/xsd/imscp_rootv1p1p2\"";
235 $out=preg_replace($check, $replace,
$out);
236 file_put_contents($this->imsmanifestFile,
$out);
245 ##check manifest-file for version. Check for schemaversion as this is a required element for SCORM 2004
246 ##accept 2004 3rd Edition an CAM 1.3 as valid schemas
250 $this->imsmanifestFile=$manifest;
251 $doc =
new DomDocument();
255 $doc->load($this->imsmanifestFile);
256 $elements = $doc->getElementsByTagName(
"schemaversion");
257 $schema=$elements->item(0)->nodeValue;
258 if (strtolower(trim(
$schema))==
"cam 1.3" || strtolower(trim(
$schema))==
"2004 3rd edition" || strtolower(trim(
$schema))==
"2004 4th edition") {
260 $this->converted=
false;
263 $this->converted=
true;
270 die(
"organizations missing in manifest");
273 if ($default==
"" || $default==
null) {
275 $organization = $doc->getElementsByTagName(
"organization");
276 $ident=$organization->item(0)->getAttribute(
"identifier");
284 $wrapperdir=$this->packageFolder .
"/GenericRunTimeWrapper1.0_aadlc";
286 copy(self::WRAPPER_HTML, $wrapperdir .
"/GenericRunTimeWrapper.htm");
287 copy(self::WRAPPER_JS, $wrapperdir .
"/SCOPlayerWrapper.js");
290 $this->backupManifest=$this->packageFolder .
"/imsmanifest.xml.back";
291 $ret=copy($this->imsmanifestFile, $this->backupManifest);
294 $this->totransform = $doc;
295 $ilLog->write(
"SCORM: about to transform to SCORM 2004");
297 $xsl =
new DOMDocument;
299 $xsl->load(self::CONVERT_XSL);
300 $prc =
new XSLTProcessor;
301 $r = @$prc->importStyleSheet($xsl);
303 file_put_contents($this->imsmanifestFile, $prc->transformToXML($this->totransform));
305 $ilLog->write(
"SCORM: Transformation completed");
325 SELECT MAX(c_timestamp) last_access
326 FROM cmi_node, cp_node
327 WHERE cmi_node.cp_node_id = cp_node.cp_node_id
328 AND cp_node.slm_id = %s
330 GROUP BY c_timestamp',
331 array(
'integer',
'integer'),
332 array($a_obj_id, $a_usr_id)
336 return $row[
"last_access"];
392 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004DeleteData.php");
393 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
394 include_once(
"./Services/Tracking/classes/class.ilChangeEvent.php");
397 foreach ($a_users as
$user) {
413 $sco_set =
$ilDB->queryF(
415 SELECT DISTINCT cmi_node.cp_node_id id
416 FROM cp_node, cmi_node
418 AND cp_node.cp_node_id = cmi_node.cp_node_id
419 ORDER BY cmi_node.cp_node_id ',
421 array($this->
getId())
426 while ($sco_rec =
$ilDB->fetchAssoc($sco_set)) {
427 $item[
'id']=$sco_rec[
"id"];
429 $items[count($items)] =$item;
443 $val_set =
$ilDB->queryF(
444 'SELECT cp_node_id FROM cp_node
446 AND cp_node.slm_id = %s',
447 array(
'text',
'integer'),
448 array(
'item',$this->
getId())
450 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
451 array_push($scos, $val_rec[
'cp_node_id']);
454 foreach ($scos as $sco) {
455 $data_set =
$ilDB->queryF(
457 SELECT c_timestamp last_access, total_time, success_status, completion_status,
458 c_raw, scaled, cp_node_id
460 WHERE cp_node_id = %s
462 array(
'integer',
'integer'),
463 array($sco,$a_user_id)
466 while ($data_rec =
$ilDB->fetchAssoc($data_set)) {
467 if ($data_rec[
"success_status"]!=
"" && $data_rec[
"success_status"]!=
"unknown") {
468 $status = $data_rec[
"success_status"];
470 if ($data_rec[
"completion_status"]==
"") {
473 $status = $data_rec[
"completion_status"];
479 if ($data_rec[
"c_raw"] !=
null) {
480 $score = $data_rec[
"c_raw"];
481 if ($data_rec[
"scaled"] !=
null) {
485 if ($data_rec[
"scaled"] !=
null) {
486 $score .= ($data_rec[
"scaled"]*100) .
"%";
490 $data[] = array(
"sco_id"=>$data_rec[
"cp_node_id"],
491 "score" => $score,
"time" =>
$time,
"status" => $status,
"last_access"=>$last_access,
"title"=>
$title);
494 $data[$data_rec[
"cp_node_id"]] = $data_rec;
509 $val_set =
$ilDB->queryF(
510 'SELECT package_attempts FROM sahs_user WHERE user_id = %s AND obj_id = %s',
511 array(
'integer',
'integer'),
512 array($a_user_id, $this->
getId())
515 $val_rec =
$ilDB->fetchAssoc($val_set);
517 if ($val_rec[
"package_attempts"] ==
null) {
518 $val_rec[
"package_attempts"]=
"";
521 return $val_rec[
"package_attempts"];
531 $val_set =
$ilDB->queryF(
532 'SELECT module_version FROM sahs_user WHERE user_id = %s AND obj_id = %s',
533 array(
'integer',
'integer'),
534 array($a_user_id, $this->
getId())
537 $val_rec =
$ilDB->fetchAssoc($val_set);
539 if ($val_rec[
"module_version"] ==
null) {
540 $val_rec[
"module_version"]=
"";
542 return $val_rec[
"module_version"];
558 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
561 include_once
'./Services/Object/classes/class.ilObjectLP.php';
563 $collection = $olp->getCollectionInstance();
565 $scos = $collection->getItems();
568 $fhandle = fopen($a_file,
"r");
570 $obj_id = $this->getID();
572 $usersToDelete = array();
573 $fields = fgetcsv($fhandle, 4096,
';');
574 while (($csv_rows = fgetcsv($fhandle, 4096,
";")) !==
false) {
575 $data = array_combine($fields, $csv_rows);
577 if (
$data[
"Login"]) {
580 if (
$data[
"login"]) {
584 if (
$data[
"user"] && is_numeric(
$data[
"user"])) {
585 $user_id =
$data[
"user"];
590 $date_ex = explode(
'.',
$data[
'Date']);
591 $last_access = implode(
'-', array($date_ex[2], $date_ex[1], $date_ex[0]));
593 if (
$data[
'LastAccess']) {
594 $last_access =
$data[
'LastAccess'];
599 if (
$data[
"Status"]) {
600 if (is_numeric(
$data[
"Status"])) {
601 $status =
$data[
"Status"];
611 if (
$data[
"Attempts"]) {
612 $attempts =
$data[
"Attempts"];
615 $percentage_completed = 0;
617 $percentage_completed = 100;
618 } elseif (
$data[
'percentageCompletedSCOs']) {
619 $percentage_completed =
$data[
'percentageCompletedSCOs'];
622 $sco_total_time_sec =
null;
623 if (
$data[
'SumTotal_timeSeconds']) {
624 $sco_total_time_sec =
$data[
'SumTotal_timeSeconds'];
628 $usersToDelete[] = $user_id;
630 $this->
importSuccessForSahsUser($user_id, $last_access, $status, $attempts, $percentage_completed, $sco_total_time_sec);
635 foreach ($scos as $sco_id) {
638 SELECT completion_status, success_status, user_id FROM cmi_node WHERE cp_node_id = %s AND user_id = %s',
639 array(
'integer',
'integer'),
640 array($sco_id,$user_id)
644 $nextId =
$ilDB->nextId(
'cmi_node');
645 $val_set =
$ilDB->manipulateF(
646 'INSERT INTO cmi_node
647 (cp_node_id,user_id,completion_status,c_timestamp,cmi_node_id)
648 VALUES(%s,%s,%s,%s,%s)',
649 array(
'integer',
'integer',
'text',
'timestamp',
'integer'),
650 array($sco_id,$user_id,
'completed',$last_access,$nextId)
655 if ((
$row[
"completion_status"] ==
"completed" &&
$row[
"success_status"] !=
"failed") ||
$row[
"success_status"] ==
"passed") {
656 if ($doUpdate !=
true) {
663 if ($doUpdate ==
true) {
667 'completion_status' => array(
'text',
'completed'),
668 'success_status' => array(
'text',
''),
669 'suspend_data' => array(
'text',
''),
670 'c_timestamp' => array(
'timestamp', $last_access)
673 'user_id' => array(
'integer', $user_id),
674 'cp_node_id' => array(
'integer', $sco_id)
686 if (count($usersToDelete)>0) {
691 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
705 $aV = array(0, 0, 0, 0, 0, 0);
708 if (strpos($str,
"P") != 0) {
712 $aT = array(
"Y",
"M",
"D",
"H",
"M",
"S");
715 $str = substr($str, 1);
716 for (
$i = 0;
$i < count($aT);
$i++) {
717 if (strpos($str,
"T")===0) {
718 $str = substr($str, 1);
722 $p = strpos($str, $aT[
$i]);
725 if (
$i == 1 && strpos($str,
"T") > -1 && strpos($str,
"T") < $p) {
728 if ($aT[
$i] ==
"S") {
729 $aV[
$i] = substr($str, 0, $p);
731 $aV[
$i] = intval(substr($str, 0, $p));
733 if (!is_numeric($aV[
$i])) {
736 } elseif (
$i > 2 && !$bTFound) {
740 $str = substr($str, $p + 1);
743 if (!$bErr && strlen($str) != 0) {
751 return $aV[0] * 3155760000 + $aV[1] * 262980000 + $aV[2] * 8640000 + $aV[3] * 360000 + $aV[4] * 6000 + round($aV[5] * 100);
762 $val_set =
$ilDB->queryF(
764 SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item
765 WHERE cp_item.cp_node_id = cp_node.cp_node_id
766 AND cp_item.resourceid = cp_resource.id
769 AND cp_node.slm_id = %s ',
770 array(
'text',
'text',
'integer'),
771 array(
'sco',
'item',$this->
getId())
774 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
775 array_push($scos, $val_rec[
'cp_node_id']);
782 for (
$i=0;
$i<count($scos);
$i++) {
783 $val_set =
$ilDB->queryF(
785 SELECT * FROM cmi_node
788 AND (completion_status=%s OR success_status=%s))',
789 array(
'integer',
'integer',
'text',
'text'),
790 array($a_user,$scos[
$i],
'completed',
'passed')
793 if (
$ilDB->numRows($val_set) > 0) {
795 $key = array_search($scos[
$i], $scos_c);
796 unset($scos_c[
$key]);
800 if (count($scos_c) == 0) {
823 $val_set =
$ilDB->queryF(
825 SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item
826 WHERE cp_item.cp_node_id = cp_node.cp_node_id
827 AND cp_item.resourceid = cp_resource.id
830 AND cp_node.slm_id = %s',
831 array(
'text',
'text',
'integer'),
832 array(
'sco' ,
'item',$a_id)
834 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
835 array_push($scos, $val_rec[
'cp_node_id']);
841 for (
$i=0;
$i<count($scos);
$i++) {
842 $val_set =
$ilDB->queryF(
844 SELECT * FROM cmi_node
847 AND (completion_status = %s OR success_status = %s))',
848 array(
'integer',
'integer',
'text',
'text'),
849 array($a_user,$scos[
$i],
'completed',
'passed')
852 if (
$ilDB->numRows($val_set) > 0) {
854 $key = array_search($scos[
$i], $scos_c);
855 unset($scos_c[
$key]);
859 if (count($scos_c) == 0) {
882 $val_set =
$ilDB->queryF(
883 "SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item WHERE" .
884 " 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",
888 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
889 array_push($scos, $val_rec[
'cp_node_id']);
893 for (
$i=0;
$i<count($scos);
$i++) {
894 $val_set =
$ilDB->queryF(
895 "SELECT scaled FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)",
896 array(
'integer',
'integer'),
897 array($a_user, $scos[
$i])
899 if ($val_set->numRows()>0) {
900 $val_rec =
$ilDB->fetchAssoc($val_set);
901 if ($val_rec[
'scaled']!=
null) {
903 $scaled = $val_rec[
'scaled'];
907 $retVal = ($set == 1) ? $scaled :
null ;
923 $item_set =
$ilDB->queryF(
925 SELECT cp_item.* FROM cp_node, cp_item WHERE slm_id = %s
926 AND cp_node.cp_node_id = cp_item.cp_node_id
927 ORDER BY cp_node.cp_node_id ',
933 while ($item_rec =
$ilDB->fetchAssoc($item_set)) {
936 SELECT cp_resource.* FROM cp_node, cp_resource
938 AND cp_node.cp_node_id = cp_resource.cp_node_id
939 AND cp_resource.id = %s ',
940 array(
'integer',
'text'),
941 array($a_obj_id,$item_rec[
"resourceid"])
946 if (
$res[
"scormtype"] ==
"sco") {
947 $items[] = array(
"id" => $item_rec[
"cp_node_id"],
948 "title" => $item_rec[
"title"]);
962 $status_set =
$ilDB->queryF(
964 SELECT * FROM cmi_gobjective
966 AND objective_id = %s
968 array(
'integer',
'text',
'integer'),
969 array($a_obj_id,
'-course_overall_status-',$a_user_id)
972 if ($status_rec =
$ilDB->fetchAssoc($status_set)) {
973 return $status_rec[
"status"];
986 $status_set =
$ilDB->queryF(
988 SELECT * FROM cmi_gobjective
990 AND objective_id = %s
992 array(
'integer',
'text',
'integer'),
993 array($a_obj_id,
'-course_overall_status-',$a_user_id)
996 if ($status_rec =
$ilDB->fetchAssoc($status_set)) {
997 return $status_rec[
"satisfied"];
1009 $status_set =
$ilDB->queryF(
1011 SELECT * FROM cmi_gobjective
1013 AND objective_id = %s
1015 array(
'integer',
'text',
'integer'),
1016 array($a_obj_id,
'-course_overall_status-',$a_user_id)
1019 if ($status_rec =
$ilDB->fetchAssoc($status_set)) {
1020 return $status_rec[
"measure"];
1034 SELECT * FROM cp_item
1035 WHERE cp_node_id = %s',
1051 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Tree.php");
1057 $this->slm_tree->addTree($this->
getId(), 1);
1060 include_once(
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1062 $seq_info->insert();
1068 $this->slm_tree->setTreeTablePK(
"slm_id");
1069 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1070 return $this->slm_tree;
1076 $ilTabs->setTabActive(
"sequencing");
1078 include_once(
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1081 return $control_settings;
1086 include_once(
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1092 $control_settings->insert();
1108 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1109 $this->slm_tree->setTreeTablePK(
"slm_id");
1111 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
1116 if (!$first_child) {
1119 $target_parent = $this->slm_tree->getParentId(
$target_id);
1123 if ($source_obj->getType() ==
"page") {
1124 if ($this->slm_tree->isInTree($source_obj->getId())) {
1125 $node_data = $this->slm_tree->getNodeData($source_obj->getId());
1128 if ($movecopy ==
"move") {
1129 $parent_id = $this->slm_tree->getParentId($source_obj->getId());
1130 $this->slm_tree->deleteTree($node_data);
1152 if (!$this->slm_tree->isInTree($source_obj->getId())) {
1156 } elseif ($as_subitem) {
1159 $pg_childs = $this->slm_tree->getChildsByType($parent,
"page");
1160 if (count($pg_childs) != 0) {
1161 $target_pos = $pg_childs[count($pg_childs) - 1][
"obj_id"];
1165 $parent = $target_parent;
1169 $this->slm_tree->insertNode(
1170 $source_obj->getId(),
1193 if ($source_obj->getType() ==
"sco" || $source_obj->getType() ==
"ass") {
1195 $source_node = $this->slm_tree->getNodeData($source_id);
1196 $subnodes = $this->slm_tree->getSubtree($source_node);
1199 foreach ($subnodes as $subnode) {
1211 $pg_childs = $this->slm_tree->getChildsByType($target_parent,
"page");
1212 if (count($pg_childs) != 0) {
1213 $target_pos = $pg_childs[count($pg_childs) - 1][
"obj_id"];
1215 } elseif ($as_subitem) {
1218 $childs = $this->slm_tree->getChilds($target_parent);
1219 if (count($childs) != 0) {
1220 $target_pos = $childs[count($childs) - 1][
"obj_id"];
1225 if ($movecopy ==
"move") {
1226 $this->slm_tree->deleteTree($source_node);
1235 if (!$this->slm_tree->isInTree($source_id)) {
1236 $this->slm_tree->insertNode($source_id, $target_parent, $target_pos);
1239 if ($movecopy ==
"move") {
1240 foreach ($subnodes as $node) {
1241 if ($node[
"obj_id"] != $source_id) {
1242 $this->slm_tree->insertNode($node[
"obj_id"], $node[
"parent"]);
1253 if ($source_obj->getType() ==
"chap") {
1255 $source_node = $this->slm_tree->getNodeData($source_id);
1256 $subnodes = $this->slm_tree->getSubtree($source_node);
1259 foreach ($subnodes as $subnode) {
1276 } elseif ($as_subitem) {
1279 $childs = $this->slm_tree->getChilds($target_parent);
1280 if (count($childs) != 0) {
1281 $target_pos = $childs[count($childs) - 1][
"obj_id"];
1286 if ($movecopy ==
"move") {
1287 $this->slm_tree->deleteTree($source_node);
1296 if (!$this->slm_tree->isInTree($source_id)) {
1297 $this->slm_tree->insertNode($source_id, $target_parent, $target_pos);
1300 if ($movecopy ==
"move") {
1301 foreach ($subnodes as $node) {
1302 if ($node[
"obj_id"] != $source_id) {
1303 $this->slm_tree->insertNode($node[
"obj_id"], $node[
"parent"]);
1320 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Export.php");
1322 $export =
new ilSCORM2004Export($this);
1323 foreach ($export->getSupportedExportTypes() as
$type) {
1324 $dir = $export->getExportDirectoryForType(
$type);
1326 if (!@is_dir($dir) or !is_writeable($dir)) {
1333 while ($entry = $cdir->read()) {
1334 if ($entry !=
"." and
1337 preg_match(
"~^[0-9]{10}_{2}[0-9]+_{2}(" . $this->
getType() .
"_)*[0-9]+\.zip\$~", $entry) or
1338 preg_match(
"~^[0-9]{10}_{2}[0-9]+_{2}(" . $this->
getType() .
"_)*[0-9]+\.pdf\$~", $entry) or
1339 preg_match(
"~^[0-9]{10}_{2}[0-9]+_{2}(" . $this->
getType() .
"_)*[0-9]+\.iso\$~", $entry)
1342 "size" => filesize($dir .
"/" . $entry));
1365 $metadata_xml = $a_xml_writer->xmlDumpMem(
false);
1366 $a_xml_writer->_XmlWriter;
1368 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/metadata.xsl");
1369 $args = array(
'/_xml' => $metadata_xml ,
'/_xsl' => $xsl );
1371 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",
null, $args,
null);
1373 file_put_contents($a_target_dir .
'/indexMD.xml',
$output);
1378 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1379 include_once(
"./Modules/Glossary/classes/class.ilGlossaryExport.php");
1382 $glo_xml_writer->xmlSetDtdDef(
"<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
1384 $glo_xml_writer->xmlHeader();
1388 $glos->exportXML($glo_xml_writer, $glos_export->getInstId(), $a_target_dir .
"/glossary", $expLog);
1389 $glo_xml_writer->xmlDumpFile($a_target_dir .
"/glossary/glossary.xml");
1390 $glo_xml_writer->_XmlWriter;
1395 $a_xml_writer->
xmlSetDtdDef(
"<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
1398 $a_xml_writer->xmlSetGenCmt(
"Export of ILIAS Content Module " . $this->
getId() .
" of installation " . $a_inst .
".");
1401 $a_xml_writer->xmlHeader();
1403 $a_xml_writer->xmlStartTag(
"ContentObject", array(
"Type"=>
"SCORM2004LearningModule"));
1411 $expLog->write(
date(
"[y-m-d H:i:s] ") .
"Start Export Sco Objects");
1413 $expLog->write(
date(
"[y-m-d H:i:s] ") .
"Finished Export Sco Objects");
1415 $a_xml_writer->xmlEndTag(
"ContentObject");
1416 $a_xml_writer->xmlDumpFile($a_target_dir .
'/index.xml',
false);
1418 if ($ver ==
"2004 4th") {
1423 if ($ver ==
"2004 3rd") {
1429 $css_dir = $a_target_dir .
"/ilias_css_4_2";
1431 include_once(
"./Modules/Scorm2004/classes/class.ilScormExportUtil.php");
1435 include_once(
"./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php");
1437 $manifestBuilder->buildManifest($ver, $revision);
1438 $manifestBuilder->dump($a_target_dir);
1440 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1441 $args = array(
'/_xml' => file_get_contents($a_target_dir .
"/imsmanifest.xml"),
'/_xsl' => $xsl );
1443 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",
null, $args,
null);
1445 fputs(fopen($a_target_dir .
'/index.html',
'w+'),
$output);
1449 if ($revision ==
"3rd") {
1450 ilUtil::rCopy(
'./libs/ilias/Scorm2004/xsd/adlcp_130_export_2004', $a_target_dir,
false);
1453 if ($revision ==
"4th") {
1454 ilUtil::rCopy(
'./libs/ilias/Scorm2004/xsd/adlcp_130_export_2004_4th', $a_target_dir,
false);
1458 ilUtil::rCopy(
'./libs/ilias/Scorm2004/xsd/adlcp_120_export_12', $a_target_dir,
false);
1462 $a_xml_writer->_XmlWriter;
1469 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1470 $tree->setTreeTablePK(
"slm_id");
1471 foreach (
$tree->getSubTree(
$tree->getNodeData(
$tree->getRootId()),
true,
'sco') as $sco) {
1472 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1473 $sco_folder = $a_target_dir .
"/" . $sco[
'obj_id'];
1476 $node->exportHTML4PDF($a_inst, $sco_folder, $expLog);
1483 $a_xml_writer->
xmlStartTag(
"ContentObject", array(
"Type"=>
"SCORM2004SCO"));
1486 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1487 $tree->setTreeTablePK(
"slm_id");
1488 foreach (
$tree->getSubTree(
$tree->getNodeData(
$tree->getRootId()),
true,
'sco') as $sco) {
1489 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1490 $sco_folder = $a_target_dir .
"/" . $sco[
'obj_id'];
1493 $node->exportPDFPrepareXmlNFiles($a_inst, $a_target_dir, $expLog, $a_xml_writer);
1497 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1498 include_once(
"./Modules/Glossary/classes/class.ilGlossaryExport.php");
1501 $glos->exportXML($a_xml_writer, $glos_export->getInstId(), $a_target_dir .
"/glossary", $expLog);
1503 $a_xml_writer->xmlEndTag(
"ContentObject");
1504 include_once
'Services/Transformation/classes/class.ilXML2FO.php';
1506 $xml2FO->setXSLTLocation(
'./Modules/Scorm2004/templates/xsl/contentobject2fo.xsl');
1507 $xml2FO->setXMLString($a_xml_writer->xmlDumpMem());
1508 $xml2FO->setXSLTParams(array(
'target_dir' => $a_target_dir));
1509 $xml2FO->transform();
1510 $fo_string = $xml2FO->getFOString();
1511 $fo_xml = simplexml_load_string($fo_string);
1512 $fo_ext = $fo_xml->xpath(
"//fo:declarations");
1513 $fo_ext = $fo_ext[0];
1515 include_once
"./Services/Utilities/classes/class.ilFileUtils.php";
1519 $e = $fo_ext->addChild(
"fox:embedded-file",
"",
"http://xml.apache.org/fop/extensions");
1520 $e->addAttribute(
"src",
$results[path][
$key] . $value);
1521 $e->addAttribute(
"name", $value);
1522 $e->addAttribute(
"desc",
"");
1525 $fo_string = $fo_xml->asXML();
1526 $a_xml_writer->_XmlWriter;
1532 $one_file = fopen($a_target_dir .
'/index.html',
'w+');
1533 $this->
exportHTML($a_inst, $a_target_dir, $expLog, $one_file);
1540 public function exportHTML($a_inst, $a_target_dir, &$expLog, $a_one_file =
"")
1568 if ($a_one_file ==
"") {
1569 include_once(
"./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php");
1571 $manifestBuilder->buildManifest(
'12');
1573 include_once(
"Services/Frameset/classes/class.ilFramesetGUI.php");
1575 $fs_gui->setFramesetTitle($this->
getTitle());
1576 $fs_gui->setMainFrameSource(
"");
1577 $fs_gui->setSideFrameSource(
"toc.html");
1578 $fs_gui->setMainFrameName(
"content");
1579 $fs_gui->setSideFrameName(
"toc");
1581 fputs(fopen($a_target_dir .
'/index.html',
'w+'),
$output);
1583 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1584 $xml = simplexml_load_string($manifestBuilder->writer->xmlDumpMem());
1585 $args = array(
'/_xml' =>
$xml->organizations->organization->asXml(),
'/_xsl' => $xsl );
1587 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",
null, $args,
null);
1589 fputs(fopen($a_target_dir .
'/toc.html',
'w+'),
$output);
1602 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
1604 $md2xml->setExportMode(
true);
1605 $md2xml->startExport();
1606 $a_xml_writer->appendXML($md2xml->getXML());
1617 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
1619 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1620 $tree->setTreeTablePK(
"slm_id");
1621 $a_xml_writer->xmlStartTag(
"StructureObject");
1622 foreach (
$tree->getFilteredSubTree(
$tree->getRootId(), array(
'page')) as $obj) {
1623 if ($obj[
'type']==
'') {
1628 $md2xml =
new ilMD2XML($this->
getId(), $obj[
'obj_id'], $obj[
'type']);
1629 $md2xml->setExportMode(
true);
1630 $md2xml->startExport();
1631 $a_xml_writer->appendXML($md2xml->getXML());
1633 $a_xml_writer->xmlEndTag(
"StructureObject");
1646 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1647 $tree->setTreeTablePK(
"slm_id");
1648 foreach (
$tree->getSubTree(
$tree->getNodeData(
$tree->getRootId()),
true, array(
'sco',
'ass')) as $sco) {
1649 if ($sco[
'type'] ==
"sco") {
1650 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1651 $sco_folder = $a_target_dir .
"/" . $sco[
'obj_id'];
1654 $node->exportScorm($a_inst, $sco_folder, $ver, $expLog);
1656 if ($sco[
'type'] ==
"ass") {
1657 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php");
1658 $sco_folder = $a_target_dir .
"/" . $sco[
'obj_id'];
1661 $node->exportScorm($a_inst, $sco_folder, $ver, $expLog);
1674 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1675 $tree->setTreeTablePK(
"slm_id");
1678 if ($a_one_file !=
"") {
1682 $sco_tpl =
new ilTemplate(
"tpl.sco.html",
true,
true,
"Modules/Scorm2004");
1683 include_once(
"./Services/COPage/classes/class.ilCOPageHTMLExport.php");
1685 $sco_tpl = $page_html_export->getPreparedMainTemplate($sco_tpl);
1687 $sco_tpl->setCurrentBlock(
"js_file");
1688 $sco_tpl->setVariable(
"JS_FILE",
"./js/pure.js");
1689 $sco_tpl->parseCurrentBlock();
1690 $sco_tpl->setCurrentBlock(
"js_file");
1691 $sco_tpl->setVariable(
"JS_FILE",
"./js/question_handling.js");
1692 $sco_tpl->parseCurrentBlock();
1695 $sco_tpl->setCurrentBlock(
"head");
1696 $sco_tpl->parseCurrentBlock();
1697 fputs($a_one_file, $sco_tpl->get(
"head"));
1700 include_once(
"./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php");
1702 $manifestBuilder->buildManifest(
'12');
1703 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1704 $xml = simplexml_load_string($manifestBuilder->writer->xmlDumpMem());
1705 $args = array(
'/_xml' =>
$xml->organizations->organization->asXml(),
'/_xsl' => $xsl );
1707 $params = array(
"one_page" =>
"y");
1708 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",
null, $args,
$params);
1713 foreach (
$tree->getSubTree(
$tree->getNodeData(
$tree->getRootId()),
true,
'sco') as $sco) {
1714 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1715 $sco_folder = $a_target_dir .
"/" . $sco[
'obj_id'];
1719 if ($a_one_file ==
"") {
1720 $node->exportHTML($a_inst, $sco_folder, $expLog, $a_one_file);
1722 $node->exportHTMLPageObjects(
1733 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1740 if ($a_one_file !=
"") {
1742 fputs($a_one_file, $sco_tpl->get(
"tail"));
1755 include_once(
"./Services/Style/System/classes/class.ilSystemStyleHTMLExport.php");
1757 $this->sys_style_html_export->export();
1760 include_once(
"./Services/COPage/classes/class.ilCOPageHTMLExport.php");
1762 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1763 $this->co_page_html_export->setContentStyleId(
1766 $this->co_page_html_export->createDirectories();
1767 $this->co_page_html_export->exportStyles();
1768 $this->co_page_html_export->exportSupportScripts();
1770 include_once(
"./Services/MediaObjects/classes/class.ilPlayerUtil.php");
1778 include_once(
"./Services/MediaObjects/classes/class.ilPlayerUtil.php");
1783 copy(
'./Modules/Scorm2004/scripts/scorm_2004.js', $a_target_dir .
'/js/scorm.js');
1784 copy(
'./Modules/Scorm2004/scripts/pager.js', $a_target_dir .
'/js/pager.js');
1785 copy(
'./Modules/Scorm2004/scripts/questions/pure.js', $a_target_dir .
'/js/pure.js');
1787 './Modules/Scorm2004/scripts/questions/question_handling.js',
1788 $a_target_dir .
'/js/question_handling.js'
1801 return $this->public_export_file[
$a_type];
1810 include_once(
"./Modules/File/classes/class.ilObjFile.php");
1812 foreach ($this->file_ids as $file_id) {
1813 $expLog->write(
date(
"[y-m-d H:i:s] ") .
"File Item " . $file_id);
1814 $file_obj =
new ilObjFile($file_id,
false);
1815 $file_obj->export($a_target_dir);
1825 $this->public_export_file[
$a_type] = $a_file;
1847 'SELECT cp_node.cp_node_id '
1848 .
'FROM cp_node, cp_resource, cp_item '
1849 .
'WHERE cp_item.cp_node_id = cp_node.cp_node_id '
1850 .
'AND cp_item.resourceId = cp_resource.id '
1851 .
'AND scormType = ' .
$ilDB->quote(
'sco',
'text') .
' '
1852 .
'AND nodeName = ' .
$ilDB->quote(
'item',
'text') .
' '
1853 .
'AND cp_node.slm_id = ' .
$ilDB->quote($a_id,
'integer') .
' '
1854 .
'GROUP BY cp_node.cp_node_id'
1858 array_push($scos,
$row[
'cp_node_id']);
1863 for (
$i = 0;
$i < count($scos);
$i++) {
1865 'SELECT c_max FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)',
1866 array(
'integer',
'integer'),
1867 array($a_user, $scos[
$i])
1872 if (
$row[
'c_max'] !=
null) {
1874 $max =
$row[
'c_max'];
1878 $retVal = ($set == 1) ? $max :
null;
1888 $retAr = array(
"raw" =>
null,
"max" =>
null,
"scaled" =>
null);
1889 $val_set =
$ilDB->queryF(
1890 "SELECT c_raw, c_max, scaled FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)",
1891 array(
'integer',
'integer'),
1892 array($a_user, $a_cp_node_id)
1894 if ($val_set->numRows()>0) {
1895 $val_rec =
$ilDB->fetchAssoc($val_set);
1896 $retAr[
"raw"] = $val_rec[
'c_raw'];
1897 $retAr[
"max"] = $val_rec[
'c_max'];
1898 $retAr[
"scaled"] = $val_rec[
'scaled'];
1899 if ($val_rec[
'scaled']==
null && $val_rec[
'c_raw']!=
null && $val_rec[
'c_max']!=
null) {
1900 $retAr[
"scaled"] = ($val_rec[
'c_raw'] / $val_rec[
'c_max']);
1915 include_once(
"./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1919 $new_id = $style_obj->ilClone();
1920 $a_new_obj->setStyleSheetId($new_id);
1921 $a_new_obj->update();
1924 $a_new_obj->createScorm2004Tree();
1925 $source_tree = $this->
getTree();
1926 $target_tree_root_id = $a_new_obj->getTree()->readRootId();
1927 $childs = $source_tree->getChilds($source_tree->readRootId());
1928 $a_copied_nodes = array();
1929 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
1930 foreach ($childs as $c) {
1934 $target_tree_root_id,
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
HTML export class for pages.
static _deleteReadEventsForUsers($a_obj_id, array $a_user_ids)
Scorm 2004 Content Object Manifest export class.
static secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
@classDescription Date and time handling
static recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
Export class for content objects.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
const LP_STATUS_FAILED_NUM
const LP_STATUS_NOT_ATTEMPTED
const LP_STATUS_IN_PROGRESS
getEditable()
Get Editable.
getAssignedGlossary()
get assigned glossary
getStyleSheetId()
get ID of assigned style sheet object
getDataDirectory($mode="filesystem")
get data directory of lm
Class ilObjSCORM2004LearningModule.
__construct($a_id=0, $a_call_by_reference=true)
Constructor @access public.
exportXMLStructureObjects(&$a_xml_writer, $a_inst, &$expLog)
export structure objects to xml (see ilias_co.dtd)
deleteTrackingDataOfUsers($a_users)
get all tracked items of current user
validate($directory)
Validate all XML-Files in a SCOM-Directory.
setImportSequencing($a_val)
Set import sequencing.
exportXMLScoObjects($a_inst, $a_target_dir, $ver, &$expLog)
export page objects to xml (see ilias_co.dtd)
static _ISODurationToCentisec($str)
convert ISO 8601 Timeperiods to centiseconds ta
exportPDF($a_inst, $a_target_dir, &$expLog)
exportHTML($a_inst, $a_target_dir, &$expLog, $a_one_file="")
Export SCORM package to HTML.
static _getTrackingItems($a_obj_id)
get all tracking items of scorm object
copyAuthoredContent($a_new_obj)
Copy authored content (everything done with the editor.
exportXMLMetaData(&$a_xml_writer)
export content objects meta data to xml (see ilias_co.dtd)
getTrackingDataAgg($a_user_id, $raw=false)
executeDragDrop($source_id, $target_id, $first_child, $as_subitem=false, $movecopy="move")
Execute Drag Drop Action.
static _getMaxScoreForUser($a_id, $a_user)
Returns score.max for the learning module, refered to the last sco where score.max is set.
getCourseCompletionForUser($a_user)
exportHTML4PDF($a_inst, $a_target_dir, &$expLog)
exportHTMLScoObjects($a_inst, $a_target_dir, &$expLog, $a_one_file="")
static _getStatus($a_obj_id, $a_user_id)
getImportSequencing()
Get import sequencing.
getAttemptsForUser($a_user_id)
get number of atttempts for a certain user and package
static _getUniqueScaledScoreForUser($a_id, $a_user)
Get the Unique Scaled Score of a course Conditions: Only one SCO may set cmi.score....
updateSequencingSettings()
exportHTMLOne($a_inst, $a_target_dir, &$expLog)
static _lookupLastAccess($a_obj_id, $a_usr_id)
Return the last access timestamp for a given user.
getTrackedItems()
get all tracked items of current user
static _getMeasure($a_obj_id, $a_user_id)
readObject()
read manifest file @access public
static _getSatisfied($a_obj_id, $a_user_id)
getPublicExportFile($a_type)
get public export file
createScorm2004Tree()
Create Scorm 2004 Tree used by Editor.
exportFileItems($a_target_dir, &$expLog)
export files of file itmes
getModuleVersionForUser($a_user_id)
get module version that tracking data for a user was recorded on
static _getScores2004ForUser($a_cp_node_id, $a_user)
static _lookupItemTitle($a_node_id)
convert_1_2_to_2004($manifest)
setPublicExportFile($a_type, $a_file)
prepareHTMLExporter($a_target_dir)
Prepare HTML exporter.
exportScorm($a_inst, $a_target_dir, $ver, &$expLog)
Export (authoring) scorm package.
static _getCourseCompletionForUser($a_id, $a_user)
Get the completion of a SCORM module for a given user.
Class ilObjSCORMLearningModule.
importSuccessForSahsUser($user_id, $last_access, $status, $attempts=null, $percentage_completed=null, $sco_total_time_sec=null)
static _lookupStandard($a_id)
Lookup standard flag.
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static getInstance($a_obj_id)
getType()
get object type @access public
getId()
get object id @access public
getTitle()
get object title @access public
static getFlashVideoPlayerDirectory()
Get flash video player directory.
static copyPlayerFilesToTargetDirectory($a_target_dir)
Copy css files to target dir.
static removeCMIDataForUserAndPackage($user_id, $packageId)
static getInstance($a_slm_object, $a_id=0, $a_halt=true)
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.
Class ilSCORM2004Sequencing.
static exportContentCSS($a_slm_object, $a_target_dir)
Export lm content css to a directory.
HTML export class for system styles.
special template class to simplify handling of ITX/PEAR
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static now()
Return current timestamp in Y-m-d H:i:s format.
static yn2tf($a_yn)
convert "y"/"n" to true/false
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
xmlSetDtdDef($dtdDef)
Sets dtd definition.
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output
if($source===NULL) $organizations
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
foreach($_POST as $key=> $value) $res