ILIAS  release_8 Revision v8.24
ilAssQuestionPreviewSession Class Reference
+ Collaboration diagram for ilAssQuestionPreviewSession:

Public Member Functions

 __construct ($userId, $questionId)
 
 init ()
 
 getUserId ()
 
 getQuestionId ()
 
 setInstantResponseActive ($instantResponseActive)
 
 isInstantResponseActive ()
 
 setParticipantsSolution ($participantSolution)
 
 getParticipantsSolution ()
 
 hasParticipantSolution ()
 
 getNumRequestedHints ()
 
 isHintRequested ($hintId)
 
 addRequestedHint ($hintId)
 
 getRequestedHints ()
 
 resetRequestedHints ()
 
 setRandomizerSeed ($seed)
 
 getRandomizerSeed ()
 
 randomizerSeedExists ()
 

Data Fields

const SESSION_BASEINDEX = 'ilAssQuestionPreviewSessions'
 
const SESSION_SUBINDEX_INSTANT_RESPONSE_ACTIVE = 'instantResponseActive'
 
const SESSION_SUBINDEX_PARTICIPANT_SOLUTION = 'participantSolution'
 
const SESSION_SUBINDEX_REQUESTED_HINTS = 'requestedHints'
 
const SESSION_SUBINDEX_RANDOMIZER_SEED = 'randomizerSeed'
 

Private Member Functions

 getSessionContextIndex ()
 
 saveSessionValue ($subIndex, $value)
 
 issetSessionValue ($subIndex)
 
 readSessionValue ($subIndex)
 
 ensureSessionStructureExists ()
 

Private Attributes

 $userId
 
 $questionId
 

Detailed Description

Definition at line 24 of file class.ilAssQuestionPreviewSession.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionPreviewSession::__construct (   $userId,
  $questionId 
)

Member Function Documentation

◆ addRequestedHint()

ilAssQuestionPreviewSession::addRequestedHint (   $hintId)

Definition at line 130 of file class.ilAssQuestionPreviewSession.php.

130 : void
131 {
132 $requestedHints = $this->getRequestedHints();
133 $requestedHints[$hintId] = $hintId;
134 $this->saveSessionValue(self::SESSION_SUBINDEX_REQUESTED_HINTS, $requestedHints);
135 }

References getRequestedHints(), and saveSessionValue().

+ Here is the call graph for this function:

◆ ensureSessionStructureExists()

ilAssQuestionPreviewSession::ensureSessionStructureExists ( )
private

Definition at line 167 of file class.ilAssQuestionPreviewSession.php.

167 : void
168 {
169 if (!is_array(ilSession::get(self::SESSION_BASEINDEX))) {
170 ilSession::set(self::SESSION_BASEINDEX, array());
171 }
172
173 $baseSession = ilSession::get(self::SESSION_BASEINDEX);
174
175 if (!isset($baseSession[$this->getSessionContextIndex()])) {
176 $baseSession[$this->getSessionContextIndex()] = array();
177 }
178
179 $contextSession = &$baseSession[$this->getSessionContextIndex()];
180
181 if (!isset($contextSession[self::SESSION_SUBINDEX_INSTANT_RESPONSE_ACTIVE])) {
183 }
184
185 if (!isset($contextSession[self::SESSION_SUBINDEX_PARTICIPANT_SOLUTION])) {
186 $contextSession[self::SESSION_SUBINDEX_PARTICIPANT_SOLUTION] = null;
187 }
188
189 if (!isset($contextSession[self::SESSION_SUBINDEX_RANDOMIZER_SEED])) {
190 $contextSession[self::SESSION_SUBINDEX_RANDOMIZER_SEED] = null;
191 }
192
193 ilSession::set(self::SESSION_BASEINDEX, $baseSession);
194 }
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.

References ilSession\get(), getSessionContextIndex(), SESSION_SUBINDEX_INSTANT_RESPONSE_ACTIVE, SESSION_SUBINDEX_PARTICIPANT_SOLUTION, SESSION_SUBINDEX_RANDOMIZER_SEED, and ilSession\set().

Referenced by init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNumRequestedHints()

ilAssQuestionPreviewSession::getNumRequestedHints ( )

Definition at line 106 of file class.ilAssQuestionPreviewSession.php.

106 : int
107 {
108 if (!$this->issetSessionValue(self::SESSION_SUBINDEX_REQUESTED_HINTS)) {
109 return 0;
110 }
111 $hints = $this->readSessionValue(self::SESSION_SUBINDEX_REQUESTED_HINTS);
112
113 if (!is_array($hints)) {
114 return 0;
115 }
116
117 return count($hints);
118 }

References issetSessionValue(), and readSessionValue().

+ Here is the call graph for this function:

