Esempio n. 1
0
 private function areSkillLevelThresholdsMissing()
 {
     if ($this->object->isDynamicTest()) {
         $questionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
         $questionContainerId = $questionSetConfig->getSourceQuestionPoolId();
     } else {
         $questionContainerId = $this->object->getId();
     }
     global $ilDB;
     require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentList.php';
     require_once 'Modules/Test/classes/class.ilTestSkillLevelThreshold.php';
     $assignmentList = new ilAssQuestionSkillAssignmentList($ilDB);
     $assignmentList->setParentObjId($questionContainerId);
     $assignmentList->loadFromDb();
     foreach ($assignmentList->getUniqueAssignedSkills() as $data) {
         foreach ($data['skill']->getLevelData() as $level) {
             $treshold = new ilTestSkillLevelThreshold($ilDB);
             $treshold->setTestId($this->object->getTestId());
             $treshold->setSkillBaseId($data['skill_base_id']);
             $treshold->setSkillTrefId($data['skill_tref_id']);
             $treshold->setSkillLevelId($level['id']);
             if (!$treshold->dbRecordExists()) {
                 return true;
             }
         }
     }
     return false;
 }
 public function copyQuestionObject()
 {
     global $ilAccess;
     if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
         // allow only write access
         ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
         $this->ctrl->redirect($this, "infoScreen");
     }
     if ($_REQUEST['q_id'] && !is_array($_REQUEST['q_id'])) {
         $ids = array($_REQUEST['q_id']);
     } else {
         if ($_REQUEST['q_id']) {
             $ids = $_REQUEST['q_id'];
         } else {
             ilUtil::sendFailure($this->lng->txt('copy_no_questions_selected'), true);
             $this->ctrl->redirect($this, 'questions');
         }
     }
     $copy_count = 0;
     $questionTitles = $this->object->getQuestionTitles();
     foreach ($ids as $id) {
         include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
         $question = assQuestion::_instanciateQuestionGUI($id);
         if ($question) {
             $title = $question->object->getTitle();
             $i = 2;
             while (in_array($title . ' (' . $i . ')', $questionTitles)) {
                 $i++;
             }
             $title .= ' (' . $i . ')';
             $questionTitles[] = $title;
             $new_id = $question->object->duplicate(false, $title);
             $clone = assQuestion::_instanciateQuestionGUI($new_id);
             $clone->object->setObjId($this->object->getId());
             $clone->object->saveToDb();
             $this->object->insertQuestion($this->testQuestionSetConfigFactory->getQuestionSetConfig(), $new_id, true);
             $copy_count++;
         }
     }
     ilUtil::sendSuccess($this->lng->txt('copy_questions_success'), true);
     $this->ctrl->redirect($this, 'questions');
 }
 private function addMiscSettingsFormSection(ilPropertyFormGUI $form)
 {
     // misc settings
     $header_misc = new ilFormSectionHeaderGUI();
     $header_misc->setTitle($this->lng->txt('misc'));
     $form->addItem($header_misc);
     // result filter taxonomies
     if ($this->testQuestionSetConfigFactory->getQuestionSetConfig()->isResultTaxonomyFilterSupported()) {
         $availableTaxonomyIds = $this->getAvailableTaxonomyIds();
         if (count($availableTaxonomyIds)) {
             require_once 'Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php';
             $labelTranslater = new ilTestTaxonomyFilterLabelTranslater($this->db);
             $labelTranslater->loadLabelsFromTaxonomyIds($availableTaxonomyIds);
             $results_presentation = new ilCheckboxGroupInputGUI($this->lng->txt('tst_results_tax_filters'), 'results_tax_filters');
             foreach ($availableTaxonomyIds as $taxonomyId) {
                 $results_presentation->addOption(new ilCheckboxOption($labelTranslater->getTaxonomyTreeLabel($taxonomyId), $taxonomyId, ''));
             }
             $results_presentation->setValue($this->testOBJ->getResultFilterTaxIds());
             $form->addItem($results_presentation);
         }
     }
     // anonymity
     $anonymity = new ilRadioGroupInputGUI($this->lng->txt('tst_anonymity'), 'anonymity');
     if ($this->testOBJ->participantDataExist()) {
         $anonymity->setDisabled(true);
     }
     $rb = new ilRadioOption($this->lng->txt('tst_anonymity_no_anonymization'), 0);
     $anonymity->addOption($rb);
     $rb = new ilRadioOption($this->lng->txt('tst_anonymity_anonymous_test'), 1);
     $anonymity->addOption($rb);
     $anonymity->setValue((int) $this->testOBJ->getAnonymity());
     $form->addItem($anonymity);
     // enable_archiving
     $enable_archiving = new ilCheckboxInputGUI($this->lng->txt('test_enable_archiving'), 'enable_archiving');
     $enable_archiving->setInfo($this->lng->txt('test_enable_archiving_desc'));
     $enable_archiving->setValue(1);
     $enable_archiving->setChecked($this->testOBJ->getEnableArchiving());
     $form->addItem($enable_archiving);
 }
 /**
  * @param ilPropertyFormGUI $form
  */
 private function saveResultMiscOptionsSettings(ilPropertyFormGUI $form)
 {
     // result filter taxonomies
     if ($this->testQuestionSetConfigFactory->getQuestionSetConfig()->isResultTaxonomyFilterSupported()) {
         if (!$this->isHiddenFormItem('results_tax_filters') && count($this->getAvailableTaxonomyIds())) {
             $this->testOBJ->setResultFilterTaxIds(array_intersect($this->getAvailableTaxonomyIds(), $form->getItemByPostVar('results_tax_filters')->getValue()));
         }
     }
     if ($this->formPropertyExists($form, 'anonymity')) {
         // anonymity setting
         $this->testOBJ->setAnonymity($form->getItemByPostVar('anonymity')->getValue());
     }
     if ($this->formPropertyExists($form, 'enable_archiving')) {
         // Archiving
         if ($this->testOBJ->getAnonymity() == true && $form->getItemByPostVar('enable_archiving')->getChecked() == true) {
             $this->testOBJ->setEnableArchiving(false);
             ilUtil::sendInfo($this->lng->txt('no_archive_on_anonymous'), true);
         } else {
             $this->testOBJ->setEnableArchiving($form->getItemByPostVar('enable_archiving')->getChecked());
         }
     }
 }
