19 declare(strict_types=1);
36 private int $owner_id,
37 private int $target_container_ref
53 $non_available_pool->
getId()
64 $this->component_repository
66 $question_list->setTestObjId($this->test_obj->getId());
67 $question_list->setTestId($this->test_obj->getTestId());
68 $question_list->setPoolId($non_available_pool->
getId());
69 $question_list->loadQuestions();
72 foreach ($question_list->getQuestions() as $question_id) {
82 $pool = $this->pool_factory->createNewInstance($this->target_container_ref);
84 if ($non_available_pool->
getTitle() !==
'') {
85 $pool->setTitle($non_available_pool->
getTitle());
96 $pool_qid_by_test_qid_map = [];
97 foreach ($questions as $question_obj) {
98 $pool_qid_by_test_qid_map[$question_obj->getId()] = $question_obj
99 ->duplicate(
false,
'',
'', $this->owner_id, $pool->
getId());
102 return $pool_qid_by_test_qid_map;
106 array $pool_qid_by_test_qid_map
108 foreach ($pool_qid_by_test_qid_map as $test_qid => $pool_qid) {
116 array $related_question_ids
118 $filtered_tax_ids = [];
119 foreach ($taxonomy_ids as $taxonomy_id) {
121 $this->test_obj->getType(),
122 $this->test_obj->getId(),
127 foreach ($related_question_ids as $question_id) {
128 if ($tax_node_assignment->getAssignmentsOfItem($question_id) !== []) {
129 $filtered_tax_ids[] = $taxonomy_id;
135 return $filtered_tax_ids;
139 array $pool_qid_by_test_qid_map,
143 $tax_duplicator->setSourceObjId($this->test_obj->getId());
144 $tax_duplicator->setSourceObjType($this->test_obj->getType());
145 $tax_duplicator->setTargetObjId($pool->
getId());
146 $tax_duplicator->setTargetObjType($pool->
getType());
147 $tax_duplicator->setQuestionIdMapping($pool_qid_by_test_qid_map);
150 $tax_duplicator->getAllTaxonomiesForSourceObject(),
151 array_keys($pool_qid_by_test_qid_map)
154 return $tax_duplicator->getDuplicatedTaxonomiesKeysMap();
159 array $mapped_taxonomy_filter
161 $original_taxonomy_filter = [];
162 foreach ($mapped_taxonomy_filter as $test_taxonomy_id => $test_tax_nodes) {
164 if ($pool_taxonomy_id ===
null) {
167 $original_taxonomy_filter[$pool_taxonomy_id] = [];
169 foreach ($test_tax_nodes as $test_tax_node) {
171 if ($mapped_tax_node_id !==
null) {
172 $original_taxonomy_filter[$pool_taxonomy_id][] = $mapped_tax_node_id;
177 return $original_taxonomy_filter;
182 int $derived_pool_id,
183 int $non_available_pool_id
185 foreach ($this->source_pool_definition_list as $definition) {
186 if ($definition->getPoolId() !== $non_available_pool_id) {
190 $definition->setPoolId($derived_pool_id);
191 $definition->setOriginalTaxonomyFilter(
194 $definition->getMappedTaxonomyFilter()
198 $definition->saveToDb();
derive(ilTestRandomQuestionSetNonAvailablePool $non_available_pool)
Readable part of repository interface to ilComponentDataDB.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
updateTestQuestionStage(array $pool_qid_by_test_qid_map)
duplicateTaxonomies(array $pool_qid_by_test_qid_map, ilObjQuestionPool $pool)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static resetOriginalId(int $questionId)
copyQuestionsToPool(ilObjQuestionPool $pool, array $questions)
static instantiateQuestion(int $question_id)
__construct(private readonly ilDBInterface $db, private readonly ilComponentRepository $component_repository, private readonly ilObjTest $test_obj, private readonly ilTestRandomQuestionSetSourcePoolDefinitionList $source_pool_definition_list, private int $owner_id, private int $target_container_ref)
getQuestionsForPool(ilTestRandomQuestionSetNonAvailablePool $non_available_pool)
filterForQuestionRelatedTaxonomies(array $taxonomy_ids, array $related_question_ids)
static saveOriginalId(int $questionId, int $originalId)
getMappedTaxonomyId(int $original_taxonomy_id)
updateRelatedSourcePoolDefinitions(ilQuestionPoolDuplicatedTaxonomiesKeysMap $tax_keys_map, int $derived_pool_id, int $non_available_pool_id)
buildOriginalTaxonomyFilterForDerivedPool(ilQuestionPoolDuplicatedTaxonomiesKeysMap $tax_keys_map, array $mapped_taxonomy_filter)
ilQuestionPoolFactory $pool_factory
getMappedTaxNodeId(int $original_tax_node_id)
createNewPool(ilTestRandomQuestionSetNonAvailablePool $non_available_pool)