ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTestPassFinishTasks.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22use ILIAS\Test\Results\Data\Repository as TestResultRepository;
23
29{
30 public function __construct(
31 private readonly ilTestSession $test_session,
32 private readonly ilObjTest $obj_test,
33 private readonly TestResultRepository $test_pass_result_repository
34 ) {
35 }
36
37 public function performFinishTasks(ilTestProcessLocker $process_locker, StatusOfAttempt $status_of_attempt)
38 {
39 $process_locker->executeTestFinishOperation(function () use ($status_of_attempt) {
40 $pass = $this->test_session->getPass();
41
42 if (!$this->test_session->isSubmitted()) {
43 $this->test_session->setSubmitted();
44 $this->test_session->setSubmittedTimestamp();
45 $this->test_session->saveToDb();
46 }
47
48 $last_started_pass = (
49 $this->test_session->getLastStartedPass() === null ? -1 : $this->test_session->getLastStartedPass()
50 );
51
52 $last_finished_pass = (
53 $this->test_session->getLastFinishedPass() === null ? -1 : $this->test_session->getLastFinishedPass()
54 );
55
56 if ($last_started_pass > -1 && $last_finished_pass < $last_started_pass) {
57 $this->test_session->setLastFinishedPass($this->test_session->getPass());
58 $this->test_session->increaseTestPass(); // saves to db
59 }
60
61 $this->test_pass_result_repository->finalizeTestAttemptResult(
62 $this->test_session->getActiveId(),
63 $pass,
64 $status_of_attempt
65 );
66 });
67
68 $this->test_pass_result_repository->updateTestResultCache($this->test_session->getActiveId(), null);
69
71 }
72
74 {
76 $this->obj_test->getId(),
77 ilObjTestAccess::_getParticipantId($this->test_session->getActiveId())
78 );
79 }
80}
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
static _getParticipantId(int $active_id)
Get user id for active id.
Class ilTestPassFinishTasks.
performFinishTasks(ilTestProcessLocker $process_locker, StatusOfAttempt $status_of_attempt)
__construct(private readonly ilTestSession $test_session, private readonly ilObjTest $obj_test, private readonly TestResultRepository $test_pass_result_repository)
executeTestFinishOperation(callable $operation)
Test session handler.
if(!file_exists('../ilias.ini.php'))