19 declare(strict_types=1);
64 return is_array($this->passes);
76 SELECT DISTINCT tst_pass_result.* FROM tst_pass_result 77 LEFT JOIN tst_test_result 78 ON tst_pass_result.pass = tst_test_result.pass 79 AND tst_pass_result.active_fi = tst_test_result.active_fi 80 WHERE tst_pass_result.active_fi = %s 81 ORDER BY tst_pass_result.pass 84 $res = $this->db->queryF(
92 while ($row = $this->db->fetchAssoc(
$res)) {
93 $this->passes[$row[
'pass']] = $row;
105 $query =
'SELECT last_finished_pass FROM tst_active WHERE active_id = %s';
107 $res = $this->db->queryF(
113 while ($row = $this->db->fetchAssoc(
$res)) {
159 $reportable_passes = [];
161 foreach ($existing_passes as $pass) {
163 $reportable_passes[] = $pass;
167 return $reportable_passes;
174 foreach ($existing_passes as $pass) {
176 $closed_passes[] = $pass;
180 return $closed_passes;
187 foreach ($existing_passes as $pass) {
188 if ($last_pass ===
null || $pass > $last_pass) {
198 switch ($this->test_obj->getScoreSettings()->getResultSummarySettings()->getScoreReporting()) {
199 case ScoreReportingTypes::SCORE_REPORTING_IMMIDIATLY:
202 case ScoreReportingTypes::SCORE_REPORTING_DATE:
205 case ScoreReportingTypes::SCORE_REPORTING_FINISHED:
206 if ($attempt < $last_attempt) {
212 case ScoreReportingTypes::SCORE_REPORTING_AFTER_PASSED:
227 throw new ilTestException(
'invalid object state: last finished pass was not set!');
248 $reporting_date = $this->test_obj->getScoreSettings()->getResultSummarySettings()->getReportingDate();
254 if (!$this->test_obj->getEnableProcessingTime()) {
258 $startingTime = $this->test_obj->getStartingTimeOfUser($this->
getActiveId(), $pass);
260 if ($startingTime ===
false) {
264 return $this->test_obj->isMaxProcessingTimeReached($startingTime, $this->
getActiveId());
270 if ($last_finished_pass ===
null || $last_finished_pass === -1) {
275 if (!isset($passes[$last_finished_pass])) {
283 if (!isset($this->test_passed_once_cache[$active_id])) {
284 $this->test_passed_once_cache[
$active_id] =
false;
286 $res = $this->db->queryF(
287 'SELECT passed_once FROM tst_result_cache WHERE active_fi = %s',
292 while ($row = $this->db->fetchAssoc(
$res)) {
293 $this->test_passed_once_cache[
$active_id] = (bool) $row[
'passed_once'];
297 return $this->test_passed_once_cache[
$active_id];
fetchClosedPasses(array $existing_passes)
hasTestPassedOnce(int $active_id)
__construct(private ilDBInterface $db, private ilObjTest $test_obj)
checkLastFinishedPassInitialised()
Base Exception for all Exceptions relating to Modules/Test.
fetchLastPass(array $existing_passes)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
isReportableAttempt(int $last_attempt, int $attempt)
setActiveId(?int $active_id)
getLastFinishedPassTimestamp()
setLastFinishedPass(?int $last_finished_pass)
isProcessingTimeReached(int $pass)
fetchReportablePasses(array $existing_passes)
array $test_passed_once_cache