コード例 #1
0
 /**
 * Creates a 1:1 copy of the object and places the copy in a given repository
 *
 * @access public
 */
 function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilLog;
     $newObj = parent::cloneObject($a_target_id, $a_copy_id);
     //copy online status if object is not the root copy object
     $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
     if (!$cp_options->isRootNode($this->getRefId())) {
         $newObj->setOnline($this->getOnline());
     }
     $newObj->setShowTaxonomies($this->getShowTaxonomies());
     $newObj->saveToDb();
     // clone the questions in the question pool
     $questions =& $this->getQplQuestions();
     $questionIdsMap = array();
     foreach ($questions as $question_id) {
         $newQuestionId = $newObj->copyQuestion($question_id, $newObj->getId());
         $questionIdsMap[$question_id] = $newQuestionId;
     }
     // clone meta data
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getId(), 0, $this->getType());
     $new_md =& $md->cloneMD($newObj->getId(), 0, $newObj->getType());
     // update the metadata with the new title of the question pool
     $newObj->updateMetaData();
     require_once 'Modules/TestQuestionPool/classes/class.ilQuestionPoolTaxonomiesDuplicator.php';
     $duplicator = new ilQuestionPoolTaxonomiesDuplicator();
     $duplicator->setSourceObjId($this->getId());
     $duplicator->setSourceObjType($this->getType());
     $duplicator->setTargetObjId($newObj->getId());
     $duplicator->setTargetObjType($newObj->getType());
     $duplicator->setQuestionIdMapping($questionIdsMap);
     $duplicator->duplicate();
     $duplicatedTaxKeyMap = $duplicator->getDuplicatedTaxonomiesKeysMap();
     $newObj->setNavTaxonomyId($duplicatedTaxKeyMap->getMappedTaxonomyId($this->getNavTaxonomyId()));
     $newObj->saveToDb();
     return $newObj;
 }
 private function mirrorSourcePoolTaxonomies($sourcePoolId, $questionIdMapping)
 {
     $duplicator = new ilQuestionPoolTaxonomiesDuplicator();
     $duplicator->setSourceObjId($sourcePoolId);
     $duplicator->setSourceObjType('qpl');
     $duplicator->setTargetObjId($this->testOBJ->getId());
     $duplicator->setTargetObjType($this->testOBJ->getType());
     $duplicator->setQuestionIdMapping($questionIdMapping);
     $duplicator->duplicate();
     return $duplicator->getDuplicatedTaxonomiesKeysMap();
 }