ILIAS  release_8 Revision v8.19
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 133 of file class.ilTestSessionFactory.php.

Referenced by getSessionByUserId().

133  : string
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 121 of file class.ilTestSessionFactory.php.

Referenced by getSession(), and getSessionByUserId().

122  {
123  if ($this->testOBJ->isDynamicTest()) {
124  return new ilTestSessionDynamicQuestionSet();
125  }
126  return new ilTestSession();
127  }
+ 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 65 of file class.ilTestSessionFactory.php.

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

66  {
67  if ($activeId === null ||
68  $this->testSession === array() ||
69  !array_key_exists($activeId, $this->testSession) ||
70  $this->testSession[$activeId] === null
71  ) {
73 
74  $testSession->setRefId($this->testOBJ->getRefId());
75  $testSession->setTestId($this->testOBJ->getTestId());
76 
77  if ($activeId) {
78  $testSession->loadFromDb($activeId);
79  $this->testSession[$activeId] = $testSession;
80  } else {
81  global $DIC;
82  $ilUser = $DIC['ilUser'];
83 
84  $testSession->loadTestSession(
85  $this->testOBJ->getTestId(),
86  $ilUser->getId(),
87  $testSession->getAccessCodeFromSession()
88  );
89 
90  return $testSession;
91  }
92  }
93 
94  return $this->testSession[$activeId];
95  }
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
+ 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 102 of file class.ilTestSessionFactory.php.

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

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

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

Referenced by getSession(), and getSessionByUserId().


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