5 require_once
"./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php";
20 const CONVERT_XSL =
'./Modules/Scorm2004/templates/xsl/op/scorm12To2004.xsl';
21 const WRAPPER_HTML =
'./Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/GenericRunTimeWrapper.htm';
22 const WRAPPER_JS =
'./Modules/Scorm2004/scripts/converter/GenericRunTimeWrapper1.0_aadlc/SCOPlayerWrapper.js';
33 parent::ilObject($a_id,$a_call_by_reference);
43 $this->import_sequencing = $a_val;
53 return $this->import_sequencing;
78 if (!function_exists(
'json_encode') || !function_exists(
'json_decode') || ($ilDB->getDBType() ==
'mysql' && !$ilDB->isMysql4_1OrHigher())) {
79 $ilias->raiseError($lng->txt(
'scplayer_phpmysqlcheck'),$ilias->error_obj->WARNING);
82 $needs_convert =
false;
89 $check_for_manifest_file = is_file($manifest_file);
94 if (!$check_for_manifest_file)
96 $this->
ilias->raiseError($this->lng->txt(
"Manifestfile $manifest_file not found!"), $this->
ilias->error_obj->MESSAGE);
101 if ($check_for_manifest_file)
103 $manifest_file_array = file($manifest_file);
105 foreach($manifest_file_array as $mfa)
108 if (@iconv(
'UTF-8',
'UTF-8', $mfa) != $mfa)
110 $needs_convert =
true;
118 $estimated_manifest_filesize = filesize($manifest_file) * 2;
122 $check_disc_free = 2;
130 if ($check_for_manifest_file && ($check_disc_free > 1))
134 if (!copy($manifest_file, $manifest_file.
".old"))
136 echo
"Failed to copy $manifest_file...<br>\n";
141 $f_write_handler = fopen($manifest_file.
".new",
"w");
142 $f_read_handler = fopen($manifest_file.
".old",
"r");
143 while (!feof($f_read_handler))
145 $zeile = fgets($f_read_handler);
147 fputs($f_write_handler, utf8_encode($zeile));
149 fclose($f_read_handler);
150 fclose($f_write_handler);
153 if (!copy($manifest_file.
".new", $manifest_file))
155 echo
"Failed to copy $manifest_file...<br>\n";
158 if (!@is_file($manifest_file))
160 $this->
ilias->raiseError($this->lng->txt(
"cont_no_manifest"),
161 $this->
ilias->error_obj->WARNING);
168 if (!($check_disc_free > 1))
169 $this->
ilias->raiseError($this->lng->txt(
"Not enough space left on device!"),$this->
ilias->error_obj->MESSAGE);
177 $hmani = fopen($manifest_file,
"r");
178 $start = fread($hmani, 3);
179 if (strtolower(bin2hex($start)) ==
"efbbbf")
181 $f_write_handler = fopen($manifest_file.
".new",
"w");
182 while (!feof($hmani))
184 $n = fread($hmani, 900);
185 fputs($f_write_handler,
$n);
187 fclose($f_write_handler);
191 if (!copy($manifest_file.
".new", $manifest_file))
193 echo
"Failed to copy $manifest_file...<br>\n";
203 if (
$_POST[
"validate"] ==
"y")
208 $this->
ilias->error_obj->WARNING);
217 include_once (
"./Modules/Scorm2004/classes/ilSCORM13Package.php");
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);
243 ##check manifest-file for version. Check for schemaversion as this is a required element for SCORM 2004 244 ##accept 2004 3rd Edition an CAM 1.3 as valid schemas 248 $this->imsmanifestFile=$manifest;
249 $doc =
new DomDocument();
253 $doc->load($this->imsmanifestFile);
254 $elements = $doc->getElementsByTagName(
"schemaversion");
255 $schema=$elements->item(0)->nodeValue;
256 if (strtolower(trim($schema))==
"cam 1.3" || strtolower(trim($schema))==
"2004 3rd edition" || strtolower(trim($schema))==
"2004 4th edition") {
258 $this->converted=
false;
262 $this->converted=
true;
266 $organizations = $doc->getElementsByTagName(
"organizations");
268 if ($organizations->item(0)==null) die(
"organizations missing in manifest");
269 $default=$organizations->item(0)->getAttribute(
"default");
270 if ($default==
"" || $default==null) {
272 $organization = $doc->getElementsByTagName(
"organization");
273 $ident=$organization->item(0)->getAttribute(
"identifier");
274 $organizations->item(0)->setAttribute(
"default",$ident);
281 $wrapperdir=$this->packageFolder.
"/GenericRunTimeWrapper1.0_aadlc";
283 copy(self::WRAPPER_HTML,$wrapperdir.
"/GenericRunTimeWrapper.htm");
284 copy(self::WRAPPER_JS,$wrapperdir.
"/SCOPlayerWrapper.js");
287 $this->backupManifest=$this->packageFolder.
"/imsmanifest.xml.back";
288 $ret=copy($this->imsmanifestFile,$this->backupManifest);
291 $this->totransform = $doc;
292 $ilLog->write(
"SCORM: about to transform to SCORM 2004");
296 $xsl->load(self::CONVERT_XSL);
297 $prc =
new XSLTProcessor;
298 $r = @$prc->importStyleSheet($xsl);
300 file_put_contents($this->imsmanifestFile, $prc->transformToXML($this->totransform));
302 $ilLog->write(
"SCORM: Transformation completed");
320 SELECT MAX(c_timestamp) last_access 321 FROM cmi_node, cp_node 322 WHERE cmi_node.cp_node_id = cp_node.cp_node_id 323 AND cp_node.slm_id = %s 325 GROUP BY c_timestamp',
326 array(
'integer',
'integer'),
327 array($a_obj_id, $a_usr_id));
331 return $row[
"last_access"];
387 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004DeleteData.php");
388 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
389 include_once(
"./Services/Tracking/classes/class.ilChangeEvent.php");
392 foreach($a_users as $user)
407 $sco_set = $ilDB->queryF(
' 408 SELECT DISTINCT cmi_node.cp_node_id id 409 FROM cp_node, cmi_node 411 AND cp_node.cp_node_id = cmi_node.cp_node_id 412 ORDER BY cp_node.cp_node_id ',
414 array($this->
getId()));
418 while($sco_rec = $ilDB->fetchAssoc($sco_set))
420 $item[
'id']=$sco_rec[
"id"];
421 $item[
'title']=self::_lookupItemTitle($sco_rec[
"id"]);
422 $items[count($items)] =$item;
437 $val_set = $ilDB->queryF(
438 'SELECT cp_node_id FROM cp_node 440 AND cp_node.slm_id = %s',
441 array(
'text',
'integer'),
442 array(
'item',$this->
getId())
444 while($val_rec = $ilDB->fetchAssoc($val_set))
446 array_push($scos,$val_rec[
'cp_node_id']);
449 foreach ($scos as $sco)
451 $data_set = $ilDB->queryF(
' 452 SELECT c_timestamp last_access, total_time, success_status, completion_status, 453 c_raw, scaled, cp_node_id 455 WHERE cp_node_id = %s 457 array(
'integer',
'integer'),
458 array($sco,$a_user_id)
461 while($data_rec = $ilDB->fetchAssoc($data_set))
463 if ($data_rec[
"success_status"]!=
"" && $data_rec[
"success_status"]!=
"unknown") {
464 $status = $data_rec[
"success_status"];
466 if ($data_rec[
"completion_status"]==
"") {
469 $status = $data_rec[
"completion_status"];
476 if ($data_rec[
"c_raw"] != null) {
477 $score = $data_rec[
"c_raw"];
478 if ($data_rec[
"scaled"] != null) $score .=
" = ";
480 if ($data_rec[
"scaled"] != null) $score .= ($data_rec[
"scaled"]*100).
"%";
481 $title = self::_lookupItemTitle($data_rec[
"cp_node_id"]);
483 $data[] = array(
"user_id" => $data_rec[
"user_id"],
"sco_id"=>$data_rec[
"cp_node_id"],
484 "score" => $score,
"time" => $time,
"status" => $status,
"last_access"=>$last_access,
"title"=>
$title);
488 $data_rec[
"total_time"] = self::_ISODurationToCentisec($data_rec[
"total_time"])/100;
489 $data[$data_rec[
"cp_node_id"]] = $data_rec;
503 $val_set = $ilDB->queryF(
'SELECT package_attempts FROM sahs_user WHERE user_id = %s AND obj_id = %s',
504 array(
'integer',
'integer'),
505 array($a_user_id, $this->
getId()));
507 $val_rec = $ilDB->fetchAssoc($val_set);
509 if ($val_rec[
"package_attempts"] == null) {
510 $val_rec[
"package_attempts"]=
"";
513 return $val_rec[
"package_attempts"];
522 $val_set = $ilDB->queryF(
'SELECT module_version FROM sahs_user WHERE user_id = %s AND obj_id = %s',
523 array(
'integer',
'integer'),
524 array($a_user_id, $this->
getId()));
526 $val_rec = $ilDB->fetchAssoc($val_set);
528 if ($val_rec[
"module_version"] == null) {
529 $val_rec[
"module_version"]=
"";
531 return $val_rec[
"module_version"];
545 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
548 include_once
'./Services/Object/classes/class.ilObjectLP.php';
550 $collection = $olp->getCollectionInstance();
553 $scos = $collection->getItems();
556 $fhandle = fopen($a_file,
"r");
558 $obj_id = $this->getID();
560 $usersToDelete = array();
561 $fields = fgetcsv($fhandle, 4096,
';');
562 while(($csv_rows = fgetcsv($fhandle, 4096,
";")) !== FALSE) {
563 $data = array_combine($fields, $csv_rows);
568 if (
$data[
"user"] && is_numeric(
$data[
"user"])) $user_id =
$data[
"user"];
572 $date_ex = explode(
'.',
$data[
'Date']);
573 $last_access = implode(
'-', array($date_ex[2], $date_ex[1], $date_ex[0]));
575 if (
$data[
'LastAccess']) {
576 $last_access =
$data[
'LastAccess'];
581 if (
$data[
"Status"]) {
582 if (is_numeric(
$data[
"Status"])) $status =
$data[
"Status"];
588 if(
$data[
"Attempts"]) $attempts =
$data[
"Attempts"];
590 $percentage_completed = 0;
592 else if (
$data[
'percentageCompletedSCOs']) $percentage_completed =
$data[
'percentageCompletedSCOs'];
594 $sco_total_time_sec = null;
595 if (
$data[
'SumTotal_timeSeconds']) $sco_total_time_sec =
$data[
'SumTotal_timeSeconds'];
598 $usersToDelete[] = $user_id;
600 $this->
importSuccessForSahsUser($user_id, $last_access, $status, $attempts, $percentage_completed, $sco_total_time_sec);
605 foreach ($scos as $sco_id)
607 $res = $ilDB->queryF(
' 608 SELECT completion_status, success_status, user_id FROM cmi_node WHERE cp_node_id = %s AND user_id = %s',
609 array(
'integer',
'integer'),
610 array($sco_id,$user_id)
613 if(!$ilDB->numRows(
$res))
615 $nextId = $ilDB->nextId(
'cmi_node');
616 $val_set = $ilDB->manipulateF(
'INSERT INTO cmi_node 617 (cp_node_id,user_id,completion_status,c_timestamp,cmi_node_id) 618 VALUES(%s,%s,%s,%s,%s)',
619 array(
'integer',
'integer',
'text',
'timestamp',
'integer'),
620 array($sco_id,$user_id,
'completed',$last_access,$nextId));
623 while (
$row = $ilDB->fetchAssoc(
$res)) {
624 if ( (
$row[
"completion_status"] ==
"completed" &&
$row[
"success_status"] !=
"failed") ||
$row[
"success_status"] ==
"passed") {
625 if ($doUpdate !=
true) $doUpdate =
false;
630 if ($doUpdate ==
true) {
631 $ilDB->update(
'cmi_node',
633 'completion_status' => array(
'text',
'completed'),
634 'success_status' => array(
'text',
''),
635 'suspend_data' => array(
'text',
''),
636 'c_timestamp' => array(
'timestamp', $last_access)
639 'user_id' => array(
'integer', $user_id),
640 'cp_node_id' => array(
'integer', $sco_id)
653 if (count($usersToDelete)>0) {
658 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
671 $aV = array(0, 0, 0, 0, 0, 0);
674 if (strpos($str,
"P") != 0) {
678 $aT = array(
"Y",
"M",
"D",
"H",
"M",
"S");
681 $str = substr($str,1);
682 for ($i = 0; $i < count($aT); $i++) {
683 if (strpos($str,
"T")===0) {
684 $str = substr($str,1);
688 $p = strpos($str,$aT[$i]);
691 if ($i == 1 && strpos($str,
"T") > -1 && strpos($str,
"T") < $p) {
694 if ($aT[$i] ==
"S") {
695 $aV[$i] = substr($str,0, $p);
698 $aV[$i] = intval(substr($str,0, $p));
700 if (!is_numeric($aV[$i])) {
703 }
else if ($i > 2 && !$bTFound) {
707 $str = substr($str,$p + 1);
711 if (!$bErr && strlen($str) != 0) {
720 return $aV[0] * 3155760000 + $aV[1] * 262980000 + $aV[2] * 8640000 + $aV[3] * 360000 + $aV[4] * 6000 + round($aV[5] * 100);
730 $val_set = $ilDB->queryF(
' 731 SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item 732 WHERE cp_item.cp_node_id = cp_node.cp_node_id 733 AND cp_item.resourceid = cp_resource.id 736 AND cp_node.slm_id = %s ',
737 array(
'text',
'text',
'integer'),
738 array(
'sco',
'item',$this->
getId()));
740 while ($val_rec = $ilDB->fetchAssoc($val_set))
742 array_push($scos,$val_rec[
'cp_node_id']);
749 for ($i=0;$i<count($scos);$i++)
752 $val_set = $ilDB->queryF(
' 753 SELECT * FROM cmi_node 756 AND (completion_status=%s OR success_status=%s))',
757 array(
'integer',
'integer',
'text',
'text'),
758 array($a_user,$scos[$i],
'completed',
'passed')
761 if ($ilDB->numRows($val_set) > 0) {
763 $key = array_search($scos[$i], $scos_c);
764 unset ($scos_c[$key]);
769 if (count($scos_c) == 0) {
789 $val_set = $ilDB->queryF(
' 790 SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item 791 WHERE cp_item.cp_node_id = cp_node.cp_node_id 792 AND cp_item.resourceid = cp_resource.id 795 AND cp_node.slm_id = %s',
796 array(
'text',
'text',
'integer'), array(
'sco' ,
'item',$a_id));
797 while ($val_rec = $ilDB->fetchAssoc($val_set))
799 array_push($scos,$val_rec[
'cp_node_id']);
805 for ($i=0;$i<count($scos);$i++)
808 $val_set = $ilDB->queryF(
' 809 SELECT * FROM cmi_node 812 AND (completion_status = %s OR success_status = %s))',
813 array(
'integer',
'integer',
'text',
'text'),
814 array($a_user,$scos[$i],
'completed',
'passed'));
816 if ($ilDB->numRows($val_set) > 0)
819 $key = array_search($scos[$i], $scos_c);
820 unset ($scos_c[$key]);
825 if (count($scos_c) == 0) {
845 $val_set = $ilDB->queryF(
"SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item WHERE".
846 " 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",
850 while ($val_rec = $ilDB->fetchAssoc($val_set))
852 array_push($scos,$val_rec[
'cp_node_id']);
856 for ($i=0;$i<count($scos);$i++)
858 $val_set = $ilDB->queryF(
"SELECT scaled FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)",
859 array(
'integer',
'integer'),
860 array($a_user, $scos[$i])
862 if ($val_set->numRows()>0)
864 $val_rec = $ilDB->fetchAssoc($val_set);
865 if ($val_rec[
'scaled']!=NULL) {
867 $scaled = $val_rec[
'scaled'];
871 $retVal = ($set == 1) ? $scaled : null ;
888 $item_set = $ilDB->queryF(
' 889 SELECT cp_item.* FROM cp_node, cp_item WHERE slm_id = %s 890 AND cp_node.cp_node_id = cp_item.cp_node_id 891 ORDER BY cp_node.cp_node_id ',
897 while ($item_rec = $ilDB->fetchAssoc($item_set))
900 $s2 = $ilDB->queryF(
' 901 SELECT cp_resource.* FROM cp_node, cp_resource 903 AND cp_node.cp_node_id = cp_resource.cp_node_id 904 AND cp_resource.id = %s ',
905 array(
'integer',
'text'),
906 array($a_obj_id,$item_rec[
"resourceid"])
910 if (
$res = $ilDB->fetchAssoc($s2))
913 if (
$res[
"scormtype"] ==
"sco")
915 $items[] = array(
"id" => $item_rec[
"cp_node_id"],
916 "title" => $item_rec[
"title"]);
928 $status_set = $ilDB->queryF(
' 929 SELECT * FROM cmi_gobjective 931 AND objective_id = %s 933 array(
'integer',
'text',
'integer'),
934 array($a_obj_id,
'course_overall_status',$a_user_id)
937 if ($status_rec = $ilDB->fetchAssoc($status_set))
939 return $status_rec[
"status"];
950 $status_set = $ilDB->queryF(
' 951 SELECT * FROM cmi_gobjective 953 AND objective_id = %s 955 array(
'integer',
'text',
'integer'),
956 array($a_obj_id,
'course_overall_status',$a_user_id)
959 if ($status_rec = $ilDB->fetchAssoc($status_set))
961 return $status_rec[
"satisfied"];
971 $status_set = $ilDB->queryF(
' 972 SELECT * FROM cmi_gobjective 974 AND objective_id = %s 976 array(
'integer',
'text',
'integer'),
977 array($a_obj_id,
'course_overall_status',$a_user_id)
980 if ($status_rec = $ilDB->fetchAssoc($status_set))
982 return $status_rec[
"measure"];
993 SELECT * FROM cp_item 994 WHERE cp_node_id = %s',
999 if ($i = $ilDB->fetchAssoc(
$r))
1011 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Tree.php");
1017 $this->slm_tree->addTree($this->
getId(), 1);
1020 include_once (
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1022 $seq_info->insert();
1028 $this->slm_tree->setTreeTablePK(
"slm_id");
1029 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1030 return $this->slm_tree;
1036 $ilTabs->setTabActive(
"sequencing");
1038 include_once (
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1041 return $control_settings;
1045 include_once (
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1051 $control_settings->insert();
1067 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1068 $this->slm_tree->setTreeTablePK(
"slm_id");
1070 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
1079 $target_parent = $this->slm_tree->getParentId(
$target_id);
1083 if ($source_obj->getType() ==
"page")
1085 if ($this->slm_tree->isInTree($source_obj->getId()))
1087 $node_data = $this->slm_tree->getNodeData($source_obj->getId());
1090 if ($movecopy ==
"move")
1092 $parent_id = $this->slm_tree->getParentId($source_obj->getId());
1093 $this->slm_tree->deleteTree($node_data);
1115 if(!$this->slm_tree->isInTree($source_obj->getId()))
1122 else if ($as_subitem)
1126 $pg_childs = $this->slm_tree->getChildsByType($parent,
"page");
1127 if (count($pg_childs) != 0)
1129 $target_pos = $pg_childs[count($pg_childs) - 1][
"obj_id"];
1135 $parent = $target_parent;
1139 $this->slm_tree->insertNode($source_obj->getId(),
1140 $parent, $target_pos);
1161 if ($source_obj->getType() ==
"sco" || $source_obj->getType() ==
"ass")
1164 $source_node = $this->slm_tree->getNodeData($source_id);
1165 $subnodes = $this->slm_tree->getSubtree($source_node);
1168 foreach ($subnodes as $subnode)
1183 $pg_childs = $this->slm_tree->getChildsByType($target_parent,
"page");
1184 if (count($pg_childs) != 0)
1186 $target_pos = $pg_childs[count($pg_childs) - 1][
"obj_id"];
1189 else if ($as_subitem)
1193 $childs = $this->slm_tree->getChilds($target_parent);
1194 if (count($childs) != 0)
1196 $target_pos = $childs[count($childs) - 1][
"obj_id"];
1201 if ($movecopy ==
"move")
1203 $this->slm_tree->deleteTree($source_node);
1212 if (!$this->slm_tree->isInTree($source_id))
1214 $this->slm_tree->insertNode($source_id, $target_parent, $target_pos);
1217 if ($movecopy ==
"move")
1219 foreach ($subnodes as $node)
1221 if($node[
"obj_id"] != $source_id)
1223 $this->slm_tree->insertNode($node[
"obj_id"], $node[
"parent"]);
1234 if ($source_obj->getType() ==
"chap")
1237 $source_node = $this->slm_tree->getNodeData($source_id);
1238 $subnodes = $this->slm_tree->getSubtree($source_node);
1241 foreach ($subnodes as $subnode)
1262 else if ($as_subitem)
1266 $childs = $this->slm_tree->getChilds($target_parent);
1267 if (count($childs) != 0)
1269 $target_pos = $childs[count($childs) - 1][
"obj_id"];
1274 if ($movecopy ==
"move")
1276 $this->slm_tree->deleteTree($source_node);
1285 if (!$this->slm_tree->isInTree($source_id))
1287 $this->slm_tree->insertNode($source_id, $target_parent, $target_pos);
1290 if ($movecopy ==
"move")
1292 foreach ($subnodes as $node)
1294 if($node[
"obj_id"] != $source_id)
1296 $this->slm_tree->insertNode($node[
"obj_id"], $node[
"parent"]);
1313 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Export.php");
1315 $export =
new ilSCORM2004Export($this);
1316 foreach ($export->getSupportedExportTypes() as
$type)
1318 $dir = $export->getExportDirectoryForType(
$type);
1320 if (!@is_dir($dir) or !is_writeable($dir))
1328 while ($entry = $cdir->read())
1330 if ($entry !=
"." and
1333 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(".$this->
getType().
"_)*[0-9]+\.zip\$", $entry) or
1334 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(".$this->
getType().
"_)*[0-9]+\.pdf\$", $entry) or
1335 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(".$this->
getType().
"_)*[0-9]+\.iso\$", $entry)
1338 $file[$entry.$type] = array(
"type" =>
$type,
"file" => $entry,
1339 "size" => filesize($dir.
"/".$entry));
1363 $metadata_xml = $a_xml_writer->xmlDumpMem(
false);
1364 $a_xml_writer->_XmlWriter;
1366 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/metadata.xsl");
1367 $args = array(
'/_xml' => $metadata_xml ,
'/_xsl' => $xsl );
1369 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args,NULL);
1371 file_put_contents($a_target_dir.
'/indexMD.xml',$output);
1377 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1378 include_once(
"./Modules/Glossary/classes/class.ilGlossaryExport.php");
1381 $glo_xml_writer->xmlSetDtdDef(
"<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
1383 $glo_xml_writer->xmlHeader();
1387 $glos->exportXML($glo_xml_writer,$glos_export->getInstId(), $a_target_dir.
"/glossary", $expLog);
1388 $glo_xml_writer->xmlDumpFile($a_target_dir.
"/glossary/glossary.xml");
1389 $glo_xml_writer->_XmlWriter;
1394 $a_xml_writer->
xmlSetDtdDef(
"<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
1397 $a_xml_writer->xmlSetGenCmt(
"Export of ILIAS Content Module ". $this->
getId().
" of installation ".$a_inst.
".");
1400 $a_xml_writer->xmlHeader();
1404 $a_xml_writer->xmlStartTag(
"ContentObject", array(
"Type"=>
"SCORM2004LearningModule"));
1412 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Sco Objects");
1414 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Sco Objects");
1416 $a_xml_writer->xmlEndTag(
"ContentObject");
1417 $a_xml_writer->xmlDumpFile($a_target_dir.
'/index.xml',
false);
1419 if ($ver ==
"2004 4th") {
1424 if ($ver ==
"2004 3rd") {
1430 $css_dir = $a_target_dir.
"/ilias_css_4_2";
1432 include_once(
"./Modules/Scorm2004/classes/class.ilScormExportUtil.php");
1436 include_once(
"./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php");
1438 $manifestBuilder->buildManifest($ver,$revision);
1439 $manifestBuilder->dump($a_target_dir);
1441 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1442 $args = array(
'/_xml' => file_get_contents($a_target_dir.
"/imsmanifest.xml"),
'/_xsl' => $xsl );
1444 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args,NULL);
1446 fputs(fopen($a_target_dir.
'/index.html',
'w+'),$output);
1451 if ($revision ==
"3rd") {
1452 ilUtil::rCopy(
'./Modules/Scorm2004/templates/xsd/adlcp_130_export_2004',$a_target_dir,
false);
1455 if ($revision ==
"4th") {
1456 ilUtil::rCopy(
'./Modules/Scorm2004/templates/xsd/adlcp_130_export_2004_4th',$a_target_dir,
false);
1460 ilUtil::rCopy(
'./Modules/Scorm2004/templates/xsd/adlcp_120_export_12',$a_target_dir,
false);
1464 $a_xml_writer->_XmlWriter;
1472 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1473 $tree->setTreeTablePK(
"slm_id");
1474 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),
true,
'sco') as $sco)
1476 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1477 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1480 $node->exportHTML4PDF($a_inst, $sco_folder, $expLog);
1488 $a_xml_writer->
xmlStartTag(
"ContentObject", array(
"Type"=>
"SCORM2004SCO"));
1491 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1492 $tree->setTreeTablePK(
"slm_id");
1493 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),
true,
'sco') as $sco)
1495 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1496 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1499 $node->exportPDFPrepareXmlNFiles($a_inst, $a_target_dir, $expLog, $a_xml_writer);
1504 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1505 include_once(
"./Modules/Glossary/classes/class.ilGlossaryExport.php");
1508 $glos->exportXML($a_xml_writer,$glos_export->getInstId(), $a_target_dir.
"/glossary", $expLog);
1510 $a_xml_writer->xmlEndTag(
"ContentObject");
1511 include_once
'Services/Transformation/classes/class.ilXML2FO.php';
1513 $xml2FO->setXSLTLocation(
'./Modules/Scorm2004/templates/xsl/contentobject2fo.xsl');
1514 $xml2FO->setXMLString($a_xml_writer->xmlDumpMem());
1515 $xml2FO->setXSLTParams(array (
'target_dir' => $a_target_dir));
1516 $xml2FO->transform();
1517 $fo_string = $xml2FO->getFOString();
1518 $fo_xml = simplexml_load_string($fo_string);
1519 $fo_ext = $fo_xml->xpath(
"//fo:declarations");
1520 $fo_ext = $fo_ext[0];
1522 include_once
"./Services/Utilities/classes/class.ilFileUtils.php";
1526 foreach (
$results[
"file"] as $key => $value)
1528 $e = $fo_ext->addChild(
"fox:embedded-file",
"",
"http://xml.apache.org/fop/extensions");
1529 $e->addAttribute(
"src",
$results[path][$key].$value);
1530 $e->addAttribute(
"name",$value);
1531 $e->addAttribute(
"desc",
"");
1534 $fo_string = $fo_xml->asXML();
1535 $a_xml_writer->_XmlWriter;
1541 $one_file = fopen($a_target_dir.
'/index.html',
'w+');
1542 $this->
exportHTML($a_inst, $a_target_dir, $expLog, $one_file);
1549 function exportHTML($a_inst, $a_target_dir, &$expLog, $a_one_file =
"")
1579 if ($a_one_file ==
"")
1581 include_once(
"./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php");
1583 $manifestBuilder->buildManifest(
'12');
1585 include_once(
"Services/Frameset/classes/class.ilFramesetGUI.php");
1587 $fs_gui->setFramesetTitle($this->
getTitle());
1588 $fs_gui->setMainFrameSource(
"");
1589 $fs_gui->setSideFrameSource(
"toc.html");
1590 $fs_gui->setMainFrameName(
"content");
1591 $fs_gui->setSideFrameName(
"toc");
1592 $output = $fs_gui->get();
1593 fputs(fopen($a_target_dir.
'/index.html',
'w+'),$output);
1595 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1596 $xml = simplexml_load_string($manifestBuilder->writer->xmlDumpMem());
1597 $args = array(
'/_xml' => $xml->organizations->organization->asXml(),
'/_xsl' => $xsl );
1599 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args,NULL);
1601 fputs(fopen($a_target_dir.
'/toc.html',
'w+'),$output);
1614 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
1616 $md2xml->setExportMode(
true);
1617 $md2xml->startExport();
1618 $a_xml_writer->appendXML($md2xml->getXML());
1629 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
1631 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1632 $tree->setTreeTablePK(
"slm_id");
1633 $a_xml_writer->xmlStartTag(
"StructureObject");
1634 foreach($tree->getFilteredSubTree($tree->getRootId(),Array(
'page')) as $obj)
1636 if($obj[
'type']==
'')
continue;
1639 $md2xml =
new ilMD2XML($this->
getId(), $obj[
'obj_id'], $obj[
'type']);
1640 $md2xml->setExportMode(
true);
1641 $md2xml->startExport();
1642 $a_xml_writer->appendXML($md2xml->getXML());
1644 $a_xml_writer->xmlEndTag(
"StructureObject");
1658 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1659 $tree->setTreeTablePK(
"slm_id");
1660 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),
true,array(
'sco',
'ass')) as $sco)
1662 if ($sco[
'type'] ==
"sco")
1664 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1665 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1668 $node->exportScorm($a_inst, $sco_folder, $ver, $expLog);
1670 if ($sco[
'type'] ==
"ass")
1672 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php");
1673 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1676 $node->exportScorm($a_inst, $sco_folder, $ver, $expLog);
1692 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1693 $tree->setTreeTablePK(
"slm_id");
1696 if ($a_one_file !=
"")
1701 $sco_tpl =
new ilTemplate(
"tpl.sco.html",
true,
true,
"Modules/Scorm2004");
1702 include_once(
"./Services/COPage/classes/class.ilCOPageHTMLExport.php");
1705 $sco_tpl->setCurrentBlock(
"js_file");
1706 $sco_tpl->setVariable(
"JS_FILE",
"./js/pure.js");
1707 $sco_tpl->parseCurrentBlock();
1708 $sco_tpl->setCurrentBlock(
"js_file");
1709 $sco_tpl->setVariable(
"JS_FILE",
"./js/question_handling.js");
1710 $sco_tpl->parseCurrentBlock();
1713 $sco_tpl->setCurrentBlock(
"head");
1714 $sco_tpl->parseCurrentBlock();
1715 fputs($a_one_file, $sco_tpl->get(
"head"));
1718 include_once(
"./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php");
1720 $manifestBuilder->buildManifest(
'12');
1721 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1722 $xml = simplexml_load_string($manifestBuilder->writer->xmlDumpMem());
1723 $args = array(
'/_xml' => $xml->organizations->organization->asXml(),
'/_xsl' => $xsl );
1725 $params = array(
"one_page" =>
"y");
1726 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args,
$params);
1728 fputs($a_one_file, $output);
1732 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),
true,
'sco') as $sco)
1734 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1735 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1739 if ($a_one_file ==
"")
1741 $node->exportHTML($a_inst, $sco_folder, $expLog, $a_one_file);
1745 $node->exportHTMLPageObjects($a_inst, $a_target_dir, $expLog,
'full',
1746 "sco", $a_one_file, $sco_tpl);
1750 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1757 if ($a_one_file !=
"")
1760 fputs($a_one_file, $sco_tpl->get(
"tail"));
1774 include_once(
"./Services/Style/classes/class.ilSystemStyleHTMLExport.php");
1776 $this->sys_style_html_export->export();
1779 include_once(
"./Services/COPage/classes/class.ilCOPageHTMLExport.php");
1781 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
1782 $this->co_page_html_export->setContentStyleId(
1784 $this->co_page_html_export->createDirectories();
1785 $this->co_page_html_export->exportStyles();
1786 $this->co_page_html_export->exportSupportScripts();
1788 include_once(
"./Services/MediaObjects/classes/class.ilPlayerUtil.php");
1796 include_once(
"./Services/MediaObjects/classes/class.ilPlayerUtil.php");
1801 copy(
'./Modules/Scorm2004/scripts/scorm_2004.js',$a_target_dir.
'/js/scorm.js');
1802 copy(
'./Modules/Scorm2004/scripts/pager.js',$a_target_dir.
'/js/pager.js');
1803 copy(
'./Modules/Scorm2004/scripts/questions/pure.js',$a_target_dir.
'/js/pure.js');
1804 copy(
'./Modules/Scorm2004/scripts/questions/question_handling.js',
1805 $a_target_dir.
'/js/question_handling.js');
1818 return $this->public_export_file[$a_type];
1827 include_once(
"./Modules/File/classes/class.ilObjFile.php");
1829 foreach ($this->file_ids as $file_id)
1831 $expLog->write(date(
"[y-m-d H:i:s] ").
"File Item ".$file_id);
1832 $file_obj =
new ilObjFile($file_id,
false);
1833 $file_obj->export($a_target_dir);
1843 $this->public_export_file[$a_type] = $a_file;
1863 'SELECT cp_node.cp_node_id ' 1864 .
'FROM cp_node, cp_resource, cp_item ' 1865 .
'WHERE cp_item.cp_node_id = cp_node.cp_node_id ' 1866 .
'AND cp_item.resourceId = cp_resource.id ' 1867 .
'AND scormType = '.$ilDB->quote(
'sco',
'text').
' ' 1868 .
'AND nodeName = '.$ilDB->quote(
'item',
'text').
' ' 1869 .
'AND cp_node.slm_id = '.$ilDB->quote($a_id,
'integer').
' ' 1870 .
'GROUP BY cp_node.cp_node_id' 1875 array_push($scos,
$row[
'cp_node_id']);
1880 for($i = 0; $i < count($scos); $i++)
1882 $res = $ilDB->queryF(
1883 'SELECT c_max FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)',
1884 array(
'integer',
'integer'),
1885 array($a_user, $scos[$i])
1888 if($ilDB->numRows(
$res) > 0)
1891 if(
$row[
'c_max'] != null)
1894 $max =
$row[
'c_max'];
1898 $retVal = ($set == 1) ? $max : null;
1905 $retAr = array(
"raw" => null,
"max" => null,
"scaled" => null);
1906 $val_set = $ilDB->queryF(
"SELECT c_raw, c_max, scaled FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)",
1907 array(
'integer',
'integer'),
1908 array($a_user, $a_cp_node_id)
1910 if ($val_set->numRows()>0)
1912 $val_rec = $ilDB->fetchAssoc($val_set);
1913 $retAr[
"raw"] = $val_rec[
'c_raw'];
1914 $retAr[
"max"] = $val_rec[
'c_max'];
1915 $retAr[
"scaled"] = $val_rec[
'scaled'];
1916 if ($val_rec[
'scaled']==null && $val_rec[
'c_raw']!=null && $val_rec[
'c_max']!=null) {
1917 $retAr[
"scaled"] = ($val_rec[
'c_raw'] / $val_rec[
'c_max']);
1934 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
1938 $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
1939 $new_id = $style_obj->ilClone();
1940 $a_new_obj->setStyleSheetId($new_id);
1941 $a_new_obj->update();
1944 $a_new_obj->createScorm2004Tree();
1945 $source_tree = $this->
getTree();
1946 $target_tree_root_id = $a_new_obj->getTree()->readRootId();
1947 $childs = $source_tree->getChilds($source_tree->readRootId());
1948 $a_copied_nodes = array();
1949 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
1950 foreach ($childs as $c)
const LP_STATUS_COMPLETED_NUM
static _lookupLastAccess($a_obj_id, $a_usr_id)
Return the last access timestamp for a given user.
_getTrackingItems($a_obj_id)
get all tracking items of scorm object
getStyleSheetId()
get ID of assigned style sheet object
copyAuthoredContent($a_new_obj)
Copy authored content (everything done with the editor.
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.
copyPlayerFilesToTargetDirectory($a_target_dir)
Copy css files to target dir.
ilObjSCORM2004LearningModule($a_id=0, $a_call_by_reference=true)
Constructor public.
static exportContentCSS($a_slm_object, $a_target_dir)
Export lm content css to a directory.
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...
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)
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
HTML export class for system styles.
removeCMIDataForUserAndPackage($user_id, $packageId)
const LP_STATUS_IN_PROGRESS_NUM
_ISODurationToCentisec($str)
convert ISO 8601 Timeperiods to centiseconds ta
getAssignedGlossary()
get assigned glossary
getEditable()
Get Editable.
prepareHTMLExporter($a_target_dir)
Prepare HTML exporter.
getPreparedMainTemplate($a_tpl="")
Get prepared main template.
static now()
Return current timestamp in Y-m-d H:i:s format.
static _getScores2004ForUser($a_cp_node_id, $a_user)
exportXMLStructureObjects(&$a_xml_writer, $a_inst, &$expLog)
export structure objects to xml (see ilias_co.dtd)
const LP_STATUS_IN_PROGRESS
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
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)
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 formatDate(ilDateTime $date)
Format a date public.
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.
redirection script todo: (a better solution should control the processing via a xml file) ...
Class ilSCORM2004Sequencing.
getType()
get object type public
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 ...
const LP_STATUS_NOT_ATTEMPTED_NUM
static _getMeasure($a_obj_id, $a_user_id)
getCourseCompletionForUser($a_user)
_lookupStandard($a_id)
Lookup standard flag.
exportXMLScoObjects($a_inst, $a_target_dir, $ver, &$expLog)
export page objects to xml (see ilias_co.dtd)
_refreshStatus($a_obj_id, $a_users=null)
Set dirty.
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.
recursive_dirscan($dir, &$arr)
Recursively scans a given directory and writes path and filename into referenced array.
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...
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.
Content Object (ILIAS native learning module / digilib book) 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)