ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTestPassFinishTasks.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
3require_once 'Modules/Test/classes/class.ilTestSession.php';
9{
10 protected $testSession;
11
12 protected $obj_id;
13
14 protected $active_id;
15
21 public function __construct($active_id, $obj_id)
22 {
23 $this->testSession = new ilTestSession();
24 $this->testSession->loadFromDb($active_id);
25 $this->obj_id = $obj_id;
26 $this->active_id = $active_id;
27 }
28
29 public function performFinishTasks(ilTestProcessLocker $processLocker)
30 {
32
33 $processLocker->executeTestFinishOperation(function () use ($testSession) {
34 if (!$testSession->isSubmitted()) {
35 $testSession->setSubmitted();
36 $testSession->setSubmittedTimestamp();
37 $testSession->saveToDb();
38 }
39
40 $lastStartedPass = (
41 $testSession->getLastStartedPass() === null ? -1 : $testSession->getLastStartedPass()
42 );
43
44 $lastFinishedPass = (
45 $testSession->getLastFinishedPass() === null ? -1 : $testSession->getLastFinishedPass()
46 );
47
48 if ($lastStartedPass > -1 && $lastFinishedPass < $lastStartedPass) {
49 $testSession->setLastFinishedPass($testSession->getPass());
50 $testSession->increaseTestPass(); // saves to db
51 }
52 });
53
55 }
56
58 {
59 require_once './Modules/Test/classes/class.ilObjTestAccess.php';
60 require_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
62 $this->obj_id,
64 );
65
66 $caller = $this->getCaller();
67 $lp = ilLPStatus::_lookupStatus($this->obj_id, $this->testSession->getUserId());
68 $debug = "finPass={$this->testSession->getLastFinishedPass()} / Lp={$lp}";
69
71 $this->testSession->getUserId(),
72 $this->obj_id,
73 "updateLearningProgressAfterPassFinishedIsWritten has been called from {$caller} ({$debug})",
74 true
75 );
76 }
77
78 protected function getCaller()
79 {
80 try {
81 throw new Exception();
82 } catch (Exception $e) {
83 $trace = $e->getTrace();
84 }
85
86 return $trace[3]['class'];
87 }
88}
An exception for terminatinating execution or to throw for unit testing.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
static _addLog($user_id, $object_id, $logtext, $question_id="", $original_id="", $test_only=false, $test_ref_id=null)
Add an assessment log entry.
static _getParticipantId($active_id)
Get user id for active id.
Class ilTestPassFinishTasks.
__construct($active_id, $obj_id)
ilTestPassFinishTasks constructor.
performFinishTasks(ilTestProcessLocker $processLocker)
executeTestFinishOperation(callable $operation)
Test session handler.
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12