ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 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 28 of file class.ilTestSessionFactory.php.

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

References $testOBJ.

Member Function Documentation

◆ buildCacheKey()

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

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

128 {
129 return "{$this->testOBJ->getTestId()}::{$userId}";
130 }

Referenced by getSessionByUserId().

+ Here is the caller graph for this function:

◆ getNewTestSessionObject()

ilTestSessionFactory::getNewTestSessionObject ( )
private
Returns
ilTestSession|ilTestSessionDynamicQuestionSet

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

103 {
104 switch($this->testOBJ->getQuestionSetType())
105 {
108
109 require_once 'Modules/Test/classes/class.ilTestSession.php';
111 break;
112
114
115 require_once 'Modules/Test/classes/class.ilTestSessionDynamicQuestionSet.php';
117 break;
118 }
119
120 return $testSession;
121 }
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 | null$activeId
Returns
ilTestSession|ilTestSessionDynamicQuestionSet

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

49 {
50 if($activeId === null || $this->testSession[$activeId] === null)
51 {
53
54 $testSession->setRefId($this->testOBJ->getRefId());
55 $testSession->setTestId($this->testOBJ->getTestId());
56
57 if($activeId)
58 {
59 $testSession->loadFromDb($activeId);
60 $this->testSession[$activeId] = $testSession;
61 }
62 else
63 {
64 global $ilUser;
65
66 $testSession->loadTestSession(
67 $this->testOBJ->getTestId(), $ilUser->getId(), $testSession->getAccessCodeFromSession()
68 );
69
70 return $testSession;
71 }
72 }
73
74 return $this->testSession[$activeId];
75 }
global $ilUser
Definition: imgupload.php:15

References $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 82 of file class.ilTestSessionFactory.php.

83 {
84 if(!isset($this->testSession[$this->buildCacheKey($userId)]))
85 {
87
88 $testSession->setRefId($this->testOBJ->getRefId());
89 $testSession->setTestId($this->testOBJ->getTestId());
90
91 $testSession->loadTestSession($this->testOBJ->getTestId(), $userId);
92
93 $this->testSession[$this->buildCacheKey($userId)] = $testSession;
94 }
95
96 return $this->testSession[$this->buildCacheKey($userId)];
97 }

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

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

38 {
39 $this->testSession = array();
40 }

Field Documentation

◆ $testOBJ

ilTestSessionFactory::$testOBJ = null
private

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

Referenced by __construct().

◆ $testSession

ilTestSessionFactory::$testSession = array()
private

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