ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilTestSessionFactory.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11{
17 private $testSession = array();
18
23 private $testOBJ = null;
24
30 {
31 $this->testOBJ = $testOBJ;
32 }
33
39 public function reset()
40 {
41 $this->testSession = array();
42 }
43
44
45
46
54 public function getSession($activeId = null)
55 {
56 if ($activeId === null || $this->testSession[$activeId] === null) {
58
59 $testSession->setRefId($this->testOBJ->getRefId());
60 $testSession->setTestId($this->testOBJ->getTestId());
61
62 if ($activeId) {
63 $testSession->loadFromDb($activeId);
64 $this->testSession[$activeId] = $testSession;
65 } else {
66 global $ilUser;
67
68 $testSession->loadTestSession(
69 $this->testOBJ->getTestId(),
70 $ilUser->getId(),
71 $testSession->getAccessCodeFromSession()
72 );
73
74 return $testSession;
75 }
76 }
77
78 return $this->testSession[$activeId];
79 }
80
86 public function getSessionByUserId($userId)
87 {
88 if (!isset($this->testSession[$this->buildCacheKey($userId)])) {
90
91 $testSession->setRefId($this->testOBJ->getRefId());
92 $testSession->setTestId($this->testOBJ->getTestId());
93
94 $testSession->loadTestSession($this->testOBJ->getTestId(), $userId);
95
96 $this->testSession[$this->buildCacheKey($userId)] = $testSession;
97 }
98
99 return $this->testSession[$this->buildCacheKey($userId)];
100 }
101
105 private function getNewTestSessionObject()
106 {
107 switch ($this->testOBJ->getQuestionSetType()) {
110
111 require_once 'Modules/Test/classes/class.ilTestSession.php';
113 break;
114
116
117 require_once 'Modules/Test/classes/class.ilTestSessionDynamicQuestionSet.php';
119 break;
120 }
121
122 return $testSession;
123 }
124
129 private function buildCacheKey($userId)
130 {
131 return "{$this->testOBJ->getTestId()}::{$userId}";
132 }
133}
An exception for terminatinating execution or to throw for unit testing.
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
reset()
temporarily bugfix for resetting the state of this singleton smeyer --> BH: not required anymore
__construct(ilObjTest $testOBJ)
constructor
getSession($activeId=null)
Creates and returns an instance of a test sequence that corresponds to the current test mode.
Test session handler.
$ilUser
Definition: imgupload.php:18