ILIAS  release_8 Revision v8.24
ilTestSession Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilTestSession:
+ Collaboration diagram for ilTestSession:

Public Member Functions

 __construct ()
 ilTestSession constructor More...
 
 setRefId (int $a_val)
 
 getRefId ()
 
 increaseTestPass ()
 
 saveToDb ()
 
 loadTestSession ($test_id, $user_id="", $anonymous_id="")
 
 loadFromDb ($active_id)
 Loads the session data for a given active id. More...
 
 getActiveId ()
 
 setUserId ($user_id)
 
 getUserId ()
 
 setTestId ($test_id)
 
 getTestId ()
 
 setAnonymousId ($anonymous_id)
 
 getAnonymousId ()
 
 setLastSequence ($lastsequence)
 
 getLastSequence ()
 
 setPass ($pass)
 
 getPass ()
 
 increasePass ()
 
 isSubmitted ()
 
 setSubmitted ()
 
 getSubmittedTimestamp ()
 
 setSubmittedTimestamp ()
 
 setLastFinishedPass ($lastFinishedPass)
 
 getLastFinishedPass ()
 
 setObjectiveOrientedContainerId ($objectiveOriented)
 
 getObjectiveOrientedContainerId ()
 
 getLastStartedPass ()
 
 setLastStartedPass ($lastStartedPass)
 
 isObjectiveOriented ()
 
 persistTestStartLock ($testStartLock)
 
 lookupTestStartLock ()
 
 setAccessCodeToSession ($access_code)
 
 unsetAccessCodeInSession ()
 
 getAccessCodeFromSession ()
 
 doesAccessCodeInSessionExists ()
 
 createNewAccessCode ()
 
 isAccessCodeUsed ($code)
 
 isAnonymousUser ()
 
 isPasswordChecked ()
 
 setPasswordChecked (bool $value)
 
 reportableResultsAvailable (ilObjTest $testOBJ)
 
 hasSinglePassReportable (ilObjTest $testObj)
 

Data Fields

const ACCESS_CODE_SESSION_INDEX = "tst_access_code"
 
const ACCESS_CODE_CHAR_DOMAIN = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
 
const ACCESS_CODE_LENGTH = 5
 
int $active_id
 
int $user_id
 
 $anonymous_id = null
 
int $test_id
 
int $lastsequence
 
bool $submitted
 
int $tstamp
 
string $submittedTimestamp
 

Protected Member Functions

 activeIDExists ($user_id, $test_id)
 

Protected Attributes

string $lastPresentationMode
 

Private Member Functions

 buildAccessCode ()
 

Private Attributes

int $ref_id
 
int $pass
 
int $objectiveOrientedContainerId
 
 $lastFinishedPass
 
 $lastStartedPass
 
 $reportableResultsAvailable = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Test session handler

This class manages the test session for a participant

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilTestSession::__construct ( )

ilTestSession constructor

The constructor takes possible arguments an creates an instance of the ilTestSession object.

@access public

Reimplemented in ilTestSessionDynamicQuestionSet.

Definition at line 60 of file class.ilTestSession.php.

61 {
62 $this->active_id = 0;
63 $this->user_id = 0;
64 $this->anonymous_id = 0;
65 $this->test_id = 0;
66 $this->lastsequence = 0;
67 $this->lastPresentationMode = null;
68 $this->submitted = false;
69 $this->submittedTimestamp = "";
70 $this->pass = 0;
71 $this->ref_id = 0;
72 $this->tstamp = 0;
73
74 $this->lastStartedPass = null;
75 $this->lastFinishedPass = null;
76 $this->objectiveOrientedContainerId = 0;
77 }

Member Function Documentation

◆ activeIDExists()

ilTestSession::activeIDExists (   $user_id,
  $test_id 
)
protected

Definition at line 89 of file class.ilTestSession.php.

