/** * Clone assignments * @param type $a_target_id * @param type $a_copy_id */ public function cloneSettings($a_copy_id, $a_target_id, $a_objective_id) { include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php'; $options = ilCopyWizardOptions::_getInstance($a_copy_id); $mappings = $options->getMappings(); if (!array_key_exists($this->getTestRefId(), $mappings)) { return FALSE; } $copy = new ilLOTestAssignment(); $copy->setContainerId($a_target_id); $copy->setAssignmentType($this->getAssignmentType()); $copy->setObjectiveId($a_objective_id); $copy->setTestRefId($mappings[$this->getTestRefId()]); $copy->create(); }
protected function saveMultiTestAssignment() { $this->ctrl->setParameter($this, 'tt', (int) $_REQUEST['tt']); $this->setTestType((int) $_REQUEST['tt']); $settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId()); include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php'; $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(), $this->getTestType()); $form = $form_helper->initForm(TRUE); if ($form->checkInput()) { $mode = $form->getInput('mode'); if ($mode == self::TEST_NEW) { $tst = new ilObjTest(); $tst->setType('tst'); $tst->setTitle($form->getInput('title')); $tst->setDescription($form->getInput('desc')); $tst->create(); $tst->createReference(); $tst->putInTree($this->getParentObject()->getRefId()); $tst->setPermissions($this->getParentObject()->getRefId()); // apply settings template $this->applySettingsTemplate($tst); $tst->setQuestionSetType($form->getInput('qtype')); $tst->saveToDb(); include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php'; $assignment = new ilLOTestAssignment(); $assignment->setContainerId($this->getParentObject()->getId()); $assignment->setAssignmentType($this->getTestType()); $assignment->setObjectiveId($form->getInput('objective')); $assignment->setTestRefId($tst->getRefId()); $assignment->save(); } else { include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php'; $assignment = new ilLOTestAssignment(); $assignment->setContainerId($this->getParentObject()->getId()); $assignment->setAssignmentType($this->getTestType()); $assignment->setObjectiveId($form->getInput('objective')); $assignment->setTestRefId($form->getInput('tst')); $assignment->save(); $tst = new ilObjTest($form->getInput('tst'), true); $this->applySettingsTemplate($tst); $tst->saveToDb(); } $this->updateStartObjects(); ilUtil::sendSuccess($this->lng->txt('settings_saved')); $this->ctrl->redirect($this, 'testsOverview'); } // Error ilUtil::sendFailure($this->lng->txt('err_check_input')); $form->setValuesByPost(); $this->testAssignment($form); }