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';
60 if (!function_exists(
'json_encode') || !function_exists(
'json_decode') || ($ilDB->getDBType() ==
'mysql' && !$ilDB->isMysql4_1OrHigher())) {
61 $ilias->raiseError($lng->txt(
'scplayer_phpmysqlcheck'),$ilias->error_obj->WARNING);
65 include_once(
"include/inc.utf8checker.php");
66 $needs_convert =
false;
73 $check_for_manifest_file = is_file($manifest_file);
78 if (!$check_for_manifest_file)
80 $this->ilias->raiseError($this->lng->txt(
"Manifestfile $manifest_file not found!"), $this->ilias->error_obj->MESSAGE);
85 if ($check_for_manifest_file)
87 $manifest_file_array = file($manifest_file);
89 foreach($manifest_file_array as $mfa)
94 $needs_convert =
true;
102 $estimated_manifest_filesize = filesize($manifest_file) * 2;
106 $check_disc_free = 2;
114 if ($check_for_manifest_file && ($check_disc_free > 1))
118 if (!copy($manifest_file, $manifest_file.
".old"))
120 echo
"Failed to copy $manifest_file...<br>\n";
125 $f_write_handler = fopen($manifest_file.
".new",
"w");
126 $f_read_handler = fopen($manifest_file.
".old",
"r");
127 while (!feof($f_read_handler))
129 $zeile = fgets($f_read_handler);
131 fputs($f_write_handler, utf8_encode($zeile));
133 fclose($f_read_handler);
134 fclose($f_write_handler);
137 if (!copy($manifest_file.
".new", $manifest_file))
139 echo
"Failed to copy $manifest_file...<br>\n";
142 if (!@is_file($manifest_file))
144 $this->ilias->raiseError($this->lng->txt(
"cont_no_manifest"),
145 $this->ilias->error_obj->WARNING);
152 if (!($check_disc_free > 1))
153 $this->ilias->raiseError($this->lng->txt(
"Not enough space left on device!"),$this->ilias->error_obj->MESSAGE);
161 $hmani = fopen($manifest_file,
"r");
162 $start = fread($hmani, 3);
163 if (strtolower(bin2hex($start)) ==
"efbbbf")
165 $f_write_handler = fopen($manifest_file.
".new",
"w");
166 while (!feof($hmani))
168 $n = fread($hmani, 900);
169 fputs($f_write_handler, $n);
171 fclose($f_write_handler);
175 if (!copy($manifest_file.
".new", $manifest_file))
177 echo
"Failed to copy $manifest_file...<br>\n";
187 if (
$_POST[
"validate"] ==
"y")
192 $this->ilias->error_obj->WARNING);
201 include_once (
"./Modules/Scorm2004/classes/ilSCORM13Package.php");
203 if (
$_POST[
"editable"] ==
"y")
210 $out = file_get_contents($this->imsmanifestFile);
211 $check =
'/xmlns="http:\/\/www.imsglobal.org\/xsd\/imscp_v1p1"/';
212 $replace=
"xmlns=\"http://www.imsproject.org/xsd/imscp_rootv1p1p2\"";
213 $out=preg_replace($check, $replace,
$out);
214 file_put_contents($this->imsmanifestFile,
$out);
221 ##check manifest-file for version. Check for schemaversion as this is a required element for SCORM 2004
222 ##accept 2004 3rd Edition an CAM 1.3 as valid schemas
226 $this->imsmanifestFile=$manifest;
227 $doc =
new DomDocument();
231 $doc->load($this->imsmanifestFile);
232 $elements = $doc->getElementsByTagName(
"schemaversion");
233 $schema=$elements->item(0)->nodeValue;
234 if (strtolower(trim($schema))==
"cam 1.3" || strtolower(trim($schema))==
"2004 3rd edition") {
236 $this->converted=
false;
240 $this->converted=
true;
244 $organizations = $doc->getElementsByTagName(
"organizations");
245 $default=$organizations->item(0)->getAttribute(
"default");
246 if ($default==
"" || $default==null) {
248 $organization = $doc->getElementsByTagName(
"organization");
249 $ident=$organization->item(0)->getAttribute(
"identifier");
250 $organizations->item(0)->setAttribute(
"default",$ident);
257 $wrapperdir=$this->packageFolder.
"/GenericRunTimeWrapper1.0_aadlc";
259 copy(self::WRAPPER_HTML,$wrapperdir.
"/GenericRunTimeWrapper.htm");
260 copy(self::WRAPPER_JS,$wrapperdir.
"/SCOPlayerWrapper.js");
263 $this->backupManifest=$this->packageFolder.
"/imsmanifest.xml.back";
264 $ret=copy($this->imsmanifestFile,$this->backupManifest);
267 $this->totransform = $doc;
268 $ilLog->write(
"SCORM: about to transform to SCORM 2004");
270 $xsl =
new DOMDocument;
272 $xsl->load(self::CONVERT_XSL);
273 $prc =
new XSLTProcessor;
274 $r = @$prc->importStyleSheet($xsl);
276 file_put_contents($this->imsmanifestFile, $prc->transformToXML($this->totransform));
278 $ilLog->write(
"SCORM: Transoformation completed");
295 $result = $ilDB->queryF(
'
296 SELECT MAX(c_timestamp) last_access
297 FROM cmi_node, cp_node
298 WHERE cmi_node.cp_node_id = cp_node.cp_node_id
299 AND cp_node.slm_id = %s
301 ORDER BY c_timestamp DESC',
302 array(
'integer',
'integer'),
303 array($a_obj_id, $a_usr_id));
304 if ($ilDB->numRows($result))
306 $row = $ilDB->fetchAssoc($result);
307 return $row[
"last_access"];
318 global $ilUser,
$ilDB, $ilUser;
320 $sco_set = $ilDB->queryF(
'
321 SELECT DISTINCT user_id,MAX(c_timestamp) last_access
322 FROM cmi_node, cp_node
323 WHERE cmi_node.cp_node_id = cp_node.cp_node_id
324 AND cp_node.slm_id = %s
327 array($this->
getId()));
332 while($sco_rec = $ilDB->fetchAssoc($sco_set))
335 if ($sco_rec[
'last_access'] != 0) {
339 $sco_rec[
'last_access'] =
"";
341 if (
ilObject::_exists($sco_rec[
'user_id']) && ilObject::_lookUpType($sco_rec[
'user_id'])==
"usr" ) {
342 $user =
new ilObjUser($sco_rec[
'user_id']);
343 $temp = array(
"user_full_name" =>
$name[
"lastname"].
", ".
345 "user_id" => $sco_rec[
"user_id"],
"last_access" => $sco_rec[
'last_access'],
346 "user_id" => $sco_rec[
"user_id"],
"last_access" => $sco_rec[
'last_access'],
349 "username" => $user->getLastname().
", ".$user->getFirstname()
351 if ($a_search !=
"" && (strpos(strtolower($user->getLastname()), strtolower($a_search)) !==
false || strpos(strtolower($user->getFirstname()), strtolower($a_search)) !==
false ) ) {
353 }
else if ($a_search ==
"") {
369 foreach($a_users as $user)
371 $res = $ilDB->manipulateF(
372 'DELETE FROM cmi_node WHERE user_id = %s'.
373 'AND cp_node_id IN (SELECT cp_node_id FROM cp_node WHERE slm_id = %s)',
374 array(
'integer',
'integer'),
375 array($user, $this->
getId()));
378 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
386 global $ilUser,
$ilDB, $ilUser;
388 $sco_set = $ilDB->queryF(
'
389 SELECT DISTINCT cmi_node.cp_node_id id
390 FROM cp_node, cmi_node
392 AND cp_node.cp_node_id = cmi_node.cp_node_id
393 ORDER BY cp_node.cp_node_id ',
395 array($this->
getId()));
399 while($sco_rec = $ilDB->fetchAssoc($sco_set))
401 $item[
'id']=$sco_rec[
"id"];
403 $items[count($items)] =$item;
418 $val_set = $ilDB->queryF(
419 'SELECT cp_node_id FROM cp_node
421 AND cp_node.slm_id = %s',
422 array(
'text',
'integer'),
423 array(
'item',$this->
getId())
425 while($val_rec = $ilDB->fetchAssoc($val_set))
427 array_push($scos,$val_rec[
'cp_node_id']);
430 foreach ($scos as $sco)
432 $data_set = $ilDB->queryF(
'
433 SELECT c_timestamp last_access, session_time, success_status, completion_status,
436 WHERE cp_node_id = %s
438 array(
'integer',
'integer'),
439 array($sco,
$_GET[
"user_id"])
442 while($data_rec = $ilDB->fetchAssoc($data_set))
444 if ($data_rec[
"success_status"]!=
"") {
445 $status = $data_rec[
"success_status"];
447 if ($data_rec[
"completion_status"]==
"") {
450 $status = $data_rec[
"completion_status"];
456 $score = $data_rec[
"c_raw"];
459 $data[] = array(
"user_id" => $data_rec[
"user_id"],
460 "score" => $score,
"time" => $time,
"status" => $status,
"last_access"=>$last_access,
"title"=>
$title);
465 $data[$data_rec[
"cp_node_id"]] = $data_rec;
480 $val_set = $ilDB->queryF(
'
481 SELECT * FROM cmi_custom
486 array(
'integer',
'integer',
'text',
'integer'),
487 array($a_user_id, 0,
'package_attempts',$this->
getId()));
489 $val_rec = $ilDB->fetchAssoc($val_set);
491 $val_rec[
"rvalue"] = str_replace(
"\r\n",
"\n", $val_rec[
"rvalue"]);
492 if ($val_rec[
"rvalue"] == null) {
493 $val_rec[
"rvalue"]=
"";
496 return $val_rec[
"rvalue"];
506 $val_set = $ilDB->queryF(
'
507 SELECT * FROM cmi_custom
512 array(
'integer',
'integer',
'text',
'integer'),
513 array($a_user_id, 0,
'module_version',$this->
getId()));
515 $val_rec = $ilDB->fetchAssoc($val_set);
517 $val_rec[
"rvalue"] = str_replace(
"\r\n",
"\n", $val_rec[
"rvalue"]);
518 if ($val_rec[
"rvalue"] == null) {
519 $val_rec[
"rvalue"]=
"";
521 return $val_rec[
"rvalue"];
528 global
$ilDB, $ilUser;
533 $query =
'SELECT cp_node.cp_node_id '
534 .
'FROM cp_node, cp_resource, cp_item '
535 .
'WHERE cp_item.cp_node_id = cp_node.cp_node_id '
536 .
'AND cp_item.resourceid = cp_resource.id AND scormtype = %s '
537 .
'AND nodename = %s AND cp_node.slm_id = %s';
538 $res = $ilDB->queryF(
540 array(
'text',
'text',
'integer'),
541 array(
'sco',
'item', $this->
getId())
543 while(
$row = $ilDB->fetchAssoc(
$res))
545 $scos[] =
$row[
'cp_node_id'];
551 $user_array = array();
553 if($a_exportall == 1)
555 $query =
'SELECT user_id '
556 .
'FROM cmi_node, cp_node '
557 .
'WHERE cmi_node.cp_node_id = cp_node.cp_node_id AND cp_node.slm_id = %s '
558 .
'GROUP BY user_id';
559 $res = $ilDB->queryF(
562 array($this->
getId())
564 while(
$row = $ilDB->fetchAssoc(
$res))
566 $user_array[] =
$row[
'user_id'];
571 $user_array = $a_user;
574 foreach($user_array as $user)
579 for($i = 0; $i < count($scos); $i++)
581 $query =
'SELECT * FROM cmi_node '
582 .
'WHERE user_id = %s AND cp_node_id = %s '
583 .
'AND completion_status = %s OR success_status = %s';
584 $res = $ilDB->queryF(
586 array(
'integer',
'integer',
'text',
'text'),
587 array($user, $scos[$i],
'completed',
'passed')
594 $key = array_search($scos[$i], $scos_c);
595 unset($scos_c[$key]);
600 if(count($scos_c) == 0)
613 $login = $e_user->getLogin();
614 $firstname = $e_user->getFirstname();
615 $lastname = $e_user->getLastname();
616 $email = $e_user->getEmail();
617 $department = $e_user->getDepartment();
619 $query =
'SELECT user_id, MAX(c_timestamp) exp_date '
620 .
'FROM cmi_node, cp_node '
621 .
'WHERE cmi_node.cp_node_id = cp_node.cp_node_id '
622 .
'AND cp_node.slm_id = %s '
623 .
'GROUP BY user_id';
624 $res = $ilDB->queryF(
627 array($this->
getId())
634 $datetime = explode(
' ',
$data[
'exp_date']);
635 if(count($datetime) == 2)
637 $date = explode(
'-', $datetime[0]);
638 if(count($date) == 3 && checkdate($date[1], $date[2], $date[0]))
643 $date = date(
'd.m.Y', strtotime(
$data[
'exp_date']));
651 $csv = $csv.
"$department;$login;$lastname;$firstname;$email;$date;$completion\n";
654 $header =
"Department;Login;Lastname;Firstname;Email;Date;Status\n";
660 global
$ilDB, $ilUser;
663 $val_set = $ilDB->queryF(
'
664 SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item
665 WHERE cp_item.cp_node_id = cp_node.cp_node_id
666 AND cp_item.resourceid = cp_resource.id
669 AND cp_node.slm_id = %s
670 GROUP BY cp_node.cp_node_id',
671 array(
'text',
'text',
'integer'),
672 array(
'sco',
'item', $this->
getId())
674 while ($val_rec = $ilDB->fetchAssoc($val_set))
676 array_push($scos,$val_rec[
'cp_node_id']);
679 $fhandle = fopen($a_file,
"r");
681 $obj_id = $this->getID();
684 $fields = fgetcsv($fhandle, 4096,
';');
685 while(($csv_rows = fgetcsv($fhandle, 4096,
";")) !== FALSE) {
686 $data = array_combine($fields, $csv_rows);
689 if (count($csv_rows) == 6) {$statuscheck = 1;}
694 $import =
$data[
"Status"];
695 if ($import ==
"") {$import = 1;}
698 foreach ($scos as $sco)
701 $date =
$data[
'Date'];
703 $res = $ilDB->queryF(
'
704 SELECT * FROM cmi_node
705 WHERE cp_node_id = %s
707 AND completion_status = %s
708 AND success_status = %s
709 AND c_timestamp = %s',
710 array(
'integer',
'integer',
'text',
'text',
'timestamp'),
711 array($sco_id,$user_id,
'completed',
'passed',
$data[
'Date']));
713 if(!$ilDB->numRows(
$res))
715 $nextId = $ilDB->nextId(
'cmi_node');
716 $val_set = $ilDB->manipulateF(
'
718 (cp_node_id,user_id,completion_status,success_status,c_timestamp,cmi_node_id)
719 VALUES(%s,%s,%s,%s,%s,%s)',
720 array(
'integer',
'integer',
'text',
'text',
'timestamp',
'integer'),
721 array($sco_id,$user_id,
'completed',
'passed',
$data[
'Date'],$nextId));
734 foreach ($users as $user_id)
736 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
750 $aV = array(0, 0, 0, 0, 0, 0);
753 if (strpos($str,
"P") != 0) {
757 $aT = array(
"Y",
"M",
"D",
"H",
"M",
"S");
760 $str = substr($str,1);
761 for ($i = 0; $i < count($aT); $i++) {
762 if (strpos($str,
"T")===0) {
763 $str = substr($str,1);
767 $p = strpos($str,$aT[$i]);
770 if ($i == 1 && strpos($str,
"T") > -1 && strpos($str,
"T") < $p) {
773 if ($aT[$i] ==
"S") {
774 $aV[$i] = substr($str,0, $p);
777 $aV[$i] = intval(substr($str,0, $p));
779 if (!is_numeric($aV[$i])) {
782 }
else if ($i > 2 && !$bTFound) {
786 $str = substr($str,$p + 1);
790 if (!$bErr && strlen($str) != 0) {
799 return $aV[0] * 3155760000 + $aV[1] * 262980000 + $aV[2] * 8640000 + $aV[3] * 360000 + $aV[4] * 6000 + round($aV[5] * 100);
804 global
$ilDB, $ilUser;
809 $val_set = $ilDB->queryF(
'
810 SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item
811 WHERE cp_item.cp_node_id = cp_node.cp_node_id
812 AND cp_item.resourceid = cp_resource.id
815 AND cp_node.slm_id = %s ',
816 array(
'text',
'text',
'integer'),
817 array(
'sco',
'item',$this->
getId()));
819 while ($val_rec = $ilDB->fetchAssoc($val_set))
821 array_push($scos,$val_rec[
'cp_node_id']);
828 for ($i=0;$i<count($scos);$i++)
831 $val_set = $ilDB->queryF(
'
832 SELECT * FROM cmi_node
835 AND (completion_status=%s OR success_status=%s))',
836 array(
'integer',
'integer',
'text',
'text'),
837 array($a_user,$scos[$i],
'completed',
'passed')
840 if ($ilDB->numRows($val_set) > 0) {
842 $key = array_search($scos[$i], $scos_c);
843 unset ($scos_c[$key]);
848 if (count($scos_c) == 0) {
864 global
$ilDB, $ilUser;
868 $val_set = $ilDB->queryF(
'
869 SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item
870 WHERE cp_item.cp_node_id = cp_node.cp_node_id
871 AND cp_item.resourceid = cp_resource.id
874 AND cp_node.slm_id = %s',
875 array(
'text',
'text',
'integer'), array(
'sco' ,
'item',$a_id));
876 while ($val_rec = $ilDB->fetchAssoc($val_set))
878 array_push($scos,$val_rec[
'cp_node_id']);
884 for ($i=0;$i<count($scos);$i++)
887 $val_set = $ilDB->queryF(
'
888 SELECT * FROM cmi_node
891 AND (completion_status = %s OR success_status = %s))',
892 array(
'integer',
'integer',
'text',
'text'),
893 array($a_user,$scos[$i],
'completed',
'passed'));
895 if ($ilDB->numRows($val_set) > 0)
898 $key = array_search($scos[$i], $scos_c);
899 unset ($scos_c[$key]);
904 if (count($scos_c) == 0) {
921 global
$ilDB, $ilUser;
924 $val_set = $ilDB->queryF(
"SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item WHERE".
925 " 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",
929 while ($val_rec = $ilDB->fetchAssoc($val_set))
931 array_push($scos,$val_rec[
'cp_node_id']);
935 for ($i=0;$i<count($scos);$i++)
937 $val_set = $ilDB->queryF(
"SELECT scaled FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)",
938 array(
'integer',
'integer'),
939 array($a_user, $scos[$i])
941 if ($val_set->numRows()>0)
943 $val_rec = $ilDB->fetchAssoc($val_set);
944 if ($val_rec[
'scaled']!=NULL) {
946 $scaled = $val_rec[
'scaled'];
950 $retVal = ($set == 1) ? $scaled : null ;
967 $item_set = $ilDB->queryF(
'
968 SELECT cp_item.* FROM cp_node, cp_item WHERE slm_id = %s
969 AND cp_node.cp_node_id = cp_item.cp_node_id
970 ORDER BY cp_node.cp_node_id ',
976 while ($item_rec = $ilDB->fetchAssoc($item_set))
979 $s2 = $ilDB->queryF(
'
980 SELECT cp_resource.* FROM cp_node, cp_resource
982 AND cp_node.cp_node_id = cp_resource.cp_node_id
983 AND cp_resource.id = %s ',
984 array(
'integer',
'text'),
985 array($a_obj_id,$item_rec[
"resourceid"])
989 if (
$res = $ilDB->fetchAssoc($s2))
992 if (
$res[
"scormtype"] ==
"sco")
994 $items[] = array(
"id" => $item_rec[
"cp_node_id"],
995 "title" => $item_rec[
"title"]);
1007 $status_set = $ilDB->queryF(
'
1008 SELECT * FROM cmi_gobjective
1010 AND objective_id = %s
1012 array(
'integer',
'text',
'integer'),
1013 array($a_obj_id,
'course_overall_status',$a_user_id)
1016 if ($status_rec = $ilDB->fetchAssoc($status_set))
1018 return $status_rec[
"status"];
1029 $status_set = $ilDB->queryF(
'
1030 SELECT * FROM cmi_gobjective
1032 AND objective_id = %s
1034 array(
'integer',
'text',
'integer'),
1035 array($a_obj_id,
'course_overall_status',$a_user_id)
1038 if ($status_rec = $ilDB->fetchAssoc($status_set))
1040 return $status_rec[
"satisfied"];
1050 $status_set = $ilDB->queryF(
'
1051 SELECT * FROM cmi_gobjective
1053 AND objective_id = %s
1055 array(
'integer',
'text',
'integer'),
1056 array($a_obj_id,
'course_overall_status',$a_user_id)
1059 if ($status_rec = $ilDB->fetchAssoc($status_set))
1061 return $status_rec[
"measure"];
1071 $r = $ilDB->queryF(
'
1072 SELECT * FROM cp_item
1073 WHERE cp_node_id = %s',
1078 if ($i = $ilDB->fetchAssoc($r))
1091 $this->slm_tree->setTreeTablePK(
"slm_id");
1092 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1093 $this->slm_tree->addTree($this->
getId(), 1);
1096 include_once (
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1098 $seq_info->insert();
1104 $this->slm_tree->setTreeTablePK(
"slm_id");
1105 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1106 return $this->slm_tree;
1112 $ilTabs->setTabActive(
"sequencing");
1114 include_once (
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1117 return $control_settings;
1121 include_once (
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1127 $control_settings->insert();
1143 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1144 $this->slm_tree->setTreeTablePK(
"slm_id");
1146 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
1155 $target_parent = $this->slm_tree->getParentId(
$target_id);
1159 if ($source_obj->getType() ==
"page")
1161 if ($this->slm_tree->isInTree($source_obj->getId()))
1163 $node_data = $this->slm_tree->getNodeData($source_obj->getId());
1166 if ($movecopy ==
"move")
1168 $parent_id = $this->slm_tree->getParentId($source_obj->getId());
1169 $this->slm_tree->deleteTree($node_data);
1191 if(!$this->slm_tree->isInTree($source_obj->getId()))
1198 else if ($as_subitem)
1202 $pg_childs = $this->slm_tree->getChildsByType($parent,
"page");
1203 if (count($pg_childs) != 0)
1205 $target_pos = $pg_childs[count($pg_childs) - 1][
"obj_id"];
1211 $parent = $target_parent;
1215 $this->slm_tree->insertNode($source_obj->getId(),
1216 $parent, $target_pos);
1237 if ($source_obj->getType() ==
"sco")
1240 $source_node = $this->slm_tree->getNodeData($source_id);
1241 $subnodes = $this->slm_tree->getSubtree($source_node);
1244 foreach ($subnodes as $subnode)
1259 $pg_childs = $this->slm_tree->getChildsByType($target_parent,
"page");
1260 if (count($pg_childs) != 0)
1262 $target_pos = $pg_childs[count($pg_childs) - 1][
"obj_id"];
1265 else if ($as_subitem)
1269 $childs = $this->slm_tree->getChilds($target_parent);
1270 if (count($childs) != 0)
1272 $target_pos = $childs[count($childs) - 1][
"obj_id"];
1277 if ($movecopy ==
"move")
1279 $this->slm_tree->deleteTree($source_node);
1288 if (!$this->slm_tree->isInTree($source_id))
1290 $this->slm_tree->insertNode($source_id, $target_parent, $target_pos);
1293 if ($movecopy ==
"move")
1295 foreach ($subnodes as $node)
1297 if($node[
"obj_id"] != $source_id)
1299 $this->slm_tree->insertNode($node[
"obj_id"], $node[
"parent"]);
1310 if ($source_obj->getType() ==
"chap")
1313 $source_node = $this->slm_tree->getNodeData($source_id);
1314 $subnodes = $this->slm_tree->getSubtree($source_node);
1317 foreach ($subnodes as $subnode)
1332 $sco_childs = $this->slm_tree->getChildsByType($target_parent,
"sco");
1333 if (count($sco_childs) != 0)
1335 $target_pos = $sco_childs[count($sco_childs) - 1][
"obj_id"];
1338 else if ($as_subitem)
1342 $childs = $this->slm_tree->getChilds($target_parent);
1343 if (count($childs) != 0)
1345 $target_pos = $childs[count($childs) - 1][
"obj_id"];
1350 if ($movecopy ==
"move")
1352 $this->slm_tree->deleteTree($source_node);
1361 if (!$this->slm_tree->isInTree($source_id))
1363 $this->slm_tree->insertNode($source_id, $target_parent, $target_pos);
1366 if ($movecopy ==
"move")
1368 foreach ($subnodes as $node)
1370 if($node[
"obj_id"] != $source_id)
1372 $this->slm_tree->insertNode($node[
"obj_id"], $node[
"parent"]);
1389 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Export.php");
1391 $export =
new ilSCORM2004Export($this);
1392 foreach ($export->getSupportedExportTypes() as
$type)
1394 $dir = $export->getExportDirectoryForType(
$type);
1396 if (!@is_dir(
$dir) or !is_writeable(
$dir))
1404 while ($entry = $cdir->read())
1406 if ($entry !=
"." and
1409 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(".$this->
getType().
"_)*[0-9]+\.zip\$", $entry) or
1410 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(".$this->
getType().
"_)*[0-9]+\.pdf\$", $entry) or
1411 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(".$this->
getType().
"_)*[0-9]+\.iso\$", $entry)
1414 $file[$entry.$type] = array(
"type" =>
$type,
"file" => $entry,
1415 "size" => filesize(
$dir.
"/".$entry));
1435 $metadata_xml = $a_xml_writer->xmlDumpMem(
false);
1436 $a_xml_writer->_XmlWriter;
1438 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/metadata.xsl");
1439 $args = array(
'/_xml' => $metadata_xml ,
'/_xsl' => $xsl );
1441 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args,NULL);
1443 file_put_contents($a_target_dir.
'/indexMD.xml',$output);
1447 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1448 include_once(
"./Modules/Glossary/classes/class.ilGlossaryExport.php");
1451 $glo_xml_writer->xmlSetDtdDef(
"<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
1453 $glo_xml_writer->xmlHeader();
1457 $glos->exportXML($glo_xml_writer,$glos_export->getInstId(), $a_target_dir.
"/glossary", $expLog);
1458 $glo_xml_writer->xmlDumpFile($a_target_dir.
"/glossary/glossary.xml");
1459 $glo_xml_writer->_XmlWriter;
1464 $a_xml_writer->
xmlSetDtdDef(
"<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
1467 $a_xml_writer->xmlSetGenCmt(
"Export of ILIAS Content Module ". $this->
getId().
" of installation ".$a_inst.
".");
1470 $a_xml_writer->xmlHeader();
1474 $a_xml_writer->xmlStartTag(
"ContentObject", array(
"Type"=>
"SCORM2004LearningModule"));
1482 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Sco Objects");
1483 $ilBench->start(
"ContentObjectExport",
"exportScoObjects");
1485 $ilBench->stop(
"ContentObjectExport",
"exportScoObjects");
1486 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Sco Objects");
1488 $a_xml_writer->xmlEndTag(
"ContentObject");
1489 $a_xml_writer->xmlDumpFile($a_target_dir.
'/index.xml',
false);
1491 if ($ver ==
"2004 4th") {
1496 if ($ver ==
"2004 3rd") {
1501 include_once(
"class.ilContObjectManifestBuilder.php");
1503 $manifestBuilder->buildManifest($ver,
$revision);
1504 $manifestBuilder->dump($a_target_dir);
1506 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1507 $args = array(
'/_xml' => file_get_contents($a_target_dir.
"/imsmanifest.xml"),
'/_xsl' => $xsl );
1509 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args,NULL);
1511 fputs(fopen($a_target_dir.
'/index.html',
'w+'),$output);
1517 ilUtil::rCopy(
'./Modules/Scorm2004/templates/xsd/adlcp_130_export_2004',$a_target_dir,
false);
1521 ilUtil::rCopy(
'./Modules/Scorm2004/templates/xsd/adlcp_130_export_2004_4th',$a_target_dir,
false);
1525 ilUtil::rCopy(
'./Modules/Scorm2004/templates/xsd/adlcp_120_export_12',$a_target_dir,
false);
1530 $a_xml_writer->_XmlWriter;
1538 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1539 $tree->setTreeTablePK(
"slm_id");
1540 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),
true,
'sco') as $sco)
1542 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1543 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1546 $node->exportHTML4PDF($a_inst, $sco_folder, $expLog);
1554 $a_xml_writer->
xmlStartTag(
"ContentObject", array(
"Type"=>
"SCORM2004SCO"));
1557 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1558 $tree->setTreeTablePK(
"slm_id");
1559 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),
true,
'sco') as $sco)
1561 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1562 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1565 $node->exportPDFPrepareXmlNFiles($a_inst, $a_target_dir, $expLog, $a_xml_writer);
1570 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1571 include_once(
"./Modules/Glossary/classes/class.ilGlossaryExport.php");
1574 $glos->exportXML($a_xml_writer,$glos_export->getInstId(), $a_target_dir.
"/glossary", $expLog);
1576 copy(
'./templates/default/images/icon_attachment_s.png',$a_target_dir.
"/icon_attachment_s.png");
1577 $a_xml_writer->xmlEndTag(
"ContentObject");
1578 include_once
'Services/Transformation/classes/class.ilXML2FO.php';
1580 $xml2FO->setXSLTLocation(
'./Modules/Scorm2004/templates/xsl/contentobject2fo.xsl');
1581 $xml2FO->setXMLString($a_xml_writer->xmlDumpMem());
1582 $xml2FO->setXSLTParams(array (
'target_dir' => $a_target_dir));
1583 $xml2FO->transform();
1584 $fo_string = $xml2FO->getFOString();
1585 $fo_xml = simplexml_load_string($fo_string);
1586 $fo_ext = $fo_xml->xpath(
"//fo:declarations");
1587 $fo_ext = $fo_ext[0];
1589 include_once
"./Services/Utilities/classes/class.ilFileUtils.php";
1593 foreach (
$results[
"file"] as $key => $value)
1595 $e = $fo_ext->addChild(
"fox:embedded-file",
"",
"http://xml.apache.org/fop/extensions");
1596 $e->addAttribute(
"src",
$results[path][$key].$value);
1597 $e->addAttribute(
"name",$value);
1598 $e->addAttribute(
"desc",
"");
1601 $fo_string = $fo_xml->asXML();
1602 $a_xml_writer->_XmlWriter;
1610 $a_xml_writer->
xmlSetDtdDef(
"<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
1613 $a_xml_writer->xmlSetGenCmt(
"Export of ILIAS Content Module ". $this->
getId().
" of installation ".$a_inst.
".");
1616 $a_xml_writer->xmlHeader();
1620 $a_xml_writer->xmlStartTag(
"ContentObject", array(
"Type"=>
"SCORM2004LearningModule"));
1622 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Sco Objects");
1623 $ilBench->start(
"ContentObjectExport",
"exportScoObjects");
1625 $ilBench->stop(
"ContentObjectExport",
"exportScoObjects");
1626 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Sco Objects");
1628 $a_xml_writer->xmlEndTag(
"ContentObject");
1630 include_once(
"class.ilContObjectManifestBuilder.php");
1632 $manifestBuilder->buildManifest(
'12');
1634 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1635 $xml = simplexml_load_string($manifestBuilder->writer->xmlDumpMem());
1636 $args = array(
'/_xml' => $xml->organizations->organization->asXml(),
'/_xsl' => $xsl );
1638 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args,NULL);
1640 fputs(fopen($a_target_dir.
'/index.html',
'w+'),$output);
1641 $a_xml_writer->_XmlWriter;
1652 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
1654 $md2xml->setExportMode(
true);
1655 $md2xml->startExport();
1656 $a_xml_writer->appendXML($md2xml->getXML());
1667 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
1669 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1670 $tree->setTreeTablePK(
"slm_id");
1671 $a_xml_writer->xmlStartTag(
"StructureObject");
1672 foreach($tree->getFilteredSubTree($tree->getRootId(),Array(
'page')) as $obj)
1674 if($obj[
'type']==
'')
continue;
1677 $md2xml =
new ilMD2XML($this->
getId(), $obj[
'obj_id'], $obj[
'type']);
1678 $md2xml->setExportMode(
true);
1679 $md2xml->startExport();
1680 $a_xml_writer->appendXML($md2xml->getXML());
1682 $a_xml_writer->xmlEndTag(
"StructureObject");
1696 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1697 $tree->setTreeTablePK(
"slm_id");
1698 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),
true,
'sco') as $sco)
1700 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1701 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1704 $node->exportScorm($a_inst, $sco_folder, $ver, $expLog);
1717 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1718 $tree->setTreeTablePK(
"slm_id");
1719 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),
true,
'sco') as $sco)
1721 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1722 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1725 $node->exportHTML($a_inst, $sco_folder, $expLog);
1728 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1742 return $this->public_export_file[$a_type];
1751 include_once(
"./Modules/File/classes/class.ilObjFile.php");
1753 foreach ($this->file_ids as $file_id)
1755 $expLog->write(date(
"[y-m-d H:i:s] ").
"File Item ".$file_id);
1756 $file_obj =
new ilObjFile($file_id,
false);
1757 $file_obj->export($a_target_dir);
1764 $this->public_export_file[$a_type] = $a_file;