Skip to content

Commit

Permalink
Test: Fix Online Status After Copy
Browse files Browse the repository at this point in the history
  • Loading branch information
kergomard committed Nov 22, 2023
1 parent 5e1b2f2 commit a2fe4ad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
3 changes: 1 addition & 2 deletions components/ILIAS/Test/classes/class.ilObjTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4592,9 +4592,8 @@ public function cloneObject(int $target_id, int $copy_id = 0, bool $omit_tree =
$cp_options = ilCopyWizardOptions::_getInstance($copy_id);
if ($cp_options->isRootNode($this->getRefId())) {
$new_obj->setOfflineStatus(true);
} else {
$new_obj->setOfflineStatus($this->getOfflineStatus());
}

$new_obj->update();

$new_obj->mark_schema = clone $this->mark_schema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1054,39 +1054,45 @@ public function getQplQuestions(): array
*
* @access public
*/
public function cloneObject(int $a_target_id, int $a_copy_id = 0, bool $a_omit_tree = false): ?ilObject
public function cloneObject(int $target_id, int $copy_id = 0, bool $omit_tree = false): ?ilObject
{
$newObj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
$new_obj = parent::cloneObject($target_id, $copy_id, $omit_tree);

$newObj->update();
//copy online status if object is not the root copy object
$cp_options = ilCopyWizardOptions::_getInstance($copy_id);
if ($cp_options->isRootNode($this->getRefId())) {
$new_obj->setOfflineStatus(true);
}

$new_obj->update();

$newObj->setSkillServiceEnabled($this->isSkillServiceEnabled());
$newObj->setShowTaxonomies($this->getShowTaxonomies());
$newObj->saveToDb();
$new_obj->setSkillServiceEnabled($this->isSkillServiceEnabled());
$new_obj->setShowTaxonomies($this->getShowTaxonomies());
$new_obj->saveToDb();

// clone the questions in the question pool
$questions = $this->getQplQuestions();
$questionIdsMap = [];
foreach ($questions as $question_id) {
$newQuestionId = $newObj->copyQuestion($question_id, $newObj->getId());
$newQuestionId = $new_obj->copyQuestion($question_id, $new_obj->getId());
$questionIdsMap[$question_id] = $newQuestionId;
}

$md = new ilMD($this->getId(), 0, $this->getType());
$md->cloneMD($newObj->getId(), 0, $newObj->getType());
$newObj->updateMetaData();
$md->cloneMD($new_obj->getId(), 0, $new_obj->getType());
$new_obj->updateMetaData();

$duplicator = new ilQuestionPoolTaxonomiesDuplicator();
$duplicator->setSourceObjId($this->getId());
$duplicator->setSourceObjType($this->getType());
$duplicator->setTargetObjId($newObj->getId());
$duplicator->setTargetObjType($newObj->getType());
$duplicator->setTargetObjId($new_obj->getId());
$duplicator->setTargetObjType($new_obj->getType());
$duplicator->setQuestionIdMapping($questionIdsMap);
$duplicator->duplicate($duplicator->getAllTaxonomiesForSourceObject());

$newObj->saveToDb();
$new_obj->saveToDb();

return $newObj;
return $new_obj;
}

public function getQuestionTypes($all_tags = false, $fixOrder = false, $withDeprecatedTypes = true): array
Expand Down

0 comments on commit a2fe4ad

Please sign in to comment.