◆ getParticipantsSolution()

◆ getQuestionId()

ilAssQuestionPreviewSession::getQuestionId ( )

Definition at line 52 of file class.ilAssQuestionPreviewSession.php.

53 {
54 return $this->questionId;
55 }

References $questionId.

◆ getRandomizerSeed()

ilAssQuestionPreviewSession::getRandomizerSeed ( )

Definition at line 156 of file class.ilAssQuestionPreviewSession.php.

156 : ?int
157 {
158 $val = $this->readSessionValue(self::SESSION_SUBINDEX_RANDOMIZER_SEED);
159 return $val === [] ? null : $val;
160 }

References readSessionValue().

Referenced by randomizerSeedExists().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRequestedHints()

ilAssQuestionPreviewSession::getRequestedHints ( )

Definition at line 137 of file class.ilAssQuestionPreviewSession.php.

138 {
139 if ($this->issetSessionValue(self::SESSION_SUBINDEX_REQUESTED_HINTS)) {
140 return $this->readSessionValue(self::SESSION_SUBINDEX_REQUESTED_HINTS);
141 }
142
143 return [];
144 }

References issetSessionValue(), and readSessionValue().

Referenced by addRequestedHint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSessionContextIndex()

ilAssQuestionPreviewSession::getSessionContextIndex ( )
private

Definition at line 57 of file class.ilAssQuestionPreviewSession.php.

57 : string
58 {
59 return "u{$this->userId}::q{$this->questionId}";
60 }

Referenced by ensureSessionStructureExists(), issetSessionValue(), readSessionValue(), and saveSessionValue().

+ Here is the caller graph for this function:

◆ getUserId()

ilAssQuestionPreviewSession::getUserId ( )

Definition at line 47 of file class.ilAssQuestionPreviewSession.php.

48 {
49 return $this->userId;
50 }

References $userId.

Referenced by assFileUpload\savePreviewData().

+ Here is the caller graph for this function:

◆ hasParticipantSolution()

ilAssQuestionPreviewSession::hasParticipantSolution ( )

Definition at line 101 of file class.ilAssQuestionPreviewSession.php.

101 : bool
102 {
103 return $this->issetSessionValue(self::SESSION_SUBINDEX_PARTICIPANT_SOLUTION);
104 }

References issetSessionValue().

Referenced by assOrderingQuestion\calculateReachedPointsFromPreviewSession().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

ilAssQuestionPreviewSession::init ( )

Definition at line 42 of file class.ilAssQuestionPreviewSession.php.

References ensureSessionStructureExists().

+ Here is the call graph for this function:

◆ isHintRequested()

ilAssQuestionPreviewSession::isHintRequested (   $hintId)

Definition at line 120 of file class.ilAssQuestionPreviewSession.php.

120 : bool
121 {
122 if ($this->issetSessionValue(self::SESSION_SUBINDEX_REQUESTED_HINTS)) {
123 $requestedHints = $this->readSessionValue(self::SESSION_SUBINDEX_REQUESTED_HINTS);
124 return isset($requestedHints[$hintId]);
125 }
126
127 return false;
128 }

References issetSessionValue(), and readSessionValue().

+ Here is the call graph for this function:

◆ isInstantResponseActive()

ilAssQuestionPreviewSession::isInstantResponseActive ( )

Definition at line 86 of file class.ilAssQuestionPreviewSession.php.

87 {
88 return $this->readSessionValue(self::SESSION_SUBINDEX_INSTANT_RESPONSE_ACTIVE);
89 }

References readSessionValue().

+ Here is the call graph for this function:

◆ issetSessionValue()

ilAssQuestionPreviewSession::issetSessionValue (   $subIndex)
private

Definition at line 69 of file class.ilAssQuestionPreviewSession.php.

69 : bool
70 {
71 $val = ilSession::get(self::SESSION_BASEINDEX);
72 return isset($val[$this->getSessionContextIndex()][$subIndex]);
73 }

References ilSession\get(), and getSessionContextIndex().

Referenced by getNumRequestedHints(), getRequestedHints(), hasParticipantSolution(), and isHintRequested().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ randomizerSeedExists()

ilAssQuestionPreviewSession::randomizerSeedExists ( )

Definition at line 162 of file class.ilAssQuestionPreviewSession.php.

162 : bool
163 {
164 return ($this->getRandomizerSeed() !== null);
165 }

References getRandomizerSeed().

+ Here is the call graph for this function:

◆ readSessionValue()

ilAssQuestionPreviewSession::readSessionValue (   $subIndex)
private

Definition at line 75 of file class.ilAssQuestionPreviewSession.php.

76 {
77 $val = ilSession::get(self::SESSION_BASEINDEX);
78 return $val[$this->getSessionContextIndex()][$subIndex] ?? [];
79 }

