5require_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");
294 $xsl =
new DOMDocument;
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");
390 foreach($a_users as $user)
405 $sco_set =
$ilDB->queryF(
'
406 SELECT DISTINCT cmi_node.cp_node_id id
407 FROM cp_node, cmi_node
409 AND cp_node.cp_node_id = cmi_node.cp_node_id
410 ORDER BY cp_node.cp_node_id ',
412 array($this->
getId()));
416 while($sco_rec =
$ilDB->fetchAssoc($sco_set))
418 $item[
'id']=$sco_rec[
"id"];
420 $items[count($items)] =$item;
435 $val_set =
$ilDB->queryF(
436 'SELECT cp_node_id FROM cp_node
438 AND cp_node.slm_id = %s',
439 array(
'text',
'integer'),
440 array(
'item',$this->
getId())
442 while($val_rec =
$ilDB->fetchAssoc($val_set))
444 array_push($scos,$val_rec[
'cp_node_id']);
447 foreach ($scos as $sco)
449 $data_set =
$ilDB->queryF(
'
450 SELECT c_timestamp last_access, total_time, success_status, completion_status,
451 c_raw, scaled, cp_node_id
453 WHERE cp_node_id = %s
455 array(
'integer',
'integer'),
456 array($sco,$a_user_id)
459 while($data_rec =
$ilDB->fetchAssoc($data_set))
461 if ($data_rec[
"success_status"]!=
"" && $data_rec[
"success_status"]!=
"unknown") {
462 $status = $data_rec[
"success_status"];
464 if ($data_rec[
"completion_status"]==
"") {
467 $status = $data_rec[
"completion_status"];
474 if ($data_rec[
"c_raw"] !=
null) {
475 $score = $data_rec[
"c_raw"];
476 if ($data_rec[
"scaled"] !=
null) $score .=
" = ";
478 if ($data_rec[
"scaled"] !=
null) $score .= ($data_rec[
"scaled"]*100).
"%";
481 $data[] = array(
"user_id" => $data_rec[
"user_id"],
"sco_id"=>$data_rec[
"cp_node_id"],
482 "score" => $score,
"time" => $time,
"status" => $status,
"last_access"=>$last_access,
"title"=>
$title);
487 $data[$data_rec[
"cp_node_id"]] = $data_rec;
501 $val_set =
$ilDB->queryF(
'SELECT package_attempts FROM sahs_user WHERE user_id = %s AND obj_id = %s',
502 array(
'integer',
'integer'),
503 array($a_user_id, $this->
getId()));
505 $val_rec =
$ilDB->fetchAssoc($val_set);
507 if ($val_rec[
"package_attempts"] ==
null) {
508 $val_rec[
"package_attempts"]=
"";
511 return $val_rec[
"package_attempts"];
520 $val_set =
$ilDB->queryF(
'SELECT module_version FROM sahs_user WHERE user_id = %s AND obj_id = %s',
521 array(
'integer',
'integer'),
522 array($a_user_id, $this->
getId()));
524 $val_rec =
$ilDB->fetchAssoc($val_set);
526 if ($val_rec[
"module_version"] ==
null) {
527 $val_rec[
"module_version"]=
"";
529 return $val_rec[
"module_version"];
543 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
546 include_once
'./Services/Object/classes/class.ilObjectLP.php';
548 $collection = $olp->getCollectionInstance();
551 $scos = $collection->getItems();
554 $fhandle = fopen($a_file,
"r");
556 $obj_id = $this->getID();
559 $fields = fgetcsv($fhandle, 4096,
';');
560 while(($csv_rows = fgetcsv($fhandle, 4096,
";")) !== FALSE) {
561 $data = array_combine($fields, $csv_rows);
570 $date_ex = explode(
'.',
$data[
'Date']);
571 $last_access = implode(
'-', array($date_ex[2], $date_ex[1], $date_ex[0]));
573 if (
$data[
'LastAccess']) {
574 $last_access =
$data[
'LastAccess'];
579 if (
$data[
"Status"]) {
580 if (is_int(
$data[
"Status"])) $status =
$data[
"Status"];
586 if(
$data[
"Attempts"]) $attempts =
$data[
"Attempts"];
588 $percentage_completed = 0;
590 if (
$data[
'percentageCompletedSCOs']) $percentage_completed =
$data[
'percentageCompletedSCOs'];
592 $sco_total_time_sec =
null;
593 if (
$data[
'SumTotal_timeSeconds']) $sco_total_time_sec =
$data[
'SumTotal_timeSeconds'];
595 $this->
importSuccessForSahsUser($user_id, $last_access, $status, $attempts, $percentage_completed, $sco_total_time_sec);
598 foreach ($scos as $sco_id)
601 SELECT * FROM cmi_node WHERE cp_node_id = %s AND user_id = %s AND (completion_status = %s OR success_status = %s)',
602 array(
'integer',
'integer',
'text',
'text'),
603 array($sco_id,$user_id,
'completed',
'passed'));
607 $nextId =
$ilDB->nextId(
'cmi_node');
608 $val_set =
$ilDB->manipulateF(
'INSERT INTO cmi_node
609 (cp_node_id,user_id,completion_status,c_timestamp,cmi_node_id)
610 VALUES(%s,%s,%s,%s,%s)',
611 array(
'integer',
'integer',
'text',
'timestamp',
'integer'),
612 array($sco_id,$user_id,
'completed',$last_access,$nextId));
614 $ilDB->update(
'cmi_node',
616 'completion_status' => array(
'text',
'completed'),
617 'success_status' => array(
'text',
''),
618 'c_timestamp' => array(
'timestamp', $last_access)
621 'user_id' => array(
'integer', $user_id),
622 'cp_node_id' => array(
'integer', $sco_id)
635 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
648 $aV = array(0, 0, 0, 0, 0, 0);
651 if (strpos($str,
"P") != 0) {
655 $aT = array(
"Y",
"M",
"D",
"H",
"M",
"S");
658 $str = substr($str,1);
659 for ($i = 0; $i < count($aT); $i++) {
660 if (strpos($str,
"T")===0) {
661 $str = substr($str,1);
665 $p = strpos($str,$aT[$i]);
668 if ($i == 1 && strpos($str,
"T") > -1 && strpos($str,
"T") < $p) {
671 if ($aT[$i] ==
"S") {
672 $aV[$i] = substr($str,0, $p);
675 $aV[$i] = intval(substr($str,0, $p));
677 if (!is_numeric($aV[$i])) {
680 }
else if ($i > 2 && !$bTFound) {
684 $str = substr($str,$p + 1);
688 if (!$bErr && strlen($str) != 0) {
697 return $aV[0] * 3155760000 + $aV[1] * 262980000 + $aV[2] * 8640000 + $aV[3] * 360000 + $aV[4] * 6000 + round($aV[5] * 100);
707 $val_set =
$ilDB->queryF(
'
708 SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item
709 WHERE cp_item.cp_node_id = cp_node.cp_node_id
710 AND cp_item.resourceid = cp_resource.id
713 AND cp_node.slm_id = %s ',
714 array(
'text',
'text',
'integer'),
715 array(
'sco',
'item',$this->
getId()));
717 while ($val_rec =
$ilDB->fetchAssoc($val_set))
719 array_push($scos,$val_rec[
'cp_node_id']);
726 for ($i=0;$i<count($scos);$i++)
729 $val_set =
$ilDB->queryF(
'
730 SELECT * FROM cmi_node
733 AND (completion_status=%s OR success_status=%s))',
734 array(
'integer',
'integer',
'text',
'text'),
735 array($a_user,$scos[$i],
'completed',
'passed')
738 if (
$ilDB->numRows($val_set) > 0) {
740 $key = array_search($scos[$i], $scos_c);
741 unset ($scos_c[$key]);
746 if (count($scos_c) == 0) {
766 $val_set =
$ilDB->queryF(
'
767 SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item
768 WHERE cp_item.cp_node_id = cp_node.cp_node_id
769 AND cp_item.resourceid = cp_resource.id
772 AND cp_node.slm_id = %s',
773 array(
'text',
'text',
'integer'), array(
'sco' ,
'item',$a_id));
774 while ($val_rec =
$ilDB->fetchAssoc($val_set))
776 array_push($scos,$val_rec[
'cp_node_id']);
782 for ($i=0;$i<count($scos);$i++)
785 $val_set =
$ilDB->queryF(
'
786 SELECT * FROM cmi_node
789 AND (completion_status = %s OR success_status = %s))',
790 array(
'integer',
'integer',
'text',
'text'),
791 array($a_user,$scos[$i],
'completed',
'passed'));
793 if (
$ilDB->numRows($val_set) > 0)
796 $key = array_search($scos[$i], $scos_c);
797 unset ($scos_c[$key]);
802 if (count($scos_c) == 0) {
822 $val_set =
$ilDB->queryF(
"SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item WHERE".
823 " 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",
827 while ($val_rec =
$ilDB->fetchAssoc($val_set))
829 array_push($scos,$val_rec[
'cp_node_id']);
833 for ($i=0;$i<count($scos);$i++)
835 $val_set =
$ilDB->queryF(
"SELECT scaled FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)",
836 array(
'integer',
'integer'),
837 array($a_user, $scos[$i])
839 if ($val_set->numRows()>0)
841 $val_rec =
$ilDB->fetchAssoc($val_set);
842 if ($val_rec[
'scaled']!=NULL) {
844 $scaled = $val_rec[
'scaled'];
848 $retVal = ($set == 1) ? $scaled :
null ;
865 $item_set =
$ilDB->queryF(
'
866 SELECT cp_item.* FROM cp_node, cp_item WHERE slm_id = %s
867 AND cp_node.cp_node_id = cp_item.cp_node_id
868 ORDER BY cp_node.cp_node_id ',
874 while ($item_rec =
$ilDB->fetchAssoc($item_set))
877 $s2 =
$ilDB->queryF(
'
878 SELECT cp_resource.* FROM cp_node, cp_resource
880 AND cp_node.cp_node_id = cp_resource.cp_node_id
881 AND cp_resource.id = %s ',
882 array(
'integer',
'text'),
883 array($a_obj_id,$item_rec[
"resourceid"])
890 if (
$res[
"scormtype"] ==
"sco")
892 $items[] = array(
"id" => $item_rec[
"cp_node_id"],
893 "title" => $item_rec[
"title"]);
905 $status_set =
$ilDB->queryF(
'
906 SELECT * FROM cmi_gobjective
908 AND objective_id = %s
910 array(
'integer',
'text',
'integer'),
911 array($a_obj_id,
'course_overall_status',$a_user_id)
914 if ($status_rec =
$ilDB->fetchAssoc($status_set))
916 return $status_rec[
"status"];
927 $status_set =
$ilDB->queryF(
'
928 SELECT * FROM cmi_gobjective
930 AND objective_id = %s
932 array(
'integer',
'text',
'integer'),
933 array($a_obj_id,
'course_overall_status',$a_user_id)
936 if ($status_rec =
$ilDB->fetchAssoc($status_set))
938 return $status_rec[
"satisfied"];
948 $status_set =
$ilDB->queryF(
'
949 SELECT * FROM cmi_gobjective
951 AND objective_id = %s
953 array(
'integer',
'text',
'integer'),
954 array($a_obj_id,
'course_overall_status',$a_user_id)
957 if ($status_rec =
$ilDB->fetchAssoc($status_set))
959 return $status_rec[
"measure"];
970 SELECT * FROM cp_item
971 WHERE cp_node_id = %s',
976 if ($i =
$ilDB->fetchAssoc($r))
988 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Tree.php");
994 $this->slm_tree->addTree($this->
getId(), 1);
997 include_once (
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1005 $this->slm_tree->setTreeTablePK(
"slm_id");
1006 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1007 return $this->slm_tree;
1013 $ilTabs->setTabActive(
"sequencing");
1015 include_once (
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1018 return $control_settings;
1022 include_once (
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1028 $control_settings->insert();
1044 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1045 $this->slm_tree->setTreeTablePK(
"slm_id");
1047 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
1056 $target_parent = $this->slm_tree->getParentId(
$target_id);
1060 if ($source_obj->getType() ==
"page")
1062 if ($this->slm_tree->isInTree($source_obj->getId()))
1064 $node_data = $this->slm_tree->getNodeData($source_obj->getId());
1067 if ($movecopy ==
"move")
1069 $parent_id = $this->slm_tree->getParentId($source_obj->getId());
1070 $this->slm_tree->deleteTree($node_data);
1092 if(!$this->slm_tree->isInTree($source_obj->getId()))
1099 else if ($as_subitem)
1103 $pg_childs = $this->slm_tree->getChildsByType($parent,
"page");
1104 if (count($pg_childs) != 0)
1106 $target_pos = $pg_childs[count($pg_childs) - 1][
"obj_id"];
1112 $parent = $target_parent;
1116 $this->slm_tree->insertNode($source_obj->getId(),
1117 $parent, $target_pos);
1138 if ($source_obj->getType() ==
"sco" || $source_obj->getType() ==
"ass")
1141 $source_node = $this->slm_tree->getNodeData($source_id);
1142 $subnodes = $this->slm_tree->getSubtree($source_node);
1145 foreach ($subnodes as $subnode)
1160 $pg_childs = $this->slm_tree->getChildsByType($target_parent,
"page");
1161 if (count($pg_childs) != 0)
1163 $target_pos = $pg_childs[count($pg_childs) - 1][
"obj_id"];
1166 else if ($as_subitem)
1170 $childs = $this->slm_tree->getChilds($target_parent);
1171 if (count($childs) != 0)
1173 $target_pos = $childs[count($childs) - 1][
"obj_id"];
1178 if ($movecopy ==
"move")
1180 $this->slm_tree->deleteTree($source_node);
1189 if (!$this->slm_tree->isInTree($source_id))
1191 $this->slm_tree->insertNode($source_id, $target_parent, $target_pos);
1194 if ($movecopy ==
"move")
1196 foreach ($subnodes as $node)
1198 if($node[
"obj_id"] != $source_id)
1200 $this->slm_tree->insertNode($node[
"obj_id"], $node[
"parent"]);
1211 if ($source_obj->getType() ==
"chap")
1214 $source_node = $this->slm_tree->getNodeData($source_id);
1215 $subnodes = $this->slm_tree->getSubtree($source_node);
1218 foreach ($subnodes as $subnode)
1239 else if ($as_subitem)
1243 $childs = $this->slm_tree->getChilds($target_parent);
1244 if (count($childs) != 0)
1246 $target_pos = $childs[count($childs) - 1][
"obj_id"];
1251 if ($movecopy ==
"move")
1253 $this->slm_tree->deleteTree($source_node);
1262 if (!$this->slm_tree->isInTree($source_id))
1264 $this->slm_tree->insertNode($source_id, $target_parent, $target_pos);
1267 if ($movecopy ==
"move")
1269 foreach ($subnodes as $node)
1271 if($node[
"obj_id"] != $source_id)
1273 $this->slm_tree->insertNode($node[
"obj_id"], $node[
"parent"]);
1290 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Export.php");
1292 $export =
new ilSCORM2004Export($this);
1293 foreach ($export->getSupportedExportTypes() as
$type)
1295 $dir = $export->getExportDirectoryForType(
$type);
1297 if (!@is_dir($dir) or !is_writeable($dir))
1305 while ($entry = $cdir->read())
1307 if ($entry !=
"." and
1310 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(".$this->
getType().
"_)*[0-9]+\.zip\$", $entry) or
1311 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(".$this->
getType().
"_)*[0-9]+\.pdf\$", $entry) or
1312 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(".$this->
getType().
"_)*[0-9]+\.iso\$", $entry)
1315 $file[$entry.$type] = array(
"type" =>
$type,
"file" => $entry,
1316 "size" => filesize($dir.
"/".$entry));
1340 $metadata_xml = $a_xml_writer->xmlDumpMem(
false);
1341 $a_xml_writer->_XmlWriter;
1343 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/metadata.xsl");
1344 $args = array(
'/_xml' => $metadata_xml ,
'/_xsl' => $xsl );
1346 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args,NULL);
1348 file_put_contents($a_target_dir.
'/indexMD.xml',$output);
1354 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1355 include_once(
"./Modules/Glossary/classes/class.ilGlossaryExport.php");
1358 $glo_xml_writer->xmlSetDtdDef(
"<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
1360 $glo_xml_writer->xmlHeader();
1364 $glos->exportXML($glo_xml_writer,$glos_export->getInstId(), $a_target_dir.
"/glossary", $expLog);
1365 $glo_xml_writer->xmlDumpFile($a_target_dir.
"/glossary/glossary.xml");
1366 $glo_xml_writer->_XmlWriter;
1371 $a_xml_writer->
xmlSetDtdDef(
"<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
1374 $a_xml_writer->xmlSetGenCmt(
"Export of ILIAS Content Module ". $this->
getId().
" of installation ".$a_inst.
".");
1377 $a_xml_writer->xmlHeader();
1381 $a_xml_writer->xmlStartTag(
"ContentObject", array(
"Type"=>
"SCORM2004LearningModule"));
1389 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Sco Objects");
1391 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Sco Objects");
1393 $a_xml_writer->xmlEndTag(
"ContentObject");
1394 $a_xml_writer->xmlDumpFile($a_target_dir.
'/index.xml',
false);
1396 if ($ver ==
"2004 4th") {
1401 if ($ver ==
"2004 3rd") {
1407 $css_dir = $a_target_dir.
"/ilias_css_4_2";
1409 include_once(
"./Modules/Scorm2004/classes/class.ilScormExportUtil.php");
1413 include_once(
"./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php");
1415 $manifestBuilder->buildManifest($ver,$revision);
1416 $manifestBuilder->dump($a_target_dir);
1418 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1419 $args = array(
'/_xml' => file_get_contents($a_target_dir.
"/imsmanifest.xml"),
'/_xsl' => $xsl );
1421 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args,NULL);
1423 fputs(fopen($a_target_dir.
'/index.html',
'w+'),$output);
1428 if ($revision ==
"3rd") {
1429 ilUtil::rCopy(
'./Modules/Scorm2004/templates/xsd/adlcp_130_export_2004',$a_target_dir,
false);
1432 if ($revision ==
"4th") {
1433 ilUtil::rCopy(
'./Modules/Scorm2004/templates/xsd/adlcp_130_export_2004_4th',$a_target_dir,
false);
1437 ilUtil::rCopy(
'./Modules/Scorm2004/templates/xsd/adlcp_120_export_12',$a_target_dir,
false);
1441 $a_xml_writer->_XmlWriter;
1449 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1450 $tree->setTreeTablePK(
"slm_id");
1451 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),
true,
'sco') as $sco)
1453 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1454 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1457 $node->exportHTML4PDF($a_inst, $sco_folder, $expLog);
1465 $a_xml_writer->
xmlStartTag(
"ContentObject", array(
"Type"=>
"SCORM2004SCO"));
1468 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1469 $tree->setTreeTablePK(
"slm_id");
1470 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->exportPDFPrepareXmlNFiles($a_inst, $a_target_dir, $expLog, $a_xml_writer);
1481 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1482 include_once(
"./Modules/Glossary/classes/class.ilGlossaryExport.php");
1485 $glos->exportXML($a_xml_writer,$glos_export->getInstId(), $a_target_dir.
"/glossary", $expLog);
1487 $a_xml_writer->xmlEndTag(
"ContentObject");
1488 include_once
'Services/Transformation/classes/class.ilXML2FO.php';
1490 $xml2FO->setXSLTLocation(
'./Modules/Scorm2004/templates/xsl/contentobject2fo.xsl');
1491 $xml2FO->setXMLString($a_xml_writer->xmlDumpMem());
1492 $xml2FO->setXSLTParams(array (
'target_dir' => $a_target_dir));
1493 $xml2FO->transform();
1494 $fo_string = $xml2FO->getFOString();
1495 $fo_xml = simplexml_load_string($fo_string);
1496 $fo_ext = $fo_xml->xpath(
"//fo:declarations");
1497 $fo_ext = $fo_ext[0];
1499 include_once
"./Services/Utilities/classes/class.ilFileUtils.php";
1503 foreach (
$results[
"file"] as $key => $value)
1505 $e = $fo_ext->addChild(
"fox:embedded-file",
"",
"http://xml.apache.org/fop/extensions");
1506 $e->addAttribute(
"src",
$results[path][$key].$value);
1507 $e->addAttribute(
"name",$value);
1508 $e->addAttribute(
"desc",
"");
1511 $fo_string = $fo_xml->asXML();
1512 $a_xml_writer->_XmlWriter;
1518 $one_file = fopen($a_target_dir.
'/index.html',
'w+');
1519 $this->
exportHTML($a_inst, $a_target_dir, $expLog, $one_file);
1526 function exportHTML($a_inst, $a_target_dir, &$expLog, $a_one_file =
"")
1556 if ($a_one_file ==
"")
1558 include_once(
"./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php");
1560 $manifestBuilder->buildManifest(
'12');
1562 include_once(
"Services/Frameset/classes/class.ilFramesetGUI.php");
1564 $fs_gui->setFramesetTitle($this->
getTitle());
1565 $fs_gui->setMainFrameSource(
"");
1566 $fs_gui->setSideFrameSource(
"toc.html");
1567 $fs_gui->setMainFrameName(
"content");
1568 $fs_gui->setSideFrameName(
"toc");
1569 $output = $fs_gui->get();
1570 fputs(fopen($a_target_dir.
'/index.html',
'w+'),$output);
1572 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1573 $xml = simplexml_load_string($manifestBuilder->writer->xmlDumpMem());
1574 $args = array(
'/_xml' => $xml->organizations->organization->asXml(),
'/_xsl' => $xsl );
1576 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args,NULL);
1578 fputs(fopen($a_target_dir.
'/toc.html',
'w+'),$output);
1591 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
1593 $md2xml->setExportMode(
true);
1594 $md2xml->startExport();
1595 $a_xml_writer->appendXML($md2xml->getXML());
1606 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
1608 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1609 $tree->setTreeTablePK(
"slm_id");
1610 $a_xml_writer->xmlStartTag(
"StructureObject");
1611 foreach($tree->getFilteredSubTree($tree->getRootId(),Array(
'page')) as $obj)
1613 if($obj[
'type']==
'')
continue;
1616 $md2xml =
new ilMD2XML($this->
getId(), $obj[
'obj_id'], $obj[
'type']);
1617 $md2xml->setExportMode(
true);
1618 $md2xml->startExport();
1619 $a_xml_writer->appendXML($md2xml->getXML());
1621 $a_xml_writer->xmlEndTag(
"StructureObject");
1635 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1636 $tree->setTreeTablePK(
"slm_id");
1637 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),
true,array(
'sco',
'ass')) as $sco)
1639 if ($sco[
'type'] ==
"sco")
1641 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1642 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1645 $node->exportScorm($a_inst, $sco_folder, $ver, $expLog);
1647 if ($sco[
'type'] ==
"ass")
1649 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php");
1650 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1653 $node->exportScorm($a_inst, $sco_folder, $ver, $expLog);
1669 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1670 $tree->setTreeTablePK(
"slm_id");
1673 if ($a_one_file !=
"")
1678 $sco_tpl =
new ilTemplate(
"tpl.sco.html",
true,
true,
"Modules/Scorm2004");
1679 include_once(
"./Services/COPage/classes/class.ilCOPageHTMLExport.php");
1682 $sco_tpl->setCurrentBlock(
"js_file");
1683 $sco_tpl->setVariable(
"JS_FILE",
"./js/pure.js");
1684 $sco_tpl->parseCurrentBlock();
1685 $sco_tpl->setCurrentBlock(
"js_file");
1686 $sco_tpl->setVariable(
"JS_FILE",
"./js/question_handling.js");
1687 $sco_tpl->parseCurrentBlock();
1690 $sco_tpl->setCurrentBlock(
"head");
1691 $sco_tpl->parseCurrentBlock();
1692 fputs($a_one_file, $sco_tpl->get(
"head"));
1695 include_once(
"./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php");
1697 $manifestBuilder->buildManifest(
'12');
1698 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1699 $xml = simplexml_load_string($manifestBuilder->writer->xmlDumpMem());
1700 $args = array(
'/_xml' => $xml->organizations->organization->asXml(),
'/_xsl' => $xsl );
1702 $params = array(
"one_page" =>
"y");
1703 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args,$params);
1705 fputs($a_one_file, $output);
1709 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),
true,
'sco') as $sco)
1711 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1712 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1716 if ($a_one_file ==
"")
1718 $node->exportHTML($a_inst, $sco_folder, $expLog, $a_one_file);
1722 $node->exportHTMLPageObjects($a_inst, $a_target_dir, $expLog,
'full',
1723 "sco", $a_one_file, $sco_tpl);
1727 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1734 if ($a_one_file !=
"")
1737 fputs($a_one_file, $sco_tpl->get(
"tail"));
1751 include_once(
"./Services/Style/classes/class.ilSystemStyleHTMLExport.php");
1753 $this->sys_style_html_export->export();
1756 include_once(
"./Services/COPage/classes/class.ilCOPageHTMLExport.php");
1758 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
1759 $this->co_page_html_export->setContentStyleId(
1761 $this->co_page_html_export->createDirectories();
1762 $this->co_page_html_export->exportStyles();
1763 $this->co_page_html_export->exportSupportScripts();
1765 include_once(
"./Services/MediaObjects/classes/class.ilPlayerUtil.php");
1773 include_once(
"./Services/MediaObjects/classes/class.ilPlayerUtil.php");
1778 copy(
'./Modules/Scorm2004/scripts/scorm_2004.js',$a_target_dir.
'/js/scorm.js');
1779 copy(
'./Modules/Scorm2004/scripts/pager.js',$a_target_dir.
'/js/pager.js');
1780 copy(
'./Modules/Scorm2004/scripts/questions/pure.js',$a_target_dir.
'/js/pure.js');
1781 copy(
'./Modules/Scorm2004/scripts/questions/question_handling.js',
1782 $a_target_dir.
'/js/question_handling.js');
1795 return $this->public_export_file[$a_type];
1804 include_once(
"./Modules/File/classes/class.ilObjFile.php");
1806 foreach ($this->file_ids as $file_id)
1808 $expLog->write(date(
"[y-m-d H:i:s] ").
"File Item ".$file_id);
1809 $file_obj =
new ilObjFile($file_id,
false);
1810 $file_obj->export($a_target_dir);
1820 $this->public_export_file[$a_type] = $a_file;
1840 'SELECT cp_node.cp_node_id '
1841 .
'FROM cp_node, cp_resource, cp_item '
1842 .
'WHERE cp_item.cp_node_id = cp_node.cp_node_id '
1843 .
'AND cp_item.resourceId = cp_resource.id '
1844 .
'AND scormType = '.
$ilDB->quote(
'sco',
'text').
' '
1845 .
'AND nodeName = '.
$ilDB->quote(
'item',
'text').
' '
1846 .
'AND cp_node.slm_id = '.
$ilDB->quote($a_id,
'integer').
' '
1847 .
'GROUP BY cp_node.cp_node_id'
1852 array_push($scos,
$row[
'cp_node_id']);
1857 for($i = 0; $i < count($scos); $i++)
1860 'SELECT c_max FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)',
1861 array(
'integer',
'integer'),
1862 array($a_user, $scos[$i])
1868 if(
$row[
'c_max'] !=
null)
1871 $max =
$row[
'c_max'];
1875 $retVal = ($set == 1) ? $max :
null;
1882 $retAr = array(
"raw" =>
null,
"max" =>
null,
"scaled" =>
null);
1883 $val_set =
$ilDB->queryF(
"SELECT c_raw, c_max, scaled FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)",
1884 array(
'integer',
'integer'),
1885 array($a_user, $a_cp_node_id)
1887 if ($val_set->numRows()>0)
1889 $val_rec =
$ilDB->fetchAssoc($val_set);
1890 $retAr[
"raw"] = $val_rec[
'c_raw'];
1891 $retAr[
"max"] = $val_rec[
'c_max'];
1892 $retAr[
"scaled"] = $val_rec[
'scaled'];
1893 if ($val_rec[
'scaled']==
null && $val_rec[
'c_raw']!=
null && $val_rec[
'c_max']!=
null) {
1894 $retAr[
"scaled"] = ($val_rec[
'c_raw'] / $val_rec[
'c_max']);
1911 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
1915 $style_obj =
$ilias->obj_factory->getInstanceByObjId($style_id);
1916 $new_id = $style_obj->ilClone();
1917 $a_new_obj->setStyleSheetId($new_id);
1918 $a_new_obj->update();
1921 $a_new_obj->createScorm2004Tree();
1922 $source_tree = $this->
getTree();
1923 $target_tree_root_id = $a_new_obj->getTree()->readRootId();
1924 $childs = $source_tree->getChilds($source_tree->readRootId());
1925 $a_copied_nodes = array();
1926 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
1927 foreach ($childs as $c)
HTML export class for pages.
getPreparedMainTemplate($a_tpl="")
Get prepared main template.
Content Object (ILIAS native learning module / digilib book) Manifest export class.
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
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_no_raise=false, $a_force_raise=false)
Update status.
_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.
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)
exportPDF($a_inst, $a_target_dir, &$expLog)
exportHTML($a_inst, $a_target_dir, &$expLog, $a_one_file="")
Export SCORM package to HTML.
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
_getTrackingItems($a_obj_id)
get all tracking items of scorm object
static _getScores2004ForUser($a_cp_node_id, $a_user)
ilObjSCORM2004LearningModule($a_id=0, $a_call_by_reference=true)
Constructor @access public.
static _lookupItemTitle($a_node_id)
convert_1_2_to_2004($manifest)
setPublicExportFile($a_type, $a_file)
prepareHTMLExporter($a_target_dir)
Prepare HTML exporter.
_ISODurationToCentisec($str)
convert ISO 8601 Timeperiods to centiseconds ta
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 getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
_lookupStandard($a_id)
Lookup standard flag.
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.
copyPlayerFilesToTargetDirectory($a_target_dir)
Copy css files to target dir.
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)
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.
redirection script todo: (a better solution should control the processing via a xml file)