6 include_once(
"./Services/DataSet/classes/class.ilDataSet.php");
41 "Id" => [
"db_col" =>
"id",
"db_type" =>
"integer"],
43 "APIAdapterName" => [
"db_col" =>
"api_adapter",
"db_type" =>
"text"],
44 "APIFunctionsPrefix" => [
"db_col" =>
"api_func_prefix",
"db_type" =>
"text"],
45 "AssignedGlossary" => [
"db_col" =>
"glossary",
"db_type" =>
"integer"],
46 "AutoContinue" => [
"db_col" =>
"auto_continue",
"db_type" =>
"text"],
47 "AutoReviewChar" => [
"db_col" =>
"auto_review",
"db_type" =>
"text"],
48 "AutoSuspend" => [
"db_col" =>
"auto_suspend",
"db_type" =>
"text"],
49 "Auto_last_visited" => [
"db_col" =>
"auto_last_visited",
"db_type" =>
"text"],
50 "Check_values" => [
"db_col" =>
"check_values",
"db_type" =>
"text"],
51 "Comments" => [
"db_col" =>
"comments",
"db_type" =>
"text"],
52 "CreditMode" => [
"db_col" =>
"credit",
"db_type" =>
"text"],
53 "Debug" => [
"db_col" =>
"debug",
"db_type" =>
"text"],
54 "DebugPw" => [
"db_col" =>
"debugpw",
"db_type" =>
"text"],
55 "DefaultLessonMode" => [
"db_col" =>
"default_lesson_mode",
"db_type" =>
"text"],
56 "Editable" => [
"db_col" =>
"editable",
"db_type" =>
"integer"],
57 "Fourth_edition" => [
"db_col" =>
"fourth_edition",
"db_type" =>
"text"],
58 "Height" => [
"db_col" =>
"height",
"db_type" =>
"integer"],
59 "HideNavig" => [
"db_col" =>
"hide_navig",
"db_type" =>
"text"],
60 "Ie_force_render" => [
"db_col" =>
"ie_force_render",
"db_type" =>
"text"],
61 "Interactions" => [
"db_col" =>
"interactions",
"db_type" =>
"text"],
62 "Localization" => [
"db_col" =>
"localization",
"db_type" =>
"text"],
63 "MasteryScore" => [
"db_col" =>
"mastery_score",
"db_type" =>
"integer"],
64 "MaxAttempt" => [
"db_col" =>
"max_attempt",
"db_type" =>
"integer"],
65 "ModuleVersion" => [
"db_col" =>
"module_version",
"db_type" =>
"integer"],
66 "NoMenu" => [
"db_col" =>
"no_menu",
"db_type" =>
"text"],
67 "Objectives" => [
"db_col" =>
"objectives",
"db_type" =>
"text"],
68 "OfflineMode" => [
"db_col" =>
"offline_mode",
"db_type" =>
"text"],
69 "OpenMode" => [
"db_col" =>
"open_mode",
"db_type" =>
"integer"],
70 "Sequencing" => [
"db_col" =>
"sequencing",
"db_type" =>
"text"],
71 "SequencingExpertMode" => [
"db_col" =>
"seq_exp_mode",
"db_type" =>
"integer"],
72 "Session" => [
"db_col" =>
"unlimited_session",
"db_type" =>
"text"],
73 "StyleSheetId" => [
"db_col" =>
"stylesheet",
"db_type" =>
"integer"],
74 "SubType" => [
"db_col" =>
"c_type",
"db_type" =>
"text"],
75 "Time_from_lms" => [
"db_col" =>
"time_from_lms",
"db_type" =>
"text"],
76 "Tries" => [
"db_col" =>
"question_tries",
"db_type" =>
"integer"],
77 "Width" => [
"db_col" =>
"width",
"db_type" =>
"integer"],
78 "IdSetting" => [
"db_col" =>
"id_setting",
"db_type" =>
"integer"],
79 "NameSetting" => [
"db_col" =>
"name_setting",
"db_type" =>
"integer"]
88 foreach ($this->properties as $key => $value) {
89 $this->element_db_mapping[$value[
"db_col"]] = $key;
98 public function readData($a_entity, $a_version, $a_id, $a_field =
"")
101 $ilDB = $DIC[
'ilDB'];
105 foreach ($this->properties as $property) {
106 array_push(
$columns, $property[
"db_col"]);
110 $query .=
" WHERE id=" .
$ilDB->quote($obj_id,
"integer");
114 $this->data = $dataset;
117 $query =
"SELECT title,description FROM object_data";
118 $query .=
" WHERE obj_id=" .
$ilDB->quote($obj_id,
"integer");
121 $this->data [
"title"] = $dataset[
"title"];
122 $this->data [
"description"] = $dataset[
"description"];
135 $ilDB = $DIC[
'ilDB'];
136 $ilLog = $DIC[
'ilLog'];
137 if (count(
$data) > 0) {
139 foreach ($this->properties as $key => $value) {
140 if ($key ==
"Id" || $key ==
"title" || $key ==
"description") {
144 if ($key ==
"MasteryScore" &&
$data[$key][0] == 0) {
147 if ($key ==
"Localization" &&
$data[$key][0] ==
"") {
151 if (isset(
$data[$key])) {
152 $columns [$value[
"db_col"]] = [$value[
"db_type"],
$data[$key]];
156 $conditions [
"id"] = [
"integer", $a_id];
161 $od_table =
"object_data";
163 "Title" => [
"db_col" =>
"title",
"db_type" =>
"text"],
164 "Description" => [
"db_col" =>
"description",
"db_type" =>
"text"]
166 foreach ($od_properties as $key => $value) {
167 if (isset(
$data[$key])) {
168 $od_columns [$value[
"db_col"]] = [$value[
"db_type"],
$data[$key]];
171 if (isset($od_columns) && count($od_columns) > 0) {
172 $od_conditions [
"obj_id"] = [
"integer", $a_id];
173 $ilDB->update(
"object_data", $od_columns, $od_conditions);
177 $ilLog->write(
"no module properties for imported object");
185 if ($db_col_name ==
"title") {
188 if ($db_col_name ==
"description") {
189 return "Description";
191 return $this->element_db_mapping[$db_col_name];
205 public function getExtendedXmlRepresentation($a_entity, $a_schema_version,
int $a_ids,
string $a_field =
"",
bool $a_omit_header =
false,
bool $a_omit_types =
false)
209 $GLOBALS[
"ilLog"]->write(json_encode($this->
getTypes(
"sahs",
"5.1.0"), JSON_PRETTY_PRINT));
213 $this->
readData($a_entity, $a_schema_version, $a_ids);
214 $id = $this->data[
"id"];
217 require_once(dirname(__DIR__, 3) .
"/Services/Export/classes/class.ilExport.php");
218 require_once(dirname(__DIR__, 3) .
"/Services/Xml/classes/class.ilXmlWriter.php");
222 $objTypeAndId =
"sahs_" . $id;
223 $this->_archive[
'directories'] = [
226 ,
"archiveDir" => time() .
"__" .
IL_INST_ID .
"__" . $objTypeAndId
227 ,
"moduleDir" => $objTypeAndId
230 $this->_archive[
'files'] = [
231 "properties" =>
"properties.xml",
232 "metadata" =>
"metadata.xml",
233 "manifest" =>
'manifest.xml',
234 'scormFile' =>
"content.zip" 238 if (!file_exists($this->_archive[
'directories'][
'exportDir'])) {
239 mkdir($this->_archive[
'directories'][
'exportDir'], 0755,
true);
242 if (!file_exists($this->_archive[
'directories'][
'tempDir'])) {
243 mkdir($this->_archive[
'directories'][
'tempDir'], 0755,
true);
248 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'metadata'],
254 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'manifest'],
259 if (isset($this->_archive[
'files'][
'scormFile'])) {
261 ilUtil::zip($lmDir, $this->_archive[
'directories'][
'tempDir'] .
"/" . substr($this->_archive[
'files'][
'scormFile'], 0, -4),
true);
266 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'properties'],
271 $fileName = $this->_archive[
'directories'][
'exportDir'] .
"/" . $this->_archive[
'directories'][
'archiveDir'] .
".zip";
272 $zArchive =
new ZipArchive();
273 if ($zArchive->open($fileName, ZipArchive::CREATE) !==
true) {
274 exit(
"cannot open <$fileName>\n");
277 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'properties'],
278 $this->_archive[
'directories'][
'archiveDir'] .
'/properties.xml' 281 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'manifest'],
282 $this->_archive[
'directories'][
'archiveDir'] .
'/' .
"manifest.xml" 285 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'metadata'],
286 $this->_archive[
'directories'][
'archiveDir'] .
'/' .
"metadata.xml" 288 if (isset($this->_archive[
'files'][
'scormFile'])) {
290 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'scormFile'],
291 $this->_archive[
'directories'][
'archiveDir'] .
'/content.zip' 297 unlink($this->_archive[
'directories'][
'tempDir'] .
"/metadata.xml");
298 unlink($this->_archive[
'directories'][
'tempDir'] .
"/manifest.xml");
299 unlink($this->_archive[
'directories'][
'tempDir'] .
"/properties.xml");
300 if (isset($this->_archive[
'files'][
'scormFile']) && file_exists($this->_archive[
'directories'][
'tempDir'] .
"/content.zip")) {
301 unlink($this->_archive[
'directories'][
'tempDir'] .
"/content.zip");
311 require_once(
"Services/MetaData/classes/class.ilMD2XML.php");
312 $md2xml =
new ilMD2XML($id, $id,
"sahs");
313 $md2xml->startExport();
314 $xml = $md2xml->getXML();
327 if ($a_entity ==
"sahs") {
328 switch ($a_version) {
331 foreach ($this->properties as $key => $value) {
332 $types[$key] = $value[
"db_type"];
347 return "http://www.ilias.de/xml/Modules/ScormAicc/" . $a_entity;
366 $manWriter->xmlHeader();
367 foreach ($this->_archive[
'files'] as $key => $value) {
368 $manWriter->xmlElement($key, null, $value,
true,
true);
371 return $manWriter->xmlDumpMem(
true);
383 if (!$a_omit_header) {
384 $writer->xmlHeader();
387 $writer->appendXML(
"\n");
388 $writer->xmlStartTag(
'DataSet', array(
390 "InstallationUrl" => ILIAS_HTTP_PATH,
391 "TopEntity" => $a_entity
394 $writer->appendXML(
"\n");
396 foreach ($this->data as $key => $value) {
398 $writer->appendXML(
"\n");
401 $writer->xmlEndTag(
"DataSet");
403 return $writer->xmlDumpMem(
false);
readData($a_entity, $a_version, $a_id, $a_field="")
Read data.
__construct()
Constructor.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
buildProperties($a_entity, $a_omit_header=false)
__construct(Container $dic, ilPlugin $plugin)
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.
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.