Test session handler. More...
Public Member Functions | |
| ilTestSession ($active_id="") | |
| ilTestSession constructor | |
| 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 | |
| $submittedTimestamp | |
Private Member Functions | |
| loadFromDb ($active_id) | |
| Loads the session data for a given active id. | |
Test session handler.
This class manages the test session for a participant
Definition at line 33 of file class.ilTestSession.php.
| ilTestSession::getActiveId | ( | ) |
Definition at line 236 of file class.ilTestSession.php.
Referenced by saveToDb().
{
return $this->active_id;
}
Here is the caller graph for this function:| ilTestSession::getAnonymousId | ( | ) |
Definition at line 266 of file class.ilTestSession.php.
Referenced by saveToDb().
{
return $this->anonymous_id;
}
Here is the caller graph for this function:| ilTestSession::getLastSequence | ( | ) |
Definition at line 276 of file class.ilTestSession.php.
{
return $this->lastsequence;
}
| ilTestSession::getPass | ( | ) |
Definition at line 286 of file class.ilTestSession.php.
{
return $this->pass;
}
| ilTestSession::getSubmittedTimestamp | ( | ) |
Definition at line 306 of file class.ilTestSession.php.
Referenced by saveToDb().
{
return $this->submittedTimestamp;
}
Here is the caller graph for this function:| ilTestSession::getTestId | ( | ) |
Definition at line 256 of file class.ilTestSession.php.
{
return $this->test_id;
}
| ilTestSession::getUserId | ( | ) |
Definition at line 246 of file class.ilTestSession.php.
{
return $this->user_id;
}
| ilTestSession::ilTestSession | ( | $ | active_id = "" |
) |
ilTestSession constructor
The constructor takes possible arguments an creates an instance of the ilTestSession object.
public
Definition at line 106 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;
if ($active_id > 0)
{
$this->loadFromDb($active_id);
}
}
Here is the call graph for this function:| ilTestSession::increasePass | ( | ) |
Definition at line 291 of file class.ilTestSession.php.
{
$this->pass += 1;
}
| ilTestSession::isSubmitted | ( | ) |
Definition at line 296 of file class.ilTestSession.php.
Referenced by saveToDb().
{
return $this->submitted;
}
Here is the caller graph for this function:| ilTestSession::loadFromDb | ( | $ | active_id | ) | [private] |
Loads the session data for a given active id.
Loads the session data for a given active id
| integer | $active_id The database id of the test session private |
Definition at line 215 of file class.ilTestSession.php.
References $active_id.
Referenced by ilTestSession().
{
global $ilDB;
$query = sprintf("SELECT * FROM tst_active WHERE active_id = %s",
$ilDB->quote($active_id . "")
);
$result = $ilDB->query($query);
if ($result->numRows())
{
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
$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"];
}
}
Here is the caller graph for this function:| ilTestSession::loadTestSession | ( | $ | test_id, | |
| $ | user_id = "", |
|||
| $ | anonymous_id = "" | |||
| ) |
Definition at line 156 of file class.ilTestSession.php.
References $_SESSION, $anonymous_id, $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])))
{
$query = sprintf("SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
$ilDB->quote($user_id),
$ilDB->quote($test_id),
$ilDB->quote($_SESSION["tst_access_code"][$test_id])
);
}
else if (strlen($anonymous_id))
{
$query = sprintf("SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
$ilDB->quote($user_id),
$ilDB->quote($test_id),
$ilDB->quote($anonymous_id)
);
}
else
{
if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
{
return NULL;
}
$query = sprintf("SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s",
$ilDB->quote($user_id),
$ilDB->quote($test_id)
);
}
$result = $ilDB->query($query);
if ($result->numRows())
{
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
$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"];
}
}
| ilTestSession::saveToDb | ( | ) |
Definition at line 122 of file class.ilTestSession.php.
References $anonymous_id, $ilLog, $submitted, $submittedTimestamp, getActiveId(), getAnonymousId(), getSubmittedTimestamp(), and isSubmitted().
{
global $ilDB, $ilLog;
$submitted = ($this->isSubmitted()) ? "1" : "0";
$submittedTimestamp = (strlen($this->getSubmittedTimestamp())) ? $ilDB->quote($this->getSubmittedTimestamp()) : "NULL";
if ($this->active_id > 0)
{
$query = sprintf("UPDATE tst_active SET lastindex = %s, tries = %s, submitted = %s, submittimestamp = %s WHERE active_id = %s",
$ilDB->quote($this->getLastSequence() . ""),
$ilDB->quote($this->getPass() . ""),
$ilDB->quote($submitted . ""),
$submittedTimestamp,
$ilDB->quote($this->getActiveId() . "")
);
$result = $ilDB->query($query);
}
else
{
$anonymous_id = ($this->getAnonymousId()) ? $ilDB->quote($this->getAnonymousId() . "") : "NULL";
$query = sprintf("INSERT INTO tst_active (active_id, user_fi, anonymous_id, test_fi, lastindex, tries, submitted, submittimestamp) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s)",
$ilDB->quote($this->getUserId() . ""),
$anonymous_id,
$ilDB->quote($this->getTestId() . ""),
$ilDB->quote($this->getLastSequence() . ""),
$ilDB->quote($this->getPass() . ""),
$ilDB->quote($submitted . ""),
$submittedTimestamp
);
$result = $ilDB->query($query);
$this->active_id = $ilDB->getLastInsertId();
}
}
Here is the call graph for this function:| ilTestSession::setAnonymousId | ( | $ | anonymous_id | ) |
Definition at line 261 of file class.ilTestSession.php.
References $anonymous_id.
{
$this->anonymous_id = $anonymous_id;
}
| ilTestSession::setLastSequence | ( | $ | lastsequence | ) |
Definition at line 271 of file class.ilTestSession.php.
References $lastsequence.
{
$this->lastsequence = $lastsequence;
}
| ilTestSession::setPass | ( | $ | pass | ) |
Definition at line 281 of file class.ilTestSession.php.
{
$this->pass = $pass;
}
| ilTestSession::setSubmitted | ( | ) |
Definition at line 301 of file class.ilTestSession.php.
{
$this->submitted = TRUE;
}
| ilTestSession::setSubmittedTimestamp | ( | ) |
Definition at line 311 of file class.ilTestSession.php.
{
$this->submittedTimestamp = strftime("%Y-%m-%d %H:%M:%S");
}
| ilTestSession::setTestId | ( | $ | test_id | ) |
Definition at line 251 of file class.ilTestSession.php.
References $test_id.
{
$this->test_id = $test_id;
}
| ilTestSession::setUserId | ( | $ | user_id | ) |
Definition at line 241 of file class.ilTestSession.php.
References $user_id.
{
$this->user_id = $user_id;
}
| ilTestSession::$active_id |
Definition at line 42 of file class.ilTestSession.php.
Referenced by ilTestSession(), and loadFromDb().
| ilTestSession::$anonymous_id |
Definition at line 60 of file class.ilTestSession.php.
Referenced by loadTestSession(), saveToDb(), and setAnonymousId().
| ilTestSession::$lastsequence |
Definition at line 78 of file class.ilTestSession.php.
Referenced by setLastSequence().
| ilTestSession::$submitted |
Definition at line 87 of file class.ilTestSession.php.
Referenced by saveToDb().
| ilTestSession::$submittedTimestamp |
Definition at line 96 of file class.ilTestSession.php.
Referenced by saveToDb().
| ilTestSession::$test_id |
Definition at line 69 of file class.ilTestSession.php.
Referenced by loadTestSession(), and setTestId().
| ilTestSession::$user_id |
Definition at line 51 of file class.ilTestSession.php.
Referenced by loadTestSession(), and setUserId().
1.7.1