ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilAssQuestionPreviewSession Class Reference
+ Collaboration diagram for ilAssQuestionPreviewSession:

Public Member Functions

 __construct ($userId, $questionId)
 
 init ()
 
 getUserId ()
 
 getQuestionId ()
 
 setInstantResponseActive ($instantResponseActive)
 
 isInstantResponseActive ()
 
 setParticipantsSolution ($participantSolution)
 
 getParticipantsSolution ()
 
 hasParticipantSolution ()
 
 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_RANDOMIZER_SEED = 'randomizerSeed'
 

Private Member Functions

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

Private Attributes

 $userId
 
 $questionId
 

Detailed Description

Definition at line 25 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

◆ ensureSessionStructureExists()

ilAssQuestionPreviewSession::ensureSessionStructureExists ( )
private

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

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

Referenced by init().

122  : void
123  {
124  if (!is_array(ilSession::get(self::SESSION_BASEINDEX))) {
125  ilSession::set(self::SESSION_BASEINDEX, []);
126  }
127 
128  $baseSession = ilSession::get(self::SESSION_BASEINDEX);
129 
130  if (!isset($baseSession[$this->getSessionContextIndex()])) {
131  $baseSession[$this->getSessionContextIndex()] = [];
132  }
133 
134  $contextSession = &$baseSession[$this->getSessionContextIndex()];
135 
136  if (!isset($contextSession[self::SESSION_SUBINDEX_INSTANT_RESPONSE_ACTIVE])) {
137  $contextSession[self::SESSION_SUBINDEX_INSTANT_RESPONSE_ACTIVE] = 0;
138  }
139 
140  if (!isset($contextSession[self::SESSION_SUBINDEX_PARTICIPANT_SOLUTION])) {
141  $contextSession[self::SESSION_SUBINDEX_PARTICIPANT_SOLUTION] = null;
142  }
143 
144  if (!isset($contextSession[self::SESSION_SUBINDEX_RANDOMIZER_SEED])) {
145  $contextSession[self::SESSION_SUBINDEX_RANDOMIZER_SEED] = null;
146  }
147 
148  ilSession::set(self::SESSION_BASEINDEX, $baseSession);
149  }
static get(string $a_var)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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:

◆ getParticipantsSolution()

ilAssQuestionPreviewSession::getParticipantsSolution ( )

◆ getQuestionId()

ilAssQuestionPreviewSession::getQuestionId ( )

◆ getRandomizerSeed()

ilAssQuestionPreviewSession::getRandomizerSeed ( )

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

References null, and readSessionValue().

Referenced by randomizerSeedExists().

111  : ?int
112  {
113  $val = $this->readSessionValue(self::SESSION_SUBINDEX_RANDOMIZER_SEED);
114  return $val === [] ? null : $val;
115  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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:

◆ isInstantResponseActive()

ilAssQuestionPreviewSession::isInstantResponseActive ( )

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

References readSessionValue().

86  : bool
87  {
88  return (bool) $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 hasParticipantSolution().

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 117 of file class.ilAssQuestionPreviewSession.php.

References getRandomizerSeed(), and null.

117  : bool
118  {
119  return ($this->getRandomizerSeed() !== null);
120  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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 getParticipantsSolution(), getRandomizerSeed(), 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:

◆ saveSessionValue()

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

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

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

Referenced by 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)

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

References saveSessionValue().

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

91  : void
92  {
93  $this->saveSessionValue(self::SESSION_SUBINDEX_PARTICIPANT_SOLUTION, $participantSolution);
94  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setRandomizerSeed()

ilAssQuestionPreviewSession::setRandomizerSeed (   $seed)

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

References saveSessionValue().

106  : void
107  {
108  $this->saveSessionValue(self::SESSION_SUBINDEX_RANDOMIZER_SEED, $seed);
109  }
+ 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 27 of file class.ilAssQuestionPreviewSession.php.

◆ SESSION_SUBINDEX_INSTANT_RESPONSE_ACTIVE

const ilAssQuestionPreviewSession::SESSION_SUBINDEX_INSTANT_RESPONSE_ACTIVE = 'instantResponseActive'

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

◆ SESSION_SUBINDEX_PARTICIPANT_SOLUTION

const ilAssQuestionPreviewSession::SESSION_SUBINDEX_PARTICIPANT_SOLUTION = 'participantSolution'

Definition at line 30 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.


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