ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTestSession Class Reference

Test session handler. More...

+ Collaboration diagram for ilTestSession:

Public Member Functions

 ilTestSession ($active_id="")
 ilTestSession constructor
 setRefId ($a_val)
 Set Ref id.
 getRefId ()
 Get Ref id.
 increaseTestPass ()
 saveToDb ()
 loadTestSession ($test_id, $user_id="", $anonymous_id="")
 getActiveId ()
 setUserId ($user_id)
 getUserId ()
 setTestId ($test_id)
 getTestId ()
 setAnonymousId ($anonymous_id)
 getAnonymousId ()
 setLastSequence ($lastsequence)
 getLastSequence ()
 setPass ($pass)
 getPass ()
 increasePass ()
 isSubmitted ()
 setSubmitted ()
 getSubmittedTimestamp ()
 setSubmittedTimestamp ()

Data Fields

 $active_id
 $user_id
 $anonymous_id
 $test_id
 $lastsequence
 $submitted
 $tstamp
 $submittedTimestamp

Private Member Functions

 activeIDExists ($user_id, $test_id)
 loadFromDb ($active_id)
 Loads the session data for a given active id.

Detailed Description

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:
class.ilTestSession.php 29346 2011-05-31 08:07:54Z hschottm

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

Member Function Documentation

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

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

References $_SESSION, $ilDB, $result, $row, $test_id, and $user_id.

Referenced by increaseTestPass(), and saveToDb().

{
global $ilDB;
if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID)
{
$result = $ilDB->queryF("SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s",
array('integer','integer'),
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
$this->active_id = $row["active_id"];
$this->active_id = $row["active_id"];
$this->user_id = $row["user_fi"];
$this->anonymous_id = $row["anonymous_id"];
$this->test_id = $row["test_fi"];
$this->lastsequence = $row["lastindex"];
$this->pass = $row["tries"];
$this->submitted = ($row["submitted"]) ? TRUE : FALSE;
$this->submittedTimestamp = $row["submittimestamp"];
$this->tstamp = $row["tstamp"];
return true;
}
}
return false;
}

+ Here is the caller graph for this function:

ilTestSession::getActiveId ( )

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

References $active_id.

Referenced by increaseTestPass(), and saveToDb().

{
}

+ Here is the caller graph for this function:

ilTestSession::getAnonymousId ( )

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

References $anonymous_id.

Referenced by increaseTestPass(), and saveToDb().

{
}

+ Here is the caller graph for this function:

ilTestSession::getLastSequence ( )

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

References $lastsequence.

Referenced by increaseTestPass(), and saveToDb().

{
}

+ Here is the caller graph for this function:

ilTestSession::getPass ( )

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

References $pass.

Referenced by increaseTestPass(), and saveToDb().

{
return $this->pass;
}

+ Here is the caller graph for this function:

ilTestSession::getRefId ( )

Get Ref id.

Returns
integer Ref id

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

References $ref_id.

Referenced by saveToDb().

{
return $this->ref_id;
}

+ Here is the caller graph for this function:

ilTestSession::getSubmittedTimestamp ( )

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

References $submittedTimestamp.

Referenced by increaseTestPass(), and saveToDb().

+ Here is the caller graph for this function:

ilTestSession::getTestId ( )

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

References $test_id.

Referenced by increaseTestPass(), and saveToDb().

{
}

+ Here is the caller graph for this function:

ilTestSession::getUserId ( )

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

References $user_id.

Referenced by increaseTestPass(), and saveToDb().

{
}

+ Here is the caller graph for this function:

ilTestSession::ilTestSession (   $active_id = "")

ilTestSession constructor

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

public

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

References $active_id, and loadFromDb().

{
$this->active_id = 0;
$this->user_id = 0;
$this->anonymous_id = 0;
$this->test_id = 0;
$this->lastsequence = 0;
$this->submitted = FALSE;
$this->submittedTimestamp = "";
$this->pass = 0;
$this->ref_id = 0;
$this->tstamp = 0;
if ($active_id > 0)
{
}
}

+ Here is the call graph for this function:

ilTestSession::increasePass ( )

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

Referenced by increaseTestPass().

{
$this->pass += 1;
}

+ Here is the caller graph for this function:

ilTestSession::increaseTestPass ( )

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

