/** * removes all question set config related data for cloned/copied test * * @param ilObjTest $cloneTestOBJ */ public function cloneQuestionSetRelatedData($cloneTestOBJ) { global $ilLog; require_once 'Services/CopyWizard/classes/class.ilCopyWizardOptions.php'; require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php'; $cwo = ilCopyWizardOptions::_getInstance($cloneTestOBJ->getId()); foreach ($this->questions as $key => $question_id) { $question = assQuestion::_instanciateQuestion($question_id); $cloneTestOBJ->questions[$key] = $question->duplicate(true, null, null, null, $cloneTestOBJ->getId()); $original_id = assQuestion::_getOriginalId($question_id); $question = assQuestion::_instanciateQuestion($cloneTestOBJ->questions[$key]); $question->saveToDb($original_id); // Save the mapping of old question id <-> new question id // This will be used in class.ilObjCourse::cloneDependencies to copy learning objectives $originalKey = $this->testOBJ->getRefId() . '_' . $question_id; $mappedKey = $cloneTestOBJ->getRefId() . '_' . $cloneTestOBJ->questions[$key]; $cwo->appendMapping($originalKey, $mappedKey); $ilLog->write(__METHOD__ . ": Added mapping {$originalKey} <-> {$mappedKey}"); } }
/** * Copies an assImagemapQuestion object * * Copies an assImagemapQuestion object * * @access public */ function copyObject($target_questionpool_id, $title = "") { if ($this->id <= 0) { // The question has not been saved. It cannot be duplicated return; } // duplicate the question in database $clone = $this; include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $original_id = assQuestion::_getOriginalId($this->id); $clone->id = -1; $source_questionpool_id = $this->getObjId(); $clone->setObjId($target_questionpool_id); if ($title) { $clone->setTitle($title); } $clone->saveToDb(); // copy question page content $clone->copyPageOfQuestion($original_id); // copy XHTML media objects $clone->copyXHTMLMediaObjectsOfQuestion($original_id); // duplicate the image $clone->copyImage($original_id, $source_questionpool_id); $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId()); return $clone->id; }
/** * Logs an action into the Test&Assessment log * * @param string $logtext The log text * @param integer $question_id If given, saves the question id to the database * @access public */ function logAction($logtext = "", $question_id = "") { global $ilUser; $original_id = ""; if (strcmp($question_id, "") != 0) { include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $original_id = assQuestion::_getOriginalId($question_id); } include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php"; ilObjAssessmentFolder::_addLog($ilUser->getId(), $this->getId(), $logtext, $question_id, $original_id, TRUE, $this->getRefId()); }
/** * Copies an assClozeTest object * * @access public */ function copyObject($target_questionpool, $title = "") { if ($this->getId() <= 0) { // The question has not been saved. It cannot be duplicated return; } $clone = $this; include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $original_id = assQuestion::_getOriginalId($this->getId()); $clone->id = -1; $source_questionpool = $this->getObjId(); $clone->setObjId($target_questionpool); if ($title) { $clone->setTitle($title); } $clone->saveToDb(); // copy question page content $clone->copyPageOfQuestion($original_id); // copy XHTML media objects $clone->copyXHTMLMediaObjectsOfQuestion($original_id); // duplicate the generic feedback $clone->duplicateGenericFeedback($original_id); // duplicate specific feedback $clone->duplicateSpecificFeedback($original_id); $clone->onCopy($this->getObjId(), $this->getId()); return $clone->getId(); }
public function copyAndLinkToQuestionpoolObject() { global $lng; require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php'; // #13761; All methods use for this request should be revised, thx japo ;-) if ('copyAndLinkToQuestionpool' == $this->ctrl->getCmd() && (!isset($_REQUEST['q_id']) || !is_array($_REQUEST['q_id']))) { ilUtil::sendFailure($this->lng->txt('tst_no_question_selected_for_moving_to_qpl'), true); $this->ctrl->redirect($this, 'questions'); } if (isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id'])) { foreach ($_REQUEST['q_id'] as $q_id) { if (!assQuestion::originalQuestionExists($q_id)) { continue; } $type = ilObject::_lookupType(assQuestion::lookupParentObjId(assQuestion::_getOriginalId($q_id))); if ($type !== 'tst') { ilUtil::sendFailure($lng->txt('tst_link_only_unassigned'), true); $this->ctrl->redirect($this, 'questions'); return; } } } $this->createQuestionpoolTargetObject('copyAndLinkQuestionsToPool'); }
/** * Copies an assAccountingQuestion object * * @access public */ function copyObject($target_questionpool_id, $title = "") { if ($this->getId() <= 0) { // The question has not been saved. It cannot be duplicated return; } // make a real clone to keep the object unchanged // therefore no local variables are needed for the original ids // but parts will still point to the original ones $clone = clone $this; include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $original_id = assQuestion::_getOriginalId($this->getId()); $source_questionpool_id = $this->getObjId(); $clone->setId(-1); $clone->setObjId($target_questionpool_id); if ($title) { $clone->setTitle($title); } // save the clone data $clone->saveToDb('', false); // clone all parts // must be done after saving when new id is set $clone->cloneParts($this); // copy question page content $clone->copyPageOfQuestion($original_id); // copy XHTML media objects $clone->copyXHTMLMediaObjectsOfQuestion($original_id); // call the event handler for copy $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId()); return $clone->getId(); }
/** * Logs an action into the Test&Assessment log * * @param string $logtext The log text * @param integer $question_id If given, saves the question id to the database * @access public */ function _logAction($logtext = "", $active_id = "", $question_id = "") { global $ilUser; $original_id = ""; if (strcmp($question_id, "") != 0) { include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $original_id = assQuestion::_getOriginalId($question_id); } include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php"; include_once "./Modules/Test/classes/class.ilObjTest.php"; ilObjAssessmentFolder::_addLog($ilUser->id, ilObjTest::_getObjectIDFromActiveID($active_id), $logtext, $question_id, $original_id); }
public function copyAndLinkToQuestionpoolObject() { global $lng; require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php'; foreach ($_REQUEST['q_id'] as $q_id) { if (!assQuestion::originalQuestionExists($q_id)) { continue; } $type = ilObject::_lookupType(assQuestion::lookupParentObjId(assQuestion::_getOriginalId($q_id))); if ($type !== 'tst') { ilUtil::sendFailure($lng->txt('tst_link_only_unassigned'), true); $this->backObject(); return; } } $this->createQuestionpoolTargetObject('copyAndLinkQuestionsToPool'); }
/** * Copies an assClozeTest object * * @access public */ function copyObject($target_questionpool_id, $title = "") { if ($this->getId() <= 0) { // The question has not been saved. It cannot be duplicated return; } $thisId = $this->getId(); $thisObjId = $this->getObjId(); $clone = $this; include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $original_id = assQuestion::_getOriginalId($this->getId()); $clone->id = -1; $clone->setObjId($target_questionpool_id); if ($title) { $clone->setTitle($title); } if ($this->gap_combinations_exists) { $this->copyGapCombination($original_id, $clone->getId()); } $clone->saveToDb(); // copy question page content $clone->copyPageOfQuestion($original_id); // copy XHTML media objects $clone->copyXHTMLMediaObjectsOfQuestion($original_id); $clone->onCopy($thisObjId, $thisId, $clone->getObjId(), $clone->getId()); return $clone->getId(); }