89 : bool
90 {
91 global $DIC;
92 $ilDB = $DIC['ilDB'];
93
94 if ($GLOBALS['DIC']['ilUser']->getId() != ANONYMOUS_USER_ID) {
95 $result = $ilDB->queryF(
96 "SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s",
97 array('integer','integer'),
98 array($user_id, $test_id)
99 );
100 if ($result->numRows()) {
101 $row = $ilDB->fetchAssoc($result);
102 $this->active_id = (int) $row["active_id"];
103 $this->user_id = (int) $row["user_fi"];
104 $this->anonymous_id = $row["anonymous_id"];
105 $this->test_id = (int) $row["test_fi"];
106 $this->lastsequence = (int) $row["lastindex"];
107 $this->pass = (int) $row["tries"];
108 $this->submitted = ($row["submitted"]) ? true : false;
109 $this->submittedTimestamp = (string) $row["submittimestamp"];
110 $this->tstamp = (int) $row["tstamp"];
111
112 $this->setLastStartedPass($row['last_started_pass']);
113 $this->setLastFinishedPass($row['last_finished_pass']);
114 $this->setObjectiveOrientedContainerId((int) $row['objective_container']);
115
116 return true;
117 }
118 }
119 return false;
120 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
setObjectiveOrientedContainerId($objectiveOriented)
setLastFinishedPass($lastFinishedPass)
setLastStartedPass($lastStartedPass)
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: feed.php:28

References $DIC, $GLOBALS, $ilDB, $test_id, $user_id, ANONYMOUS_USER_ID, ILIAS\Survey\Mode\getId(), ILIAS\Repository\int(), setLastFinishedPass(), setLastStartedPass(), and setObjectiveOrientedContainerId().

Referenced by saveToDb(), and ilTestSessionDynamicQuestionSet\saveToDb().

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

◆ buildAccessCode()

ilTestSession::buildAccessCode ( )
private

Definition at line 533 of file class.ilTestSession.php.

533 : string
534 {
535 // create a 5 character code
536 $codestring = self::ACCESS_CODE_CHAR_DOMAIN;
537
538 mt_srand();
539
540 $code = "";
541
542 for ($i = 1; $i <= self::ACCESS_CODE_LENGTH; $i++) {
543 $index = mt_rand(0, strlen($codestring) - 1);
544 $code .= substr($codestring, $index, 1);
545 }
546
547 return $code;
548 }
$index
Definition: metadata.php:145
$i
Definition: metadata.php:41

References $i, $index, ACCESS_CODE_CHAR_DOMAIN, and ACCESS_CODE_LENGTH.

Referenced by createNewAccessCode().

+ Here is the caller graph for this function:

◆ createNewAccessCode()

ilTestSession::createNewAccessCode ( )

Definition at line 508 of file class.ilTestSession.php.

508 : string
509 {
510 do {
511 $code = $this->buildAccessCode();
512 } while ($this->isAccessCodeUsed($code));
513
514 return $code;
515 }

References buildAccessCode(), and isAccessCodeUsed().

+ Here is the call graph for this function:

◆ doesAccessCodeInSessionExists()

ilTestSession::doesAccessCodeInSessionExists ( )

Definition at line 495 of file class.ilTestSession.php.

495 : bool
496 {
497 if (!is_array(ilSession::get(self::ACCESS_CODE_SESSION_INDEX))) {
498 return false;
499 }
500 $session_code = ilSession::get(self::ACCESS_CODE_SESSION_INDEX);
501 if (!isset($session_code[$this->getTestId()])) {
502 return false;
503 }
504
505 return isset($session_code[$this->getTestId()]);
506 }
static get(string $a_var)

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

Referenced by loadTestSession(), and ilTestSessionDynamicQuestionSet\loadTestSession().

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

◆ getAccessCodeFromSession()

ilTestSession::getAccessCodeFromSession ( )

Definition at line 482 of file class.ilTestSession.php.

483 {
484 if (!is_array(ilSession::get(self::ACCESS_CODE_SESSION_INDEX))) {
485 return null;
486 }
487 $session_code = ilSession::get(self::ACCESS_CODE_SESSION_INDEX);
488 if (!isset($session_code[$this->getTestId()])) {
489 return null;
490 }
491
492 return $session_code[$this->getTestId()];
493 }

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

Referenced by loadTestSession(), and ilTestSessionDynamicQuestionSet\loadTestSession().

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

◆ getActiveId()

◆ getAnonymousId()

ilTestSession::getAnonymousId ( )
Returns
int|string|null

Definition at line 342 of file class.ilTestSession.php.

343 {
344 return $this->anonymous_id;
345 }

References $anonymous_id.

Referenced by saveToDb(), and ilTestSessionDynamicQuestionSet\saveToDb().

+ Here is the caller graph for this function:

◆ getLastFinishedPass()

ilTestSession::getLastFinishedPass ( )

Definition at line 397 of file class.ilTestSession.php.

398 {
400 }

References $lastFinishedPass.

Referenced by ilObjTest\canShowTestResults(), ilObjTest\hasAnyTestResult(), hasSinglePassReportable(), increaseTestPass(), and saveToDb().

+ Here is the caller graph for this function:

◆ getLastSequence()

ilTestSession::getLastSequence ( )

Definition at line 352 of file class.ilTestSession.php.

352 : int
353 {
354 return $this->lastsequence;
355 }

References $lastsequence.

Referenced by ilTestSessionDynamicQuestionSet\getCurrentQuestionId(), ilTestSequence\hasStarted(), increaseTestPass(), saveToDb(), and ilTestSessionDynamicQuestionSet\saveToDb().

+ Here is the caller graph for this function:

◆ getLastStartedPass()

ilTestSession::getLastStartedPass ( )
Returns
int

Definition at line 415 of file class.ilTestSession.php.

415 : ?int
416 {
418 }

References $lastStartedPass.

Referenced by increaseTestPass().

+ Here is the caller graph for this function:

◆ getObjectiveOrientedContainerId()

ilTestSession::getObjectiveOrientedContainerId ( )

Definition at line 407 of file class.ilTestSession.php.

407 : int
408 {
410 }

References $objectiveOrientedContainerId.

Referenced by ilLOTestQuestionAdapter\getInstance(), increaseTestPass(), isObjectiveOriented(), ilLOTestQuestionAdapter\notifyTestStart(), and saveToDb().

+ Here is the caller graph for this function:

◆ getPass()

ilTestSession::getPass ( )

Definition at line 362 of file class.ilTestSession.php.

362 : int
363 {
364 return $this->pass;
365 }

References $pass.

Referenced by increaseTestPass(), saveToDb(), ilTestSessionDynamicQuestionSet\saveToDb(), and ilTestRandomQuestionSetBuilder\storeQuestion().

+ Here is the caller graph for this function:

◆ getRefId()

ilTestSession::getRefId ( )

◆ getSubmittedTimestamp()

ilTestSession::getSubmittedTimestamp ( )

Definition at line 382 of file class.ilTestSession.php.

382 : ?string
383 {
385 }

References $submittedTimestamp.

Referenced by increaseTestPass(), saveToDb(), and ilTestSessionDynamicQuestionSet\saveToDb().

+ Here is the caller graph for this function:

◆ getTestId()

ilTestSession::getTestId ( )

Definition at line 325 of file class.ilTestSession.php.

325 : int
326 {
327 return $this->test_id;
328 }

References $test_id.

Referenced by doesAccessCodeInSessionExists(), getAccessCodeFromSession(), isAccessCodeUsed(), saveToDb(), ilTestSessionDynamicQuestionSet\saveToDb(), setAccessCodeToSession(), and unsetAccessCodeInSession().

+ Here is the caller graph for this function:

◆ getUserId()

ilTestSession::getUserId ( )

Definition at line 315 of file class.ilTestSession.php.

315 : int
316 {
317 return $this->user_id;
318 }

References $user_id.

Referenced by ilLOTestQuestionAdapter\getInstance(), isAnonymousUser(), ilLOTestQuestionAdapter\notifyTestStart(), saveToDb(), and ilTestSessionDynamicQuestionSet\saveToDb().

+ Here is the caller graph for this function:

◆ hasSinglePassReportable()

ilTestSession::hasSinglePassReportable ( ilObjTest  $testObj)
Returns
bool

Definition at line 597 of file class.ilTestSession.php.

597 : bool
598 {
599 global $DIC; /* @var ILIAS\DI\Container $DIC */
600
601 require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
602 $testPassesSelector = new ilTestPassesSelector($DIC->database(), $testObj);
603 $testPassesSelector->setActiveId($this->getActiveId());
604 $testPassesSelector->setLastFinishedPass($this->getLastFinishedPass());
605
606 if (count($testPassesSelector->getReportablePasses()) == 1) {
607 return true;
608 }
609
610 return false;
611 }

References $DIC, getActiveId(), and getLastFinishedPass().

+ Here is the call graph for this function:

◆ increasePass()

ilTestSession::increasePass ( )

Definition at line 367 of file class.ilTestSession.php.

368 {
369 $this->pass += 1;
370 }

Referenced by increaseTestPass().

+ Here is the caller graph for this function:

◆ increaseTestPass()

ilTestSession::increaseTestPass ( )

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

122 : void
123 {
124 global $DIC;
125 $ilDB = $DIC['ilDB'];
126 $ilLog = $DIC['ilLog'];
127
128 if (!$this->active_id) {
129 require_once 'Modules/Test/exceptions/class.ilTestException.php';
130 throw new ilTestException('missing active id on test pass increase!');
131 }
132
133 $this->increasePass();
134 $this->setLastSequence(0);
135 $submitted = ($this->isSubmitted()) ? 1 : 0;
136 $active = ilSession::get($this->active_id);
137 if (!isset($active['tst_last_increase_pass']) || $active['tst_last_increase_pass'] !== null) {
138 $active['tst_last_increase_pass'] = 0;
139 //ilSession::set($this->active_id, $active);
140 //$_SESSION[$this->active_id]['tst_last_increase_pass'] = 0;
141 }
142
143 // there has to be at least 10 seconds between new test passes (to ensure that noone double clicks the finish button and increases the test pass by more than 1)
144 if (time() - $active['tst_last_increase_pass'] > 10) {
145 $active['tst_last_increase_pass'] = time();
146 //ilSession::set($this->active_id, $active);
147 $this->tstamp = time();
148 $ilDB->update(
149 'tst_active',
150 array(
151 'lastindex' => array('integer', $this->getLastSequence()),
152 'tries' => array('integer', $this->getPass()),
153 'submitted' => array('integer', $submitted),
154 'submittimestamp' => array('timestamp', strlen($this->getSubmittedTimestamp()) ? $this->getSubmittedTimestamp() : null),
155 'tstamp' => array('integer', time()),
156 'last_finished_pass' => array('integer', $this->getLastFinishedPass()),
157 'last_started_pass' => array('integer', $this->getLastStartedPass()),
158 'objective_container' => array('integer', $this->getObjectiveOrientedContainerId())
159 ),
160 array(
161 'active_id' => array('integer', $this->getActiveId())
162 )
163 );
164 }
165 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLastSequence($lastsequence)

References $DIC, $ilDB, $submitted, ilSession\get(), getActiveId(), getLastFinishedPass(), getLastSequence(), getLastStartedPass(), getObjectiveOrientedContainerId(), getPass(), getSubmittedTimestamp(), increasePass(), isSubmitted(), and setLastSequence().

+ Here is the call graph for this function:

◆ isAccessCodeUsed()

ilTestSession::isAccessCodeUsed (   $code)

Definition at line 517 of file class.ilTestSession.php.

517 : bool
518 {
519 global $DIC;
520 $ilDB = $DIC['ilDB'];
521
522 $query = "SELECT anonymous_id FROM tst_active WHERE test_fi = %s AND anonymous_id = %s";
523
524 $result = $ilDB->queryF(
525 $query,
526 array('integer', 'text'),
527 array($this->getTestId(), $code)
528 );
529
530 return ($result->numRows() > 0);
531 }
$query

References $DIC, $ilDB, $query, and getTestId().

Referenced by createNewAccessCode().

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

◆ isAnonymousUser()

ilTestSession::isAnonymousUser ( )

Definition at line 550 of file class.ilTestSession.php.

550 : bool
551 {
552 return $this->getUserId() == ANONYMOUS_USER_ID;
553 }

References ANONYMOUS_USER_ID, and getUserId().

+ Here is the call graph for this function:

◆ isObjectiveOriented()

ilTestSession::isObjectiveOriented ( )

Definition at line 428 of file class.ilTestSession.php.

428 : bool
429 {
430 return (bool) $this->getObjectiveOrientedContainerId();
431 }

References getObjectiveOrientedContainerId().

+ Here is the call graph for this function:

◆ isPasswordChecked()

ilTestSession::isPasswordChecked ( )

Definition at line 555 of file class.ilTestSession.php.

555 : bool
556 {
557 if (ilSession::get('pw_checked_' . $this->active_id) === null) {
558 return false;
559 }
560 return ilSession::get('pw_checked_' . $this->active_id);
561 }

References ilSession\get().

+ Here is the call graph for this function:

◆ isSubmitted()

ilTestSession::isSubmitted ( )

Definition at line 372 of file class.ilTestSession.php.

372 : bool
373 {
374 return $this->submitted;
375 }

References $submitted.

Referenced by increaseTestPass(), saveToDb(), and ilTestSessionDynamicQuestionSet\saveToDb().

+ Here is the caller graph for this function:

◆ loadFromDb()

ilTestSession::loadFromDb (   $active_id)

Loads the session data for a given active id.

Parameters
integer$active_idThe database id of the test session

Reimplemented in ilTestSessionDynamicQuestionSet.

Definition at line 278 of file class.ilTestSession.php.

279 {
280 global $DIC;
281 $ilDB = $DIC['ilDB'];
282 $result = $ilDB->queryF(
283 "SELECT * FROM tst_active WHERE active_id = %s",
284 array('integer'),
285 array($active_id)
286 );
287 if ($result->numRows()) {
288 $row = $ilDB->fetchAssoc($result);
289 $this->active_id = $row["active_id"];
290 $this->user_id = $row["user_fi"];
291 $this->anonymous_id = $row["anonymous_id"];
292 $this->test_id = $row["test_fi"];
293 $this->lastsequence = $row["lastindex"];
294 $this->pass = $row["tries"];
295 $this->submitted = ($row["submitted"]) ? true : false;
296 $this->submittedTimestamp = $row["submittimestamp"];
297 $this->tstamp = $row["tstamp"];
298
299 $this->setLastStartedPass($row['last_started_pass']);
300 $this->setLastFinishedPass($row['last_finished_pass']);
301 $this->setObjectiveOrientedContainerId((int) $row['objective_container']);
302 }
303 }

References $active_id, $DIC, $ilDB, setLastFinishedPass(), setLastStartedPass(), and setObjectiveOrientedContainerId().

+ Here is the call graph for this function:

◆ loadTestSession()

ilTestSession::loadTestSession (   $test_id,
  $user_id = "",
  $anonymous_id = "" 
)

Reimplemented in ilTestSessionDynamicQuestionSet.

Definition at line 218 of file class.ilTestSession.php.

218 : void
219 {
220 global $DIC;
221 $ilDB = $DIC['ilDB'];
222 $ilUser = $DIC['ilUser'];
223
224 if (!$user_id) {
225 $user_id = $ilUser->getId();
226 }
227 if (($GLOBALS['DIC']['ilUser']->getId() == ANONYMOUS_USER_ID) && $this->doesAccessCodeInSessionExists()) {
228 $result = $ilDB->queryF(
229 "SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
230 array('integer','integer','text'),
232 );
233 } elseif (strlen($anonymous_id)) {
234 $result = $ilDB->queryF(
235 "SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
236 array('integer','integer','text'),
238 );
239 } else {
240 if ($GLOBALS['DIC']['ilUser']->getId() == ANONYMOUS_USER_ID) {
241 return;
242 }
243 $result = $ilDB->queryF(
244 "SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s",
245 array('integer','integer'),
246 array($user_id, $test_id)
247 );
248 }
249
250 // TODO bheyser: Refactor
251 $this->user_id = $user_id;
252
253 if ($result->numRows()) {
254 $row = $ilDB->fetchAssoc($result);
255 $this->active_id = $row["active_id"];
256 $this->user_id = $row["user_fi"];
257 $this->anonymous_id = $row["anonymous_id"];
258 $this->test_id = $row["test_fi"];
259 $this->lastsequence = $row["lastindex"];
260 $this->pass = $row["tries"];
261 $this->submitted = ($row["submitted"]) ? true : false;
262 $this->submittedTimestamp = $row["submittimestamp"];
263 $this->tstamp = $row["tstamp"];
264
265 $this->setLastStartedPass($row['last_started_pass']);
266 $this->setLastFinishedPass($row['last_finished_pass']);
267 $this->setObjectiveOrientedContainerId((int) $row['objective_container']);
268 } elseif ($this->doesAccessCodeInSessionExists()) {
270 }
271 }
$ilUser
Definition: imgupload.php:34

References $anonymous_id, $DIC, $GLOBALS, $ilDB, $ilUser, $test_id, $user_id, ANONYMOUS_USER_ID, doesAccessCodeInSessionExists(), getAccessCodeFromSession(), ILIAS\Survey\Mode\getId(), setLastFinishedPass(), setLastStartedPass(), setObjectiveOrientedContainerId(), and unsetAccessCodeInSession().

+ Here is the call graph for this function:

◆ lookupTestStartLock()

ilTestSession::lookupTestStartLock ( )

Definition at line 445 of file class.ilTestSession.php.

446 {
447 global $DIC;
448 $ilDB = $DIC['ilDB'];
449
450 $res = $ilDB->queryF(
451 "SELECT start_lock FROM tst_active WHERE active_id = %s",
452 array('integer'),
453 array($this->getActiveId())
454 );
455
456 while ($row = $ilDB->fetchAssoc($res)) {
457 return $row['start_lock'];
458 }
459
460 return null;
461 }
$res
Definition: ltiservices.php:69

References $DIC, $ilDB, $res, and getActiveId().

+ Here is the call graph for this function:

◆ persistTestStartLock()

ilTestSession::persistTestStartLock (   $testStartLock)

Definition at line 433 of file class.ilTestSession.php.

434 {
435 global $DIC;
436 $ilDB = $DIC['ilDB'];
437
438 $ilDB->update(
439 'tst_active',
440 array('start_lock' => array('text', $testStartLock)),
441 array('active_id' => array('integer', $this->getActiveId()))
442 );
443 }

References $DIC, $ilDB, and getActiveId().

+ Here is the call graph for this function:

◆ reportableResultsAvailable()

ilTestSession::reportableResultsAvailable ( ilObjTest  $testOBJ)
Parameters
ilObjTest$testOBJ
Returns
bool

Definition at line 577 of file class.ilTestSession.php.

577 : ?bool
578 {
579 if ($this->reportableResultsAvailable === null) {
580 $this->reportableResultsAvailable = true;
581
582 if (!$this->getActiveId()) {
583 $this->reportableResultsAvailable = false;
584 }
585
586 if (!$testOBJ->canShowTestResults($this)) {
587 $this->reportableResultsAvailable = false;
588 }
589 }
590
592 }
canShowTestResults(ilTestSession $testSession)
reportableResultsAvailable(ilObjTest $testOBJ)

References $reportableResultsAvailable, ilObjTest\canShowTestResults(), getActiveId(), and reportableResultsAvailable().

Referenced by reportableResultsAvailable().

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

◆ saveToDb()

ilTestSession::saveToDb ( )

Reimplemented in ilTestSessionDynamicQuestionSet.

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

167 : void
168 {
169 global $DIC;
170 $ilDB = $DIC['ilDB'];
171 $ilLog = $DIC['ilLog'];
172
173 $submitted = ($this->isSubmitted()) ? 1 : 0;
174 if ($this->active_id > 0) {
175 $ilDB->update(
176 'tst_active',
177 array(
178 'lastindex' => array('integer', $this->getLastSequence()),
179 'tries' => array('integer', $this->getPass()),
180 'submitted' => array('integer', $submitted),
181 'submittimestamp' => array('timestamp', (strlen($this->getSubmittedTimestamp())) ? $this->getSubmittedTimestamp() : null),
182 'tstamp' => array('integer', time() - 10),
183 'last_finished_pass' => array('integer', $this->getLastFinishedPass()),
184 'last_started_pass' => array('integer', $this->getPass()),
185 'objective_container' => array('integer', $this->getObjectiveOrientedContainerId())
186 ),
187 array(
188 'active_id' => array('integer', $this->getActiveId())
189 )
190 );
191 } else {
192 if (!$this->activeIDExists($this->getUserId(), $this->getTestId())) {
193 $anonymous_id = $this->getAnonymousId() ?: null;
194
195 $next_id = $ilDB->nextId('tst_active');
196 $ilDB->insert(
197 'tst_active',
198 array(
199 'active_id' => array('integer', $next_id),
200 'user_fi' => array('integer', $this->getUserId()),
201 'anonymous_id' => array('text', $anonymous_id),
202 'test_fi' => array('integer', $this->getTestId()),
203 'lastindex' => array('integer', $this->getLastSequence()),
204 'tries' => array('integer', $this->getPass()),
205 'submitted' => array('integer', $submitted),
206 'submittimestamp' => array('timestamp', (strlen($this->getSubmittedTimestamp())) ? $this->getSubmittedTimestamp() : null),
207 'tstamp' => array('integer', time() - 10),
208 'last_finished_pass' => array('integer', $this->getLastFinishedPass()),
209 'last_started_pass' => array('integer', $this->getPass()),
210 'objective_container' => array('integer', $this->getObjectiveOrientedContainerId())
211 )
212 );
213 $this->active_id = $next_id;
214 }
215 }
216 }
activeIDExists($user_id, $test_id)

References $anonymous_id, $DIC, $ilDB, $submitted, activeIDExists(), getActiveId(), getAnonymousId(), getLastFinishedPass(), getLastSequence(), getObjectiveOrientedContainerId(), getPass(), getSubmittedTimestamp(), getTestId(), getUserId(), and isSubmitted().

+ Here is the call graph for this function:

◆ setAccessCodeToSession()

ilTestSession::setAccessCodeToSession (   $access_code)

Definition at line 463 of file class.ilTestSession.php.

464 {
465 if (!is_array(ilSession::get(self::ACCESS_CODE_SESSION_INDEX))) {
466 ilSession::set(self::ACCESS_CODE_SESSION_INDEX, array());
467 }
468 $session_code = ilSession::get(self::ACCESS_CODE_SESSION_INDEX);
469 $session_code[$this->getTestId()] = $access_code;
470 ilSession::set(self::ACCESS_CODE_SESSION_INDEX, $session_code);
471 //$_SESSION[self::ACCESS_CODE_SESSION_INDEX][$this->getTestId()] = $access_code;
472 }
static set(string $a_var, $a_val)
Set a value.

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

+ Here is the call graph for this function:

◆ setAnonymousId()

ilTestSession::setAnonymousId (   $anonymous_id)
Parameters
int | null | string$anonymous_id
Returns
void

Definition at line 334 of file class.ilTestSession.php.

334 : void
335 {
336 $this->anonymous_id = $anonymous_id;
337 }

References $anonymous_id.

◆ setLastFinishedPass()

ilTestSession::setLastFinishedPass (   $lastFinishedPass)

Definition at line 392 of file class.ilTestSession.php.

393 {
394 $this->lastFinishedPass = $lastFinishedPass;
395 }

References $lastFinishedPass.

Referenced by activeIDExists(), loadFromDb(), and loadTestSession().

+ Here is the caller graph for this function:

◆ setLastSequence()

ilTestSession::setLastSequence (   $lastsequence)

Definition at line 347 of file class.ilTestSession.php.

348 {
349 $this->lastsequence = $lastsequence;
350 }

References $lastsequence.

Referenced by increaseTestPass(), and ilTestSessionDynamicQuestionSet\setCurrentQuestionId().

+ Here is the caller graph for this function:

◆ setLastStartedPass()

ilTestSession::setLastStartedPass (   $lastStartedPass)
Parameters
int$lastStartedPass

Definition at line 423 of file class.ilTestSession.php.

424 {
425 $this->lastStartedPass = $lastStartedPass;
426 }

References $lastStartedPass.

Referenced by activeIDExists(), loadFromDb(), and loadTestSession().

+ Here is the caller graph for this function:

◆ setObjectiveOrientedContainerId()

ilTestSession::setObjectiveOrientedContainerId (   $objectiveOriented)

Definition at line 402 of file class.ilTestSession.php.

403 {
404 $this->objectiveOrientedContainerId = $objectiveOriented;
405 }

Referenced by activeIDExists(), loadFromDb(), and loadTestSession().

+ Here is the caller graph for this function:

◆ setPass()

ilTestSession::setPass (   $pass)

Definition at line 357 of file class.ilTestSession.php.

358 {
359 $this->pass = $pass;
360 }

References $pass.

◆ setPasswordChecked()

ilTestSession::setPasswordChecked ( bool  $value)

Definition at line 563 of file class.ilTestSession.php.

563 : void
564 {
565 ilSession::set('pw_checked_' . $this->active_id, $value);
566 }

References ilSession\set().

+ Here is the call graph for this function:

◆ setRefId()

ilTestSession::setRefId ( int  $a_val)

Definition at line 79 of file class.ilTestSession.php.

79 : void
80 {
81 $this->ref_id = $a_val;
82 }

◆ setSubmitted()

ilTestSession::setSubmitted ( )

Definition at line 377 of file class.ilTestSession.php.

378 {
379 $this->submitted = true;
380 }

◆ setSubmittedTimestamp()

ilTestSession::setSubmittedTimestamp ( )

Definition at line 387 of file class.ilTestSession.php.

388 {
389 $this->submittedTimestamp = date('Y-m-d H:i:s');
390 }

◆ setTestId()

ilTestSession::setTestId (   $test_id)

Definition at line 320 of file class.ilTestSession.php.

320 : void
321 {
322 $this->test_id = $test_id;
323 }

References $test_id.

◆ setUserId()

ilTestSession::setUserId (   $user_id)

Definition at line 310 of file class.ilTestSession.php.

310 : void
311 {
312 $this->user_id = $user_id;
313 }

References $user_id.

◆ unsetAccessCodeInSession()

ilTestSession::unsetAccessCodeInSession ( )

Definition at line 474 of file class.ilTestSession.php.

475 {
476 $session_code = ilSession::get(self::ACCESS_CODE_SESSION_INDEX);
477 unset($session_code[$this->getTestId()]);
478 ilSession::set(self::ACCESS_CODE_SESSION_INDEX, $session_code);
479 //unset($_SESSION[self::ACCESS_CODE_SESSION_INDEX][$this->getTestId()]);
480 }

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

Referenced by loadTestSession(), and ilTestSessionDynamicQuestionSet\loadTestSession().

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

Field Documentation

◆ $active_id

int ilTestSession::$active_id

◆ $anonymous_id

◆ $lastFinishedPass

ilTestSession::$lastFinishedPass
private

Definition at line 48 of file class.ilTestSession.php.

Referenced by getLastFinishedPass(), and setLastFinishedPass().

◆ $lastPresentationMode

string ilTestSession::$lastPresentationMode
protected

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

◆ $lastsequence

int ilTestSession::$lastsequence

Definition at line 41 of file class.ilTestSession.php.

Referenced by getLastSequence(), and setLastSequence().

◆ $lastStartedPass

ilTestSession::$lastStartedPass
private

Definition at line 49 of file class.ilTestSession.php.

Referenced by getLastStartedPass(), and setLastStartedPass().

◆ $objectiveOrientedContainerId

int ilTestSession::$objectiveOrientedContainerId
private

Definition at line 46 of file class.ilTestSession.php.

Referenced by getObjectiveOrientedContainerId().

◆ $pass

int ilTestSession::$pass
private

Definition at line 35 of file class.ilTestSession.php.

Referenced by getPass(), and setPass().

◆ $ref_id

int ilTestSession::$ref_id
private

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

Referenced by getRefId().

◆ $reportableResultsAvailable

ilTestSession::$reportableResultsAvailable = null
private

Definition at line 571 of file class.ilTestSession.php.

Referenced by reportableResultsAvailable().

◆ $submitted

bool ilTestSession::$submitted

◆ $submittedTimestamp

string ilTestSession::$submittedTimestamp

Definition at line 45 of file class.ilTestSession.php.

Referenced by getSubmittedTimestamp().

◆ $test_id

int ilTestSession::$test_id

◆ $tstamp

int ilTestSession::$tstamp

Definition at line 44 of file class.ilTestSession.php.

◆ $user_id

int ilTestSession::$user_id

◆ ACCESS_CODE_CHAR_DOMAIN

const ilTestSession::ACCESS_CODE_CHAR_DOMAIN = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

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

Referenced by buildAccessCode().

◆ ACCESS_CODE_LENGTH

const ilTestSession::ACCESS_CODE_LENGTH = 5

Definition at line 32 of file class.ilTestSession.php.

Referenced by buildAccessCode().

◆ ACCESS_CODE_SESSION_INDEX


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