Exemplo n.º 1
0
 /**
  * Save the form input of the scoring form
  *
  * @access	public
  */
 function saveScoringObject()
 {
     $hasErrors = $this->scoringObject(true);
     if (!$hasErrors) {
         $total = $this->object->evalTotalPersons();
         $this->object->setCountSystem($_POST["count_system"]);
         $this->object->setMCScoring($_POST["mc_scoring"]);
         $this->object->setScoreCutting($_POST["score_cutting"]);
         $this->object->setPassScoring($_POST["pass_scoring"]);
         if (isset($_POST['obligations_enabled']) && $_POST['obligations_enabled']) {
             $this->object->setObligationsEnabled(true);
         } else {
             $this->object->setObligationsEnabled(false);
         }
         if (isset($_POST['offer_hints']) && $_POST['offer_hints']) {
             $this->object->setOfferingQuestionHintsEnabled(true);
         } else {
             $this->object->setOfferingQuestionHintsEnabled(false);
         }
         /*
         			$this->object->setAnswerFeedback((is_array($_POST['instant_feedback']) && in_array('instant_feedback_answer', $_POST['instant_feedback'])) ? 1 : 0);
         			$this->object->setAnswerFeedbackPoints((is_array($_POST['instant_feedback']) && in_array('instant_feedback_points', $_POST['instant_feedback'])) ? 1 : 0);
         			$this->object->setInstantFeedbackSolution((is_array($_POST['instant_feedback']) && in_array('instant_feedback_solution', $_POST['instant_feedback'])) ? 1 : 0);
         */
         /**
          * I introduced a single setter for instant_feedback options
          * @author jposselt at databay . de
          */
         $this->object->setScoringFeedbackOptionsByArray($_POST['instant_feedback']);
         $this->object->setScoreReporting($_POST["results_access"]);
         if ($this->object->getScoreReporting() == REPORT_AFTER_DATE) {
             $this->object->setReportingDate(str_replace(array(':', '-'), '', $_POST["reporting_date"]['date'] . $_POST["reporting_date"]['time']));
         } else {
             $this->object->setReportingDate('');
         }
         $this->object->setShowPassDetails(is_array($_POST['results_presentation']) && in_array('pass_details', $_POST['results_presentation']) ? 1 : 0);
         $this->object->setShowSolutionDetails(is_array($_POST['results_presentation']) && in_array('solution_details', $_POST['results_presentation']) ? 1 : 0);
         $this->object->setShowSolutionPrintview(is_array($_POST['results_presentation']) && in_array('solution_printview', $_POST['results_presentation']) ? 1 : 0);
         $this->object->setShowSolutionFeedback(is_array($_POST['results_presentation']) && in_array('solution_feedback', $_POST['results_presentation']) ? 1 : 0);
         $this->object->setShowSolutionAnswersOnly(is_array($_POST['results_presentation']) && in_array('solution_answers_only', $_POST['results_presentation']) ? 1 : 0);
         $this->object->setShowSolutionSignature(is_array($_POST['results_presentation']) && in_array('solution_signature', $_POST['results_presentation']) ? 1 : 0);
         $this->object->setShowSolutionSuggested(is_array($_POST['results_presentation']) && in_array('solution_suggested', $_POST['results_presentation']) ? 1 : 0);
         $this->object->setShowSolutionListComparison(is_array($_POST['results_presentation']) && in_array('solution_compare', $_POST['results_presentation']) ? 1 : 0);
         $this->object->setExportSettingsSingleChoiceShort(is_array($_POST['export_settings']) && in_array('exp_sc_short', $_POST['export_settings']) ? 1 : 0);
         $this->object->setPrintBestSolutionWithResult((int) $_POST['print_bs_with_res'] ? true : false);
         $this->object->setPassDeletionAllowed((bool) $_POST['pass_deletion_allowed']);
         $this->object->saveToDb(true);
         ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), TRUE);
         if ($total != 0) {
             $this->object->recalculateScores();
         }
         $this->ctrl->redirect($this, "scoring");
     }
 }
 /**
  * @param ilPropertyFormGUI $form
  */
 private function saveResultDetailsSettings(ilPropertyFormGUI $form)
 {
     if ($this->formPropertyExists($form, 'solution_details')) {
         if ($form->getItemByPostVar('solution_details')->getChecked()) {
             $this->testOBJ->setShowSolutionDetails(1);
             $this->testOBJ->setPrintBestSolutionWithResult((int) $form->getItemByPostVar('print_bs_with_res')->getChecked());
         } else {
             $this->testOBJ->setShowSolutionDetails(0);
             $this->testOBJ->setPrintBestSolutionWithResult(0);
         }
     }
     if ($this->formPropertyExists($form, 'solution_feedback')) {
         $this->testOBJ->setShowSolutionFeedback($form->getItemByPostVar('solution_feedback')->getChecked());
     }
     if ($this->formPropertyExists($form, 'solution_suggested')) {
         $this->testOBJ->setShowSolutionSuggested($form->getItemByPostVar('solution_suggested')->getChecked());
     }
     if ($this->formPropertyExists($form, 'solution_printview')) {
         if ($form->getItemByPostVar('solution_printview')->getChecked()) {
             $this->testOBJ->setShowSolutionPrintview(1);
             $this->testOBJ->setShowSolutionListComparison((bool) $form->getItemByPostVar('solution_compare')->getChecked());
             $this->testOBJ->setShowSolutionAnswersOnly((int) $form->getItemByPostVar('solution_answers_only')->getChecked());
         } else {
             $this->testOBJ->setShowSolutionPrintview(0);
             $this->testOBJ->setShowSolutionListComparison(false);
             $this->testOBJ->setShowSolutionAnswersOnly(0);
         }
     }
     if ($this->formPropertyExists($form, 'highscore_enabled')) {
         // highscore settings
         $this->testOBJ->setHighscoreEnabled((bool) $form->getItemByPostVar('highscore_enabled')->getChecked());
         $this->testOBJ->setHighscoreAnon((bool) $form->getItemByPostVar('highscore_anon')->getChecked());
         $this->testOBJ->setHighscoreAchievedTS((bool) $form->getItemByPostVar('highscore_achieved_ts')->getChecked());
         $this->testOBJ->setHighscoreScore((bool) $form->getItemByPostVar('highscore_score')->getChecked());
         $this->testOBJ->setHighscorePercentage((bool) $form->getItemByPostVar('highscore_percentage')->getChecked());
         $this->testOBJ->setHighscoreHints((bool) $form->getItemByPostVar('highscore_hints')->getChecked());
         $this->testOBJ->setHighscoreWTime((bool) $form->getItemByPostVar('highscore_wtime')->getChecked());
         $this->testOBJ->setHighscoreMode((int) $form->getItemByPostVar('highscore_mode')->getValue());
         $this->testOBJ->setHighscoreTopNum((int) $form->getItemByPostVar('highscore_top_num')->getValue());
     }
     if ($this->formPropertyExists($form, 'solution_signature')) {
         $this->testOBJ->setShowSolutionSignature($form->getItemByPostVar('solution_signature')->getChecked());
     }
     if ($this->formPropertyExists($form, 'examid_in_test_res')) {
         $this->testOBJ->setShowExamIdInTestResultsEnabled($form->getItemByPostVar('examid_in_test_res')->getChecked());
     }
     if ($this->formPropertyExists($form, 'exp_sc_short')) {
         $this->testOBJ->setExportSettingsSingleChoiceShort((int) $form->getItemByPostVar('exp_sc_short')->getChecked());
     }
 }
 private function performSaveForm(ilPropertyFormGUI $form)
 {
     if ($this->areScoringSettingsWritable()) {
         if (!$this->isHiddenFormItem('count_system')) {
             $this->testOBJ->setCountSystem($form->getItemByPostVar('count_system')->getValue());
         }
         if (!$this->isHiddenFormItem('mc_scoring')) {
             $this->testOBJ->setMCScoring($form->getItemByPostVar('mc_scoring')->getValue());
         }
         if (!$this->isHiddenFormItem('score_cutting')) {
             $this->testOBJ->setScoreCutting($form->getItemByPostVar('score_cutting')->getValue());
         }
         if (!$this->isHiddenFormItem('pass_scoring')) {
             $this->testOBJ->setPassScoring($form->getItemByPostVar('pass_scoring')->getValue());
         }
     }
     if (!$this->isHiddenFormItem('results_access_enabled')) {
         if ($form->getItemByPostVar('results_access_enabled')->getChecked()) {
             $this->testOBJ->setScoreReporting($form->getItemByPostVar('results_access_setting')->getValue());
             if ($this->testOBJ->getScoreReporting() == REPORT_AFTER_DATE) {
                 $this->testOBJ->setReportingDate($form->getItemByPostVar('reporting_date')->getDate()->get(IL_CAL_FKT_DATE, 'YmdHis'));
             } else {
                 $this->testOBJ->setReportingDate('');
             }
             $this->testOBJ->setShowPassDetails($form->getItemByPostVar('pass_details')->getChecked());
         } else {
             $this->testOBJ->setScoreReporting(4);
             // never
             $this->testOBJ->setShowPassDetails(false);
             $this->testOBJ->setReportingDate('');
         }
     }
     if (!$this->isHiddenFormItem('show_result_grading')) {
         $this->testOBJ->setShowGradingStatusEnabled($form->getItemByPostVar('grading_status')->getChecked());
         $this->testOBJ->setShowGradingMarkEnabled((int) $form->getItemByPostVar('grading_mark')->getChecked());
     }
     if (!$this->isHiddenFormItem('solution_details')) {
         if ($form->getItemByPostVar('solution_details')->getChecked()) {
             $this->testOBJ->setShowSolutionDetails(1);
             $this->testOBJ->setPrintBestSolutionWithResult((int) $form->getItemByPostVar('print_bs_with_res')->getChecked());
         } else {
             $this->testOBJ->setShowSolutionDetails(0);
             $this->testOBJ->setPrintBestSolutionWithResult(0);
         }
     }
     if (!$this->isHiddenFormItem('solution_printview')) {
         if ($form->getItemByPostVar('solution_printview')->getChecked()) {
             $this->testOBJ->setShowSolutionPrintview(1);
             $this->testOBJ->setShowSolutionListComparison((bool) $form->getItemByPostVar('solution_compare')->getChecked());
             $this->testOBJ->setShowSolutionAnswersOnly((int) $form->getItemByPostVar('solution_answers_only')->getChecked());
         } else {
             $this->testOBJ->setShowSolutionPrintview(0);
             $this->testOBJ->setShowSolutionListComparison(false);
             $this->testOBJ->setShowSolutionAnswersOnly(0);
         }
     }
     if (!$this->isHiddenFormItem('solution_feedback')) {
         $this->testOBJ->setShowSolutionFeedback($form->getItemByPostVar('solution_feedback')->getChecked());
     }
     if (!$this->isHiddenFormItem('solution_signature')) {
         $this->testOBJ->setShowSolutionSignature($form->getItemByPostVar('solution_signature')->getChecked());
     }
     if (!$this->isHiddenFormItem('examid_in_test_res')) {
         $this->testOBJ->setShowExamIdInTestResultsEnabled($form->getItemByPostVar('examid_in_test_res')->getChecked());
     }
     if (!$this->isHiddenFormItem('solution_suggested')) {
         $this->testOBJ->setShowSolutionSuggested($form->getItemByPostVar('solution_suggested')->getChecked());
     }
     if (!$this->isHiddenFormItem('exp_sc_short')) {
         $this->testOBJ->setExportSettingsSingleChoiceShort((int) $form->getItemByPostVar('exp_sc_short')->getChecked());
     }
     if (!$this->isHiddenFormItem('pass_deletion_allowed')) {
         $this->testOBJ->setPassDeletionAllowed((bool) $form->getItemByPostVar('pass_deletion_allowed')->getValue());
     }
     // 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->isHiddenFormItem('anonymity')) {
         // anonymity setting
         $this->testOBJ->setAnonymity($form->getItemByPostVar('anonymity')->getValue());
     }
     if (!$this->isHiddenFormItem('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());
         }
     }
     if (!$this->isHiddenFormItem('highscore_enabled')) {
         // highscore settings
         $this->testOBJ->setHighscoreEnabled((bool) $form->getItemByPostVar('highscore_enabled')->getChecked());
         $this->testOBJ->setHighscoreAnon((bool) $form->getItemByPostVar('highscore_anon')->getChecked());
         $this->testOBJ->setHighscoreAchievedTS((bool) $form->getItemByPostVar('highscore_achieved_ts')->getChecked());
         $this->testOBJ->setHighscoreScore((bool) $form->getItemByPostVar('highscore_score')->getChecked());
         $this->testOBJ->setHighscorePercentage((bool) $form->getItemByPostVar('highscore_percentage')->getChecked());
         $this->testOBJ->setHighscoreHints((bool) $form->getItemByPostVar('highscore_hints')->getChecked());
         $this->testOBJ->setHighscoreWTime((bool) $form->getItemByPostVar('highscore_wtime')->getChecked());
         $this->testOBJ->setHighscoreMode((int) $form->getItemByPostVar('highscore_mode')->getValue());
         $this->testOBJ->setHighscoreTopNum((int) $form->getItemByPostVar('highscore_top_num')->getValue());
     }
     // store settings to db
     $this->testOBJ->saveToDb(true);
 }