19 declare(strict_types=1);
34 "LrsTypeId" => [
"db_col" =>
"lrs_type_id",
"db_type" =>
"integer"]
36 "ContentType" => [
"db_col" =>
"content_type",
"db_type" =>
"text"]
38 "SourceType" => [
"db_col" =>
"source_type",
"db_type" =>
"text"]
40 "ActivityId" => [
"db_col" =>
"activity_id",
"db_type" =>
"text"]
42 "Instructions" => [
"db_col" =>
"instructions",
"db_type" =>
"text"]
45 "LaunchUrl" => [
"db_col" =>
"launch_url",
"db_type" =>
"text"]
47 "AuthFetchUrl" => [
"db_col" =>
"auth_fetch_url",
"db_type" =>
"integer"]
49 "LaunchMethod" => [
"db_col" =>
"launch_method",
"db_type" =>
"text"]
51 "LaunchMode" => [
"db_col" =>
"launch_mode",
"db_type" =>
"text"]
53 "MasteryScore" => [
"db_col" =>
"mastery_score",
"db_type" =>
"float"]
55 "KeepLp" => [
"db_col" =>
"keep_lp",
"db_type" =>
"integer"]
57 "PrivacyIdent" => [
"db_col" =>
"privacy_ident",
"db_type" =>
"integer"]
59 "PrivacyName" => [
"db_col" =>
"privacy_name",
"db_type" =>
"integer"]
61 "UsrPrivacyComment" => [
"db_col" =>
"usr_privacy_comment",
"db_type" =>
"text"]
63 "ShowStatements" => [
"db_col" =>
"show_statements",
"db_type" =>
"integer"]
65 "XmlManifest" => [
"db_col" =>
"xml_manifest",
"db_type" =>
"text"]
67 "Version" => [
"db_col" =>
"version",
"db_type" =>
"integer"]
69 "HighscoreEnabled" => [
"db_col" =>
"highscore_enabled",
"db_type" =>
"integer"]
71 "HighscoreAchievedTs" => [
"db_col" =>
"highscore_achieved_ts",
"db_type" =>
"integer"]
73 "HighscorePercentage" => [
"db_col" =>
"highscore_percentage",
"db_type" =>
"integer"]
75 "HighscoreWtime" => [
"db_col" =>
"highscore_wtime",
"db_type" =>
"integer"]
77 "HighscoreOwnTable" => [
"db_col" =>
"highscore_own_table",
"db_type" =>
"integer"]
79 "HighscoreTopTable" => [
"db_col" =>
"highscore_top_table",
"db_type" =>
"integer"]
81 "HighscoreTopNum" => [
"db_col" =>
"highscore_top_num",
"db_type" =>
"integer"]
83 "BypassProxy" => [
"db_col" =>
"bypass_proxy",
"db_type" =>
"integer"]
85 "OnlyMoveon" => [
"db_col" =>
"only_moveon",
"db_type" =>
"integer"]
87 "Achieved" => [
"db_col" =>
"achieved",
"db_type" =>
"integer"]
89 "Answered" => [
"db_col" =>
"answered",
"db_type" =>
"integer"]
91 "Completed" => [
"db_col" =>
"completed",
"db_type" =>
"integer"]
93 "Failed" => [
"db_col" =>
"failed",
"db_type" =>
"integer"]
95 "Initialized" => [
"db_col" =>
"initialized",
"db_type" =>
"integer"]
97 "Passed" => [
"db_col" =>
"passed",
"db_type" =>
"integer"]
99 "Progressed" => [
"db_col" =>
"progressed",
"db_type" =>
"integer"]
101 "Satisfied" => [
"db_col" =>
"satisfied",
"db_type" =>
"integer"]
103 "Terminated" => [
"db_col" =>
"c_terminated",
"db_type" =>
"integer"]
105 "HideData" => [
"db_col" =>
"hide_data",
"db_type" =>
"integer"]
107 "Timestamp" => [
"db_col" =>
"c_timestamp",
"db_type" =>
"integer"]
109 "Duration" => [
"db_col" =>
"duration",
"db_type" =>
"integer"]
111 "NoSubstatements" => [
"db_col" =>
"no_substatements",
"db_type" =>
"integer"]
113 "PublisherId" => [
"db_col" =>
"publisher_id",
"db_type" =>
"text"]
115 "AnonymousHomepage" => [
"db_col" =>
"anonymous_homepage",
"db_type" =>
"integer"]
117 "MoveOn" => [
"db_col" =>
"moveon",
"db_type" =>
"text"]
119 "LaunchParameters" => [
"db_col" =>
"launch_parameters",
"db_type" =>
"text"]
121 "EntitlementKey" => [
"db_col" =>
"entitlement_key",
"db_type" =>
"text"]
123 "SwitchToReview" => [
"db_col" =>
"switch_to_review",
"db_type" =>
"integer"]
125 "DeleteData" => [
"db_col" =>
"delete_data",
"db_type" =>
"integer"]
132 public function __construct(
int $a_id = 0,
bool $a_reference =
true)
143 foreach ($this->_cmixSettingsProperties as $key => $value) {
144 $this->_element_db_mapping [$value[
"db_col"]] = $key;
155 ?array $a_rec =
null,
160 public function getCmiXapiXmlRepresentation(
162 string $a_schema_version,
164 string $a_field =
"",
165 bool $a_omit_header =
false,
166 bool $a_omit_types =
false 171 $GLOBALS[
"ilLog"]->write(json_encode($this->
getTypes(
"cmix",
"5.1.0"), JSON_PRETTY_PRINT));
175 $this->
readData($a_entity, $a_schema_version, $a_ids);
178 $id = (
int) $this->data[
"Id"];
181 $objTypeAndId =
"cmix_" .
$id;
182 $this->_archive[
'directories'] = [
187 "archiveDir" => time() .
"__" .
IL_INST_ID .
"__" . $objTypeAndId
189 "moduleDir" =>
"cmix_" .
$id 192 $this->_archive[
'files'] = [
193 "properties" =>
"properties.xml",
194 "manifest" =>
'manifest.xml' 196 if (
false !== strpos($this->data[
'SourceType'],
'local')) {
197 $this->_archive[
'files'][
'content'] =
"content.zip";
203 if (!file_exists($this->_archive[
'directories'][
'exportDir'])) {
204 mkdir($this->_archive[
'directories'][
'exportDir'], 0755,
true);
207 if (!file_exists($this->_archive[
'directories'][
'tempDir'])) {
208 mkdir($this->_archive[
'directories'][
'tempDir'], 0755,
true);
214 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'manifest'],
219 if (isset($this->_archive[
'files'][
'content'])) {
223 $this->_archive[
'directories'][
'tempDir'] .
"/" . substr($this->_archive[
'files'][
'content'], 0, -4),
230 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'properties'],
236 $fileName = $this->_archive[
'directories'][
'exportDir'] .
"/" . $this->_archive[
'directories'][
'archiveDir'] .
".zip";
238 if ($zArchive->open($fileName, ZipArchive::CREATE) !==
true) {
239 exit(
"cannot open <$fileName>\n");
242 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'properties'],
243 $this->_archive[
'directories'][
'archiveDir'] .
'/properties.xml' 246 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'manifest'],
247 $this->_archive[
'directories'][
'archiveDir'] .
'/' .
"manifest.xml" 249 if (isset($this->_archive[
'files'][
'content'])) {
251 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'content'],
252 $this->_archive[
'directories'][
'archiveDir'] .
'/content.zip' 266 unlink($this->_archive[
'directories'][
'tempDir'] .
"/manifest.xml");
267 unlink($this->_archive[
'directories'][
'tempDir'] .
"/properties.xml");
268 if (isset($this->_archive[
'files'][
'content'])) {
269 unlink($this->_archive[
'directories'][
'tempDir'] .
"/content.zip");
286 protected function getTypes(
string $a_entity,
string $a_version): array
289 foreach ($this->_cmixSettingsProperties as $key => $value) {
290 $types[$key] = $value[
"db_type"];
295 if ($a_entity ==
"cmix") {
296 switch ($a_version) {
299 foreach ($this->_cmixSettingsProperties as $key => $value) {
300 $types[$key] = $value[
"db_type"];
309 public function readData(
string $a_entity,
string $a_version, array $a_ids):
void 315 if (!is_array($a_ids)) {
316 $a_ids = array($a_ids);
320 if ($a_entity ==
"cmix") {
321 switch ($a_version) {
324 " FROM object_data " .
326 $DIC->database()->in(
"obj_id", $a_ids,
false,
"integer"));
331 foreach ($this->data as $key =>
$data) {
332 $query =
"SELECT " . implode(
",", array_keys($this->_element_db_mapping)) .
" ";
333 $query .=
"FROM `cmix_settings` ";
334 $query .=
"WHERE " . $DIC->database()->in(
"obj_id", $a_ids,
false,
"integer");
335 $result = $DIC->database()->query($query);
337 if ($dataset = $DIC->database()->fetchAssoc($result)) {
338 $this->_data = $dataset;
342 foreach ($this->_data as $dbColName => $value) {
343 $attr = $this->_element_db_mapping[$dbColName];
344 $this->data[$key][$attr] = $value;
348 $this->data = $this->data[0];
355 $manWriter->xmlHeader();
356 foreach ($this->_archive[
'files'] as $key => $value) {
357 $manWriter->xmlElement($key,
null, $value,
true,
true);
359 #$manWriter->appendXML ("</content>\n"); 360 return $manWriter->xmlDumpMem(
true);
363 private function buildProperties(mixed $a_entity,
bool $a_omit_header =
false): string
367 "InstallationUrl" => ILIAS_HTTP_PATH,
368 "TopEntity" => $a_entity
373 $writer->xmlStartTag(
'DataSet', $atts);
375 if (!$a_omit_header) {
376 $writer->xmlHeader();
379 foreach ($this->data as $key => $value) {
380 $writer->xmlElement($key,
null, $value,
true,
true);
383 $writer->xmlEndTag(
"DataSet");
385 return $writer->xmlDumpMem(
true);
393 string $a_schema_version
399 if ($new_id = $a_mapping->
getMapping(
'components/ILIAS/Container',
'objs', $a_rec[
'Id'])) {
403 $newObj->setType(
"cmix");
404 $newObj->create(
true);
407 $newObj->setTitle($a_rec[
"Title"]);
408 $newObj->setDescription($a_rec[
"Description"]);
412 $a_mapping->
addMapping(
"components/ILIAS/CmiXapi",
"cmix", $a_rec[
"Id"], (
string) $newObj->getId());
414 "components/ILIAS/MetaData",
416 $a_rec[
"Id"] .
":0:cmix",
417 $newObj->getId() .
":0:cmix" 429 return array(
"5.1.0");
437 return "http://www.ilias.de/xml/Modules/CmiXapi/" . $a_entity;
static getWebspaceDir(string $mode="filesystem")
get webspace directory
readData(string $a_entity, string $a_version, array $a_ids)
Read data from DB.
getSupportedVersions()
Get supported versions.
getTypes(string $a_entity, string $a_version)
Get field types for entity.
array $_element_db_mapping
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
static _getExportDirectory(int $a_obj_id, string $a_type="xml", string $a_obj_type="", string $a_entity="")
Get export directory for an repository object
array $_cmixSettingsProperties
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getMapping(string $a_comp, string $a_entity, string $a_old_id)
importRecord(string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
getDependencies(string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
Determine the dependent sets of data.
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 ...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct(Container $dic, ilPlugin $plugin)
static zip(string $a_dir, string $a_file, bool $compress_content=false)
buildProperties(mixed $a_entity, bool $a_omit_header=false)
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getXmlNamespace(string $a_entity, string $a_schema_version)
Get xml namespace.