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'); }
/** * Sync images of a MC question on synchronisation with the original question */ protected function syncImages() { global $ilLog; $imagepath = $this->getImagePath(); $question_id = $this->getOriginalId(); $originalObjId = parent::lookupParentObjId($this->getOriginalId()); $imagepath_original = $this->getImagePath($question_id, $originalObjId); ilUtil::delDir($imagepath_original); foreach ($this->answers as $answer) { $filename = $answer->getImage(); if (strlen($filename)) { if (@file_exists($imagepath . $filename)) { if (!file_exists($imagepath)) { ilUtil::makeDirParents($imagepath); } if (!file_exists($imagepath_original)) { ilUtil::makeDirParents($imagepath_original); } if (!@copy($imagepath . $filename, $imagepath_original . $filename)) { $ilLog->write("image could not be duplicated!!!!", $ilLog->ERROR); $ilLog->write("object: " . print_r($this, TRUE), $ilLog->ERROR); } } if (@file_exists($imagepath . $this->getThumbPrefix() . $filename)) { if (!@copy($imagepath . $this->getThumbPrefix() . $filename, $imagepath_original . $this->getThumbPrefix() . $filename)) { $ilLog->write("image thumbnail could not be duplicated!!!!", $ilLog->ERROR); $ilLog->write("object: " . print_r($this, TRUE), $ilLog->ERROR); } } } } }
private function isSyncOriginalPossibleAndAllowed($questionId) { $questionData = $this->questionList->getDataArrayForQuestionId($questionId); if (!$questionData['original_id']) { return false; } require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php'; $parentObjId = assQuestion::lookupParentObjId($questionData['original_id']); if (!$this->doesObjectTypeMatch($parentObjId)) { return false; } foreach (ilObject::_getAllReferences($parentObjId) as $parentRefId) { if ($this->access->checkAccess('write', '', $parentRefId)) { return true; } } return false; }
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'); }