19 declare(strict_types=1);
44 $this->log = $DIC[
'ilLog'];
45 $this->db = $DIC[
'ilDB'];
46 $this->irss = $DIC[
'resource_storage'];
66 if ($new_id = (
int) $a_mapping->
getMapping(
'Services/Container',
'objs', $a_id)) {
71 $question_parent_obj_id = $new_obj->getId();
74 $new_id = (
int) $a_mapping->
getMapping(
'Modules/Test',
'tst',
'new_id');
77 $question_parent_obj_id = (
int) (
ilSession::get(
'tst_import_qst_parent') ?? $new_obj->getId());
80 $new_obj->loadFromDb();
84 if (!@file_exists($xml_file)) {
85 $this->log->write(__METHOD__ .
': Cannot find xml definition: ' . $xml_file);
88 if (!@file_exists($qti_file)) {
89 $this->log->write(__METHOD__ .
': Cannot find xml definition: ' . $qti_file);
98 $new_obj->getMarkSchema()->flush();
106 $question_parent_obj_id,
111 $qtiParser->startParsing();
112 $new_obj = $qtiParser->getTestObject();
116 $questionPageParser->setQuestionMapping($qtiParser->getImportMapping());
117 $questionPageParser->startParsing();
121 if ($new_obj->isRandomTest()) {
127 if ($results_file_path !== null && file_exists($results_file_path)) {
134 $new_obj->saveToDb();
141 $a_mapping->
addMapping(
"Modules/Test",
"tst", (
string) $a_id, (
string) $new_obj->getId());
146 foreach ($question_id_mapping as $oldQuestionId => $newQuestionId) {
150 "tst:quest:$oldQuestionId",
151 (
string) $newQuestionId
157 "tst:quest:$oldQuestionId",
164 (
string) $oldQuestionId,
165 (
string) $newQuestionId
181 foreach ($maps as $old => $new) {
182 if ($old ==
"new_id" || (
int) $old <= 0) {
186 if (isset(self::$finallyProcessedTestsRegistry[$new])) {
191 if ($test_obj->isRandomTest()) {
195 self::$finallyProcessedTestsRegistry[$new] =
true;
211 if ($new_tax_ids !== null) {
212 $tax_ids = explode(
":", $new_tax_ids);
214 foreach ($tax_ids as $tid) {
230 $srcPoolDefList->loadDefinitions();
232 foreach ($srcPoolDefList as $definition) {
234 if (!is_array($definition->getMappedTaxonomyFilter()) || 0 === count($definition->getMappedTaxonomyFilter())) {
238 $definition->setMappedTaxonomyFilter(
241 $definition->getMappedTaxonomyFilter()
244 $definition->saveToDb();
255 $newMappedFilter = [];
257 foreach ($mappedFilter as $taxId => $taxNodes) {
268 $newMappedFilter[$newTaxId] = [];
270 foreach ($taxNodes as $taxNodeId) {
277 if (!$newTaxNodeId) {
281 $newMappedFilter[$newTaxId][] = $newTaxNodeId;
285 return $newMappedFilter;
299 $qti = $this->
getImportDirectory() .
'/' . preg_replace(
'/test|tst/',
'qti', $basename) .
'.xml';
307 $dir = dirname($dir);
314 $name = basename($dir);
320 $test_obj->questions = [];
322 $parser->setTestOBJ($test_obj);
323 $parser->setImportMapping($a_mapping);
324 $parser->startParsing();
336 $parser->startParsing();
339 $importer->setTargetParentObjId($test_obj->
getId());
340 $importer->setImportInstallationId((
int) $this->
getInstallId());
341 $importer->setImportMappingRegistry($mapping);
342 $importer->setImportMappingComponent(
'Modules/Test');
343 $importer->setImportAssignmentList($parser->getAssignmentList());
347 if ($importer->getFailedImportAssignmentList()->assignmentsExist()) {
356 return $importer->getSuccessImportAssignmentList();
368 $parser->initSkillLevelThresholdImportList();
369 $parser->startParsing();
372 $importer->setTargetTestId($test_obj->
getTestId());
373 $importer->setImportInstallationId((
int) $this->
getInstallId());
374 $importer->setImportMappingRegistry($mapping);
375 $importer->setImportedQuestionSkillAssignmentList($assignmentList);
376 $importer->setImportThresholdList($parser->getSkillLevelThresholdImportList());
379 if ($importer->getFailedThresholdImportSkillList()->skillsExist()) {
static get(string $a_var)
finalRandomTestTaxonomyProcessing(ilImportMapping $mapping, string $oldTstObjId, string $newTstObjId, ilObjTest $test_obj)
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
Import XML.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
importSkillLevelThresholds(ilImportMapping $mapping, ilAssQuestionSkillAssignmentList $assignmentList, ilObjTest $test_obj, $xmlFile)
registerFailedImports(ilAssQuestionAssignedSkillList $skillList)
getTestId()
Gets the database id of the additional test data.
importQuestionSkillAssignments(ilImportMapping $mapping, ilObjTest $test_obj, $xmlFile)
getNewMappedTaxonomyFilter(ilImportMapping $mapping, array $mappedFilter)
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getImportDirectoryContainer()
parseXmlFileNames()
Create qti and xml file name.
Importer class for files.
getMapping(string $a_comp, string $a_entity, string $a_old_id)
getMappingsOfEntity(string $a_comp, string $a_entity)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addTexonomyAndQuestionsMapping(array $question_id_mapping, int $new_obj_id, ilImportMapping $mapping)
Legacy Content Object Parser.
setOfflineStatus(bool $status)
static saveUsage(int $a_tax_id, int $a_obj_id)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
importRandomQuestionSetConfig(ilObjTest $test_obj, $xmlFile, $a_mapping)
finalProcessing(ilImportMapping $a_mapping)
Final processing.
static $finallyProcessedTestsRegistry
registerFailedImports(ilAssQuestionSkillAssignmentImportList $assignmentList)
static set(string $a_var, $a_val)
Set a value.
static _setImportDirectory($a_import_dir=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTestObject(ilObjTest $a_tst_object)