ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 24 of file class.ilTestSessionFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestSessionFactory::__construct ( ilObjTest  $testOBJ)

constructor

Parameters
ilObjTest$testOBJ

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

References $testOBJ.

44  {
45  $this->testOBJ = $testOBJ;
46  }

Member Function Documentation

◆ buildCacheKey()

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

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

Referenced by getSessionByUserId().

145  {
146  return "{$this->testOBJ->getTestId()}::{$userId}";
147  }
+ Here is the caller graph for this function:

◆ getNewTestSessionObject()

ilTestSessionFactory::getNewTestSessionObject ( )
private
Returns
ilTestSession|ilTestSessionDynamicQuestionSet

Definition at line 120 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().

121  {
122  switch ($this->testOBJ->getQuestionSetType()) {
125 
126  require_once 'Modules/Test/classes/class.ilTestSession.php';
127  $testSession = new ilTestSession();
128  break;
129 
131 
132  require_once 'Modules/Test/classes/class.ilTestSessionDynamicQuestionSet.php';
134  break;
135  }
136 
137  return $testSession;
138  }
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
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 68 of file class.ilTestSessionFactory.php.

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

69  {
70  if ($activeId === null || $this->testSession[$activeId] === null) {
72 
73  $testSession->setRefId($this->testOBJ->getRefId());
74  $testSession->setTestId($this->testOBJ->getTestId());
75 
76  if ($activeId) {
77  $testSession->loadFromDb($activeId);
78  $this->testSession[$activeId] = $testSession;
79  } else {
80  global $DIC;
81  $ilUser = $DIC['ilUser'];
82 
83  $testSession->loadTestSession(
84  $this->testOBJ->getTestId(),
85  $ilUser->getId(),
86  $testSession->getAccessCodeFromSession()
87  );
88 
89  return $testSession;
90  }
91  }
92 
93  return $this->testSession[$activeId];
94  }
global $DIC
Definition: goto.php:24
$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 101 of file class.ilTestSessionFactory.php.

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

102  {
103  if (!isset($this->testSession[$this->buildCacheKey($userId)])) {
105 
106  $testSession->setRefId($this->testOBJ->getRefId());
107  $testSession->setTestId($this->testOBJ->getTestId());
108 
109  $testSession->loadTestSession($this->testOBJ->getTestId(), $userId);
110 
111  $this->testSession[$this->buildCacheKey($userId)] = $testSession;
112  }
113 
114  return $this->testSession[$this->buildCacheKey($userId)];
115  }
+ 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 53 of file class.ilTestSessionFactory.php.

54  {
55  $this->testSession = array();
56  }

Field Documentation

◆ $testOBJ

ilTestSessionFactory::$testOBJ = null
private

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

Referenced by __construct().

◆ $testSession

ilTestSessionFactory::$testSession = array()
private

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