20        "LrsTypeId" => [
"db_col" => 
"lrs_type_id", 
"db_type" => 
"integer"]
 
   21        ,
"ContentType" => [
"db_col" => 
"content_type", 
"db_type" => 
"text"]
 
   22        ,
"SourceType" => [
"db_col" => 
"source_type", 
"db_type" => 
"text"]
 
   23        ,
"ActivityId" => [
"db_col" => 
"activity_id", 
"db_type" => 
"text"]
 
   24        ,
"Instructions" => [
"db_col" => 
"instructions", 
"db_type" => 
"text"]
 
   26        ,
"LaunchUrl" => [
"db_col" => 
"launch_url", 
"db_type" => 
"text"]
 
   27        ,
"AuthFetchUrl" => [
"db_col" => 
"auth_fetch_url", 
"db_type" => 
"integer"]
 
   28        ,
"LaunchMethod" => [
"db_col" => 
"launch_method", 
"db_type" => 
"text"]
 
   29        ,
"LaunchMode" => [
"db_col" => 
"launch_mode", 
"db_type" => 
"text"]
 
   30        ,
"MasteryScore" => [
"db_col" => 
"mastery_score", 
"db_type" => 
"float"]
 
   31        ,
"KeepLp" => [
"db_col" => 
"keep_lp", 
"db_type" => 
"integer"]
 
   32        ,
"PrivacyIdent" => [
"db_col" => 
"privacy_ident", 
"db_type" => 
"integer"]
 
   33        ,
"PrivacyName" => [
"db_col" => 
"privacy_name", 
"db_type" => 
"integer"]
 
   34        ,
"UsrPrivacyComment" => [
"db_col" => 
"usr_privacy_comment", 
"db_type" => 
"text"]
 
   35        ,
"ShowStatements" => [
"db_col" => 
"show_statements", 
"db_type" => 
"integer"]
 
   36        ,
"XmlManifest" => [
"db_col" => 
"xml_manifest", 
"db_type" => 
"text"]
 
   37        ,
"Version" => [
"db_col" => 
"version", 
"db_type" => 
"integer"]
 
   38        ,
"HighscoreEnabled" => [
"db_col" => 
"highscore_enabled", 
"db_type" => 
"integer"]
 
   39        ,
"HighscoreAchievedTs" => [
"db_col" => 
"highscore_achieved_ts", 
"db_type" => 
"integer"]
 
   40        ,
"HighscorePercentage" => [
"db_col" => 
"highscore_percentage", 
"db_type" => 
"integer"]
 
   41        ,
"HighscoreWtime" => [
"db_col" => 
"highscore_wtime", 
"db_type" => 
"integer"]
 
   42        ,
"HighscoreOwnTable" => [
"db_col" => 
"highscore_own_table", 
"db_type" => 
"integer"]
 
   43        ,
"HighscoreTopTable" => [
"db_col" => 
"highscore_top_table", 
"db_type" => 
"integer"]
 
   44        ,
"HighscoreTopNum" => [
"db_col" => 
"highscore_top_num", 
"db_type" => 
"integer"]
 
   45        ,
"BypassProxy" => [
"db_col" => 
"bypass_proxy", 
"db_type" => 
"integer"]
 
   46        ,
"OnlyMoveon" => [
"db_col" => 
"only_moveon", 
"db_type" => 
"integer"]
 
   47        ,
"Achieved" => [
"db_col" => 
"achieved", 
"db_type" => 
"integer"]
 
   48        ,
"Answered" => [
"db_col" => 
"answered", 
"db_type" => 
"integer"]
 
   49        ,
"Completed" => [
"db_col" => 
"completed", 
"db_type" => 
"integer"]
 
   50        ,
"Failed" => [
"db_col" => 
"failed", 
"db_type" => 
"integer"]
 
   51        ,
"Initialized" => [
"db_col" => 
"initialized", 
"db_type" => 
"integer"]
 
   52        ,
"Passed" => [
"db_col" => 
"passed", 
"db_type" => 
"integer"]
 
   53        ,
"Progressed" => [
"db_col" => 
"progressed", 
"db_type" => 
"integer"]
 
   54        ,
"Satisfied" => [
"db_col" => 
"satisfied", 
"db_type" => 
"integer"]
 
   55        ,
"Terminated" => [
"db_col" => 
"c_terminated", 
"db_type" => 
"integer"]
 
   56        ,
"HideData" => [
"db_col" => 
"hide_data", 
"db_type" => 
"integer"]
 
   57        ,
"Timestamp" => [
"db_col" => 
"c_timestamp", 
"db_type" => 
"integer"]
 
   58        ,
"Duration" => [
"db_col" => 
"duration", 
"db_type" => 
"integer"]
 
   59        ,
