19declare(strict_types=1);
64 return is_array($this->passes);
76 SELECT tst_pass_result.* FROM tst_pass_result
77 WHERE tst_pass_result.active_fi = %s
78 ORDER BY tst_pass_result.pass
81 $res = $this->db->queryF(
89 while ($row = $this->db->fetchAssoc(
$res)) {
90 $this->passes[$row[
'pass']] = $row;
102 $query =
'SELECT last_finished_pass FROM tst_active WHERE active_id = %s';
104 $res = $this->db->queryF(
110 while ($row = $this->db->fetchAssoc(
$res)) {
156 $reportable_passes = [];
158 foreach ($existing_passes as $pass) {
160 $reportable_passes[] = $pass;
164 return $reportable_passes;
171 foreach ($existing_passes as $pass) {
173 $closed_passes[] = $pass;
177 return $closed_passes;
184 foreach ($existing_passes as $pass) {
185 if ($last_pass ===
null || $pass > $last_pass) {
195 switch ($this->test_obj->getScoreSettings()->getResultSummarySettings()->getScoreReporting()) {
196 case ScoreReportingTypes::SCORE_REPORTING_IMMIDIATLY:
199 case ScoreReportingTypes::SCORE_REPORTING_DATE:
202 case ScoreReportingTypes::SCORE_REPORTING_FINISHED:
203 if ($attempt < $last_attempt) {
209 case ScoreReportingTypes::SCORE_REPORTING_AFTER_PASSED:
224 throw new ilTestException(
'invalid object state: last finished pass was not set!');
245 $reporting_date = $this->test_obj->getScoreSettings()->getResultSummarySettings()->getReportingDate();
246 return $reporting_date <=
new DateTimeImmutable(
'now',
new DateTimeZone(
'UTC'));
251 if (!$this->test_obj->getEnableProcessingTime()) {
255 $startingTime = $this->test_obj->getStartingTimeOfUser($this->
getActiveId(), $pass);
257 if ($startingTime ===
false) {
261 return $this->test_obj->isMaxProcessingTimeReached($startingTime, $this->
getActiveId());
280 if (!isset($this->test_passed_once_cache[
$active_id])) {
281 $this->test_passed_once_cache[
$active_id] =
false;
283 $res = $this->db->queryF(
284 'SELECT passed_once FROM tst_result_cache WHERE active_fi = %s',
289 while ($row = $this->db->fetchAssoc(
$res)) {
290 $this->test_passed_once_cache[
$active_id] = (bool) $row[
'passed_once'];
294 return $this->test_passed_once_cache[
$active_id];
Base Exception for all Exceptions relating to Modules/Test.
isReportableAttempt(int $last_attempt, int $attempt)
setActiveId(?int $active_id)
fetchReportablePasses(array $existing_passes)
isProcessingTimeReached(int $pass)
hasTestPassedOnce(int $active_id)
setLastFinishedPass(?int $last_finished_pass)
__construct(private ilDBInterface $db, private ilObjTest $test_obj)
checkLastFinishedPassInitialised()
getLastFinishedPassTimestamp()
fetchClosedPasses(array $existing_passes)
array $test_passed_once_cache
fetchLastPass(array $existing_passes)