Esempio n. 5
0
 /**
  * Clone object
  *
  * @access public
  * @param int ref id of parent container
  * @param int copy id
  * @return object new test object
  */
 public function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilLog, $tree, $ilDB, $ilPluginAdmin;
     $this->loadFromDb();
     // Copy settings
     /** @var $newObj ilObjTest */
     $newObj = parent::cloneObject($a_target_id, $a_copy_id);
     $this->cloneMetaData($newObj);
     $newObj->setAnonymity($this->getAnonymity());
     $newObj->setAnswerFeedback($this->getAnswerFeedback());
     $newObj->setAnswerFeedbackPoints($this->getAnswerFeedbackPoints());
     $newObj->setAuthor($this->getAuthor());
     $newObj->setLimitUsersEnabled($this->isLimitUsersEnabled());
     $newObj->setAllowedUsers($this->getAllowedUsers());
     $newObj->setAllowedUsersTimeGap($this->getAllowedUsersTimeGap());
     $newObj->setCountSystem($this->getCountSystem());
     $newObj->setECTSFX($this->getECTSFX());
     $newObj->setECTSGrades($this->getECTSGrades());
     $newObj->setECTSOutput($this->getECTSOutput());
     $newObj->setEnableProcessingTime($this->getEnableProcessingTime());
     $newObj->setEndingTimeEnabled($this->isEndingTimeEnabled());
     $newObj->setEndingTime($this->getEndingTime());
     $newObj->setFixedParticipants($this->getFixedParticipants());
     $newObj->setInstantFeedbackSolution($this->getInstantFeedbackSolution());
     $newObj->setIntroductionEnabled($this->isIntroductionEnabled());
     $newObj->setIntroduction($this->getIntroduction());
     $newObj->setFinalStatement($this->getFinalStatement());
     $newObj->setShowInfo($this->getShowInfo());
     $newObj->setForceJS($this->getForceJS());
     $newObj->setCustomStyle($this->getCustomStyle());
     $newObj->setKiosk($this->getKiosk());
     $newObj->setShowFinalStatement($this->getShowFinalStatement());
     $newObj->setListOfQuestionsSettings($this->getListOfQuestionsSettings());
     $newObj->setMCScoring($this->getMCScoring());
     $newObj->setMailNotification($this->getMailNotification());
     $newObj->setMailNotificationType($this->getMailNotificationType());
     $newObj->setNrOfTries($this->getNrOfTries());
     $newObj->setPassScoring($this->getPassScoring());
     $newObj->setPasswordEnabled($this->isPasswordEnabled());
     $newObj->setPassword($this->getPassword());
     $newObj->setProcessingTime($this->getProcessingTime());
     $newObj->setQuestionSetType($this->getQuestionSetType());
     $newObj->setReportingDate($this->getReportingDate());
     $newObj->setResetProcessingTime($this->getResetProcessingTime());
     $newObj->setResultsPresentation($this->getResultsPresentation());
     $newObj->setScoreCutting($this->getScoreCutting());
     $newObj->setScoreReporting($this->getScoreReporting());
     $newObj->setSequenceSettings($this->getSequenceSettings());
     $newObj->setShowCancel($this->getShowCancel());
     $newObj->setShowMarker($this->getShowMarker());
     $newObj->setShuffleQuestions($this->getShuffleQuestions());
     $newObj->setStartingTimeEnabled($this->isStartingTimeEnabled());
     $newObj->setStartingTime($this->getStartingTime());
     $newObj->setTitleOutput($this->getTitleOutput());
     $newObj->setUsePreviousAnswers($this->getUsePreviousAnswers());
     $newObj->setRedirectionMode($this->getRedirectionMode());
     $newObj->setRedirectionUrl($this->getRedirectionUrl());
     $newObj->setCertificateVisibility($this->getCertificateVisibility());
     $newObj->mark_schema = clone $this->mark_schema;
     $newObj->setEnabledViewMode($this->getEnabledViewMode());
     $newObj->setTemplate($this->getTemplate());
     $newObj->setPoolUsage($this->getPoolUsage());
     $newObj->setPrintBestSolutionWithResult($this->isBestSolutionPrintedWithResult());
     $newObj->setShowExamIdInTestPassEnabled($this->isShowExamIdInTestPassEnabled());
     $newObj->setShowExamIdInTestResultsEnabled($this->isShowExamIdInTestResultsEnabled());
     $newObj->setEnableExamView($this->getEnableExamview());
     $newObj->setShowExamViewHtml($this->getShowExamviewHtml());
     $newObj->setShowExamViewPdf($this->getShowExamviewPdf());
     $newObj->setEnableArchiving($this->getEnableArchiving());
     $newObj->setSignSubmission($this->getSignSubmission());
     $newObj->setCharSelectorAvailability((int) $this->getCharSelectorAvailability());
     $newObj->setCharSelectorDefinition($this->getCharSelectorDefinition());
     $newObj->setSkillServiceEnabled($this->isSkillServiceEnabled());
     $newObj->setResultFilterTaxIds($this->getResultFilterTaxIds());
     $newObj->setInstantFeedbackAnswerFixationEnabled($this->isInstantFeedbackAnswerFixationEnabled());
     $newObj->saveToDb();
     // clone certificate
     include_once "./Services/Certificate/classes/class.ilCertificate.php";
     include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
     $cert = new ilCertificate(new ilTestCertificateAdapter($this));
     $newcert = new ilCertificate(new ilTestCertificateAdapter($newObj));
     $cert->cloneCertificate($newcert);
     require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
     $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $this);
     $testQuestionSetConfigFactory->getQuestionSetConfig()->cloneQuestionSetRelatedData($newObj);
     require_once 'Modules/Test/classes/class.ilTestSkillLevelThresholdList.php';
     $skillLevelThresholdList = new ilTestSkillLevelThresholdList($ilDB);
     $skillLevelThresholdList->setTestId($this->getTestId());
     $skillLevelThresholdList->loadFromDb();
     $skillLevelThresholdList->cloneListForTest($newObj->getTestId());
     $newObj->saveToDb();
     $newObj->updateMetaData();
     // #14467
     return $newObj;
 }
