ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 
)

Member Function Documentation

◆ ensureSessionStructureExists()

ilAssQuestionPreviewSession::ensureSessionStructureExists ( )
private

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

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])) {
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)
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:

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

111 : ?int
112 {
113 $val = $this->readSessionValue(self::SESSION_SUBINDEX_RANDOMIZER_SEED);
114 return $val === [] ? null : $val;
115 }

References readSessionValue().

Referenced by randomizerSeedExists().

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

◆ isInstantResponseActive()

ilAssQuestionPreviewSession::isInstantResponseActive ( )

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

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

+ 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.

117 : bool
118 {
119 return ($this->getRandomizerSeed() !== null);
120 }

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 getParticipantsSolution(), getRandomizerSeed(), and isInstantResponseActive().

+ 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.

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 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 assLongMenu\savePreviewData(), assQuestion\savePreviewData(), assErrorText\savePreviewData(), assFileUpload\savePreviewData(), assFormulaQuestion\savePreviewData(), assMatchingQuestion\savePreviewData(), assNumeric\savePreviewData(), assOrderingQuestion\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 106 of file class.ilAssQuestionPreviewSession.php.

106 : void
107 {
108 $this->saveSessionValue(self::SESSION_SUBINDEX_RANDOMIZER_SEED, $seed);
109 }

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 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.

Referenced by ensureSessionStructureExists().

◆ SESSION_SUBINDEX_PARTICIPANT_SOLUTION

const ilAssQuestionPreviewSession::SESSION_SUBINDEX_PARTICIPANT_SOLUTION = 'participantSolution'

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


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