19 declare(strict_types=1);
48 $this->
logger = TestDIC::dic()[
'logging.logger'];
49 $this->db = $DIC[
'ilDB'];
50 $this->irss = $DIC[
'resource_storage'];
61 $results_file_path =
null;
62 if ($new_id = (
int) $a_mapping->
getMapping(
'components/ILIAS/Container',
'objs', $a_id)) {
71 $selected_questions = [];
74 $new_id = (
int) $a_mapping->
getMapping(
'components/ILIAS/Test',
'tst',
'new_id');
77 $selected_questions =
ilSession::get(
'tst_import_selected_questions') ?? [];
85 $new_obj->loadFromDb();
87 if (!file_exists($xmlfile)) {
88 $this->
logger->error(__METHOD__ .
': Cannot find xml definition: ' . $xmlfile);
91 if (!file_exists($qtifile)) {
92 $this->
logger->error(__METHOD__ .
': Cannot find xml definition: ' . $qtifile);
106 $qti_parser->startParsing();
107 $new_obj = $qti_parser->getTestObject();
115 $question_page_parser->setQuestionMapping($qti_parser->getImportMapping());
116 $question_page_parser->startParsing();
120 if ($new_obj->isRandomTest()) {
124 if ($results_file_path !==
null && file_exists($results_file_path)) {
131 $new_obj->saveToDb();
141 $a_mapping->
addMapping(
"components/ILIAS/Test",
"tst", (
string) $a_id, (
string) $new_obj->getId());
143 "components/ILIAS/MetaData",
146 $new_obj->getId() .
":0:tst" 151 array $question_id_mapping,
155 foreach ($question_id_mapping as $old_question_id => $new_question_id) {
157 'components/ILIAS/Taxonomy',
159 "tst:quest:{$old_question_id}",
160 (
string) $new_question_id
164 'components/ILIAS/Taxonomy',
166 "tst:quest:{$old_question_id}",
171 'components/ILIAS/Test',
173 (
string) $old_question_id,
174 (
string) $new_question_id
185 foreach ($maps as $old => $new) {
186 if ($old ==
"new_id" || (
int) $old <= 0) {
190 if (isset(self::$finallyProcessedTestsRegistry[$new])) {
195 if ($test_obj->isRandomTest()) {
199 self::$finallyProcessedTestsRegistry[$new] =
true;
205 string $old_tst_obj_id,
206 string $new_tst_obj_id,
210 'components/ILIAS/Taxonomy',
215 if ($new_tax_ids !==
null) {
216 foreach (explode(
':', $new_tax_ids) as $tax_id) {
230 $src_pool_def_list->loadDefinitions();
232 foreach ($src_pool_def_list as $definition) {
233 $mapped_taxonomy_filter = $definition->getMappedTaxonomyFilter();
234 if ($mapped_taxonomy_filter === []) {
238 $definition->setMappedTaxonomyFilter(
241 $mapped_taxonomy_filter
244 $definition->saveToDb();
252 $new_mapped_filter = [];
253 foreach ($mapped_filter as $tax_id => $tax_nodes) {
255 'components/ILIAS/Taxonomy',
260 if ($new_tax_id ===
null) {
264 $new_mapped_filter[$new_tax_id] = [];
266 foreach ($tax_nodes as $tax_node_id) {
268 'components/ILIAS/Taxonomy',
270 (
string) $tax_node_id
273 if ($new_tax_node_id ===
null) {
277 $new_mapped_filter[$new_tax_id][] = $new_tax_node_id;
281 return $new_mapped_filter;
289 $test_obj->questions = [];
291 $parser->setTestOBJ($test_obj);
292 $parser->setImportMapping($a_mapping);
293 $parser->startParsing();
302 $parser->startParsing();
305 $importer->setTargetParentObjId($test_obj->
getId());
306 $importer->setImportInstallationId((
int) $this->
getInstallId());
307 $importer->setImportMappingRegistry($mapping);
308 $importer->setImportMappingComponent(
'components/ILIAS/Test');
309 $importer->setImportAssignmentList($parser->getAssignmentList());
313 if ($importer->getFailedImportAssignmentList()->assignmentsExist()) {
322 return $importer->getSuccessImportAssignmentList();
332 $parser->initSkillLevelThresholdImportList();
333 $parser->startParsing();
336 $importer->setTargetTestId($test_obj->
getTestId());
337 $importer->setImportInstallationId((
int) $this->
getInstallId());
338 $importer->setImportMappingRegistry($mapping);
339 $importer->setImportedQuestionSkillAssignmentList($assignment_list);
340 $importer->setImportThresholdList($parser->getSkillLevelThresholdImportList());
343 if ($importer->getFailedThresholdImportSkillList()->skillsExist()) {
static get(string $a_var)
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
getNewMappedTaxonomyFilter(ilImportMapping $mapping, array $mapped_filter)
registerFailedImports(ilAssQuestionAssignedSkillList $skillList)
getTestId()
Gets the database id of the additional test data.
trait TestQuestionsImportTrait
importRandomQuestionSetConfig(ilObjTest $test_obj, ?string $xml_file, \ilImportMapping $a_mapping)
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
buildImportDirectoriesFromContainerImport(string $importdir)
buildResultsFilePath(string $importdir, string $subdir)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
finalRandomTestTaxonomyProcessing(ilImportMapping $mapping, string $old_tst_obj_id, string $new_tst_obj_id, ilObjTest $test_obj)
readonly ResourceStorage $irss
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...
importQuestionSkillAssignments(ilImportMapping $mapping, ilObjTest $test_obj, ?string $xml_file)
readonly TestLogger $logger
Legacy Content Object Parser.
readonly ilDBInterface $db
setOfflineStatus(bool $status)
addTaxonomyAndQuestionsMapping(array $question_id_mapping, int $new_obj_id, ilImportMapping $mapping)
setTestObject(ilObjTest $tst_object)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
importSkillLevelThresholds(ilImportMapping $mapping, ilAssQuestionSkillAssignmentList $assignment_list, ilObjTest $test_obj, ?string $xml_file)
__construct(Container $dic, ilPlugin $plugin)
finalProcessing(ilImportMapping $a_mapping)
array buildImportDirectoriesFromImportFile(string $file_to_import)
static $finallyProcessedTestsRegistry
static clear(string $a_var)
registerFailedImports(ilAssQuestionSkillAssignmentImportList $assignmentList)
static set(string $a_var, $a_val)
Set a value.