ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
11 protected $testSession;
12
13 protected $obj_id;
14
15 protected $active_id;
16
22 public function __construct($active_id, $obj_id)
23 {
24 $this->testSession = new ilTestSession();
25 $this->testSession->loadFromDb($active_id);
26 $this->obj_id = $obj_id;
27 $this->active_id = $active_id;
28 }
29
30 public function performFinishTasks(ilTestProcessLocker $processLocker)
31 {
33
34 $processLocker->executeTestFinishOperation(function() use ($testSession) {
35
36 if( !$testSession->isSubmitted() )
37 {
38 $testSession->setSubmitted();
39 $testSession->setSubmittedTimestamp();
40 $testSession->saveToDb();
41 }
42
43 $lastStartedPass = (
44 $testSession->getLastStartedPass() === null ? -1 : $testSession->getLastStartedPass()
45 );
46
47 $lastFinishedPass = (
48 $testSession->getLastFinishedPass() === null ? -1 : $testSession->getLastFinishedPass()
49 );
50
51 if( $lastStartedPass > -1 && $lastFinishedPass < $lastStartedPass )
52 {
53 $testSession->setLastFinishedPass($testSession->getPass());
54 $testSession->increaseTestPass(); // saves to db
55 }
56 });
57
59 }
60
62 {
63 require_once './Modules/Test/classes/class.ilObjTestAccess.php';
64 require_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
66 $this->obj_id, ilObjTestAccess::_getParticipantId($this->active_id)
67 );
68
69 $caller = $this->getCaller();
70 $lp = ilLPStatus::_lookupStatus($this->obj_id, $this->testSession->getUserId());
71 $debug = "finPass={$this->testSession->getLastFinishedPass()} / Lp={$lp}";
72
73 ilObjAssessmentFolder::_addLog( $this->testSession->getUserId(), $this->obj_id,
74 "updateLearningProgressAfterPassFinishedIsWritten has been called from {$caller} ({$debug})", 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.