36 $this->log = $DIC[
"ilLog"];
38 $this->spl_import_manager = $DIC->surveyQuestionPool()
45 public function init(): void
48 $this->ds->setDSPrefix(
"ds");
49 $this->ds->setImport($this);
62 self::$survey = $a_val;
82 if ($a_entity ===
"svy") {
84 if (!($new_id = $a_mapping->
getMapping(
'Services/Container',
'objs', $a_id))) {
85 $new_id = $a_mapping->
getMapping(
"Modules/Survey",
"svy", 0);
94 if (!file_exists($xml_file)) {
95 $GLOBALS[
'ilLog']->write(__METHOD__ .
': Cannot find xml definition: ' . $xml_file);
98 $GLOBALS[
'ilLog']->write(
"getQuestionPoolID = " . $this->
getImport()->getConfig(
"Modules/Survey")->getQuestionPoolID());
101 $this->
getImport()->getConfig(
"Modules/Survey")->getQuestionPoolID(),
107 $import->setSurveyObject($newObj);
108 $import->startParsing();
112 $mobs = $this->spl_import_manager->getMobs();
113 if (count(
$mobs) > 0) {
114 foreach (
$mobs as $mob) {
115 $this->svy_log->debug(
"import mob xhtml, type: " . $mob[
"type"] .
", id: " . $mob[
"mob"]);
117 if (!isset($mob[
"type"])) {
118 $mob[
"type"] =
"svy:html";
121 $importfile = dirname($xml_file) .
"/" . $mob[
"uri"];
122 $this->svy_log->debug(
"import file: " . $importfile);
124 if (file_exists($importfile)) {
128 if ($mob[
"type"] ===
"svy:html") {
130 $this->svy_log->debug(
"old introduction: " . $newObj->getIntroduction());
131 $newObj->setIntroduction(str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $newObj->getIntroduction()));
132 $newObj->setOutro(str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $newObj->getOutro()));
134 $this->svy_log->debug(
"new introduction: " . $newObj->getIntroduction());
135 } elseif ($import->questions[$mob[
"id"]]) {
136 $new_qid = $import->questions[$mob[
"id"]];
139 $qtext = $new_question->getQuestiontext();
141 $this->svy_log->debug(
"old question text: " . $qtext);
144 $qtext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" .
IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $qtext);
146 $new_question->setQuestiontext($qtext);
147 $new_question->saveToDb();
149 $this->svy_log->debug(
"new question text: " . $qtext);
152 if ($new_question->getOriginalId()) {
154 $pool_question->setQuestiontext($qtext);
155 $pool_question->saveToDb();
159 $this->svy_log->error(
"Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
166 $a_mapping->
addMapping(
"Modules/Survey",
"svy", (
int) $a_id, $newObj->getId());
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
Manifest parser for ILIAS standard export files.
setSurvey(ilObjSurvey $a_val)
Set current survey object (being imported).
getMapping(string $a_comp, string $a_entity, string $a_old_id)
static ilObjSurvey $survey
parseXmlFileNames()
Create qti and xml file name.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
__construct(Container $dic, ilPlugin $plugin)
ILIAS SurveyQuestionPool Export ImportManager $spl_import_manager
static _instanciateQuestion(int $question_id)
Get question object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...