19 declare(strict_types=1);
44 $local_dic = QuestionPoolDIC::dic();
45 $this->request_data_collector = $local_dic[
'request_data_collector'];
56 if (($new_id = $a_mapping->
getMapping(
'components/ILIAS/Container',
'objs', $a_id)) !==
null) {
58 $new_obj->getObjectProperties()->storePropertyIsOnline($new_obj->getObjectProperties()->getPropertyIsOnline()->withOffline());
60 $selected_questions = [];
64 } elseif (($new_id = $a_mapping->
getMapping(
'components/ILIAS/TestQuestionPool',
'qpl',
'new_id')) !==
null) {
67 $selected_questions =
ilSession::get(
'qpl_import_selected_questions');
74 $DIC[
'ilLog']->write(__METHOD__ .
': non container and no tax mapping, perhaps old qpl export');
78 if (!file_exists($xmlfile)) {
79 $DIC[
'ilLog']->write(__METHOD__ .
': Cannot find xml definition: ' . $xmlfile);
82 if (!file_exists($qtifile)) {
83 $DIC[
'ilLog']->write(__METHOD__ .
': Cannot find qti definition: ' . $qtifile);
87 $this->pool_obj = $new_obj;
89 $new_obj->fromXML($xmlfile);
91 $qpl_new = $this->request_data_collector->string(
'qpl_new');
94 if ($qpl_new !==
'') {
95 $new_obj->setTitle($qpl_new);
105 $DIC[
'ilLog']->write(__METHOD__ .
': xml file: ' . $xmlfile .
', qti file:' . $qtifile);
121 $questionPageParser->setQuestionMapping($qtiParser->getImportMapping());
122 $questionPageParser->startParsing();
124 foreach ($qtiParser->getImportMapping() as $k => $v) {
125 $old_question_id = substr($k, strpos($k,
'qst_') + strlen(
'qst_'));
126 $new_question_id = (string) $v[
'pool'];
129 'components/ILIAS/Taxonomy',
131 "qpl:quest:{$old_question_id}",
136 'components/ILIAS/Taxonomy',
138 "qpl:quest:{$old_question_id}",
139 (
string) $new_obj->getId()
143 'components/ILIAS/TestQuestionPool',
152 $a_mapping->
addMapping(
'components/ILIAS/TestQuestionPool',
'qpl', $a_id, (
string) $new_obj->getId());
154 'components/ILIAS/MetaData',
157 $new_obj->getId() .
':0:qpl' 161 $new_obj->saveToDb();
172 foreach ($maps as $old => $new) {
173 if ($old !==
'new_id' && (
int) $old > 0) {
174 $new_tax_ids = $a_mapping->
getMapping(
'components/ILIAS/Taxonomy',
'tax_usage_of_obj', (
string) $old);
175 if ($new_tax_ids !==
null) {
176 $tax_ids = explode(
':', $new_tax_ids);
177 foreach ($tax_ids as $tid) {
188 $parser->startParsing();
191 $importer->setTargetParentObjId($targetParentObjId);
192 $importer->setImportInstallationId($this->
getInstallId());
193 $importer->setImportMappingRegistry($mappingRegistry);
194 $importer->setImportMappingComponent(
'components/ILIAS/TestQuestionPool');
195 $importer->setImportAssignmentList($parser->getAssignmentList());
199 if ($importer->getFailedImportAssignmentList()->assignmentsExist()) {
201 $qsaImportFails->registerFailedImports($importer->getFailedImportAssignmentList());
203 $this->pool_obj->getObjectProperties()->storePropertyIsOnline($this->pool_obj->getObjectProperties()->getPropertyIsOnline()->withOffline());
Importer class for question pools.
static get(string $a_var)
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
readonly RequestDataCollector $request_data_collector
trait TestQuestionsImportTrait
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
buildImportDirectoriesFromContainerImport(string $importdir)
finalProcessing(ilImportMapping $a_mapping)
Final processing.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getMapping(string $a_comp, string $a_entity, string $a_old_id)
getMappingsOfEntity(string $a_comp, string $a_entity)
Legacy Content Object Parser.
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
__construct(Container $dic, ilPlugin $plugin)
array buildImportDirectoriesFromImportFile(string $file_to_import)
ilObjQuestionPool $pool_obj
importQuestionSkillAssignments($xmlFile, ilImportMapping $mappingRegistry, $targetParentObjId)
static clear(string $a_var)