public function recalculateScores($preserve_manscoring = false) { require_once 'class.ilTestScoring.php'; $scoring = new ilTestScoring($this); $scoring->setPreserveManualScores($preserve_manscoring); $scoring->recalculateSolutions(); if ($this->getEnableArchiving()) { require_once 'Modules/Test/classes/class.ilTestArchiveService.php'; $archiveService = new ilTestArchiveService($this); $archiveService->archivePassesByActives($scoring->getRecalculatedPassesByActives()); } }
protected function saveQuestion() { $question_id = $_POST['q_id']; $question_pool_id = $_POST['qpl_id']; $form = $this->buildAdjustQuestionForm($question_id, $question_pool_id); $form->setValuesByPost($_POST); if (!$form->checkInput()) { ilUtil::sendFailure($this->lng->txt('adjust_question_form_error')); $this->outputAdjustQuestionForm($form); return; } require_once './Modules/TestQuestionPool/classes/class.assQuestion.php'; /** @var $question assQuestionGUI|ilGuiQuestionScoringAdjustable */ $question = assQuestion::instantiateQuestionGUI($question_id); if ($question instanceof ilGuiQuestionScoringAdjustable) { $question->writeQuestionSpecificPostData($form); } if ($question->object instanceof ilObjQuestionScoringAdjustable) { $question->object->saveAdditionalQuestionDataToDb(); } if ($question instanceof ilGuiAnswerScoringAdjustable) { $question->writeAnswerSpecificPostData($form); } if ($question->object instanceof ilObjAnswerScoringAdjustable) { $question->object->saveAnswerSpecificDataToDb(); } $question->object->setPoints($question->object->getMaximumPoints()); $question->object->saveQuestionDataToDb(); require_once './Modules/Test/classes/class.ilTestScoring.php'; $scoring = new ilTestScoring($this->object); $scoring->setPreserveManualScores($_POST['preserve_manscoring'] == 1 ? true : false); $scoring->recalculateSolutions(); ilUtil::sendSuccess($this->lng->txt('saved_adjustment')); $this->questionsObject(); }
private function saveManScoringParticipantScreen($redirect = true) { global $tpl, $ilCtrl, $lng; $activeId = $this->fetchActiveIdParameter(); $pass = $this->fetchPassParameter($activeId); $questionGuiList = $this->service->getManScoringQuestionGuiList($activeId, $pass); $form = $this->buildManScoringParticipantForm($questionGuiList, $activeId, $pass, false); $form->setValuesByPost(); if (!$form->checkInput()) { ilUtil::sendFailure(sprintf($lng->txt('tst_save_manscoring_failed'), $pass + 1)); return $this->showManScoringParticipantScreen($form); } include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $maxPointsByQuestionId = array(); $maxPointsExceeded = false; foreach ($questionGuiList as $questionId => $questionGui) { $reachedPoints = $form->getItemByPostVar("question__{$questionId}__points")->getValue(); $maxPoints = assQuestion::_getMaximumPoints($questionId); if ($reachedPoints > $maxPoints) { $maxPointsExceeded = true; $form->getItemByPostVar("question__{$questionId}__points")->setAlert(sprintf($lng->txt('tst_manscoring_maxpoints_exceeded_input_alert'), $maxPoints)); } $maxPointsByQuestionId[$questionId] = $maxPoints; } if ($maxPointsExceeded) { ilUtil::sendFailure(sprintf($lng->txt('tst_save_manscoring_failed'), $pass + 1)); return $this->showManScoringParticipantScreen($form); } include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php"; foreach ($questionGuiList as $questionId => $questionGui) { $reachedPoints = $form->getItemByPostVar("question__{$questionId}__points")->getValue(); assQuestion::_setReachedPoints($activeId, $questionId, $reachedPoints, $maxPointsByQuestionId[$questionId], $pass, 1, $this->object->areObligationsEnabled()); $feedback = ilUtil::stripSlashes($form->getItemByPostVar("question__{$questionId}__feedback")->getValue(), false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment")); $this->object->saveManualFeedback($activeId, $questionId, $pass, $feedback); $notificationData[$questionId] = array('points' => $reachedPoints, 'feedback' => $feedback); } include_once "./Modules/Test/classes/class.ilObjTestAccess.php"; include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php"; ilLPStatusWrapper::_updateStatus($this->object->getId(), ilObjTestAccess::_getParticipantId($activeId)); $manScoringDone = $form->getItemByPostVar("manscoring_done")->getChecked(); ilTestService::setManScoringDone($activeId, $manScoringDone); $manScoringNotify = $form->getItemByPostVar("manscoring_notify")->getChecked(); if ($manScoringNotify) { require_once 'Modules/Test/classes/notifications/class.ilTestManScoringParticipantNotification.php'; $notification = new ilTestManScoringParticipantNotification($this->object->_getUserIdFromActiveId($activeId), $this->object->getRefId()); $notification->setAdditionalInformation(array('test_title' => $this->object->getTitle(), 'test_pass' => $pass + 1, 'questions_gui_list' => $questionGuiList, 'questions_scoring_data' => $notificationData)); $notification->send(); } require_once './Modules/Test/classes/class.ilTestScoring.php'; $scorer = new ilTestScoring($this->object); $scorer->setPreserveManualScores(true); $scorer->recalculateSolutions(); if ($this->object->getAnonymity() == 0) { $user_name = ilObjUser::_lookupName(ilObjTestAccess::_getParticipantId($activeId)); $name_real_or_anon = $user_name['firstname'] . ' ' . $user_name['lastname']; } else { $name_real_or_anon = $lng->txt('anonymous'); } ilUtil::sendSuccess(sprintf($lng->txt('tst_saved_manscoring_successfully'), $pass + 1, $name_real_or_anon), true); if ($redirect == true) { $ilCtrl->redirect($this, 'showManScoringParticipantScreen'); } else { return; } }
public function recalculateScores($preserve_manscoring = false) { require_once 'class.ilTestScoring.php'; $scoring = new ilTestScoring($this); $scoring->setPreserveManualScores($preserve_manscoring); $scoring->recalculateSolutions(); }
public function saveManScoringByQuestion() { /** * @var $ilAccess ilAccessHandler */ global $ilAccess, $lng; if (!$ilAccess->checkAccess('write', '', $this->ref_id)) { ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true); $this->ctrl->redirectByClass('ilobjtestgui', 'infoScreen'); } if (!isset($_POST['scoring']) || !is_array($_POST['scoring'])) { ilUtil::sendFailure($this->lng->txt('tst_save_manscoring_failed_unknown')); $this->showManScoringByQuestionParticipantsTable(); return; } include_once 'Modules/TestQuestionPool/classes/class.assQuestion.php'; include_once 'Modules/Test/classes/class.ilObjTestAccess.php'; include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php'; $oneExceededMaxPoints = false; $manPointsPost = array(); $skipParticipant = array(); $maxPointsByQuestionId = array(); foreach ($_POST['scoring'] as $pass => $active_ids) { foreach ((array) $active_ids as $active_id => $questions) { // check for existing test result data if (!$this->object->getTestResult($active_id, $pass)) { if (!isset($skipParticipant[$pass])) { $skipParticipant[$pass] = array(); } $skipParticipant[$pass][$active_id] = true; continue; } foreach ((array) $questions as $qst_id => $reached_points) { if (!isset($manPointsPost[$pass])) { $manPointsPost[$pass] = array(); } if (!isset($manPointsPost[$pass][$active_id])) { $manPointsPost[$pass][$active_id] = array(); } $maxPointsByQuestionId[$qst_id] = assQuestion::_getMaximumPoints($qst_id); if ($reached_points > $maxPointsByQuestionId[$qst_id]) { $oneExceededMaxPoints = true; } $manPointsPost[$pass][$active_id][$qst_id] = $reached_points; } } } if ($oneExceededMaxPoints) { ilUtil::sendFailure(sprintf($this->lng->txt('tst_save_manscoring_failed'), $pass + 1)); $this->showManScoringByQuestionParticipantsTable($manPointsPost); return; } $changed_one = false; foreach ($_POST['scoring'] as $pass => $active_ids) { foreach ((array) $active_ids as $active_id => $questions) { $update_participant = false; if ($skipParticipant[$pass][$active_id]) { continue; } foreach ((array) $questions as $qst_id => $reached_points) { $update_participant = assQuestion::_setReachedPoints($active_id, $qst_id, $reached_points, $maxPointsByQuestionId[$qst_id], $pass, 1, $this->object->areObligationsEnabled()); } if ($update_participant) { $changed_one = true; ilLPStatusWrapper::_updateStatus($this->object->getId(), ilObjTestAccess::_getParticipantId($active_id)); } } } if ($changed_one) { if ($this->object->getAnonymity() == 0) { $user_name = $user_name = ilObjUser::_lookupName(ilObjTestAccess::_getParticipantId($active_id)); $name_real_or_anon = $user_name['firstname'] . ' ' . $user_name['lastname']; } else { $name_real_or_anon = $lng->txt('anonymous'); } ilUtil::sendSuccess(sprintf($this->lng->txt('tst_saved_manscoring_successfully'), $pass + 1, $name_real_or_anon), true); require_once './Modules/Test/classes/class.ilTestScoring.php'; $scorer = new ilTestScoring($this->object); $scorer->setPreserveManualScores(true); $scorer->recalculateSolutions(); if ($this->object->getEnableArchiving()) { require_once 'Modules/Test/classes/class.ilTestArchiveService.php'; $archiveService = new ilTestArchiveService($this->object); $archiveService->archivePassesByActives($scorer->getRecalculatedPassesByActives()); } } $this->showManScoringByQuestionParticipantsTable(); }