ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTestSessionFactory Class Reference
+ Collaboration diagram for ilTestSessionFactory:

Public Member Functions

 __construct (ilObjTest $testOBJ)
 constructor
 reset ()
 temporarily bugfix for resetting the state of this singleton smeyer
 getSession ($activeId=null)
 Creates and returns an instance of a test sequence that corresponds to the current test mode.
 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

ilTestSessionFactory::__construct ( ilObjTest  $testOBJ)

constructor

Parameters
ilObjTest$testOBJ

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

References $testOBJ.

{
$this->testOBJ = $testOBJ;
}

Member Function Documentation

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

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

Referenced by getSessionByUserId().

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

+ Here is the caller graph for this function:

ilTestSessionFactory::getNewTestSessionObject ( )
private
Returns
ilTestSession|ilTestSessionDynamicQuestionSet

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

{
switch($this->testOBJ->getQuestionSetType())
{
require_once 'Modules/Test/classes/class.ilTestSession.php';
break;
require_once 'Modules/Test/classes/class.ilTestSessionDynamicQuestionSet.php';
break;
}
return $testSession;
}

+ Here is the caller graph for this function:

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.

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

{
if($activeId === null || $this->testSession[$activeId] === null)
{
$testSession->setRefId($this->testOBJ->getRefId());
$testSession->setTestId($this->testOBJ->getTestId());
if($activeId)
{
$testSession->loadFromDb($activeId);
$this->testSession[$activeId] = $testSession;
}
else
{
global $ilUser;
$testSession->loadTestSession(
$this->testOBJ->getTestId(), $ilUser->getId(), $testSession->getAccessCodeFromSession()
);
return $testSession;
}
}
return $this->testSession[$activeId];
}

+ Here is the call graph for this function:

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.

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

{
if(!isset($this->testSession[$this->buildCacheKey($userId)]))
{
$testSession->setRefId($this->testOBJ->getRefId());
$testSession->setTestId($this->testOBJ->getTestId());
$testSession->loadTestSession($this->testOBJ->getTestId(), $userId);
$this->testSession[$this->buildCacheKey($userId)] = $testSession;
}
return $this->testSession[$this->buildCacheKey($userId)];
}

+ Here is the call graph for this function:

ilTestSessionFactory::reset ( )

temporarily bugfix for resetting the state of this singleton smeyer

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

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

Field Documentation

ilTestSessionFactory::$testOBJ = null
private

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

Referenced by __construct().

ilTestSessionFactory::$testSession = array()
private

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