3 include_once(
"./Services/DataSet/classes/class.ilDataSet.php");
9 $this->db_table =
"sahs_lm";
12 "Id" => [
"db_col" =>
"id",
"db_type" =>
"integer"],
14 "APIAdapterName" => [
"db_col" =>
"api_adapter",
"db_type" =>
"text"],
15 "APIFunctionsPrefix" => [
"db_col" =>
"api_func_prefix",
"db_type" =>
"text"],
16 "AssignedGlossary" => [
"db_col" =>
"glossary",
"db_type" =>
"integer"],
17 "AutoContinue" => [
"db_col" =>
"auto_continue",
"db_type" =>
"text"],
18 "AutoReviewChar" => [
"db_col" =>
"auto_review",
"db_type" =>
"text"],
19 "AutoSuspend" => [
"db_col" =>
"auto_suspend",
"db_type" =>
"text"],
20 "Auto_last_visited" => [
"db_col" =>
"auto_last_visited",
"db_type" =>
"text"],
21 "Check_values" => [
"db_col" =>
"check_values",
"db_type" =>
"text"],
22 "Comments" => [
"db_col" =>
"comments",
"db_type" =>
"text"],
23 "CreditMode" => [
"db_col" =>
"credit",
"db_type" =>
"text"],
24 "Debug" => [
"db_col" =>
"debug",
"db_type" =>
"text"],
25 "DebugPw" => [
"db_col" =>
"debugpw",
"db_type" =>
"text"],
26 "DefaultLessonMode" => [
"db_col" =>
"default_lesson_mode",
"db_type" =>
"text"],
27 "Editable" => [
"db_col" =>
"editable",
"db_type" =>
"integer"],
28 "Fourth_edition" => [
"db_col" =>
"fourth_edition",
"db_type" =>
"text"],
29 "Height" => [
"db_col" =>
"height",
"db_type" =>
"integer"],
30 "HideNavig" => [
"db_col" =>
"hide_navig",
"db_type" =>
"text"],
31 "Ie_compatibility" => [
"db_col" =>
"ie_compatibility",
"db_type" =>
"text"],
32 "Ie_force_render" => [
"db_col" =>
"ie_force_render",
"db_type" =>
"text"],
33 "Interactions" => [
"db_col" =>
"interactions",
"db_type" =>
"text"],
34 "Localization" => [
"db_col" =>
"localization",
"db_type" =>
"text"],
35 "MasteryScore" => [
"db_col" =>
"mastery_score",
"db_type" =>
"integer"],
36 "MaxAttempt" => [
"db_col" =>
"max_attempt",
"db_type" =>
"integer"],
37 "ModuleVersion" => [
"db_col" =>
"module_version",
"db_type" =>
"integer"],
38 "NoMenu" => [
"db_col" =>
"no_menu",
"db_type" =>
"text"],
39 "Objectives" => [
"db_col" =>
"objectives",
"db_type" =>
"text"],
40 "OfflineMode" => [
"db_col" =>
"offline_mode",
"db_type" =>
"text"],
41 "Online" => [
"db_col" =>
"c_online",
"db_type" =>
"text"],
42 "OpenMode" => [
"db_col" =>
"open_mode",
"db_type" =>
"integer"],
43 "Sequencing" => [
"db_col" =>
"sequencing",
"db_type" =>
"text"],
44 "SequencingExpertMode" => [
"db_col" =>
"seq_exp_mode",
"db_type" =>
"integer"],
45 "Session" => [
"db_col" =>
"unlimited_session",
"db_type" =>
"text"],
46 "StyleSheetId" => [
"db_col" =>
"stylesheet",
"db_type" =>
"integer"],
47 "SubType" => [
"db_col" =>
"c_type",
"db_type" =>
"text"],
48 "Time_from_lms" => [
"db_col" =>
"time_from_lms",
"db_type" =>
"text"],
49 "Tries" => [
"db_col" =>
"question_tries",
"db_type" =>
"integer"],
50 "Width" => [
"db_col" =>
"width",
"db_type" =>
"integer"]
53 $this->element_db_mapping = [];
56 $this->element_db_mapping [$value[
"db_col"]] = $key;
65 public function readData($a_entity, $a_version, $a_id, $a_field =
"")
72 array_push (
$columns, $property[
"db_col"]);
74 $query =
"SELECT " . implode (
",",
$columns) .
" FROM " . $this->db_table;
75 $query .=
" WHERE id=" . $ilDB->quote($obj_id,
"integer");
78 if ($dataset = $ilDB->fetchAssoc(
$result))
80 $this->
data = $dataset;
83 $query =
"SELECT title,description FROM object_data";
84 $query .=
" WHERE obj_id=" . $ilDB->quote($obj_id,
"integer");
86 while ($dataset = $ilDB->fetchAssoc(
$result))
88 $this->
data [
"title"] = $dataset[
"title"];
89 $this->
data [
"description"] = $dataset[
"description"];
102 if (count (
$data) > 0)
107 if ($key ==
"Id" || $key ==
"title"|| $key ==
"description")
continue;
108 if (isset (
$data[$key]))
109 if (count (
$data[$key]) > 0)
110 $columns [$value[
"db_col"]] = [$value[
"db_type"],
$data[$key][0]];
114 $conditions [
"id"] = [
"integer", $a_id];
115 $ilDB->update ($this->db_table,
$columns, $conditions);
119 $od_table =
"object_data";
121 "Title" => [
"db_col" =>
"title",
"db_type" =>
"text"],
122 "Description" => [
"db_col" =>
"description",
"db_type" =>
"text"]
124 foreach ($od_properties as $key => $value)
126 if (isset (
$data[$key]))
127 if (count (
$data[$key]) > 0)
128 $od_columns [$value[
"db_col"]] = [$value[
"db_type"],
$data[$key][0]];
130 if (count ($od_columns) > 0)
132 $od_conditions [
"obj_id"] = [
"integer", $a_id];
133 $ilDB->update (
"object_data", $od_columns, $od_conditions);
139 $ilLog->write (
"no module properties for imported object");
147 if ($db_col_name ==
"title")
return "Title";
148 if ($db_col_name ==
"description")
return "Description";
149 return $this->element_db_mapping[$db_col_name];
157 $GLOBALS[
"ilLog"]->write(json_encode($this->
getTypes(
"sahs",
"5.1.0"), JSON_PRETTY_PRINT));
162 $this->
readData($a_entity, $a_schema_version, $a_ids, $a_field =
"");
163 $id = $this->
data[
"id"];
165 require_once (
"./Services/Export/classes/class.ilExport.php");
170 require_once (
"./Services/Xml/classes/class.ilXmlWriter.php");
172 if (!$a_omit_header) { $writer->xmlHeader(); }
174 $atts =
array(
"InstallationId" => IL_INST_ID,
175 "InstallationUrl" => ILIAS_HTTP_PATH,
"TopEntity" => $a_entity);
177 $writer->appendXML (
"\n");
179 $writer->appendXML (
"\n");
181 foreach ($this->
data as $key => $value)
184 $writer->appendXML (
"\n");
188 $baseFileName =
"sahs_" . $id;
189 $scormBasePath=$exportDir .
"/" . $baseFileName;
190 if (!file_exists ($exportDir)) mkdir ($exportDir, 0755,
true);
193 $scormFilePath = $scormBasePath .
".zip";
196 $writer->appendXML (
"\n");
198 $xml = $writer->xmlDumpMem(
false);
199 $baseExportName =
time() .
"__" . IL_INST_ID .
"__". $baseFileName;
200 $xmlFilePath = $exportDir .
"/" . $baseExportName .
".xml";
202 if (!file_exists ($xmlFilePath))
204 $xmlFile = fopen ($xmlFilePath,
"w");
205 fwrite ($xmlFile, $xml);
212 $metaDataFilePath = $exportDir .
"/" . $baseExportName .
"_metadata.xml";
213 if (!file_exists ($metaDataFilePath))
215 $metaDataFile = fopen ($metaDataFilePath,
"w");
216 fwrite ($metaDataFile, $metaData);
217 fclose($metaDataFile);
222 $manWriter->xmlHeader();
223 $manWriter->appendXML (
"\n<content>\n");
226 "scormFile" => $baseFileName .
".zip",
227 "properties" => $baseFileName .
".xml",
228 "metadata" =>
"metadata.xml" 230 foreach (
$files as $key => $value)
232 $manWriter->xmlElement($key, Null, $value, TRUE, TRUE);
233 $manWriter->appendXML (
"\n");
236 $manWriter->appendXML (
"</content>\n");
237 $manifest = $manWriter->xmlDumpMem(
false);
239 $manifestFilePath = $exportDir .
"/" . $baseExportName .
"_manifest.xml";
240 if (!file_exists ($manifestFilePath))
242 $manifestFile = fopen ($manifestFilePath,
"w");
243 fwrite ($manifestFile, $manifest);
244 fclose($manifestFile);
247 $zArchive =
new zipArchive();
248 $fileName = $exportDir .
"/" . $baseExportName .
".zip";
250 if ($zArchive->open($fileName, ZipArchive::CREATE)!==TRUE) {
251 exit(
"cannot open <$fileName>\n");
255 $zArchive->addFile($xmlFilePath, $baseFileName .
".xml");
256 $zArchive->addFile($scormFilePath, $baseFileName .
".zip");
257 $zArchive->addFile($manifestFilePath,
"manifest.xml");
258 $zArchive->addFile($metaDataFilePath,
"metadata.xml");
261 unlink ($xmlFilePath);
262 unlink ($scormFilePath);
263 unlink ($manifestFilePath);
264 unlink ($metaDataFilePath);
271 require_once (
"Services/MetaData/classes/class.ilMD2XML.php");
272 $md2xml =
new ilMD2XML ($id, $id,
"sahs");
273 $md2xml->startExport();
274 $xml = $md2xml->getXML();
287 if ($a_entity ==
"sahs")
294 $types[$key] = $value[
"db_type"];
308 return "http://www.ilias.de/xml/Modules/ScormAicc/".$a_entity;
readData($a_entity, $a_version, $a_id, $a_field="")
Read data.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
getExtendedXmlRepresentation($a_entity, $a_schema_version, $a_ids, $a_field="", $a_omit_header=false, $a_omit_types=false)
static _lookupObjectId($a_ref_id)
lookup object id
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
Create styles array
The data for the language used.
writeData($a_entity, $a_version, $a_id, $data)
Write properties for imported object (actually updates !!)
getElementNameByDbColumn($db_col_name)
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
A dataset contains in data in a common structure that can be shared and transformed for different pur...
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
static getWebspaceDir($mode="filesystem")
get webspace directory
getTypes($a_entity, $a_version)
Get field types for entity.