References $_SESSION, $anonymous_id, $ilDB, $ilLog, $submitted, ilObjTestAccess\_getParticipantId(), ilObjTestAccess\_lookupObjIdForTestId(), ilLPStatusWrapper\_updateStatus(), activeIDExists(), getActiveId(), getAnonymousId(), getLastSequence(), getPass(), getSubmittedTimestamp(), getTestId(), getUserId(), increasePass(), isSubmitted(), and setLastSequence().

{
global $ilDB, $ilLog;
$this->increasePass();
$this->setLastSequence(0);
$submitted = ($this->isSubmitted()) ? 1 : 0;
// 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)
if (time() - $_SESSION['tst_last_increase_pass'] > 10)
{
$_SESSION['tst_last_increase_pass'] = time();
$this->tstamp = time();
if ($this->active_id > 0)
{
$affectedRows = $ilDB->manipulateF("UPDATE tst_active SET lastindex = %s, tries = %s, submitted = %s, submittimestamp = %s, tstamp = %s WHERE active_id = %s",
array('integer', 'integer', 'integer', 'timestamp', 'integer', 'integer'),
array(
$this->getLastSequence(),
$this->getPass(),
(strlen($this->getSubmittedTimestamp())) ? $this->getSubmittedTimestamp() : NULL,
time(),
$this->getActiveId()
)
);
// update learning progress
include_once("./Modules/Test/classes/class.ilObjTestAccess.php");
include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
}
else
{
if (!$this->activeIDExists($this->getUserId(), $this->getTestId()))
{
$anonymous_id = ($this->getAnonymousId()) ? $this->getAnonymousId() : NULL;
$next_id = $ilDB->nextId('tst_active');
$affectedRows = $ilDB->manipulateF("INSERT INTO tst_active (active_id, user_fi, anonymous_id, test_fi, lastindex, tries, submitted, submittimestamp, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
array('integer', 'integer', 'text', 'integer', 'integer', 'integer', 'integer', 'timestamp', 'integer'),
array(
$next_id,
$this->getUserId(),
$this->getTestId(),
$this->getLastSequence(),
$this->getPass(),
(strlen($this->getSubmittedTimestamp())) ? $this->getSubmittedTimestamp() : NULL,
time()
)
);
$this->active_id = $next_id;
// update learning progress
include_once("./Modules/Test/classes/class.ilObjTestAccess.php");
include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
$this->getUserId());
}
}
}
}

+ Here is the call graph for this function:

ilTestSession::isSubmitted ( )

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

References $submitted.

Referenced by increaseTestPass(), and saveToDb().

{
}

+ Here is the caller graph for this function:

ilTestSession::loadFromDb (   $active_id)
private

Loads the session data for a given active id.

Parameters
integer$active_idThe database id of the test session private

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

References $active_id, $ilDB, $result, and $row.

Referenced by ilTestSession().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM tst_active WHERE active_id = %s",
array('integer'),
array($active_id)
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
$this->active_id = $row["active_id"];
$this->user_id = $row["user_fi"];
$this->anonymous_id = $row["anonymous_id"];
$this->test_id = $row["test_fi"];
$this->lastsequence = $row["lastindex"];
$this->pass = $row["tries"];
$this->submitted = ($row["submitted"]) ? TRUE : FALSE;
$this->submittedTimestamp = $row["submittimestamp"];
$this->tstamp = $row["tstamp"];
}
}

+ Here is the caller graph for this function:

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

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

References $_SESSION, $anonymous_id, $ilDB, $result, $row, $test_id, and $user_id.

{
global $ilDB;
global $ilUser;
if (!$user_id)
{
$user_id = $ilUser->getId();
}
if (($_SESSION["AccountId"] == ANONYMOUS_USER_ID) && (strlen($_SESSION["tst_access_code"][$test_id])))
{
$result = $ilDB->queryF("SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
array('integer','integer','text'),
array($user_id, $test_id, $_SESSION["tst_access_code"][$test_id])
);
}
else if (strlen($anonymous_id))
{
$result = $ilDB->queryF("SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
array('integer','integer','text'),
array($user_id, $test_id, $anonymous_id)
);
}
else
{
if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
{
return NULL;
}
$result = $ilDB->queryF("SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s",
array('integer','integer'),
array($user_id, $test_id)
);
}
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
$this->active_id = $row["active_id"];
$this->user_id = $row["user_fi"];
$this->anonymous_id = $row["anonymous_id"];
$this->test_id = $row["test_fi"];
$this->lastsequence = $row["lastindex"];
$this->pass = $row["tries"];
$this->submitted = ($row["submitted"]) ? TRUE : FALSE;
$this->submittedTimestamp = $row["submittimestamp"];
$this->tstamp = $row["tstamp"];
}
}
ilTestSession::saveToDb ( )

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

References $anonymous_id, $ilDB, $ilLog, $submitted, ilObjTestAccess\_getParticipantId(), ilObjTestAccess\_lookupObjIdForTestId(), ilLearningProgress\_tracProgress(), ilLPStatusWrapper\_updateStatus(), activeIDExists(), getActiveId(), getAnonymousId(), getLastSequence(), getPass(), getRefId(), getSubmittedTimestamp(), getTestId(), getUserId(), and isSubmitted().

{
global $ilDB, $ilLog;
$submitted = ($this->isSubmitted()) ? 1 : 0;
if ($this->active_id > 0)
{
$affectedRows = $ilDB->manipulateF("UPDATE tst_active SET lastindex = %s, tries = %s, submitted = %s, submittimestamp = %s, tstamp = %s WHERE active_id = %s",
array('integer', 'integer', 'integer', 'timestamp', 'integer', 'integer'),
array(
$this->getLastSequence(),
$this->getPass(),
(strlen($this->getSubmittedTimestamp())) ? $this->getSubmittedTimestamp() : NULL,
time()-10,
$this->getActiveId()
)
);
// update learning progress
include_once("./Modules/Test/classes/class.ilObjTestAccess.php");
include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
}
else
{
if (!$this->activeIDExists($this->getUserId(), $this->getTestId()))
{
$anonymous_id = ($this->getAnonymousId()) ? $this->getAnonymousId() : NULL;
$next_id = $ilDB->nextId('tst_active');
$affectedRows = $ilDB->manipulateF("INSERT INTO tst_active (active_id, user_fi, anonymous_id, test_fi, lastindex, tries, submitted, submittimestamp, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
array('integer', 'integer', 'text', 'integer', 'integer', 'integer', 'integer', 'timestamp', 'integer'),
array(
$next_id,
$this->getUserId(),
$this->getTestId(),
$this->getLastSequence(),
$this->getPass(),
(strlen($this->getSubmittedTimestamp())) ? $this->getSubmittedTimestamp() : NULL,
time()-10
)
);
$this->active_id = $next_id;
// update learning progress
include_once("./Modules/Test/classes/class.ilObjTestAccess.php");
include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
$this->getUserId());
}
}
include_once("./Services/Tracking/classes/class.ilLearningProgress.php");
$this->getRefId(),
'tst');
}

+ Here is the call graph for this function:

ilTestSession::setAnonymousId (   $anonymous_id)

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

References $anonymous_id.

{
$this->anonymous_id = $anonymous_id;
}
ilTestSession::setLastSequence (   $lastsequence)

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

References $lastsequence.

Referenced by increaseTestPass().

{
$this->lastsequence = $lastsequence;
}

+ Here is the caller graph for this function:

ilTestSession::setPass (   $pass)

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

References $pass.

{
$this->pass = $pass;
}
ilTestSession::setRefId (   $a_val)

Set Ref id.

Parameters
integerRef id

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

{
$this->ref_id = $a_val;
}
ilTestSession::setSubmitted ( )

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

{
$this->submitted = TRUE;
}
ilTestSession::setSubmittedTimestamp ( )

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

{
$this->submittedTimestamp = strftime("%Y-%m-%d %H:%M:%S");
}
ilTestSession::setTestId (   $test_id)

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

References $test_id.

{
$this->test_id = $test_id;
}
ilTestSession::setUserId (   $user_id)

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

References $user_id.

{
$this->user_id = $user_id;
}

Field Documentation

ilTestSession::$active_id

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

Referenced by getActiveId(), ilTestSession(), and loadFromDb().

ilTestSession::$anonymous_id
ilTestSession::$lastsequence

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

Referenced by getLastSequence(), and setLastSequence().

ilTestSession::$submitted

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

Referenced by increaseTestPass(), isSubmitted(), and saveToDb().

ilTestSession::$submittedTimestamp

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

Referenced by getSubmittedTimestamp().

ilTestSession::$test_id

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

Referenced by activeIDExists(), getTestId(), loadTestSession(), and setTestId().

ilTestSession::$tstamp

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

ilTestSession::$user_id

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

Referenced by activeIDExists(), getUserId(), loadTestSession(), and setUserId().


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