ILIAS  trunk Revision v5.2.0beta1-34132-g2d4d73d4a0
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 
)

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

References $questionId, and $userId.

Member Function Documentation

◆ addRequestedHint()

ilAssQuestionPreviewSession::addRequestedHint (   $hintId)

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

References getRequestedHints(), and saveSessionValue().

130  : void
131  {
132  $requestedHints = $this->getRequestedHints();
133  $requestedHints[$hintId] = $hintId;
134  $this->saveSessionValue(self::SESSION_SUBINDEX_REQUESTED_HINTS, $requestedHints);
135  }
+ Here is the call graph for this function:

◆ ensureSessionStructureExists()

ilAssQuestionPreviewSession::ensureSessionStructureExists ( )
private

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

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

Referenced by init().

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])) {
182  $contextSession[self::SESSION_SUBINDEX_INSTANT_RESPONSE_ACTIVE] = 0;
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.
+ 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.

References issetSessionValue(), and readSessionValue().

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  }
+ Here is the call graph for this function:

◆ getParticipantsSolution()

◆ getQuestionId()

ilAssQuestionPreviewSession::getQuestionId ( )

◆ getRandomizerSeed()

ilAssQuestionPreviewSession::getRandomizerSeed ( )

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

References readSessionValue().

Referenced by randomizerSeedExists().

156  : ?int
157  {
158  $val = $this->readSessionValue(self::SESSION_SUBINDEX_RANDOMIZER_SEED);
159  return $val === [] ? null : $val;
160  }
+ 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.

References issetSessionValue(), and readSessionValue().

Referenced by addRequestedHint().

138  {
139  if ($this->issetSessionValue(self::SESSION_SUBINDEX_REQUESTED_HINTS)) {
140  return $this->readSessionValue(self::SESSION_SUBINDEX_REQUESTED_HINTS);
141  }
142 
143  return [];
144  }
+ 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.

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

57  : string
58  {
59  return "u{$this->userId}::q{$this->questionId}";
60  }
+ Here is the caller graph for this function:

◆ getUserId()

ilAssQuestionPreviewSession::getUserId ( )

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

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.

References issetSessionValue().

Referenced by assOrderingQuestion\calculateReachedPointsFromPreviewSession().

101  : bool
102  {
103  return $this->issetSessionValue(self::SESSION_SUBINDEX_PARTICIPANT_SOLUTION);
104  }
+ 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().

42  : void
43  {
45  }
+ Here is the call graph for this function:

◆ isHintRequested()

ilAssQuestionPreviewSession::isHintRequested (   $hintId)

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

References issetSessionValue(), and readSessionValue().

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  }
+ Here is the call graph for this function:

◆ isInstantResponseActive()

ilAssQuestionPreviewSession::isInstantResponseActive ( )

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

References readSessionValue().

87  {
88  return $this->readSessionValue(self::SESSION_SUBINDEX_INSTANT_RESPONSE_ACTIVE);
89  }
+ Here is the call graph for this function:

◆ issetSessionValue()

ilAssQuestionPreviewSession::issetSessionValue (   $subIndex)
private

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

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

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

69  : bool
70  {
71  $val = ilSession::get(self::SESSION_BASEINDEX);
72  return isset($val[$this->getSessionContextIndex()][$subIndex]);
73  }
static get(string $a_var)
+ 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.

References getRandomizerSeed().

162  : bool
163  {
164  return ($this->getRandomizerSeed() !== null);
165  }
+ Here is the call graph for this function:

◆ readSessionValue()

ilAssQuestionPreviewSession::readSessionValue (   $subIndex)
private

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

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

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

76  {
77  $val = ilSession::get(self::SESSION_BASEINDEX);
78  return $val[$this->getSessionContextIndex()][$subIndex] ?? [];
79  }
static get(string $a_var)
+ 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.

References saveSessionValue().

146  : void
147  {
148  $this->saveSessionValue(self::SESSION_SUBINDEX_REQUESTED_HINTS, array());
149  }
+ Here is the call graph for this function:

◆ saveSessionValue()

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

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

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

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

62  : void
63  {
64  $val = ilSession::get(self::SESSION_BASEINDEX);
65  $val[$this->getSessionContextIndex()][$subIndex] = $value;
66  ilSession::set(self::SESSION_BASEINDEX, $val);
67  }
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
+ 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.

References saveSessionValue().

81  : void
82  {
83  $this->saveSessionValue(self::SESSION_SUBINDEX_INSTANT_RESPONSE_ACTIVE, $instantResponseActive);
84  }
+ Here is the call graph for this function:

◆ setParticipantsSolution()

ilAssQuestionPreviewSession::setParticipantsSolution (   $participantSolution)

◆ setRandomizerSeed()

ilAssQuestionPreviewSession::setRandomizerSeed (   $seed)

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

References saveSessionValue().

151  : void
152  {
153  $this->saveSessionValue(self::SESSION_SUBINDEX_RANDOMIZER_SEED, $seed);
154  }
+ 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.

◆ SESSION_SUBINDEX_PARTICIPANT_SOLUTION

const ilAssQuestionPreviewSession::SESSION_SUBINDEX_PARTICIPANT_SOLUTION = 'participantSolution'

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

◆ SESSION_SUBINDEX_RANDOMIZER_SEED

const ilAssQuestionPreviewSession::SESSION_SUBINDEX_RANDOMIZER_SEED = 'randomizerSeed'

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

◆ 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: