ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilScormAiccDataSet Class Reference
+ Inheritance diagram for ilScormAiccDataSet:
+ Collaboration diagram for ilScormAiccDataSet:

Public Member Functions

 __construct ()
 
 writeData (string $a_entity, string $a_version, int $a_id, array $data)
 
 getExtendedXmlRepresentation (string $a_entity, string $a_schema_version, array $a_ids, string $a_field="", bool $a_omit_header=false, bool $a_omit_types=false)
 own getXmlRepresentation function to embed zipfile in xml More...
 
 readData (string $a_entity, string $a_version, array $a_ids, string $a_field="")
 
 getElementNameByDbColumn (string $db_col_name)
 retrieve element name by database column name More...
 
 getSupportedVersions ()
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 
 init (string $a_entity, string $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 initByExporter (ilXmlExporter $xml_exporter)
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setDSPrefix (string $a_val)
 
 getDSPrefix ()
 
 getDSPrefixString ()
 
 getDirectDataFromQuery (string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper (string $a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, ?array $a_ids, string $a_field="", bool $a_omit_header=false, bool $a_omit_types=false)
 Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text"> <ftype name="field_2" type="date"> <ftype name="field_3" type="integer"> </types> <types ...> ... More...
 
 addRecordsXml (ilXmlWriter $a_writer, array $a_prefixes, string $a_entity, string $a_schema_version, array $a_ids, ?string $a_field="")
 
 afterXmlRecordWriting (string $a_entity, string $a_version, array $a_set)
 
 getNamespaces (array &$namespaces, string $a_entity, string $a_schema_version)
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. More...
 
 getXmlTypes (string $a_entity, string $a_version)
 Get xml types. More...
 
 getXMLEntityName (string $a_entity, string $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag (string $a_entity, string $a_schema_version)
 Get entity tag. More...
 
 setImport (ilSurveyImporter $a_val)
 
 getImport ()
 
 setCurrentInstallationId (string $a_val)
 
 getCurrentInstallationId ()
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 Needs to be overwritten for import use case. More...
 
 getCollection (array $record, string $entity, string $schema_version, string $field, string $value)
 
 getContainerExportConfig (array $record, string $entity, string $schema_version, string $field, string $value)
 

Data Fields

array $properties
 
- Data Fields inherited from ilDataSet
const DATASET_NS = 'http://www.ilias.de/Services/DataSet/ds/4_3'
 
const DATASET_NS_PREFIX = 'ds'
 
const EXPORT_NO_INST_ID = 1
 
const EXPORT_ID_ILIAS_LOCAL = 2
 
const EXPORT_ID_ILIAS_LOCAL_INVALID = 3
 
const EXPORT_ID_ILIAS_REMOTE = 4
 
const EXPORT_ID_ILIAS_REMOTE_INVALID = 5
 
const EXPORT_ID = 6
 
const EXPORT_ID_INVALID = 7
 
int $dircnt = 0
 

Protected Member Functions

 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
 getTypes (string $a_entity, string $a_version)
 Get field types for entity. More...
 
 getXmlNamespace (string $a_entity, string $a_schema_version)
 Get xml namespace. More...
 
- Protected Member Functions inherited from ilDataSet
 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getExportDirInContainer (string $exp_dir)
 
 getIRSSContainerExportConfig (StorableResource $source_container, string $source_path, string $target_path="")
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
 createObjectExportId (string $a_type, string $a_id)
 Build ilias export id. More...
 
 parseObjectExportId (string $a_id, ?string $a_fallback_id=null)
 Parse export id. More...
 
 stripTags (array $rec, array $omit_keys=[])
 

Private Member Functions

 buildManifest ()
 
 buildProperties ($a_entity, bool $a_omit_header=false)
 

Private Attributes

string $db_table
 
array $_archive
 
array $element_db_mapping
 

Additional Inherited Members

- Protected Attributes inherited from ilDataSet
ILIAS ResourceStorage Services $irss
 
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $component_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 
ilExport $export
 

Detailed Description

Definition at line 21 of file class.ilScormAiccDataSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilScormAiccDataSet::__construct ( )

Definition at line 28 of file class.ilScormAiccDataSet.php.

29  {
30  $this->db_table = "sahs_lm";
31  $this->_archive = [];
32  $this->properties = [
33  "Id" => ["db_col" => "id", "db_type" => "integer"],
34  "APIAdapterName" => ["db_col" => "api_adapter", "db_type" => "text"],
35  "APIFunctionsPrefix" => ["db_col" => "api_func_prefix", "db_type" => "text"],
36  "AssignedGlossary" => ["db_col" => "glossary", "db_type" => "integer"],
37  "AutoContinue" => ["db_col" => "auto_continue", "db_type" => "text"],
38  "AutoReviewChar" => ["db_col" => "auto_review", "db_type" => "text"],
39  "AutoSuspend" => ["db_col" => "auto_suspend", "db_type" => "text"],
40  "Auto_last_visited" => ["db_col" => "auto_last_visited", "db_type" => "text"],
41  "Check_values" => ["db_col" => "check_values", "db_type" => "text"],
42  "Comments" => ["db_col" => "comments", "db_type" => "text"],
43  "CreditMode" => ["db_col" => "credit", "db_type" => "text"],
44  "Debug" => ["db_col" => "debug", "db_type" => "text"],
45  "DebugPw" => ["db_col" => "debugpw", "db_type" => "text"],
46  "DefaultLessonMode" => ["db_col" => "default_lesson_mode", "db_type" => "text"],
47  "Editable" => ["db_col" => "editable", "db_type" => "integer"],
48  "Fourth_edition" => ["db_col" => "fourth_edition", "db_type" => "text"],
49  "Height" => ["db_col" => "height", "db_type" => "integer"],
50  "HideNavig" => ["db_col" => "hide_navig", "db_type" => "text"],
51  "Ie_force_render" => ["db_col" => "ie_force_render", "db_type" => "text"],
52  "Interactions" => ["db_col" => "interactions", "db_type" => "text"],
53  "Localization" => ["db_col" => "localization", "db_type" => "text"],
54  "MasteryScore" => ["db_col" => "mastery_score", "db_type" => "integer"],
55  "MaxAttempt" => ["db_col" => "max_attempt", "db_type" => "integer"],
56  "ModuleVersion" => ["db_col" => "module_version", "db_type" => "integer"],
57  "NoMenu" => ["db_col" => "no_menu", "db_type" => "text"],
58  "Objectives" => ["db_col" => "objectives", "db_type" => "text"],
59  "OfflineMode" => ["db_col" => "offline_mode", "db_type" => "text"],
60  "OpenMode" => ["db_col" => "open_mode", "db_type" => "integer"],
61  "Sequencing" => ["db_col" => "sequencing", "db_type" => "text"],
62  "SequencingExpertMode" => ["db_col" => "seq_exp_mode", "db_type" => "integer"],
63  "Session" => ["db_col" => "unlimited_session", "db_type" => "text"],
64  "StyleSheetId" => ["db_col" => "stylesheet", "db_type" => "integer"],
65  "SubType" => ["db_col" => "c_type", "db_type" => "text"],
66  "Time_from_lms" => ["db_col" => "time_from_lms", "db_type" => "text"],
67  "Tries" => ["db_col" => "question_tries", "db_type" => "integer"],
68  "Width" => ["db_col" => "width", "db_type" => "integer"],
69  "IdSetting" => ["db_col" => "id_setting", "db_type" => "integer"],
70  "NameSetting" => ["db_col" => "name_setting", "db_type" => "integer"]
71  ];
72 
73  $this->element_db_mapping = [];
74  foreach ($this->properties as $key => $value) {
75  $this->element_db_mapping [$value["db_col"]] = $key;
76  }
77  }

Member Function Documentation

◆ buildManifest()

ilScormAiccDataSet::buildManifest ( )
private
Returns
string

Definition at line 320 of file class.ilScormAiccDataSet.php.

References null.

Referenced by getExtendedXmlRepresentation().

320  : string
321  {
322  $manWriter = new ilXmlWriter();
323  $manWriter->xmlHeader();
324  foreach ($this->_archive['files'] as $key => $value) {
325  $manWriter->xmlElement($key, null, $value, true, true);
326  }
327 
328  return $manWriter->xmlDumpMem(true);
329  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ buildProperties()

ilScormAiccDataSet::buildProperties (   $a_entity,
bool  $a_omit_header = false 
)
private
Parameters
$a_entity
bool$a_omit_header
Returns
string

Definition at line 336 of file class.ilScormAiccDataSet.php.

References getElementNameByDbColumn(), IL_INST_ID, and null.

Referenced by getExtendedXmlRepresentation().

336  : string
337  {
338  $writer = new ilXmlWriter();
339 
340  if (!$a_omit_header) {
341  $writer->xmlHeader();
342  }
343 
344  $writer->appendXML("\n");
345  $writer->xmlStartTag('DataSet', array(
346  "InstallationId" => IL_INST_ID,
347  "InstallationUrl" => ILIAS_HTTP_PATH,
348  "TopEntity" => $a_entity
349  ));
350 
351  $writer->appendXML("\n");
352 
353  foreach ($this->data as $key => $value) {
354  $writer->xmlElement($this->getElementNameByDbColumn($key), null, $value, true, true);
355  $writer->appendXML("\n");
356  }
357 
358  $writer->xmlEndTag("DataSet");
359 
360  return $writer->xmlDumpMem(false);
361  }
const IL_INST_ID
Definition: constants.php:40
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getElementNameByDbColumn(string $db_col_name)
retrieve element name by database column name
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDependencies()

ilScormAiccDataSet::getDependencies ( string  $a_entity,
string  $a_version,
?array  $a_rec = null,
?array  $a_ids = null 
)
protected

Definition at line 79 of file class.ilScormAiccDataSet.php.

84  : array {
85  return [];
86  }

◆ getElementNameByDbColumn()

ilScormAiccDataSet::getElementNameByDbColumn ( string  $db_col_name)

retrieve element name by database column name

Definition at line 290 of file class.ilScormAiccDataSet.php.

Referenced by buildProperties().

290  : string
291  {
292  if ($db_col_name === "title") {
293  return "Title";
294  }
295  if ($db_col_name === "description") {
296  return "Description";
297  }
298  return $this->element_db_mapping[$db_col_name];
299  }
+ Here is the caller graph for this function:

◆ getExtendedXmlRepresentation()

ilScormAiccDataSet::getExtendedXmlRepresentation ( string  $a_entity,
string  $a_schema_version,
array  $a_ids,
string  $a_field = "",
bool  $a_omit_header = false,
bool  $a_omit_types = false 
)

own getXmlRepresentation function to embed zipfile in xml

Definition at line 148 of file class.ilScormAiccDataSet.php.

References $GLOBALS, $id, ilExport\_getExportDirectory(), buildManifest(), buildProperties(), exit, getTypes(), ilFileUtils\getWebspaceDir(), IL_INST_ID, ILIAS\Repository\int(), readData(), and ilFileUtils\zip().

155  : string {
156  $GLOBALS['DIC']["ilLog"]->write(json_encode($this->getTypes("sahs", "5.1.0"), JSON_PRETTY_PRINT));
157 
158  $this->dircnt = 1;
159 
160  $this->readData($a_entity, $a_schema_version, $a_ids, $a_field = "");
161  $id = (int) $this->data["id"];
162  $exportDir = ilExport::_getExportDirectory((int) $id, "xml", "sahs");
163 
164  // prepare archive skeleton
165  $objTypeAndId = "sahs_" . $id;
166  $this->_archive['directories'] = [
167  "exportDir" => ilExport::_getExportDirectory($id)
168  ,"tempDir" => ilExport::_getExportDirectory($id) . "/temp"
169  ,"archiveDir" => time() . "__" . IL_INST_ID . "__" . $objTypeAndId
170  ,"moduleDir" => $objTypeAndId
171  ];
172 
173  $this->_archive['files'] = [
174  "properties" => "properties.xml",
175  "manifest" => 'manifest.xml',
176  'scormFile' => "content.zip"
177  ];
178 
179  // Prepare temp storage on the local filesystem
180  if (!file_exists($this->_archive['directories']['exportDir'])) {
181  mkdir($this->_archive['directories']['exportDir'], 0755, true);
182  //$DIC->filesystem()->storage()->createDir($this->_archive['directories']['tempDir']);
183  }
184  if (!file_exists($this->_archive['directories']['tempDir'])) {
185  mkdir($this->_archive['directories']['tempDir'], 0755, true);
186  }
187 
188  // build manifest xml file
189  file_put_contents(
190  $this->_archive['directories']['tempDir'] . "/" . $this->_archive['files']['manifest'],
191  $this->buildManifest()
192  );
193 
194  // build content zip file
195  if (isset($this->_archive['files']['scormFile'])) {
196  $lmDir = ilFileUtils::getWebspaceDir("filesystem") . "/lm_data/lm_" . $id;
197  ilFileUtils::zip($lmDir, $this->_archive['directories']['tempDir'] . "/" . substr($this->_archive['files']['scormFile'], 0, -4), true);
198  }
199 
200  // build property xml file
201  file_put_contents(
202  $this->_archive['directories']['tempDir'] . "/" . $this->_archive['files']['properties'],
203  $this->buildProperties($a_entity, $a_omit_header)
204  );
205 
206  // zip tempDir and append to export folder
207  $fileName = $this->_archive['directories']['exportDir'] . "/" . $this->_archive['directories']['archiveDir'] . ".zip";
208  $zArchive = new ZipArchive();
209  if ($zArchive->open($fileName, ZipArchive::CREATE) !== true) {
210  exit("cannot open <$fileName>\n");
211  }
212  $zArchive->addFile(
213  $this->_archive['directories']['tempDir'] . "/" . $this->_archive['files']['properties'],
214  $this->_archive['directories']['archiveDir'] . '/properties.xml'
215  );
216  $zArchive->addFile(
217  $this->_archive['directories']['tempDir'] . "/" . $this->_archive['files']['manifest'],
218  $this->_archive['directories']['archiveDir'] . '/' . "manifest.xml"
219  );
220  if (isset($this->_archive['files']['scormFile'])) {
221  $zArchive->addFile(
222  $this->_archive['directories']['tempDir'] . "/" . $this->_archive['files']['scormFile'],
223  $this->_archive['directories']['archiveDir'] . '/content.zip'
224  );
225  }
226  $zArchive->close();
227 
228  // unlink tempDir and its content
229  unlink($this->_archive['directories']['tempDir'] . "/manifest.xml");
230  unlink($this->_archive['directories']['tempDir'] . "/properties.xml");
231  if (isset($this->_archive['files']['scormFile']) && file_exists($this->_archive['directories']['tempDir'] . "/content.zip")) {
232  unlink($this->_archive['directories']['tempDir'] . "/content.zip");
233  }
234 
235  return $fileName;
236  }
static getWebspaceDir(string $mode="filesystem")
get webspace directory
const IL_INST_ID
Definition: constants.php:40
getTypes(string $a_entity, string $a_version)
Get field types for entity.
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
Get export directory for an repository object
$GLOBALS["DIC"]
Definition: wac.php:53
buildProperties($a_entity, bool $a_omit_header=false)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static zip(string $a_dir, string $a_file, bool $compress_content=false)
readData(string $a_entity, string $a_version, array $a_ids, string $a_field="")
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getSupportedVersions()

ilScormAiccDataSet::getSupportedVersions ( )
Returns
string[]

Definition at line 312 of file class.ilScormAiccDataSet.php.

312  : array
313  {
314  return ["5.1.0"];
315  }

◆ getTypes()

ilScormAiccDataSet::getTypes ( string  $a_entity,
string  $a_version 
)
protected

Get field types for entity.

Parameters
string$a_entityentity
string$a_versionversion number
Returns
array types array

Definition at line 244 of file class.ilScormAiccDataSet.php.

Referenced by getExtendedXmlRepresentation().

244  : array
245  {
246  if ($a_entity === "sahs") {
247  switch ($a_version) {
248  case "5.1.0":
249  $types = [];
250  foreach ($this->properties as $key => $value) {
251  $types[$key] = $value["db_type"];
252  }
253  return $types;
254  }
255  }
256  return [];
257  }
+ Here is the caller graph for this function:

◆ getXmlNamespace()

ilScormAiccDataSet::getXmlNamespace ( string  $a_entity,
string  $a_schema_version 
)
protected

Get xml namespace.

Definition at line 304 of file class.ilScormAiccDataSet.php.

304  : string
305  {
306  return "http://www.ilias.de/xml/Modules/ScormAicc/" . $a_entity;
307  }

◆ readData()

ilScormAiccDataSet::readData ( string  $a_entity,
string  $a_version,
array  $a_ids,
string  $a_field = "" 
)

Definition at line 259 of file class.ilScormAiccDataSet.php.

References $db_table, $DIC, $ilDB, and ILIAS\Repository\int().

Referenced by getExtendedXmlRepresentation().

259  : void
260  {
261  global $DIC;
262  $ilDB = $DIC->database();
263 
264  $obj_id = (int) $a_ids[0];
265  $columns = [];
266  foreach ($this->properties as $property) {
267  $columns[] = $property["db_col"];
268  }
269 
270  $query = "SELECT " . implode(",", $columns) . " FROM " . $this->db_table;
271  $query .= " WHERE id=" . $ilDB->quote($obj_id, "integer");
272  $result = $ilDB->query($query);
273  $this->data = [];
274  if ($dataset = $ilDB->fetchAssoc($result)) {
275  $this->data = $dataset;
276  }
277 
278  $query = "SELECT title,description FROM object_data";
279  $query .= " WHERE obj_id=" . $ilDB->quote($obj_id, "integer");
280  $result = $ilDB->query($query);
281  while ($dataset = $ilDB->fetchAssoc($result)) {
282  $this->data ["title"] = $dataset["title"];
283  $this->data ["description"] = $dataset["description"];
284  }
285  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeData()

ilScormAiccDataSet::writeData ( string  $a_entity,
string  $a_version,
int  $a_id,
array  $data 
)

Definition at line 88 of file class.ilScormAiccDataSet.php.

References $DIC, $ilDB, and ilLoggerFactory\getLogger().

88  : void
89  {
90  global $DIC;
91  $ilDB = $DIC->database();
92  $ilLog = ilLoggerFactory::getLogger('sahs');
93  if (count($data) > 0) {
94  $columns = [];
95  foreach ($this->properties as $key => $value) {
96  if ($key === "Id" || $key === "title" || $key === "description") {
97  continue;
98  }
99  //fix localization and mastery_score
100  if ($key === "MasteryScore" && isset($data[$key][0]) && $data[$key][0] == 0) {
101  continue;
102  }
103  if ($key === "Localization" && isset($data[$key][0]) && $data[$key][0] == "") {
104  continue;
105  }
106  //end fix
107  if (isset($data[$key]) && is_array($data[$key])) {
108  if (count($data[$key]) > 0) {
109  $columns [$value["db_col"]] = [$value["db_type"], $data[$key][0]];
110  }
111  }
112  }
113  if (is_array($columns)) {
114  if (count($columns) > 0) {
115  $conditions ["id"] = ["integer", $a_id];
116  $ilDB->update($this->db_table, $columns, $conditions);
117  }
118  }
119 
120  //setting title and description in table object_data
121  $od_table = "object_data";
122  $od_properties = [
123  "Title" => ["db_col" => "title", "db_type" => "text"],
124  "Description" => ["db_col" => "description", "db_type" => "text"]
125  ];
126  foreach ($od_properties as $key => $value) {
127  if (isset($data[$key]) && is_array($data[$key])) {
128  if (count($data[$key]) > 0) {
129  $od_columns [$value["db_col"]] = [$value["db_type"], $data[$key][0]];
130  }
131  }
132 
133  if (isset($od_columns) && is_array($od_columns)) {
134  if (count($od_columns) > 0) {
135  $od_conditions ["obj_id"] = ["integer", $a_id];
136  $ilDB->update("object_data", $od_columns, $od_conditions);
137  }
138  }
139  }
140  } else {
141  $ilLog->write("no module properties for imported object");
142  }
143  }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Field Documentation

◆ $_archive

array ilScormAiccDataSet::$_archive
private

Definition at line 25 of file class.ilScormAiccDataSet.php.

◆ $db_table

string ilScormAiccDataSet::$db_table
private

Definition at line 23 of file class.ilScormAiccDataSet.php.

Referenced by readData().

◆ $element_db_mapping

array ilScormAiccDataSet::$element_db_mapping
private

Definition at line 26 of file class.ilScormAiccDataSet.php.

◆ $properties

array ilScormAiccDataSet::$properties

Definition at line 24 of file class.ilScormAiccDataSet.php.


The documentation for this class was generated from the following file: