ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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.

public

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.

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

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

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  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
setObjectiveOrientedContainerId($objectiveOriented)
global $DIC
Definition: feed.php:28
setLastFinishedPass($lastFinishedPass)
setLastStartedPass($lastStartedPass)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
+ 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.

References $i, and $index.

Referenced by createNewAccessCode().

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

◆ createNewAccessCode()

ilTestSession::createNewAccessCode ( )

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

References buildAccessCode(), and isAccessCodeUsed().

508  : string
509  {
510  do {
511  $code = $this->buildAccessCode();
512  } while ($this->isAccessCodeUsed($code));
513 
514  return $code;
515  }
+ Here is the call graph for this function:

◆ doesAccessCodeInSessionExists()

ilTestSession::doesAccessCodeInSessionExists ( )

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

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

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

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

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

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

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  }
static get(string $a_var)
+ 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.

References $anonymous_id.

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

343  {
344  return $this->anonymous_id;
345  }
+ Here is the caller graph for this function:

◆ getLastFinishedPass()

ilTestSession::getLastFinishedPass ( )

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

References $lastFinishedPass.

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

398  {
400  }
+ Here is the caller graph for this function:

◆ getLastSequence()

ilTestSession::getLastSequence ( )

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

References $lastsequence.

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

352  : int
353  {
354  return $this->lastsequence;
355  }
+ Here is the caller graph for this function:

◆ getLastStartedPass()

ilTestSession::getLastStartedPass ( )
Returns
int

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

References $lastStartedPass.

Referenced by increaseTestPass().

415  : ?int
416  {
417  return $this->lastStartedPass;
418  }
+ Here is the caller graph for this function:

◆ getObjectiveOrientedContainerId()

ilTestSession::getObjectiveOrientedContainerId ( )

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

References $objectiveOrientedContainerId.

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

407  : int
408  {
410  }
+ Here is the caller graph for this function:

◆ getPass()

ilTestSession::getPass ( )

◆ getRefId()

◆ getSubmittedTimestamp()

ilTestSession::getSubmittedTimestamp ( )

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

References $submittedTimestamp.

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

382  : ?string
383  {
385  }
+ Here is the caller graph for this function:

◆ getTestId()

ilTestSession::getTestId ( )

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

References $test_id.

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

325  : int
326  {
327  return $this->test_id;
328  }
+ Here is the caller graph for this function:

◆ getUserId()

◆ hasSinglePassReportable()

ilTestSession::hasSinglePassReportable ( ilObjTest  $testObj)
Returns
bool

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

References $DIC, getActiveId(), getLastFinishedPass(), and ilTestPassesSelector\setActiveId().

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  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ increasePass()

ilTestSession::increasePass ( )

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

Referenced by increaseTestPass().

368  {
369  $this->pass += 1;
370  }
+ Here is the caller graph for this function:

◆ increaseTestPass()

ilTestSession::increaseTestPass ( )

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

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

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  }
static get(string $a_var)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
setLastSequence($lastsequence)
+ Here is the call graph for this function:

◆ isAccessCodeUsed()

ilTestSession::isAccessCodeUsed (   $code)

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

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

Referenced by createNewAccessCode().

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  }
global $DIC
Definition: feed.php:28
$query
+ 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.

References ANONYMOUS_USER_ID, and getUserId().

Referenced by ilTestPlayerAbstractGUI\ensureExistingTestSession().

550  : bool
551  {
552  return $this->getUserId() == ANONYMOUS_USER_ID;
553  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isObjectiveOriented()

ilTestSession::isObjectiveOriented ( )

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

References getObjectiveOrientedContainerId().

428  : bool
429  {
430  return (bool) $this->getObjectiveOrientedContainerId();
431  }
+ Here is the call graph for this function:

◆ isPasswordChecked()

ilTestSession::isPasswordChecked ( )

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

References ilSession\get().

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  }
static get(string $a_var)
+ Here is the call graph for this function:

◆ isSubmitted()

ilTestSession::isSubmitted ( )

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

References $submitted.

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

372  : bool
373  {
374  return $this->submitted;
375  }
+ 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

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

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

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  }
setObjectiveOrientedContainerId($objectiveOriented)
global $DIC
Definition: feed.php:28
setLastFinishedPass($lastFinishedPass)
setLastStartedPass($lastStartedPass)
+ Here is the call graph for this function:

◆ loadTestSession()

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

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

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

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'),
231  array($user_id, $test_id, $this->getAccessCodeFromSession())
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()) {
269  $this->unsetAccessCodeInSession();
270  }
271  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
setObjectiveOrientedContainerId($objectiveOriented)
global $DIC
Definition: feed.php:28
setLastFinishedPass($lastFinishedPass)
setLastStartedPass($lastStartedPass)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:

◆ lookupTestStartLock()

ilTestSession::lookupTestStartLock ( )

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

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

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
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ persistTestStartLock()

ilTestSession::persistTestStartLock (   $testStartLock)

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

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

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  }
global $DIC
Definition: feed.php:28
+ 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.

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

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  }
reportableResultsAvailable(ilObjTest $testOBJ)
canShowTestResults(ilTestSession $testSession)
+ Here is the call graph for this function:

◆ saveToDb()

ilTestSession::saveToDb ( )

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

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

Referenced by ilTestPlayerAbstractGUI\ensureExistingTestSession().

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  }
global $DIC
Definition: feed.php:28
activeIDExists($user_id, $test_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAccessCodeToSession()

ilTestSession::setAccessCodeToSession (   $access_code)

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

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

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 get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
+ 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.

References $anonymous_id.

Referenced by ilTestPlayerAbstractGUI\ensureExistingTestSession().

334  : void
335  {
336  $this->anonymous_id = $anonymous_id;
337  }
+ Here is the caller graph for this function:

◆ setLastFinishedPass()

ilTestSession::setLastFinishedPass (   $lastFinishedPass)

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

References $lastFinishedPass.

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

393  {
394  $this->lastFinishedPass = $lastFinishedPass;
395  }
+ Here is the caller graph for this function:

◆ setLastSequence()

ilTestSession::setLastSequence (   $lastsequence)

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

References $lastsequence.

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

348  {
349  $this->lastsequence = $lastsequence;
350  }
+ Here is the caller graph for this function:

◆ setLastStartedPass()

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

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

References $lastStartedPass.

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

424  {
425  $this->lastStartedPass = $lastStartedPass;
426  }
+ Here is the caller graph for this function:

◆ setObjectiveOrientedContainerId()

ilTestSession::setObjectiveOrientedContainerId (   $objectiveOriented)

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

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

403  {
404  $this->objectiveOrientedContainerId = $objectiveOriented;
405  }
+ Here is the caller graph for this function:

◆ setPass()

ilTestSession::setPass (   $pass)

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

References $pass.

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

◆ setPasswordChecked()

ilTestSession::setPasswordChecked ( bool  $value)

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

References ilSession\set().

563  : void
564  {
565  ilSession::set('pw_checked_' . $this->active_id, $value);
566  }
static set(string $a_var, $a_val)
Set a value.
+ 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.

References $test_id.

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

◆ setUserId()

ilTestSession::setUserId (   $user_id)

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

References $user_id.

Referenced by ilTestPlayerAbstractGUI\ensureExistingTestSession().

310  : void
311  {
312  $this->user_id = $user_id;
313  }
+ Here is the caller graph for this function:

◆ unsetAccessCodeInSession()

ilTestSession::unsetAccessCodeInSession ( )

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

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

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

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

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.

◆ ACCESS_CODE_LENGTH

const ilTestSession::ACCESS_CODE_LENGTH = 5

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

◆ ACCESS_CODE_SESSION_INDEX


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