ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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)
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 }
82
88 public function getSessionByUserId($userId)
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 }
104
108 private function getNewTestSessionObject()
109 {
110 switch($this->testOBJ->getQuestionSetType())
111 {
114
115 require_once 'Modules/Test/classes/class.ilTestSession.php';
117 break;
118
120
121 require_once 'Modules/Test/classes/class.ilTestSessionDynamicQuestionSet.php';
123 break;
124 }
125
126 return $testSession;
127 }
128
133 private function buildCacheKey($userId)
134 {
135 return "{$this->testOBJ->getTestId()}::{$userId}";
136 }
137}
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.
global $ilUser
Definition: imgupload.php:15