/** * Checks if the test is executable by the given user * * @param ilTestSession|ilTestSessionDynamicQuestionSet * @param integer $user_id The user id * @return array Result array * @access public */ function isExecutable($testSession, $user_id, $allowPassIncrease = FALSE) { $result = array("executable" => true, "errormessage" => ""); if (!$this->startingTimeReached()) { $result["executable"] = false; $result["errormessage"] = sprintf($this->lng->txt("detail_starting_time_not_reached"), ilFormat::ftimestamp2datetimeDB($this->getStartingTime())); return $result; } if ($this->endingTimeReached()) { $result["executable"] = false; $result["errormessage"] = sprintf($this->lng->txt("detail_ending_time_reached"), ilFormat::ftimestamp2datetimeDB($this->getEndingTime())); return $result; } $active_id = $this->getActiveIdOfUser($user_id); if ($this->getEnableProcessingTime()) { if ($active_id > 0) { $starting_time = $this->getStartingTimeOfUser($active_id); if ($starting_time !== FALSE) { if ($this->isMaxProcessingTimeReached($starting_time, $active_id)) { if ($allowPassIncrease && $this->getResetProcessingTime() && ($this->getNrOfTries() == 0 || $this->getNrOfTries() > $this->_getPass($active_id) + 1)) { // a test pass was quitted because the maximum processing time was reached, but the time // will be resetted for future passes, so if there are more passes allowed, the participant may // start the test again. // This code block is only called when $allowPassIncrease is TRUE which only happens when // the test info page is opened. Otherwise this will lead to unexpected results! $testSession->increasePass(); $testSession->setLastSequence(0); $testSession->saveToDb(); } else { $result["executable"] = false; $result["errormessage"] = $this->lng->txt("detail_max_processing_time_reached"); } return $result; } } } } if ($this->hasNrOfTriesRestriction() && $active_id > 0) { require_once 'Modules/Test/classes/class.ilTestPassesSelector.php'; $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this); $testPassesSelector->setActiveId($active_id); $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass()); $closedPasses = $testPassesSelector->getReportablePasses(); if (count($closedPasses) >= $this->getNrOfTries()) { $result["executable"] = false; $result["errormessage"] = $this->lng->txt("maximum_nr_of_tries_reached"); return $result; } } return $result; }
/** * handle endingTimeReached * @private */ function endingTimeReached() { ilUtil::sendInfo(sprintf($this->lng->txt("detail_ending_time_reached"), ilFormat::ftimestamp2datetimeDB($this->object->getEndingTime()))); $this->testSession->increasePass(); $this->testSession->setLastSequence(0); $this->testSession->saveToDb(); if (!$this->object->canViewResults()) { $this->outIntroductionPage(); } else { $this->ctrl->redirectByClass("ilTestEvaluationGUI", "outUserResultsOverview"); } }