References ilSession\get(), and getSessionContextIndex().

Referenced by getNumRequestedHints(), getParticipantsSolution(), getRandomizerSeed(), getRequestedHints(), isHintRequested(), and isInstantResponseActive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetRequestedHints()

ilAssQuestionPreviewSession::resetRequestedHints ( )

Definition at line 146 of file class.ilAssQuestionPreviewSession.php.

146 : void
147 {
148 $this->saveSessionValue(self::SESSION_SUBINDEX_REQUESTED_HINTS, array());
149 }

References saveSessionValue().

+ Here is the call graph for this function:

◆ saveSessionValue()

ilAssQuestionPreviewSession::saveSessionValue (   $subIndex,
  $value 
)
private

Definition at line 62 of file class.ilAssQuestionPreviewSession.php.

62 : void
63 {
64 $val = ilSession::get(self::SESSION_BASEINDEX);
65 $val[$this->getSessionContextIndex()][$subIndex] = $value;
66 ilSession::set(self::SESSION_BASEINDEX, $val);
67 }

References ilSession\get(), getSessionContextIndex(), and ilSession\set().

Referenced by addRequestedHint(), resetRequestedHints(), setInstantResponseActive(), setParticipantsSolution(), and setRandomizerSeed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setInstantResponseActive()

ilAssQuestionPreviewSession::setInstantResponseActive (   $instantResponseActive)

Definition at line 81 of file class.ilAssQuestionPreviewSession.php.

81 : void
82 {
83 $this->saveSessionValue(self::SESSION_SUBINDEX_INSTANT_RESPONSE_ACTIVE, $instantResponseActive);
84 }

References saveSessionValue().

+ Here is the call graph for this function:

◆ setParticipantsSolution()

ilAssQuestionPreviewSession::setParticipantsSolution (   $participantSolution)

Definition at line 91 of file class.ilAssQuestionPreviewSession.php.

91 : void
92 {
93 $this->saveSessionValue(self::SESSION_SUBINDEX_PARTICIPANT_SOLUTION, $participantSolution);
94 }

References saveSessionValue().

Referenced by assErrorText\savePreviewData(), assFileUpload\savePreviewData(), assFormulaQuestion\savePreviewData(), assImagemapQuestion\savePreviewData(), assLongMenu\savePreviewData(), assMatchingQuestion\savePreviewData(), assNumeric\savePreviewData(), assOrderingQuestion\savePreviewData(), assQuestion\savePreviewData(), and assSingleChoice\savePreviewData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setRandomizerSeed()

ilAssQuestionPreviewSession::setRandomizerSeed (   $seed)

Definition at line 151 of file class.ilAssQuestionPreviewSession.php.

151 : void
152 {
153 $this->saveSessionValue(self::SESSION_SUBINDEX_RANDOMIZER_SEED, $seed);
154 }

References saveSessionValue().

+ Here is the call graph for this function:

Field Documentation

◆ $questionId

ilAssQuestionPreviewSession::$questionId
private

Definition at line 34 of file class.ilAssQuestionPreviewSession.php.

Referenced by __construct(), and getQuestionId().

◆ $userId

ilAssQuestionPreviewSession::$userId
private

Definition at line 33 of file class.ilAssQuestionPreviewSession.php.

Referenced by __construct(), and getUserId().

◆ SESSION_BASEINDEX

const ilAssQuestionPreviewSession::SESSION_BASEINDEX = 'ilAssQuestionPreviewSessions'

Definition at line 26 of file class.ilAssQuestionPreviewSession.php.

◆ SESSION_SUBINDEX_INSTANT_RESPONSE_ACTIVE

const ilAssQuestionPreviewSession::SESSION_SUBINDEX_INSTANT_RESPONSE_ACTIVE = 'instantResponseActive'

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

Referenced by ensureSessionStructureExists().

◆ SESSION_SUBINDEX_PARTICIPANT_SOLUTION

const ilAssQuestionPreviewSession::SESSION_SUBINDEX_PARTICIPANT_SOLUTION = 'participantSolution'

Definition at line 29 of file class.ilAssQuestionPreviewSession.php.

Referenced by ensureSessionStructureExists().

◆ SESSION_SUBINDEX_RANDOMIZER_SEED

const ilAssQuestionPreviewSession::SESSION_SUBINDEX_RANDOMIZER_SEED = 'randomizerSeed'

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

Referenced by ensureSessionStructureExists().

◆ SESSION_SUBINDEX_REQUESTED_HINTS

const ilAssQuestionPreviewSession::SESSION_SUBINDEX_REQUESTED_HINTS = 'requestedHints'

Definition at line 30 of file class.ilAssQuestionPreviewSession.php.


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