Esempio n. 6
0
 /**
  * save question
  */
 function saveReturn()
 {
     global $ilUser;
     $old_id = $_GET["q_id"];
     $result = $this->writePostData();
     if ($result == 0) {
         $ilUser->setPref("tst_lastquestiontype", $this->object->getQuestionType());
         $ilUser->writePref("tst_lastquestiontype", $this->object->getQuestionType());
         $this->object->saveToDb();
         $originalexists = $this->object->_questionExistsInPool($this->object->original_id);
         include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
         if (($_GET["calling_test"] || isset($_GET['calling_consumer']) && (int) $_GET['calling_consumer']) && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId())) {
             ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
             $this->ctrl->redirect($this, "originalSyncForm");
             return;
         } elseif ($_GET["calling_test"]) {
             require_once 'Modules/Test/classes/class.ilObjTest.php';
             $test = new ilObjTest($_GET["calling_test"]);
             #var_dump(assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId()));
             $q_id = $this->object->getId();
             if (!assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId())) {
                 global $tree, $ilDB, $ilPluginAdmin;
                 include_once "./Modules/Test/classes/class.ilObjTest.php";
                 $_GET["ref_id"] = $_GET["calling_test"];
                 $test = new ilObjTest($_GET["calling_test"], true);
                 require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
                 $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $test);
                 $new_id = $test->insertQuestion($testQuestionSetConfigFactory->getQuestionSetConfig(), $this->object->getId());
                 $q_id = $new_id;
                 if (isset($_REQUEST['prev_qid'])) {
                     $test->moveQuestionAfter($this->object->getId() + 1, $_REQUEST['prev_qid']);
                 }
                 $this->ctrl->setParameter($this, 'q_id', $new_id);
                 $this->ctrl->setParameter($this, 'calling_test', $_GET['calling_test']);
                 #$this->ctrl->setParameter($this, 'test_ref_id', false);
             }
             ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
             if ($_REQUEST['test_express_mode']) {
                 ilUtil::redirect(ilTestExpressPage::getReturnToPageLink($q_id));
             } else {
                 ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=" . $_GET["calling_test"]);
             }
         } else {
             if ($this->object->getId() != $old_id) {
                 $this->callNewIdListeners($this->object->getId());
                 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
                 $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
             }
             if (strcmp($_SESSION["info"], "") != 0) {
                 ilUtil::sendSuccess($_SESSION["info"] . "<br />" . $this->lng->txt("msg_obj_modified"), true);
             } else {
                 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
             }
             $this->ctrl->redirectByClass("ilobjquestionpoolgui", "questions");
         }
     }
 }
 private function saveFormCmd($isConfirmedSave = false)
 {
     $form = $this->buildForm();
     // form validation and initialisation
     $errors = !$form->checkInput();
     // ALWAYS CALL BEFORE setValuesByPost()
     $form->setValuesByPost();
     // NEVER CALL THIS BEFORE checkInput()
     // Sarcasm? No. Because checkInput checks the form graph against the POST without
     // actually setting the values into the form. Sounds ridiculous? Indeed, and it is.
     // return to form when any form validation errors exist
     if ($errors) {
         ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
         return $this->showFormCmd($form);
     }
     // return to form when online is to be set, but no questions are configured
     $currentQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
     if ($form->getItemByPostVar('online')->getChecked() && !$this->testOBJ->isComplete($currentQuestionSetConfig)) {
         $form->getItemByPostVar('online')->setAlert($this->lng->txt("cannot_switch_to_online_no_questions_andor_no_mark_steps"));
         ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
         return $this->showFormCmd($form);
     }
     // solve conflicts with question set type setting with confirmation screen if required
     // determine wether question set type relating data is to be removed (questions/pools)
     $questionSetTypeRelatingDataCleanupRequired = false;
     if ($form->getItemByPostVar('question_set_type') instanceof ilFormPropertyGUI) {
         $oldQuestionSetType = $this->testOBJ->getQuestionSetType();
         $newQuestionSetType = $form->getItemByPostVar('question_set_type')->getValue();
         if (!$this->testOBJ->participantDataExist() && $newQuestionSetType != $oldQuestionSetType) {
             $oldQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfigByType($oldQuestionSetType);
             if ($oldQuestionSetConfig->doesQuestionSetRelatedDataExist()) {
                 if (!$isConfirmedSave) {
                     if ($oldQuestionSetType == ilObjTest::QUESTION_SET_TYPE_FIXED) {
                         return $this->showConfirmation($form, $oldQuestionSetType, $newQuestionSetType, $this->testOBJ->hasQuestionsWithoutQuestionpool());
                     }
                     return $this->showConfirmation($form, $oldQuestionSetType, $newQuestionSetType, false);
                 }
                 $questionSetTypeRelatingDataCleanupRequired = true;
             }
             if ($form->getItemByPostVar('online')->getChecked()) {
                 $form->getItemByPostVar('online')->setChecked(false);
                 if ($this->testOBJ->isOnline()) {
                     $infoMsg = $this->lng->txt("tst_set_offline_due_to_switched_question_set_type_setting");
                 } else {
                     $infoMsg = $this->lng->txt("tst_cannot_online_due_to_switched_quest_set_type_setting");
                 }
                 ilUtil::sendInfo($infoMsg, true);
             }
         }
     }
     // adjust use previous answers setting due to desired question set type
     if ($newQuestionSetType != ilObjTest::QUESTION_SET_TYPE_FIXED) {
         $form->getItemByPostVar('chb_use_previous_answers')->setValue(0);
     }
     // perform saving the form data
     $this->performSaveForm($form);
     // clean up test mode relating configuration data (questions/questionpools)
     if ($questionSetTypeRelatingDataCleanupRequired) {
         $oldQuestionSetConfig->removeQuestionSetRelatedData();
     }
     // disinvite all invited users if required
     if (!$this->testOBJ->participantDataExist() && !$this->testOBJ->getFixedParticipants()) {
         foreach ($this->testOBJ->getInvitedUsers() as $usrId => $usrData) {
             $this->testOBJ->disinviteUser($usrId);
         }
     }
     // redirect to form output
     ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
     $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
 }
 function insertQuestions()
 {
     $selected_array = is_array($_POST['q_id']) ? $_POST['q_id'] : array();
     if (!count($selected_array)) {
         ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"), true);
         $this->ctrl->redirect($this, "browseForQuestions");
     } else {
         include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
         $manscoring = FALSE;
         global $tree, $ilDB, $ilPluginAdmin;
         require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
         $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $this->test_object);
         $testQuestionSetConfig = $testQuestionSetConfigFactory->getQuestionSetConfig();
         foreach ($selected_array as $key => $value) {
             $last_question_id = $this->test_object->insertQuestion($testQuestionSetConfig, $value);
             if (!$manscoring) {
                 $manscoring = $manscoring | assQuestion::_needsManualScoring($value);
             }
         }
         $this->test_object->saveCompleteStatus($testQuestionSetConfig);
         if ($manscoring) {
             ilUtil::sendInfo($this->lng->txt("manscoring_hint"), TRUE);
         } else {
             ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), TRUE);
         }
         $this->ctrl->setParameter($this, 'q_id', $last_question_id);
         $this->ctrl->redirect($this, "showPage");
         return;
     }
 }
 /**
  * @return ilTestQuestionSetConfig
  */
 private function buildTestQuestionSetConfig()
 {
     require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
     $testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($this->tree, $this->db, $this->pluginAdmin, $this->testOBJ);
     return $testQuestionSetConfigFactory->getQuestionSetConfig();
 }
 private function getQuestionContainerId()
 {
     if ($this->testOBJ->isDynamicTest()) {
         $questionSetConfigFactory = new ilTestQuestionSetConfigFactory($this->tree, $this->db, $this->pluginAdmin, $this->testOBJ);
         $questionSetConfig = $questionSetConfigFactory->getQuestionSetConfig();
         return $questionSetConfig->getSourceQuestionPoolId();
     }
     return $this->testOBJ->getId();
 }