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';
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");
267 $default=$organizations->item(0)->getAttribute(
"default");
268 if ($default==
"" || $default==null) {
270 $organization = $doc->getElementsByTagName(
"organization");
271 $ident=$organization->item(0)->getAttribute(
"identifier");
272 $organizations->item(0)->setAttribute(
"default",$ident);
279 $wrapperdir=$this->packageFolder.
"/GenericRunTimeWrapper1.0_aadlc";
281 copy(self::WRAPPER_HTML,$wrapperdir.
"/GenericRunTimeWrapper.htm");
282 copy(self::WRAPPER_JS,$wrapperdir.
"/SCOPlayerWrapper.js");
285 $this->backupManifest=$this->packageFolder.
"/imsmanifest.xml.back";
286 $ret=copy($this->imsmanifestFile,$this->backupManifest);
289 $this->totransform = $doc;
290 $ilLog->write(
"SCORM: about to transform to SCORM 2004");
292 $xsl =
new DOMDocument;
294 $xsl->load(self::CONVERT_XSL);
295 $prc =
new XSLTProcessor;
296 $r = @$prc->importStyleSheet($xsl);
298 file_put_contents($this->imsmanifestFile, $prc->transformToXML($this->totransform));
300 $ilLog->write(
"SCORM: Transoformation completed");
318 SELECT MAX(c_timestamp) last_access
319 FROM cmi_node, cp_node
320 WHERE cmi_node.cp_node_id = cp_node.cp_node_id
321 AND cp_node.slm_id = %s
323 GROUP BY c_timestamp',
324 array(
'integer',
'integer'),
325 array($a_obj_id, $a_usr_id));
329 return $row[
"last_access"];
342 $sco_set = $ilDB->queryF(
'
343 SELECT DISTINCT user_id,MAX(c_timestamp) last_access
344 FROM cmi_node, cp_node
345 WHERE cmi_node.cp_node_id = cp_node.cp_node_id
346 AND cp_node.slm_id = %s
349 array($this->
getId()));
354 while($sco_rec = $ilDB->fetchAssoc($sco_set))
357 if ($sco_rec[
'last_access'] != 0) {
360 $sco_rec[
'last_access'] =
"";
362 if (
ilObject::_exists($sco_rec[
'user_id']) && ilObject::_lookUpType($sco_rec[
'user_id'])==
"usr" ) {
363 $user =
new ilObjUser($sco_rec[
'user_id']);
364 $temp = array(
"user_full_name" => $name[
"lastname"].
", ".
366 "user_id" => $sco_rec[
"user_id"],
"last_access" => $sco_rec[
'last_access'],
369 "username" => $user->getLastname().
", ".$user->getFirstname()
371 if ($a_search !=
"" && (strpos(strtolower($user->getLastname()), strtolower($a_search)) !==
false || strpos(strtolower($user->getFirstname()), strtolower($a_search)) !==
false ) ) {
373 }
else if ($a_search ==
"") {
389 foreach($a_users as $user)
391 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004DeleteData.php");
395 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
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;
502 $val_set = $ilDB->queryF(
'
503 SELECT * FROM cmi_custom
508 array(
'integer',
'integer',
'text',
'integer'),
509 array($a_user_id, 0,
'package_attempts',$this->
getId()));
511 $val_rec = $ilDB->fetchAssoc($val_set);
513 $val_rec[
"rvalue"] = str_replace(
"\r\n",
"\n", $val_rec[
"rvalue"]);
514 if ($val_rec[
"rvalue"] == null) {
515 $val_rec[
"rvalue"]=
"";
518 return $val_rec[
"rvalue"];
528 $val_set = $ilDB->queryF(
'
529 SELECT * FROM cmi_custom
534 array(
'integer',
'integer',
'text',
'integer'),
535 array($a_user_id, 0,
'module_version',$this->
getId()));
537 $val_rec = $ilDB->fetchAssoc($val_set);
539 $val_rec[
"rvalue"] = str_replace(
"\r\n",
"\n", $val_rec[
"rvalue"]);
540 if ($val_rec[
"rvalue"] == null) {
541 $val_rec[
"rvalue"]=
"";
543 return $val_rec[
"rvalue"];
555 $query =
'SELECT cp_node.cp_node_id '
556 .
'FROM cp_node, cp_resource, cp_item '
557 .
'WHERE cp_item.cp_node_id = cp_node.cp_node_id '
558 .
'AND cp_item.resourceid = cp_resource.id AND scormtype = %s '
559 .
'AND nodename = %s AND cp_node.slm_id = %s';
560 $res = $ilDB->queryF(
562 array(
'text',
'text',
'integer'),
563 array(
'sco',
'item', $this->
getId())
565 while(
$row = $ilDB->fetchAssoc(
$res))
567 $scos[] =
$row[
'cp_node_id'];
573 $user_array = array();
575 if($a_exportall == 1)
577 $query =
'SELECT user_id '
578 .
'FROM cmi_node, cp_node '
579 .
'WHERE cmi_node.cp_node_id = cp_node.cp_node_id AND cp_node.slm_id = %s '
580 .
'GROUP BY user_id';
581 $res = $ilDB->queryF(
584 array($this->
getId())
586 while(
$row = $ilDB->fetchAssoc(
$res))
588 $user_array[] =
$row[
'user_id'];
593 $user_array = $a_user;
596 foreach($user_array as $user)
601 for($i = 0; $i < count($scos); $i++)
603 $query =
'SELECT * FROM cmi_node '
604 .
'WHERE user_id = %s AND cp_node_id = %s '
605 .
'AND completion_status = %s OR success_status = %s';
606 $res = $ilDB->queryF(
608 array(
'integer',
'integer',
'text',
'text'),
609 array($user, $scos[$i],
'completed',
'passed')
616 $key = array_search($scos[$i], $scos_c);
617 unset($scos_c[$key]);
622 if(count($scos_c) == 0)
635 $login = $e_user->getLogin();
636 $firstname = $e_user->getFirstname();
637 $lastname = $e_user->getLastname();
638 $email = $e_user->getEmail();
639 $department = $e_user->getDepartment();
641 $query =
'SELECT user_id, MAX(c_timestamp) exp_date '
642 .
'FROM cmi_node, cp_node '
643 .
'WHERE cmi_node.cp_node_id = cp_node.cp_node_id '
644 .
'AND cp_node.slm_id = %s '
645 .
'GROUP BY user_id';
646 $res = $ilDB->queryF(
649 array($this->
getId())
656 $datetime = explode(
' ',
$data[
'exp_date']);
657 if(count($datetime) == 2)
659 $date = explode(
'-', $datetime[0]);
660 if(count($date) == 3 && checkdate($date[1], $date[2], $date[0]))
665 $date = date(
'd.m.Y', strtotime(
$data[
'exp_date']));
673 $csv = $csv.
"$department;$login;$lastname;$firstname;$email;$date;$completion\n";
676 $header =
"Department;Login;Lastname;Firstname;Email;Date;Status\n";
685 $val_set = $ilDB->queryF(
'
686 SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item
687 WHERE cp_item.cp_node_id = cp_node.cp_node_id
688 AND cp_item.resourceid = cp_resource.id
691 AND cp_node.slm_id = %s
692 GROUP BY cp_node.cp_node_id',
693 array(
'text',
'text',
'integer'),
694 array(
'sco',
'item', $this->
getId())
696 while ($val_rec = $ilDB->fetchAssoc($val_set))
698 array_push($scos,$val_rec[
'cp_node_id']);
701 $fhandle = fopen($a_file,
"r");
703 $obj_id = $this->getID();
706 $fields = fgetcsv($fhandle, 4096,
';');
707 while(($csv_rows = fgetcsv($fhandle, 4096,
";")) !== FALSE) {
708 $data = array_combine($fields, $csv_rows);
711 if (count($csv_rows) == 6) {$statuscheck = 1;}
716 $import =
$data[
"Status"];
717 if ($import ==
"") {$import = 1;}
720 foreach ($scos as $sco)
723 $date =
$data[
'Date'];
725 $res = $ilDB->queryF(
'
726 SELECT * FROM cmi_node
727 WHERE cp_node_id = %s
729 AND completion_status = %s
730 AND success_status = %s
731 AND c_timestamp = %s',
732 array(
'integer',
'integer',
'text',
'text',
'timestamp'),
733 array($sco_id,$user_id,
'completed',
'passed',
$data[
'Date']));
735 if(!$ilDB->numRows(
$res))
737 $nextId = $ilDB->nextId(
'cmi_node');
738 $val_set = $ilDB->manipulateF(
'
740 (cp_node_id,user_id,completion_status,success_status,c_timestamp,cmi_node_id)
741 VALUES(%s,%s,%s,%s,%s,%s)',
742 array(
'integer',
'integer',
'text',
'text',
'timestamp',
'integer'),
743 array($sco_id,$user_id,
'completed',
'passed',
$data[
'Date'],$nextId));
756 foreach ($users as $user_id)
758 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
772 $aV = array(0, 0, 0, 0, 0, 0);
775 if (strpos($str,
"P") != 0) {
779 $aT = array(
"Y",
"M",
"D",
"H",
"M",
"S");
782 $str = substr($str,1);
783 for ($i = 0; $i < count($aT); $i++) {
784 if (strpos($str,
"T")===0) {
785 $str = substr($str,1);
789 $p = strpos($str,$aT[$i]);
792 if ($i == 1 && strpos($str,
"T") > -1 && strpos($str,
"T") < $p) {
795 if ($aT[$i] ==
"S") {
796 $aV[$i] = substr($str,0, $p);
799 $aV[$i] = intval(substr($str,0, $p));
801 if (!is_numeric($aV[$i])) {
804 }
else if ($i > 2 && !$bTFound) {
808 $str = substr($str,$p + 1);
812 if (!$bErr && strlen($str) != 0) {
821 return $aV[0] * 3155760000 + $aV[1] * 262980000 + $aV[2] * 8640000 + $aV[3] * 360000 + $aV[4] * 6000 + round($aV[5] * 100);
831 $val_set = $ilDB->queryF(
'
832 SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item
833 WHERE cp_item.cp_node_id = cp_node.cp_node_id
834 AND cp_item.resourceid = cp_resource.id
837 AND cp_node.slm_id = %s ',
838 array(
'text',
'text',
'integer'),
839 array(
'sco',
'item',$this->
getId()));
841 while ($val_rec = $ilDB->fetchAssoc($val_set))
843 array_push($scos,$val_rec[
'cp_node_id']);
850 for ($i=0;$i<count($scos);$i++)
853 $val_set = $ilDB->queryF(
'
854 SELECT * FROM cmi_node
857 AND (completion_status=%s OR success_status=%s))',
858 array(
'integer',
'integer',
'text',
'text'),
859 array($a_user,$scos[$i],
'completed',
'passed')
862 if ($ilDB->numRows($val_set) > 0) {
864 $key = array_search($scos[$i], $scos_c);
865 unset ($scos_c[$key]);
870 if (count($scos_c) == 0) {
890 $val_set = $ilDB->queryF(
'
891 SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item
892 WHERE cp_item.cp_node_id = cp_node.cp_node_id
893 AND cp_item.resourceid = cp_resource.id
896 AND cp_node.slm_id = %s',
897 array(
'text',
'text',
'integer'), array(
'sco' ,
'item',$a_id));
898 while ($val_rec = $ilDB->fetchAssoc($val_set))
900 array_push($scos,$val_rec[
'cp_node_id']);
906 for ($i=0;$i<count($scos);$i++)
909 $val_set = $ilDB->queryF(
'
910 SELECT * FROM cmi_node
913 AND (completion_status = %s OR success_status = %s))',
914 array(
'integer',
'integer',
'text',
'text'),
915 array($a_user,$scos[$i],
'completed',
'passed'));
917 if ($ilDB->numRows($val_set) > 0)
920 $key = array_search($scos[$i], $scos_c);
921 unset ($scos_c[$key]);
926 if (count($scos_c) == 0) {
946 $val_set = $ilDB->queryF(
"SELECT cp_node.cp_node_id FROM cp_node,cp_resource,cp_item WHERE".
947 " 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",
951 while ($val_rec = $ilDB->fetchAssoc($val_set))
953 array_push($scos,$val_rec[
'cp_node_id']);
957 for ($i=0;$i<count($scos);$i++)
959 $val_set = $ilDB->queryF(
"SELECT scaled FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)",
960 array(
'integer',
'integer'),
961 array($a_user, $scos[$i])
963 if ($val_set->numRows()>0)
965 $val_rec = $ilDB->fetchAssoc($val_set);
966 if ($val_rec[
'scaled']!=NULL) {
968 $scaled = $val_rec[
'scaled'];
972 $retVal = ($set == 1) ? $scaled : null ;
989 $item_set = $ilDB->queryF(
'
990 SELECT cp_item.* FROM cp_node, cp_item WHERE slm_id = %s
991 AND cp_node.cp_node_id = cp_item.cp_node_id
992 ORDER BY cp_node.cp_node_id ',
998 while ($item_rec = $ilDB->fetchAssoc($item_set))
1001 $s2 = $ilDB->queryF(
'
1002 SELECT cp_resource.* FROM cp_node, cp_resource
1004 AND cp_node.cp_node_id = cp_resource.cp_node_id
1005 AND cp_resource.id = %s ',
1006 array(
'integer',
'text'),
1007 array($a_obj_id,$item_rec[
"resourceid"])
1011 if (
$res = $ilDB->fetchAssoc($s2))
1014 if (
$res[
"scormtype"] ==
"sco")
1016 $items[] = array(
"id" => $item_rec[
"cp_node_id"],
1017 "title" => $item_rec[
"title"]);
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[
"status"];
1051 $status_set = $ilDB->queryF(
'
1052 SELECT * FROM cmi_gobjective
1054 AND objective_id = %s
1056 array(
'integer',
'text',
'integer'),
1057 array($a_obj_id,
'course_overall_status',$a_user_id)
1060 if ($status_rec = $ilDB->fetchAssoc($status_set))
1062 return $status_rec[
"satisfied"];
1072 $status_set = $ilDB->queryF(
'
1073 SELECT * FROM cmi_gobjective
1075 AND objective_id = %s
1077 array(
'integer',
'text',
'integer'),
1078 array($a_obj_id,
'course_overall_status',$a_user_id)
1081 if ($status_rec = $ilDB->fetchAssoc($status_set))
1083 return $status_rec[
"measure"];
1093 $r = $ilDB->queryF(
'
1094 SELECT * FROM cp_item
1095 WHERE cp_node_id = %s',
1100 if ($i = $ilDB->fetchAssoc($r))
1112 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Tree.php");
1118 $this->slm_tree->addTree($this->
getId(), 1);
1121 include_once (
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1123 $seq_info->insert();
1129 $this->slm_tree->setTreeTablePK(
"slm_id");
1130 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1131 return $this->slm_tree;
1137 $ilTabs->setTabActive(
"sequencing");
1139 include_once (
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1142 return $control_settings;
1146 include_once (
"./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php");
1152 $control_settings->insert();
1168 $this->slm_tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1169 $this->slm_tree->setTreeTablePK(
"slm_id");
1171 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php");
1180 $target_parent = $this->slm_tree->getParentId(
$target_id);
1184 if ($source_obj->getType() ==
"page")
1186 if ($this->slm_tree->isInTree($source_obj->getId()))
1188 $node_data = $this->slm_tree->getNodeData($source_obj->getId());
1191 if ($movecopy ==
"move")
1193 $parent_id = $this->slm_tree->getParentId($source_obj->getId());
1194 $this->slm_tree->deleteTree($node_data);
1216 if(!$this->slm_tree->isInTree($source_obj->getId()))
1223 else if ($as_subitem)
1227 $pg_childs = $this->slm_tree->getChildsByType($parent,
"page");
1228 if (count($pg_childs) != 0)
1230 $target_pos = $pg_childs[count($pg_childs) - 1][
"obj_id"];
1236 $parent = $target_parent;
1240 $this->slm_tree->insertNode($source_obj->getId(),
1241 $parent, $target_pos);
1262 if ($source_obj->getType() ==
"sco" || $source_obj->getType() ==
"ass")
1265 $source_node = $this->slm_tree->getNodeData($source_id);
1266 $subnodes = $this->slm_tree->getSubtree($source_node);
1269 foreach ($subnodes as $subnode)
1284 $pg_childs = $this->slm_tree->getChildsByType($target_parent,
"page");
1285 if (count($pg_childs) != 0)
1287 $target_pos = $pg_childs[count($pg_childs) - 1][
"obj_id"];
1290 else if ($as_subitem)
1294 $childs = $this->slm_tree->getChilds($target_parent);
1295 if (count($childs) != 0)
1297 $target_pos = $childs[count($childs) - 1][
"obj_id"];
1302 if ($movecopy ==
"move")
1304 $this->slm_tree->deleteTree($source_node);
1313 if (!$this->slm_tree->isInTree($source_id))
1315 $this->slm_tree->insertNode($source_id, $target_parent, $target_pos);
1318 if ($movecopy ==
"move")
1320 foreach ($subnodes as $node)
1322 if($node[
"obj_id"] != $source_id)
1324 $this->slm_tree->insertNode($node[
"obj_id"], $node[
"parent"]);
1335 if ($source_obj->getType() ==
"chap")
1338 $source_node = $this->slm_tree->getNodeData($source_id);
1339 $subnodes = $this->slm_tree->getSubtree($source_node);
1342 foreach ($subnodes as $subnode)
1363 else if ($as_subitem)
1367 $childs = $this->slm_tree->getChilds($target_parent);
1368 if (count($childs) != 0)
1370 $target_pos = $childs[count($childs) - 1][
"obj_id"];
1375 if ($movecopy ==
"move")
1377 $this->slm_tree->deleteTree($source_node);
1386 if (!$this->slm_tree->isInTree($source_id))
1388 $this->slm_tree->insertNode($source_id, $target_parent, $target_pos);
1391 if ($movecopy ==
"move")
1393 foreach ($subnodes as $node)
1395 if($node[
"obj_id"] != $source_id)
1397 $this->slm_tree->insertNode($node[
"obj_id"], $node[
"parent"]);
1414 require_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Export.php");
1416 $export =
new ilSCORM2004Export($this);
1417 foreach ($export->getSupportedExportTypes() as
$type)
1419 $dir = $export->getExportDirectoryForType(
$type);
1421 if (!@is_dir($dir) or !is_writeable($dir))
1429 while ($entry = $cdir->read())
1431 if ($entry !=
"." and
1434 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(".$this->
getType().
"_)*[0-9]+\.zip\$", $entry) or
1435 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(".$this->
getType().
"_)*[0-9]+\.pdf\$", $entry) or
1436 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(".$this->
getType().
"_)*[0-9]+\.iso\$", $entry)
1439 $file[$entry.$type] = array(
"type" =>
$type,
"file" => $entry,
1440 "size" => filesize($dir.
"/".$entry));
1464 $metadata_xml = $a_xml_writer->xmlDumpMem(
false);
1465 $a_xml_writer->_XmlWriter;
1467 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/metadata.xsl");
1468 $args = array(
'/_xml' => $metadata_xml ,
'/_xsl' => $xsl );
1470 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args,NULL);
1472 file_put_contents($a_target_dir.
'/indexMD.xml',$output);
1478 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1479 include_once(
"./Modules/Glossary/classes/class.ilGlossaryExport.php");
1482 $glo_xml_writer->xmlSetDtdDef(
"<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
1484 $glo_xml_writer->xmlHeader();
1488 $glos->exportXML($glo_xml_writer,$glos_export->getInstId(), $a_target_dir.
"/glossary", $expLog);
1489 $glo_xml_writer->xmlDumpFile($a_target_dir.
"/glossary/glossary.xml");
1490 $glo_xml_writer->_XmlWriter;
1495 $a_xml_writer->
xmlSetDtdDef(
"<!DOCTYPE ContentObject SYSTEM \"http://www.ilias.de/download/dtd/ilias_co_3_7.dtd\">");
1498 $a_xml_writer->xmlSetGenCmt(
"Export of ILIAS Content Module ". $this->
getId().
" of installation ".$a_inst.
".");
1501 $a_xml_writer->xmlHeader();
1505 $a_xml_writer->xmlStartTag(
"ContentObject", array(
"Type"=>
"SCORM2004LearningModule"));
1513 $expLog->write(date(
"[y-m-d H:i:s] ").
"Start Export Sco Objects");
1515 $expLog->write(date(
"[y-m-d H:i:s] ").
"Finished Export Sco Objects");
1517 $a_xml_writer->xmlEndTag(
"ContentObject");
1518 $a_xml_writer->xmlDumpFile($a_target_dir.
'/index.xml',
false);
1520 if ($ver ==
"2004 4th") {
1525 if ($ver ==
"2004 3rd") {
1531 $css_dir = $a_target_dir.
"/ilias_css_4_2";
1533 include_once(
"./Modules/Scorm2004/classes/class.ilScormExportUtil.php");
1537 include_once(
"./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php");
1539 $manifestBuilder->buildManifest($ver,$revision);
1540 $manifestBuilder->dump($a_target_dir);
1542 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1543 $args = array(
'/_xml' => file_get_contents($a_target_dir.
"/imsmanifest.xml"),
'/_xsl' => $xsl );
1545 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args,NULL);
1547 fputs(fopen($a_target_dir.
'/index.html',
'w+'),$output);
1552 if ($revision ==
"3rd") {
1553 ilUtil::rCopy(
'./Modules/Scorm2004/templates/xsd/adlcp_130_export_2004',$a_target_dir,
false);
1556 if ($revision ==
"4th") {
1557 ilUtil::rCopy(
'./Modules/Scorm2004/templates/xsd/adlcp_130_export_2004_4th',$a_target_dir,
false);
1561 ilUtil::rCopy(
'./Modules/Scorm2004/templates/xsd/adlcp_120_export_12',$a_target_dir,
false);
1565 $a_xml_writer->_XmlWriter;
1573 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1574 $tree->setTreeTablePK(
"slm_id");
1575 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),
true,
'sco') as $sco)
1577 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1578 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1581 $node->exportHTML4PDF($a_inst, $sco_folder, $expLog);
1589 $a_xml_writer->
xmlStartTag(
"ContentObject", array(
"Type"=>
"SCORM2004SCO"));
1592 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1593 $tree->setTreeTablePK(
"slm_id");
1594 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),
true,
'sco') as $sco)
1596 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1597 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1600 $node->exportPDFPrepareXmlNFiles($a_inst, $a_target_dir, $expLog, $a_xml_writer);
1605 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1606 include_once(
"./Modules/Glossary/classes/class.ilGlossaryExport.php");
1609 $glos->exportXML($a_xml_writer,$glos_export->getInstId(), $a_target_dir.
"/glossary", $expLog);
1611 copy(
'./templates/default/images/icon_attachment_s.png',$a_target_dir.
"/icon_attachment_s.png");
1612 $a_xml_writer->xmlEndTag(
"ContentObject");
1613 include_once
'Services/Transformation/classes/class.ilXML2FO.php';
1615 $xml2FO->setXSLTLocation(
'./Modules/Scorm2004/templates/xsl/contentobject2fo.xsl');
1616 $xml2FO->setXMLString($a_xml_writer->xmlDumpMem());
1617 $xml2FO->setXSLTParams(array (
'target_dir' => $a_target_dir));
1618 $xml2FO->transform();
1619 $fo_string = $xml2FO->getFOString();
1620 $fo_xml = simplexml_load_string($fo_string);
1621 $fo_ext = $fo_xml->xpath(
"//fo:declarations");
1622 $fo_ext = $fo_ext[0];
1624 include_once
"./Services/Utilities/classes/class.ilFileUtils.php";
1628 foreach (
$results[
"file"] as $key => $value)
1630 $e = $fo_ext->addChild(
"fox:embedded-file",
"",
"http://xml.apache.org/fop/extensions");
1631 $e->addAttribute(
"src",
$results[path][$key].$value);
1632 $e->addAttribute(
"name",$value);
1633 $e->addAttribute(
"desc",
"");
1636 $fo_string = $fo_xml->asXML();
1637 $a_xml_writer->_XmlWriter;
1643 $one_file = fopen($a_target_dir.
'/index.html',
'w+');
1644 $this->
exportHTML($a_inst, $a_target_dir, $expLog, $one_file);
1651 function exportHTML($a_inst, $a_target_dir, &$expLog, $a_one_file =
"")
1681 if ($a_one_file ==
"")
1683 include_once(
"./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php");
1685 $manifestBuilder->buildManifest(
'12');
1687 include_once(
"Services/Frameset/classes/class.ilFramesetGUI.php");
1689 $fs_gui->setFramesetTitle($this->
getTitle());
1690 $fs_gui->setMainFrameSource(
"");
1691 $fs_gui->setSideFrameSource(
"toc.html");
1692 $fs_gui->setMainFrameName(
"content");
1693 $fs_gui->setSideFrameName(
"toc");
1694 $output = $fs_gui->get();
1695 fputs(fopen($a_target_dir.
'/index.html',
'w+'),$output);
1697 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1698 $xml = simplexml_load_string($manifestBuilder->writer->xmlDumpMem());
1699 $args = array(
'/_xml' => $xml->organizations->organization->asXml(),
'/_xsl' => $xsl );
1701 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args,NULL);
1703 fputs(fopen($a_target_dir.
'/toc.html',
'w+'),$output);
1716 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
1718 $md2xml->setExportMode(
true);
1719 $md2xml->startExport();
1720 $a_xml_writer->appendXML($md2xml->getXML());
1731 include_once(
"Services/MetaData/classes/class.ilMD2XML.php");
1733 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1734 $tree->setTreeTablePK(
"slm_id");
1735 $a_xml_writer->xmlStartTag(
"StructureObject");
1736 foreach($tree->getFilteredSubTree($tree->getRootId(),Array(
'page')) as $obj)
1738 if($obj[
'type']==
'')
continue;
1741 $md2xml =
new ilMD2XML($this->
getId(), $obj[
'obj_id'], $obj[
'type']);
1742 $md2xml->setExportMode(
true);
1743 $md2xml->startExport();
1744 $a_xml_writer->appendXML($md2xml->getXML());
1746 $a_xml_writer->xmlEndTag(
"StructureObject");
1760 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1761 $tree->setTreeTablePK(
"slm_id");
1762 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),
true,array(
'sco',
'ass')) as $sco)
1764 if ($sco[
'type'] ==
"sco")
1766 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1767 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1770 $node->exportScorm($a_inst, $sco_folder, $ver, $expLog);
1772 if ($sco[
'type'] ==
"ass")
1774 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php");
1775 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1778 $node->exportScorm($a_inst, $sco_folder, $ver, $expLog);
1794 $tree->setTableNames(
'sahs_sc13_tree',
'sahs_sc13_tree_node');
1795 $tree->setTreeTablePK(
"slm_id");
1798 if ($a_one_file !=
"")
1803 $sco_tpl =
new ilTemplate(
"tpl.sco.html",
true,
true,
"Modules/Scorm2004");
1804 include_once(
"./Services/COPage/classes/class.ilCOPageHTMLExport.php");
1807 $sco_tpl->setCurrentBlock(
"js_file");
1808 $sco_tpl->setVariable(
"JS_FILE",
"./js/pure.js");
1809 $sco_tpl->parseCurrentBlock();
1810 $sco_tpl->setCurrentBlock(
"js_file");
1811 $sco_tpl->setVariable(
"JS_FILE",
"./js/question_handling.js");
1812 $sco_tpl->parseCurrentBlock();
1815 $sco_tpl->setCurrentBlock(
"head");
1816 $sco_tpl->parseCurrentBlock();
1817 fputs($a_one_file, $sco_tpl->get(
"head"));
1820 include_once(
"./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php");
1822 $manifestBuilder->buildManifest(
'12');
1823 $xsl = file_get_contents(
"./Modules/Scorm2004/templates/xsl/module.xsl");
1824 $xml = simplexml_load_string($manifestBuilder->writer->xmlDumpMem());
1825 $args = array(
'/_xml' => $xml->organizations->organization->asXml(),
'/_xsl' => $xsl );
1827 $params = array(
"one_page" =>
"y");
1828 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args,$params);
1830 fputs($a_one_file, $output);
1834 foreach($tree->getSubTree($tree->getNodeData($tree->getRootId()),
true,
'sco') as $sco)
1836 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php");
1837 $sco_folder = $a_target_dir.
"/".$sco[
'obj_id'];
1841 if ($a_one_file ==
"")
1843 $node->exportHTML($a_inst, $sco_folder, $expLog, $a_one_file);
1847 $node->exportHTMLPageObjects($a_inst, $a_target_dir, $expLog,
'full',
1848 "sco", $a_one_file, $sco_tpl);
1852 include_once(
"./Modules/Glossary/classes/class.ilObjGlossary.php");
1859 if ($a_one_file !=
"")
1862 fputs($a_one_file, $sco_tpl->get(
"tail"));
1876 include_once(
"./Services/Style/classes/class.ilSystemStyleHTMLExport.php");
1878 $this->sys_style_html_export->export();
1881 include_once(
"./Services/COPage/classes/class.ilCOPageHTMLExport.php");
1883 $this->co_page_html_export->setContentStyleId(
1885 $this->co_page_html_export->createDirectories();
1886 $this->co_page_html_export->exportStyles();
1887 $this->co_page_html_export->exportSupportScripts();
1889 include_once(
"./Services/MediaObjects/classes/class.ilPlayerUtil.php");
1897 include_once(
"./Services/MediaObjects/classes/class.ilPlayerUtil.php");
1902 copy(
'./Services/MediaObjects/flash_mp3_player/mp3player.swf', $a_target_dir.
'/players/mp3player.swf');
1903 copy(
'./Modules/Scorm2004/scripts/scorm_2004.js',$a_target_dir.
'/js/scorm.js');
1904 copy(
'./Modules/Scorm2004/scripts/pager.js',$a_target_dir.
'/js/pager.js');
1905 copy(
'./Modules/Scorm2004/scripts/questions/pure.js',$a_target_dir.
'/js/pure.js');
1906 copy(
'./Modules/Scorm2004/scripts/questions/question_handling.js',
1907 $a_target_dir.
'/js/question_handling.js');
1920 return $this->public_export_file[$a_type];
1929 include_once(
"./Modules/File/classes/class.ilObjFile.php");
1931 foreach ($this->file_ids as $file_id)
1933 $expLog->write(date(
"[y-m-d H:i:s] ").
"File Item ".$file_id);
1934 $file_obj =
new ilObjFile($file_id,
false);
1935 $file_obj->export($a_target_dir);
1945 $this->public_export_file[$a_type] = $a_file;
1965 'SELECT cp_node.cp_node_id '
1966 .
'FROM cp_node, cp_resource, cp_item '
1967 .
'WHERE cp_item.cp_node_id = cp_node.cp_node_id '
1968 .
'AND cp_item.resourceId = cp_resource.id '
1969 .
'AND scormType = '.$ilDB->quote(
'sco',
'text').
' '
1970 .
'AND nodeName = '.$ilDB->quote(
'item',
'text').
' '
1971 .
'AND cp_node.slm_id = '.$ilDB->quote($a_id,
'integer').
' '
1972 .
'GROUP BY cp_node.cp_node_id'
1977 array_push($scos,
$row[
'cp_node_id']);
1982 for($i = 0; $i < count($scos); $i++)
1984 $res = $ilDB->queryF(
1985 'SELECT c_max FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)',
1986 array(
'integer',
'integer'),
1987 array($a_user, $scos[$i])
1990 if($ilDB->numRows(
$res) > 0)
1993 if(
$row[
'c_max'] != null)
1996 $max =
$row[
'c_max'];
2000 $retVal = ($set == 1) ? $max : null;
2007 $retAr = array(
"raw" => null,
"max" => null,
"scaled" => null);
2008 $val_set = $ilDB->queryF(
"SELECT c_raw, c_max, scaled FROM cmi_node WHERE (user_id = %s AND cp_node_id = %s)",
2009 array(
'integer',
'integer'),
2010 array($a_user, $a_cp_node_id)
2012 if ($val_set->numRows()>0)
2014 $val_rec = $ilDB->fetchAssoc($val_set);
2015 $retAr[
"raw"] = $val_rec[
'c_raw'];
2016 $retAr[
"max"] = $val_rec[
'c_max'];
2017 $retAr[
"scaled"] = $val_rec[
'scaled'];
2018 if ($val_rec[
'scaled']==null && $val_rec[
'c_raw']!=null && $val_rec[
'c_max']!=null) {
2019 $retAr[
"scaled"] = ($val_rec[
'c_raw'] / $val_rec[
'c_max']);
2036 include_once(
"./Services/Style/classes/class.ilObjStyleSheet.php");
2040 $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id);
2041 $new_id = $style_obj->ilClone();
2042 $a_new_obj->setStyleSheetId($new_id);
2043 $a_new_obj->update();
2046 $a_new_obj->createScorm2004Tree();
2047 $source_tree = $this->
getTree();
2048 $target_tree_root_id = $a_new_obj->getTree()->readRootId();
2049 $childs = $source_tree->getChilds($source_tree->readRootId());
2050 $a_copied_nodes = array();
2051 include_once(
"./Modules/Scorm2004/classes/class.ilSCORM2004Node.php");
2052 foreach ($childs as $c)