ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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.

References $testOBJ.

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

Member Function Documentation

◆ buildCacheKey()

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

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

Referenced by getSessionByUserId().

134  {
135  return "{$this->testOBJ->getTestId()}::{$userId}";
136  }
+ Here is the caller graph for this function:

◆ getNewTestSessionObject()

ilTestSessionFactory::getNewTestSessionObject ( )
private
Returns
ilTestSession|ilTestSessionDynamicQuestionSet

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

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

Referenced by getSession(), and getSessionByUserId().

109  {
110  switch($this->testOBJ->getQuestionSetType())
111  {
114 
115  require_once 'Modules/Test/classes/class.ilTestSession.php';
116  $testSession = new ilTestSession();
117  break;
118 
120 
121  require_once 'Modules/Test/classes/class.ilTestSessionDynamicQuestionSet.php';
123  break;
124  }
125 
126  return $testSession;
127  }
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
Test session handler.
const QUESTION_SET_TYPE_FIXED
type setting value for fixed question set
const QUESTION_SET_TYPE_DYNAMIC
type setting value for dynamic question set (continues testing mode)
+ 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.

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

55  {
56  if( $activeId === null || $this->testSession[$activeId] === null)
57  {
59 
60  $testSession->setRefId($this->testOBJ->getRefId());
61  $testSession->setTestId($this->testOBJ->getTestId());
62 
63  if($activeId)
64  {
65  $testSession->loadFromDb($activeId);
66  $this->testSession[$activeId] = $testSession;
67  }
68  else
69  {
70  global $ilUser;
71 
72  $testSession->loadTestSession(
73  $this->testOBJ->getTestId(), $ilUser->getId(), $testSession->getAccessCodeFromSession()
74  );
75 
76  return $testSession;
77  }
78  }
79 
80  return $this->testSession[$activeId];
81  }
$ilUser
Definition: imgupload.php:18
+ 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 88 of file class.ilTestSessionFactory.php.

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

89  {
90  if( !isset($this->testSession[$this->buildCacheKey($userId)]) )
91  {
93 
94  $testSession->setRefId($this->testOBJ->getRefId());
95  $testSession->setTestId($this->testOBJ->getTestId());
96 
97  $testSession->loadTestSession($this->testOBJ->getTestId(), $userId);
98 
99  $this->testSession[$this->buildCacheKey($userId)] = $testSession;
100  }
101 
102  return $this->testSession[$this->buildCacheKey($userId)];
103  }
+ 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.

References array.

40  {
41  $this->testSession = array();
42  }
Create styles array
The data for the language used.

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: