ILIAS  release_8 Revision v8.24
class.ilTestPassFinishTasks.php
Go to the documentation of this file.
1<?php
2
24{
25 protected $testSession;
26
27 protected $obj_id;
28
29 protected $active_id;
30
36 public function __construct($active_id, $obj_id)
37 {
38 $this->testSession = new ilTestSession();
39 $this->testSession->loadFromDb($active_id);
40 $this->obj_id = $obj_id;
41 $this->active_id = $active_id;
42 }
43
44 public function performFinishTasks(ilTestProcessLocker $processLocker)
45 {
47
48 $processLocker->executeTestFinishOperation(function () use ($testSession) {
49 if (!$testSession->isSubmitted()) {
50 $testSession->setSubmitted();
51 $testSession->setSubmittedTimestamp();
52 $testSession->saveToDb();
53 }
54
55 $lastStartedPass = (
56 $testSession->getLastStartedPass() === null ? -1 : $testSession->getLastStartedPass()
57 );
58
59 $lastFinishedPass = (
60 $testSession->getLastFinishedPass() === null ? -1 : $testSession->getLastFinishedPass()
61 );
62
63 if ($lastStartedPass > -1 && $lastFinishedPass < $lastStartedPass) {
64 $testSession->setLastFinishedPass($testSession->getPass());
65 $testSession->increaseTestPass(); // saves to db
66 }
67 });
68
70 }
71
73 {
74 require_once './Modules/Test/classes/class.ilObjTestAccess.php';
75 require_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
77 $this->obj_id,
79 );
80
81 $caller = $this->getCaller();
82 $lp = ilLPStatus::_lookupStatus($this->obj_id, $this->testSession->getUserId());
83 $debug = "finPass={$this->testSession->getLastFinishedPass()} / Lp={$lp}";
84
86 $this->testSession->getUserId(),
87 $this->obj_id,
88 "updateLearningProgressAfterPassFinishedIsWritten has been called from {$caller} ({$debug})",
89 true
90 );
91 }
92
93 protected function getCaller()
94 {
95 try {
96 throw new Exception();
97 } catch (Exception $e) {
98 $trace = $e->getTrace();
99 }
100
101 return $trace[3]['class'];
102 }
103}
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
static _lookupStatus(int $a_obj_id, int $a_user_id, bool $a_create=true)
Lookup status.
static _addLog( $user_id, $object_id, $logtext, $question_id=0, $original_id=0, $test_only=false, $test_ref_id=0)
Add an assessment log entry.
static _getParticipantId($active_id)
Get user id for active id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct($active_id, $obj_id)
ilTestPassFinishTasks constructor.
performFinishTasks(ilTestProcessLocker $processLocker)
executeTestFinishOperation(callable $operation)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20