3 declare(strict_types=1);
33 "LrsTypeId" => [
"db_col" =>
"lrs_type_id",
"db_type" =>
"integer"]
35 "ContentType" => [
"db_col" =>
"content_type",
"db_type" =>
"text"]
37 "SourceType" => [
"db_col" =>
"source_type",
"db_type" =>
"text"]
39 "ActivityId" => [
"db_col" =>
"activity_id",
"db_type" =>
"text"]
41 "Instructions" => [
"db_col" =>
"instructions",
"db_type" =>
"text"]
44 "LaunchUrl" => [
"db_col" =>
"launch_url",
"db_type" =>
"text"]
46 "AuthFetchUrl" => [
"db_col" =>
"auth_fetch_url",
"db_type" =>
"integer"]
48 "LaunchMethod" => [
"db_col" =>
"launch_method",
"db_type" =>
"text"]
50 "LaunchMode" => [
"db_col" =>
"launch_mode",
"db_type" =>
"text"]
52 "MasteryScore" => [
"db_col" =>
"mastery_score",
"db_type" =>
"float"]
54 "KeepLp" => [
"db_col" =>
"keep_lp",
"db_type" =>
"integer"]
56 "PrivacyIdent" => [
"db_col" =>
"privacy_ident",
"db_type" =>
"integer"]
58 "PrivacyName" => [
"db_col" =>
"privacy_name",
"db_type" =>
"integer"]
60 "UsrPrivacyComment" => [
"db_col" =>
"usr_privacy_comment",
"db_type" =>
"text"]
62 "ShowStatements" => [
"db_col" =>
"show_statements",
"db_type" =>
"integer"]
64 "XmlManifest" => [
"db_col" =>
"xml_manifest",
"db_type" =>
"text"]
66 "Version" => [
"db_col" =>
"version",
"db_type" =>
"integer"]
68 "HighscoreEnabled" => [
"db_col" =>
"highscore_enabled",
"db_type" =>
"integer"]
70 "HighscoreAchievedTs" => [
"db_col" =>
"highscore_achieved_ts",
"db_type" =>
"integer"]
72 "HighscorePercentage" => [
"db_col" =>
"highscore_percentage",
"db_type" =>
"integer"]
74 "HighscoreWtime" => [
"db_col" =>
"highscore_wtime",
"db_type" =>
"integer"]
76 "HighscoreOwnTable" => [
"db_col" =>
"highscore_own_table",
"db_type" =>
"integer"]
78 "HighscoreTopTable" => [
"db_col" =>
"highscore_top_table",
"db_type" =>
"integer"]
80 "HighscoreTopNum" => [
"db_col" =>
"highscore_top_num",
"db_type" =>
"integer"]
82 "BypassProxy" => [
"db_col" =>
"bypass_proxy",
"db_type" =>
"integer"]
84 "OnlyMoveon" => [
"db_col" =>
"only_moveon",
"db_type" =>
"integer"]
86 "Achieved" => [
"db_col" =>
"achieved",
"db_type" =>
"integer"]
88 "Answered" => [
"db_col" =>
"answered",
"db_type" =>
"integer"]
90 "Completed" => [
"db_col" =>
"completed",
"db_type" =>
"integer"]
92 "Failed" => [
"db_col" =>
"failed",
"db_type" =>
"integer"]
94 "Initialized" => [
"db_col" =>
"initialized",
"db_type" =>
"integer"]
96 "Passed" => [
"db_col" =>
"passed",
"db_type" =>
"integer"]
98 "Progressed" => [
"db_col" =>
"progressed",
"db_type" =>
"integer"]
100 "Satisfied" => [
"db_col" =>
"satisfied",
"db_type" =>
"integer"]
102 "Terminated" => [
"db_col" =>
"c_terminated",
"db_type" =>
"integer"]
104 "HideData" => [
"db_col" =>
"hide_data",
"db_type" =>
"integer"]
106 "Timestamp" => [
"db_col" =>
"c_timestamp",
"db_type" =>
"integer"]
108 "Duration" => [
"db_col" =>
"duration",
"db_type" =>
"integer"]
110 "NoSubstatements" => [
"db_col" =>
"no_substatements",
"db_type" =>
"integer"]
112 "PublisherId" => [
"db_col" =>
"publisher_id",
"db_type" =>
"text"]
114 "AnonymousHomepage" => [
"db_col" =>
"anonymous_homepage",
"db_type" =>
"integer"]
116 "MoveOn" => [
"db_col" =>
"moveon",
"db_type" =>
"text"]
118 "LaunchParameters" => [
"db_col" =>
"launch_parameters",
"db_type" =>
"text"]
120 "EntitlementKey" => [
"db_col" =>
"entitlement_key",
"db_type" =>
"text"]
122 "SwitchToReview" => [
"db_col" =>
"switch_to_review",
"db_type" =>
"integer"]
129 public function __construct(
int $a_id = 0,
bool $a_reference =
true)
140 foreach ($this->_cmixSettingsProperties as
$key => $value) {
141 $this->_element_db_mapping [$value[
"db_col"]] =
$key;
152 ?array $a_rec = null,
157 public function getCmiXapiXmlRepresentation(
159 string $a_schema_version,
161 string $a_field =
"",
162 bool $a_omit_header =
false,
163 bool $a_omit_types =
false 168 $GLOBALS[
"ilLog"]->write(json_encode($this->
getTypes(
"cmix",
"5.1.0"), JSON_PRETTY_PRINT));
172 $this->
readData($a_entity, $a_schema_version, $a_ids);
175 $id = (
int) $this->data[
"Id"];
178 $objTypeAndId =
"cmix_" .
$id;
179 $this->_archive[
'directories'] = [
184 "archiveDir" => time() .
"__" .
IL_INST_ID .
"__" . $objTypeAndId
186 "moduleDir" =>
"cmix_" .
$id 189 $this->_archive[
'files'] = [
190 "properties" =>
"properties.xml",
191 "metadata" =>
"metadata.xml",
192 "manifest" =>
'manifest.xml',
194 if (
false !== strpos($this->data[
'SourceType'],
'local')) {
195 $this->_archive[
'files'][
'content'] =
"content.zip";
201 if (!file_exists($this->_archive[
'directories'][
'exportDir'])) {
202 mkdir($this->_archive[
'directories'][
'exportDir'], 0755,
true);
205 if (!file_exists($this->_archive[
'directories'][
'tempDir'])) {
206 mkdir($this->_archive[
'directories'][
'tempDir'], 0755,
true);
212 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'metadata'],
218 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'manifest'],
223 if (isset($this->_archive[
'files'][
'content'])) {
227 $this->_archive[
'directories'][
'tempDir'] .
"/" . substr($this->_archive[
'files'][
'content'], 0, -4),
234 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'properties'],
240 $fileName = $this->_archive[
'directories'][
'exportDir'] .
"/" . $this->_archive[
'directories'][
'archiveDir'] .
".zip";
241 $zArchive =
new ZipArchive();
242 if ($zArchive->open($fileName, ZipArchive::CREATE) !==
true) {
243 exit(
"cannot open <$fileName>\n");
246 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'properties'],
247 $this->_archive[
'directories'][
'archiveDir'] .
'/properties.xml' 250 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'manifest'],
251 $this->_archive[
'directories'][
'archiveDir'] .
'/' .
"manifest.xml" 254 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'metadata'],
255 $this->_archive[
'directories'][
'archiveDir'] .
'/' .
"metadata.xml" 257 if (isset($this->_archive[
'files'][
'content'])) {
259 $this->_archive[
'directories'][
'tempDir'] .
"/" . $this->_archive[
'files'][
'content'],
260 $this->_archive[
'directories'][
'archiveDir'] .
'/content.zip' 274 unlink($this->_archive[
'directories'][
'tempDir'] .
"/metadata.xml");
275 unlink($this->_archive[
'directories'][
'tempDir'] .
"/manifest.xml");
276 unlink($this->_archive[
'directories'][
'tempDir'] .
"/properties.xml");
277 if (isset($this->_archive[
'files'][
'content'])) {
278 unlink($this->_archive[
'directories'][
'tempDir'] .
"/content.zip");
295 protected function getTypes(
string $a_entity,
string $a_version): array
298 foreach ($this->_cmixSettingsProperties as
$key => $value) {
299 $types[
$key] = $value[
"db_type"];
304 if ($a_entity ==
"cmix") {
305 switch ($a_version) {
308 foreach ($this->_cmixSettingsProperties as
$key => $value) {
309 $types[
$key] = $value[
"db_type"];
318 public function readData(
string $a_entity,
string $a_version, array $a_ids):
void 324 if (!is_array($a_ids)) {
325 $a_ids = array($a_ids);
329 if ($a_entity ==
"cmix") {
330 switch ($a_version) {
333 " FROM object_data " .
335 $DIC->database()->in(
"obj_id", $a_ids,
false,
"integer"));
341 $query =
"SELECT " . implode(
",", array_keys($this->_element_db_mapping)) .
" ";
342 $query .=
"FROM `cmix_settings` ";
343 $query .=
"WHERE " . $DIC->database()->in(
"obj_id", $a_ids,
false,
"integer");
344 $result = $DIC->database()->query(
$query);
346 if ($dataset = $DIC->database()->fetchAssoc($result)) {
347 $this->_data = $dataset;
351 foreach ($this->_data as $dbColName => $value) {
352 $attr = $this->_element_db_mapping[$dbColName];
353 $this->data[
$key][$attr] = $value;
357 $this->data = $this->data[0];
363 $md2xml =
new ilMD2XML($id, $id,
"cmix");
364 $md2xml->startExport();
365 return $md2xml->getXML();
371 $manWriter->xmlHeader();
372 foreach ($this->_archive[
'files'] as
$key => $value) {
373 $manWriter->xmlElement(
$key, null, $value,
true,
true);
375 #$manWriter->appendXML ("</content>\n"); 376 return $manWriter->xmlDumpMem(
true);
386 "InstallationUrl" => ILIAS_HTTP_PATH,
387 "TopEntity" => $a_entity
392 $writer->xmlStartTag(
'DataSet', $atts);
394 if (!$a_omit_header) {
395 $writer->xmlHeader();
398 foreach ($this->data as
$key => $value) {
399 $writer->xmlElement(
$key, null, $value,
true,
true);
402 $writer->xmlEndTag(
"DataSet");
404 return $writer->xmlDumpMem(
true);
412 string $a_schema_version
418 if ($new_id = $a_mapping->
getMapping(
'Services/Container',
'objs', $a_rec[
'Id'])) {
422 $newObj->setType(
"cmix");
423 $newObj->create(
true);
426 $newObj->setTitle($a_rec[
"Title"]);
427 $newObj->setDescription($a_rec[
"Description"]);
431 $a_mapping->
addMapping(
"Modules/CmiXapi",
"cmix", $a_rec[
"Id"], (
string) $newObj->getId());
442 return array(
"5.1.0");
450 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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getTypes(string $a_entity, string $a_version)
Get field types for entity.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
getMapping(string $a_comp, string $a_entity, string $a_old_id)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
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
buildProperties($a_entity, bool $a_omit_header=false)
__construct(Container $dic, ilPlugin $plugin)
static zip(string $a_dir, string $a_file, bool $compress_content=false)
zips given directory/file into given zip.file
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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.