/** * init user result */ protected function initUserResult(ilTestSession $session) { // check if current test is start object and fullfilled // if yes => do not increase tries. $is_qualified_run = false; if ($this->isQualifiedStartRun($session)) { $is_qualified_run = true; } foreach ($this->run as $run) { include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php'; include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php'; $old_result = ilLOUserResults::lookupResult($this->container_id, $this->user_id, $run->getObjectiveId(), $this->getSettings()->getQualifiedTest() == $session->getRefId() ? ilLOUserResults::TYPE_QUALIFIED : ilLOUserResults::TYPE_INITIAL); include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php'; $limit = ilLOUtils::lookupObjectiveRequiredPercentage($this->container_id, $run->getObjectiveId(), $this->getSettings()->getQualifiedTest() == $session->getRefId() ? ilLOSettings::TYPE_TEST_QUALIFIED : ilLOSettings::TYPE_TEST_INITIAL, $run->getMaxPoints()); $max_attempts = ilLOUtils::lookupMaxAttempts($this->container_id, $run->getObjectiveId()); if ($max_attempts) { // check if current test is start object and fullfilled // if yes => do not increase tries. $GLOBALS['ilLog']->write(__METHOD__ . ': check for qualified...'); if (!$is_qualified_run) { $GLOBALS['ilLog']->write(__METHOD__ . ': and increase attempts'); ++$old_result['tries']; } $old_result['is_final'] = $old_result['tries'] >= $max_attempts; } $ur = new ilLOUserResults($this->container_id, $this->user_id); $ur->saveObjectiveResult($run->getObjectiveId(), $this->getSettings()->getQualifiedTest() == $session->getRefId() ? ilLOUserResults::TYPE_QUALIFIED : ilLOUserResults::TYPE_INITIAL, $old_result['status'], $old_result['result_perc'], $limit, $old_result['tries'], $old_result['is_final']); } }