Skip to content

Commit

Permalink
Test/TestQuestionPool: LOM as tail dependency in export (#7924)
Browse files Browse the repository at this point in the history
* Test/TestQuestionPool: LOM as tail dependency in export

* TestQuestionPool: fix cp notice

* TestQuestionPool: use xmlElement instead of appending from string
  • Loading branch information
schmitz-ilias authored and kergomard committed Nov 8, 2024
1 parent 0152617 commit 8994728
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 40 deletions.
17 changes: 0 additions & 17 deletions components/ILIAS/Test/classes/class.ilObjTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3962,9 +3962,6 @@ public function exportPagesXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
{
$this->mob_ids = [];

// MetaData
$this->exportXMLMetaData($a_xml_writer);

// PageObjects
$expLog->write(date("[y-m-d H:i:s] ") . "Start Export Page Objects");
$this->bench->start("ContentObjectExport", "exportPageObjects");
Expand All @@ -3987,20 +3984,6 @@ public function exportPagesXML(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
$expLog->write(date("[y-m-d H:i:s] ") . "Finished Export File Items");
}

/**
* export content objects meta data to xml (see ilias_co.dtd)
*
* @param object $a_xml_writer ilXmlWriter object that receives the
* xml data
*/
public function exportXMLMetaData(&$a_xml_writer)
{
$md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
$md2xml->setExportMode(true);
$md2xml->startExport();
$a_xml_writer->appendXML($md2xml->getXML());
}

/**
* Returns the installation id for a given identifier
*
Expand Down
13 changes: 13 additions & 0 deletions components/ILIAS/Test/classes/class.ilTestExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ public function getXmlExportTailDependencies(string $a_entity, string $a_target_
'ids' => $a_ids
];


$md_ids = [];
foreach ($a_ids as $id) {
$md_ids[] = $id . ':0:tst';
}
if ($md_ids !== []) {
$deps[] = [
'component' => 'components/ILIAS/MetaData',
'entity' => 'md',
'ids' => $md_ids
];
}

return $deps;
}

Expand Down
6 changes: 6 additions & 0 deletions components/ILIAS/Test/classes/class.ilTestImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ public function importXmlRepresentation(
$this->importSkillLevelThresholds($a_mapping, $importedAssignmentList, $new_obj, $xmlfile);

$a_mapping->addMapping("components/ILIAS/Test", "tst", (string) $a_id, (string) $new_obj->getId());
$a_mapping->addMapping(
"components/ILIAS/MetaData",
"md",
$a_id . ":0:tst",
$new_obj->getId() . ":0:tst"
);
}

public function addTexonomyAndQuestionsMapping(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct(int $a_id = 0, bool $a_call_by_reference = true)

$this->type = 'qpl';

parent::__construct($a_id, $a_call_by_reference);
parent::__construct((int) $a_id, $a_call_by_reference);

$this->skill_service_enabled = false;
}
Expand Down Expand Up @@ -345,7 +345,7 @@ public function objectToXmlWriter(ilXmlWriter &$a_xml_writer, $a_inst, $a_target
$a_xml_writer->xmlStartTag('ContentObject', $attrs);

// MetaData
$this->exportXMLMetaData($a_xml_writer);
$this->exportTitleAndDescription($a_xml_writer);

// Settings
$this->exportXMLSettings($a_xml_writer);
Expand Down Expand Up @@ -395,18 +395,10 @@ protected function populateQuestionSkillAssignmentsXml(ilXmlWriter &$a_xml_write
$skillQuestionAssignmentExporter->export();
}

/**
* export content objects meta data to xml (see ilias_co.dtd)
*
* @param object $a_xml_writer ilXmlWriter object that receives the
* xml data
*/
public function exportXMLMetaData(&$a_xml_writer): void
public function exportTitleAndDescription(ilXmlWriter &$a_xml_writer): void
{
$md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
$md2xml->setExportMode(true);
$md2xml->startExport();
$a_xml_writer->appendXML($md2xml->getXML());
$a_xml_writer->xmlElement('Title', null, $this->getTitle());
$a_xml_writer->xmlElement('Description', null, $this->getDescription());
}

public function modifyExportIdentifier($a_tag, $a_param, $a_value)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
Expand Down Expand Up @@ -69,15 +70,8 @@ public function handlerBeginTag($xmlParser, $tagName, $tagAttributes): void
break;

case 'Title':
if ($this->inMetaDataTag && $this->inMdGeneralTag) {
$this->cdata = '';
}
break;

case 'Description':
if ($this->inMetaDataTag && $this->inMdGeneralTag) {
$this->cdata = '';
}
$this->cdata = '';
break;

case 'Settings':
Expand Down Expand Up @@ -108,15 +102,15 @@ public function handlerEndTag($xmlParser, $tagName): void
break;

case 'Title':
if ($this->inMetaDataTag && $this->inMdGeneralTag && !$this->description_processed) {
if (!$this->title_processed) {
$this->poolOBJ->setTitle($this->cdata);
$this->title_processed = true;
$this->cdata = '';
}
break;

case 'Description':
if ($this->inMetaDataTag && $this->inMdGeneralTag && !$this->description_processed) {
if (!$this->description_processed) {
$this->poolOBJ->setDescription($this->cdata);
$this->description_processed = true;
$this->cdata = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ public function getXmlExportTailDependencies(string $a_entity, string $a_target_
];
}

$md_ids = [];
foreach ($a_ids as $id) {
$md_ids[] = $id . ':0:qpl';
}
if ($md_ids !== []) {
$deps[] = [
'component' => 'components/ILIAS/MetaData',
'entity' => 'md',
'ids' => $md_ids
];
}

return $deps;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ public function importXmlRepresentation(string $a_entity, string $a_id, string $
$this->importQuestionSkillAssignments($xmlfile, $a_mapping, $new_obj->getId());

$a_mapping->addMapping("components/ILIAS/TestQuestionPool", "qpl", $a_id, (string) $new_obj->getId());
$a_mapping->addMapping(
"components/ILIAS/MetaData",
"md",
$a_id . ":0:qpl",
$new_obj->getId() . ":0:qpl"
);


$new_obj->saveToDb();
}
Expand Down

0 comments on commit 8994728

Please sign in to comment.