ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilTestSessionFactory Class Reference
+ Collaboration diagram for ilTestSessionFactory:

Public Member Functions

 __construct (ilObjTest $testOBJ)
 constructor More...
 
 reset ()
 temporarily bugfix for resetting the state of this singleton smeyer --> BH: not required anymore More...
 
 getSession ($activeId=null)
 Creates and returns an instance of a test sequence that corresponds to the current test mode. More...
 
 getSessionByUserId ($userId)
 

Private Member Functions

 getNewTestSessionObject ()
 
 buildCacheKey ($userId)
 

Private Attributes

 $testSession = array()
 
 $testOBJ = null
 

Detailed Description

Definition at line 10 of file class.ilTestSessionFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestSessionFactory::__construct ( ilObjTest  $testOBJ)

constructor

Parameters
ilObjTest$testOBJ

Definition at line 29 of file class.ilTestSessionFactory.php.

30 {
31 $this->testOBJ = $testOBJ;
32 }

References $testOBJ.

Member Function Documentation

◆ buildCacheKey()

ilTestSessionFactory::buildCacheKey (   $userId)
private
Parameters
$userId
Returns
string

Definition at line 130 of file class.ilTestSessionFactory.php.

131 {
132 return "{$this->testOBJ->getTestId()}::{$userId}";
133 }

Referenced by getSessionByUserId().

+ Here is the caller graph for this function:

◆ getNewTestSessionObject()

ilTestSessionFactory::getNewTestSessionObject ( )
private
Returns
ilTestSession|ilTestSessionDynamicQuestionSet

Definition at line 106 of file class.ilTestSessionFactory.php.

107 {
108 switch ($this->testOBJ->getQuestionSetType()) {
111
112 require_once 'Modules/Test/classes/class.ilTestSession.php';
114 break;
115
117
118 require_once 'Modules/Test/classes/class.ilTestSessionDynamicQuestionSet.php';
120 break;
121 }
122
123 return $testSession;
124 }
const QUESTION_SET_TYPE_DYNAMIC
type setting value for dynamic question set (continues testing mode)
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
const QUESTION_SET_TYPE_FIXED
type setting value for fixed question set
Test session handler.

References $testSession, ilObjTest\QUESTION_SET_TYPE_DYNAMIC, ilObjTest\QUESTION_SET_TYPE_FIXED, and ilObjTest\QUESTION_SET_TYPE_RANDOM.

Referenced by getSession(), and getSessionByUserId().

+ Here is the caller graph for this function:

◆ getSession()

ilTestSessionFactory::getSession (   $activeId = null)

Creates and returns an instance of a test sequence that corresponds to the current test mode.

Parameters
integer$activeId
Returns
ilTestSession|ilTestSessionDynamicQuestionSet

Definition at line 54 of file class.ilTestSessionFactory.php.

55 {
56 if ($activeId === null || $this->testSession[$activeId] === null) {
58
59 $testSession->setRefId($this->testOBJ->getRefId());
60 $testSession->setTestId($this->testOBJ->getTestId());
61
62 if ($activeId) {
63 $testSession->loadFromDb($activeId);
64 $this->testSession[$activeId] = $testSession;
65 } else {
66 global $DIC;
67 $ilUser = $DIC['ilUser'];
68
69 $testSession->loadTestSession(
70 $this->testOBJ->getTestId(),
71 $ilUser->getId(),
72 $testSession->getAccessCodeFromSession()
73 );
74
75 return $testSession;
76 }
77 }
78
79 return $this->testSession[$activeId];
80 }
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46

References $DIC, $ilUser, $testSession, and getNewTestSessionObject().

+ Here is the call graph for this function:

◆ getSessionByUserId()

ilTestSessionFactory::getSessionByUserId (   $userId)
Todo:
: Björn, we also need to handle the anonymous user here
Parameters
integer$userId
Returns
ilTestSession|ilTestSessionDynamicQuestionSet

Definition at line 87 of file class.ilTestSessionFactory.php.

88 {
89 if (!isset($this->testSession[$this->buildCacheKey($userId)])) {
91
92 $testSession->setRefId($this->testOBJ->getRefId());
93 $testSession->setTestId($this->testOBJ->getTestId());
94
95 $testSession->loadTestSession($this->testOBJ->getTestId(), $userId);
96
97 $this->testSession[$this->buildCacheKey($userId)] = $testSession;
98 }
99
100 return $this->testSession[$this->buildCacheKey($userId)];
101 }

References $testSession, buildCacheKey(), and getNewTestSessionObject().

+ Here is the call graph for this function:

◆ reset()

ilTestSessionFactory::reset ( )

temporarily bugfix for resetting the state of this singleton smeyer --> BH: not required anymore

Definition at line 39 of file class.ilTestSessionFactory.php.

40 {
41 $this->testSession = array();
42 }

Field Documentation

◆ $testOBJ

ilTestSessionFactory::$testOBJ = null
private

Definition at line 23 of file class.ilTestSessionFactory.php.

Referenced by __construct().

◆ $testSession

ilTestSessionFactory::$testSession = array()
private

The documentation for this class was generated from the following file: