public function removeTestResultsByUserIds($userIds) { global $ilDB, $lng; require_once 'Modules/Test/classes/class.ilTestParticipantData.php'; $participantData = new ilTestParticipantData($ilDB, $lng); $participantData->setUserIds($userIds); $participantData->load($this->getTestId()); $IN_userIds = $ilDB->in('usr_id', $participantData->getUserIds(), false, 'integer'); $ilDB->manipulateF("DELETE FROM usr_pref WHERE {$IN_userIds} AND keyword = %s", array('text'), array("tst_password_" . $this->getTestId())); if (count($participantData->getActiveIds())) { $this->removeTestResultsByActiveIds($participantData->getActiveIds()); } }
/** * Deletes the selected user data for the test object * * Deletes the selected user data for the test object * * @access public */ function confirmDeleteSelectedUserDataObject() { global $ilDB, $lng; require_once 'Modules/Test/classes/class.ilTestParticipantData.php'; $participantData = new ilTestParticipantData($ilDB, $lng); if ($this->object->getFixedParticipants()) { $participantData->setUserIds($_POST["chbUser"]); } else { $participantData->setActiveIds($_POST["chbUser"]); } $participantData->load($this->object->getTestId()); /* @var ilTestLP $testLP */ require_once 'Services/Object/classes/class.ilObjectLP.php'; $testLP = ilObjectLP::getInstance($this->object->getId()); $testLP->resetLPDataForUserIds($participantData->getUserIds(), false); $this->object->removeTestActives($participantData->getActiveIds()); #$this->object->removeSelectedTestResults($active_ids); // Update lp status #include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php'; #ilLPStatusWrapper::_refreshStatus($this->object->getId()); ilUtil::sendSuccess($this->lng->txt("tst_selected_user_data_deleted"), true); $this->ctrl->redirect($this, "participants"); }
/** * Returns (request cached) information if a specific user has finished at least one test pass * * @param integer $user_id obj_id of the user * @param integer $a_obj_id obj_id of the test * @return bool */ public static function hasFinished($a_user_id, $a_obj_id) { if (!isset(self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"])) { require_once 'Modules/Test/classes/class.ilTestParticipantData.php'; require_once 'Modules/Test/classes/class.ilTestSessionFactory.php'; require_once 'Modules/Test/classes/class.ilTestPassesSelector.php'; global $ilDB, $lng; $testOBJ = ilObjectFactory::getInstanceByObjId($a_obj_id); $partData = new ilTestParticipantData($ilDB, $lng); $partData->setUserIds(array($a_user_id)); $partData->load($testOBJ->getTestId()); $activeId = $partData->getActiveIdByUserId($a_user_id); $testSessionFactory = new ilTestSessionFactory($testOBJ); $testSession = $testSessionFactory->getSession($activeId); $testPassesSelector = new ilTestPassesSelector($ilDB, $testOBJ); $testPassesSelector->setActiveId($activeId); $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass()); self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"] = count($testPassesSelector->getClosedPasses()); } return self::$hasFinishedCache["{$a_user_id}:{$a_obj_id}"]; }
/** * Deletes the selected user data for the test object * * Deletes the selected user data for the test object * * @access public */ function confirmDeleteSelectedUserDataObject() { global $ilDB, $lng; require_once 'Modules/Test/classes/class.ilTestParticipantData.php'; $participantData = new ilTestParticipantData($ilDB, $lng); if ($this->object->getFixedParticipants()) { $participantData->setUserIds($_POST["chbUser"]); } else { $participantData->setActiveIds($_POST["chbUser"]); } $participantData->load($this->object->getTestId()); $this->object->removeTestResults($participantData); ilUtil::sendSuccess($this->lng->txt("tst_selected_user_data_deleted"), true); $this->ctrl->redirect($this, "participants"); }
/** * Output of the pass overview for a test called by a test participant * * @param ilTestSession|ilTestSessionDynamicQuestionSet $testSession * @param integer $active_id * @param integer $pass * @param boolean $show_pass_details * @param boolean $show_answers * @param boolean $show_question_only * @param boolean $show_reached_points * @access public */ function getResultsOfUserOutput($testSession, $active_id, $pass, $targetGUI, $show_pass_details = TRUE, $show_answers = TRUE, $show_question_only = FALSE, $show_reached_points = FALSE) { global $ilObjDataCache; include_once "./Services/UICore/classes/class.ilTemplate.php"; $template = new ilTemplate("tpl.il_as_tst_results_participant.html", TRUE, TRUE, "Modules/Test"); if ($this->participantData instanceof ilTestParticipantData) { $user_id = $this->participantData->getUserIdByActiveId($active_id); $uname = $this->participantData->getConcatedFullnameByActiveId($active_id, false); } else { $user_id = $this->object->_getUserIdFromActiveId($active_id); $uname = $this->object->userLookupFullName($user_id, TRUE); } if (array_key_exists("pass", $_GET) && strlen($_GET["pass"]) > 0 || !is_null($pass)) { if (is_null($pass)) { $pass = $_GET["pass"]; } } $user_data = $this->getResultsUserdata($testSession, $active_id, TRUE); if (!is_null($pass)) { require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php'; $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache); $objectivesList = null; if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) { $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($active_id, $pass); $testSequence->loadFromDb(); $testSequence->loadQuestions(); require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php'; $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession); $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence); $objectivesList->loadObjectivesTitles(); $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId()); $testResultHeaderLabelBuilder->setUserId($testSession->getUserId()); $testResultHeaderLabelBuilder->setTestObjId($this->object->getId()); $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId()); $testResultHeaderLabelBuilder->initObjectiveOrientedMode(); } $result_array = $this->object->getTestResult($active_id, $pass, false, !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()); $command_solution_details = ""; if ($show_pass_details) { $detailsoverview = $this->getPassDetailsOverview($result_array, $active_id, $pass, $targetGUI, "getResultsOfUserOutput", $command_solution_details, $show_answers, $objectivesList); } $user_id = $this->object->_getUserIdFromActiveId($active_id); $showAllAnswers = TRUE; if ($this->object->isExecutable($testSession, $user_id)) { $showAllAnswers = FALSE; } if ($show_answers) { $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, $_SESSION['tst_results_show_best_solutions'], $showAllAnswers, $show_question_only, $show_reached_points, $show_pass_details, $objectivesList, $testResultHeaderLabelBuilder); } $template->setVariable("LIST_OF_ANSWERS", $list_of_answers); //$template->setVariable("PASS_RESULTS_OVERVIEW", sprintf($this->lng->txt("tst_results_overview_pass"), $pass + 1)); $template->setVariable("PASS_DETAILS", $detailsoverview); $signature = $this->getResultsSignature(); $template->setVariable("SIGNATURE", $signature); if ($this->object->isShowExamIdInTestResultsEnabled()) { $template->setCurrentBlock('exam_id_footer'); $template->setVariable('EXAM_ID_VAL', $this->object->lookupExamId($testSession->getActiveId(), $pass)); $template->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id')); $template->parseCurrentBlock(); } } $template->setCurrentBlock('participant_back_anchor'); $template->setVariable("HREF_PARTICIPANT_BACK_ANCHOR", "#tst_results_toolbar"); $template->setVariable("TXT_PARTICIPANT_BACK_ANCHOR", $this->lng->txt('tst_back_to_top')); $template->parseCurrentBlock(); $template->setCurrentBlock('participant_block_id'); $template->setVariable("PARTICIPANT_BLOCK_ID", "participant_active_{$active_id}"); $template->parseCurrentBlock(); if ($this->isGradingMessageRequired()) { $template->setCurrentBlock('grading_message'); $template->setVariable('GRADING_MESSAGE', $this->getGradingMessage($active_id)); $template->parseCurrentBlock(); } $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname)); $template->setVariable("USER_DATA", $testResultHeaderLabelBuilder->getPassDetailsHeaderLabel($pass + 1)); return $template->get(); }