ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilScormAiccDataSet Class Reference
+ Inheritance diagram for ilScormAiccDataSet:
+ Collaboration diagram for ilScormAiccDataSet:

Public Member Functions

 readData ($a_entity, $a_version, $a_id, $a_field="")
 Read data. More...
 
 writeData ($a_entity, $a_version, $a_id, $data=[])
 Write properties for imported object (actually updates !!) More...
 
 getElementNameByDbColumn ($db_col_name)
 
 buildMetaData ($id)
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 getDependencies ()
 
 getSupportedVersions ()
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 Constructor. More...
 
 init ($a_entity, $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 Get supported version. More...
 
 readData ($a_entity, $a_version, $a_ids)
 Read data from DB. More...
 
 setExportDirectories ($a_relative, $a_absolute)
 Set export directories. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setDSPrefix ($a_val)
 Set XML dataset namespace prefix. More...
 
 getDSPrefix ()
 Get XML dataset namespace prefix. More...
 
 getDSPrefixString ()
 
 getDirectDataFromQuery ($a_query, $a_convert_to_leading_upper=true, $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper ($a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getJsonRepresentation ()
 Get json representation. More...
 
 getXmlRepresentation ( $a_entity, $a_schema_version, $a_ids, $a_field="", $a_omit_header=false, $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 ($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
 Add records xml. More...
 
 afterXmlRecordWriting ($a_entity, $a_version, $a_set)
 After xml record writing hook record. More...
 
 getNamespaces (&$namespaces, $a_entity, $a_schema_version)
 Get xml namespaces. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record for version. More...
 
 getJsonRecord ($a_set)
 Get json record for version. More...
 
 getXmlTypes ($a_entity, $a_version)
 Get xml types. More...
 
 getJsonTypes ($a_entity, $a_version)
 Get json types. More...
 
 getXMLEntityName ($a_entity, $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag ($a_entity, $a_schema_version)
 Get entity tag. More...
 
 getJsonEntityName ($a_entity, $a_version)
 Get entity name for json (may be overwritten) More...
 
 setImport ($a_val)
 Set import object. More...
 
 getImport ()
 Get import object. More...
 
 setCurrentInstallationId ($a_val)
 Set current installation id. More...
 
 getCurrentInstallationId ()
 Get current installation id. More...
 

Data Fields

 $data = []
 
 $properties
 
 db_type
 
- Data Fields inherited from ilDataSet
 $dircnt
 
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
 

Protected Member Functions

 getTypes ($a_entity, $a_version)
 Get field types for entity. More...
 
- Protected Member Functions inherited from ilDataSet
 getTypes ($a_entity, $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 createObjectExportId ($a_type, $a_id)
 Build ilias export id. More...
 
 parseObjectExportId ($a_id, $a_fallback_id=null)
 Parse export id. More...
 
 stripTags (array $rec, array $omit_keys=[])
 

Private Member Functions

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

Private Attributes

 $dic
 
 $db_table = "sahs_lm"
 
 $_archive = []
 
 $element_db_mapping = []
 

Additional Inherited Members

- Protected Attributes inherited from ilDataSet
 $current_installation_id = ""
 
 $db
 
 $ds_log
 
 $ds_namespace = 'ds'
 

Detailed Description

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

Member Function Documentation

◆ buildManifest()

ilScormAiccDataSet::buildManifest ( )
private
Returns
string

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

Referenced by getElementNameByDbColumn().

363  : string
364  {
365  $manWriter = new ilXmlWriter();
366  $manWriter->xmlHeader();
367  foreach ($this->_archive['files'] as $key => $value) {
368  $manWriter->xmlElement($key, null, $value, true, true);
369  }
370 
371  return $manWriter->xmlDumpMem(true);
372  }
XML writer class.
+ Here is the caller graph for this function:

◆ buildMetaData()

ilScormAiccDataSet::buildMetaData (   $id)

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

References $xml.

Referenced by getElementNameByDbColumn().

310  {
311  require_once("Services/MetaData/classes/class.ilMD2XML.php");
312  $md2xml = new ilMD2XML($id, $id, "sahs");
313  $md2xml->startExport();
314  $xml = $md2xml->getXML();
315  return $xml;
316  }
$xml
Definition: metadata.php:332
+ Here is the caller graph for this function:

◆ buildProperties()

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

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

References getElementNameByDbColumn(), and IL_INST_ID.

Referenced by getElementNameByDbColumn().

380  {
381  $writer = new ilXmlWriter();
382 
383  if (!$a_omit_header) {
384  $writer->xmlHeader();
385  }
386 
387  $writer->appendXML("\n");
388  $writer->xmlStartTag('DataSet', array(
389  "InstallationId" => IL_INST_ID,
390  "InstallationUrl" => ILIAS_HTTP_PATH,
391  "TopEntity" => $a_entity
392  ));
393 
394  $writer->appendXML("\n");
395 
396  foreach ($this->data as $key => $value) {
397  $writer->xmlElement($this->getElementNameByDbColumn($key), null, $value, true, true);
398  $writer->appendXML("\n");
399  }
400 
401  $writer->xmlEndTag("DataSet");
402 
403  return $writer->xmlDumpMem(false);
404  }
const IL_INST_ID
Definition: constants.php:38
XML writer class.
getElementNameByDbColumn($db_col_name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDependencies()

ilScormAiccDataSet::getDependencies ( )

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

351  {
352  return null;
353  }

◆ getElementNameByDbColumn()

ilScormAiccDataSet::getElementNameByDbColumn (   $db_col_name)

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

References $DIC, $GLOBALS, ilExport\_getExportDirectory(), buildManifest(), buildMetaData(), buildProperties(), exit, getTypes(), ilUtil\getWebspaceDir(), IL_INST_ID, readData(), and ilUtil\zip().

Referenced by buildProperties().

184  {
185  if ($db_col_name == "title") {
186  return "Title";
187  }
188  if ($db_col_name == "description") {
189  return "Description";
190  }
191  return $this->element_db_mapping[$db_col_name];
192  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSupportedVersions()

ilScormAiccDataSet::getSupportedVersions ( )

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

356  {
357  return ["5.1.0"];
358  }

◆ getTypes()

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

Get field types for entity.

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

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

Referenced by getElementNameByDbColumn().

326  {
327  if ($a_entity == "sahs") {
328  switch ($a_version) {
329  case "5.1.0":
330  $types = [];
331  foreach ($this->properties as $key => $value) {
332  $types[$key] = $value["db_type"];
333  }
334  return $types;
335  break;
336  }
337  }
338  }
+ Here is the caller graph for this function:

◆ getXmlNamespace()

ilScormAiccDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters

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

346  {
347  return "http://www.ilias.de/xml/Modules/ScormAicc/" . $a_entity;
348  }

◆ readData()

ilScormAiccDataSet::readData (   $a_entity,
  $a_version,
  $a_id,
  $a_field = "" 
)

Read data.

Parameters

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

References $columns, $db_table, $DIC, $ilDB, $query, and $result.

Referenced by getElementNameByDbColumn().

99  {
100  global $DIC;
101  $ilDB = $DIC['ilDB'];
102 
103  $obj_id = $a_id;
104  $columns = [];
105  foreach ($this->properties as $property) {
106  array_push($columns, $property["db_col"]);
107  }
108 
109  $query = "SELECT " . implode(",", $columns) . " FROM " . $this->db_table;
110  $query .= " WHERE id=" . $ilDB->quote($obj_id, "integer");
111  $result = $ilDB->query($query);
112  $this->data = [];
113  if ($dataset = $ilDB->fetchAssoc($result)) {
114  $this->data = $dataset;
115  }
116 
117  $query = "SELECT title,description FROM object_data";
118  $query .= " WHERE obj_id=" . $ilDB->quote($obj_id, "integer");
119  $result = $ilDB->query($query);
120  while ($dataset = $ilDB->fetchAssoc($result)) {
121  $this->data ["title"] = $dataset["title"];
122  $this->data ["description"] = $dataset["description"];
123  }
124  }
$result
global $DIC
Definition: goto.php:24
$query
global $ilDB
if(! $in) $columns
Definition: Utf8Test.php:45
+ Here is the caller graph for this function:

◆ writeData()

ilScormAiccDataSet::writeData (   $a_entity,
  $a_version,
  $a_id,
  $data = [] 
)

Write properties for imported object (actually updates !!)

Parameters
$datacontains imported module properties from xml file
Returns

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

References $columns, $data, $DIC, and $ilDB.

133  {
134  global $DIC;
135  $ilDB = $DIC['ilDB'];
136  $ilLog = $DIC['ilLog'];
137  if (count($data) > 0) {
138  $columns = [];
139  foreach ($this->properties as $key => $value) {
140  if ($key == "Id" || $key == "title" || $key == "description") {
141  continue;
142  }
143  //fix localization and mastery_score
144  if ($key == "MasteryScore" && $data[$key][0] == 0) {
145  continue;
146  }
147  if ($key == "Localization" && $data[$key][0] == "") {
148  continue;
149  }
150  //end fix
151  if (isset($data[$key])) {
152  $columns [$value["db_col"]] = [$value["db_type"], $data[$key]];
153  }
154  }
155  if (count($columns) > 0) {
156  $conditions ["id"] = ["integer", $a_id];
157  $ilDB->update($this->db_table, $columns, $conditions);
158  }
159 
160  //setting title and description in table object_data
161  $od_table = "object_data";
162  $od_properties = [
163  "Title" => ["db_col" => "title", "db_type" => "text"],
164  "Description" => ["db_col" => "description", "db_type" => "text"]
165  ];
166  foreach ($od_properties as $key => $value) {
167  if (isset($data[$key])) {
168  $od_columns [$value["db_col"]] = [$value["db_type"], $data[$key]];
169  }
170 
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);
174  }
175  }
176  } else {
177  $ilLog->write("no module properties for imported object");
178  }
179  }
global $DIC
Definition: goto.php:24
global $ilDB
if(! $in) $columns
Definition: Utf8Test.php:45

Field Documentation

◆ $_archive

ilScormAiccDataSet::$_archive = []
private

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

◆ $data

ilScormAiccDataSet::$data = []

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

Referenced by writeData().

◆ $db_table

ilScormAiccDataSet::$db_table = "sahs_lm"
private

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

Referenced by readData().

◆ $dic

ilScormAiccDataSet::$dic
private

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

◆ $element_db_mapping

ilScormAiccDataSet::$element_db_mapping = []
private

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

◆ $properties

ilScormAiccDataSet::$properties
Initial value:
= [
"Id" => ["db_col" => "id"

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

◆ db_type

ilScormAiccDataSet::db_type

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


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