"NoSubstatements" => [
"db_col" => 
"no_substatements", 
"db_type" => 
"integer"]
 
   60        ,
"PublisherId" => [
"db_col" => 
"publisher_id", 
"db_type" => 
"text"]
 
   61        ,
"AnonymousHomepage" => [
"db_col" => 
"anonymous_homepage", 
"db_type" => 
"integer"]
 
   62        ,
"MoveOn" => [
"db_col" => 
"moveon", 
"db_type" => 
"text"]
 
   63        ,
"LaunchParameters" => [
"db_col" => 
"launch_parameters", 
"db_type" => 
"text"]
 
   64        ,
"EntitlementKey" => [
"db_col" => 
"entitlement_key", 
"db_type" => 
"text"]
 
   65        ,
"SwitchToReview" => [
"db_col" => 
"switch_to_review", 
"db_type" => 
"integer"]
 
   71    public function __construct($a_id = 0, $a_reference = 
true)
 
   75        $this->_main_object_id = $a_id;
 
   81        foreach ($this->_cmixSettingsProperties as $key => $value) {
 
   82            $this->_element_db_mapping [$value[
"db_col"]] = $key;
 
   93    public function readData($a_entity, $a_version, $a_ids) : void
 
   98        if (!is_array($a_ids)) {
 
   99            $a_ids = array($a_ids);
 
  103        if ($a_entity == 
"cmix") {
 
  104            switch ($a_version) {
 
  107                      " FROM object_data " .
 
  109                      $DIC->database()->in(
"obj_id", $a_ids, 
false, 
"integer"));
 
  114        foreach ($this->data as $key => 
$data) {
 
  115            $query = 
"SELECT " . implode(
",", array_keys($this->_element_db_mapping)) . 
" ";
 
  116            $query .= 
"FROM `cmix_settings` ";
 
  117            $query .= 
"WHERE " . 
$DIC->database()->in(
"obj_id", $a_ids, 
false, 
"integer");
 
  120            if ($dataset = 
$DIC->database()->fetchAssoc(
$result)) {
 
  121                $this->_data = $dataset;
 
  125            foreach ($this->_data as $dbColName => $value) {
 
  126                $attr = $this->_element_db_mapping[$dbColName];
 
  127                $this->data[$key][$attr] = $value;
 
  131        $this->data = $this->data[0];
 
  143    protected function getTypes($a_entity, $a_version) : array
 
  146        foreach ($this->_cmixSettingsProperties as $key => $value) {
 
  147            $types[$key] = $value[
"db_type"];
 
  152        if ($a_entity == 
"cmix") {
 
  153            switch ($a_version) {
 
  156                  foreach ($this->_cmixSettingsProperties as $key => $value) {
 
  157                      $types[$key] = $value[
"db_type"];
 
  169    public function getCmiXapiXmlRepresentation($a_entity, $a_schema_version, $a_ids, $a_field = 
"", $a_omit_header = 
false, $a_omit_types = 
false)
 
  173        $GLOBALS[
"ilLog"]->write(json_encode($this->
getTypes(
"cmix", 
"5.1.0"), JSON_PRETTY_PRINT));
 
  177        $this->
readData($a_entity, $a_schema_version, $a_ids);
 
  180        $id = $this->data[
"Id"];
 
  183        require_once(
"./Services/Export/classes/class.ilExport.php");
 
  184        require_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
 
  187        $objTypeAndId = 
"cmix_" . $id;
 
  188        $this->_archive[
'directories'] = [
 
  191           ,
"archiveDir" => time() . 
"__" . 
IL_INST_ID . 
"__" . $objTypeAndId
 
  192           ,
"moduleDir" => 
"cmix_" . $id
 
  195        $this->_archive[
'files'] = [
 
  196           "properties" => 
"properties.xml",
 
  197           "metadata" => 
"metadata.xml",
 
  198           "manifest" => 
'manifest.xml',
 
  200        if (
false !== strpos($this->data[
'SourceType'], 
'local')) {
 
  201            $this->_archive[
'files'][
'content'] = 
"content.zip";
 
  208        if (!file_exists($this->_archive[
'directories'][
'exportDir'])) {
 
  209            mkdir($this->_archive[
'directories'][
'exportDir'], 0755, 
true);
 
  212        if (!file_exists($this->_archive[
'directories'][
'tempDir'])) {
 
  213            mkdir($this->_archive[
'directories'][
'tempDir'], 0755, 
true);
 
  220            $this->_archive[
'directories'][
'tempDir'] . 
"/" . $this->_archive[
'files'][
'metadata'],
 
  226            $this->_archive[
'directories'][
'tempDir'] . 
"/" . $this->_archive[
'files'][
'manifest'],
 
  231        if (isset($this->_archive[
'files'][
'content'])) {
 
  233            ilUtil::zip($lmDir, $this->_archive[
'directories'][
'tempDir'] . 
"/" . substr($this->_archive[
'files'][
'content'], 0, -4), 
true);
 
  238            $this->_archive[
'directories'][
'tempDir'] . 
"/" . $this->_archive[
'files'][
'properties'],
 
  245        $fileName = $this->_archive[
'directories'][
'exportDir'] . 
"/" . $this->_archive[
'directories'][
'archiveDir'] . 
".zip";
 
  246        $zArchive = 
new ZipArchive();
 
  247        if ($zArchive->open($fileName, ZipArchive::CREATE) !== 
true) {
 
  248            exit(
"cannot open <$fileName>\n");
 
  251            $this->_archive[
'directories'][
'tempDir'] . 
"/" . $this->_archive[
'files'][
'properties'],
 
  252            $this->_archive[
'directories'][
'archiveDir'] . 
'/properties.xml' 
  255            $this->_archive[
'directories'][
'tempDir'] . 
"/" . $this->_archive[
'files'][
'manifest'],
 
  256            $this->_archive[
'directories'][
'archiveDir'] . 
'/' . 
"manifest.xml" 
  259            $this->_archive[
'directories'][
'tempDir'] . 
"/" . $this->_archive[
'files'][
'metadata'],
 
  260            $this->_archive[
'directories'][
'archiveDir'] . 
'/' . 
"metadata.xml" 
  262        if (isset($this->_archive[
'files'][
'content'])) {
 
  264                $this->_archive[
'directories'][
'tempDir'] . 
"/" . $this->_archive[
'files'][
'content'],
 
  265                $this->_archive[
'directories'][
'archiveDir'] . 
'/content.zip' 
  280        unlink($this->_archive[
'directories'][
'tempDir'] . 
"/metadata.xml");
 
  281        unlink($this->_archive[
'directories'][
'tempDir'] . 
"/manifest.xml");
 
  282        unlink($this->_archive[
'directories'][
'tempDir'] . 
"/properties.xml");
 
  283        if (isset($this->_archive[
'files'][
'content'])) {
 
  284            unlink($this->_archive[
'directories'][
'tempDir'] . 
"/content.zip");
 
  305        $md2xml = 
new ilMD2XML($id, $id, 
"cmix");
 
  306        $md2xml->startExport();
 
  307        return $md2xml->getXML();
 
  316        $manWriter->xmlHeader();
 
  317        foreach ($this->_archive[
'files'] as $key => $value) {
 
  318            $manWriter->xmlElement($key, 
null, $value, 
true, 
true);
 
  320        #$manWriter->appendXML ("</content>\n");
 
  321        return $manWriter->xmlDumpMem(
true);
 
  333           "InstallationUrl" => ILIAS_HTTP_PATH,
 
  334           "TopEntity" => $a_entity
 
  339        $writer->xmlStartTag(
'DataSet', $atts);
 
  341        if (!$a_omit_header) {
 
  342            $writer->xmlHeader();
 
  345        foreach ($this->data as $key => $value) {
 
  346            $writer->xmlElement($key, 
null, $value, 
true, 
true);
 
  349        $writer->xmlEndTag(
"DataSet");
 
  351        return $writer->xmlDumpMem(
true);
 
  366        string $a_schema_version
 
  372               include_once(
"./Modules/CmiXapi/classes/class.ilObjCmiXapi.php");
 
  374               if ($new_id = $a_mapping->
getMapping(
'Services/Container', 
'objs', $a_rec[
'Id'])) {
 
  378                   $newObj->setType(
"cmix");
 
  379                   $newObj->create(
true);
 
  382               $newObj->setTitle($a_rec[
"Title"]);
 
  383               $newObj->setDescription($a_rec[
"Description"]);
 
  388               $a_mapping->
addMapping(
"Modules/CmiXapi", 
"cmix", $a_rec[
"Id"], $newObj->getId());
 
  400        return array(
"5.1.0");
 
  411        return "http://www.ilias.de/xml/Modules/CmiXapi/" . $a_entity;
 
  420        ?array $a_rec = 
null,
 
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
getSupportedVersions()
Get supported versions.
buildProperties($a_entity, $a_omit_header=false)
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
getDependencies(string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
Determine the dependent sets of data.
importRecord(string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
getTypes($a_entity, $a_version)
Get field types for entity.
A dataset contains in data in a common structure that can be shared and transformed for different pur...
__construct()
Constructor.
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 ...
readData($a_entity, $a_version, $a_ids)
Read data from DB.
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
getMapping($a_comp, $a_entity, $a_old_id)
Get a mapping.
addMapping($a_comp, $a_entity, $a_old_id, $a_new_id)
Add mapping.
static getInstance($a_id=0, $a_reference=true)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static getWebspaceDir($mode="filesystem")
get webspace directory
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc