91 $this->anonymous_id = 0;
93 $this->lastsequence = 0;
94 $this->submitted = FALSE;
95 $this->submittedTimestamp =
"";
100 $this->lastFinishedPass = null;
110 $this->ref_id = $a_val;
127 if (
$_SESSION[
"AccountId"] != ANONYMOUS_USER_ID)
129 $result = $ilDB->queryF(
"SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s",
130 array(
'integer',
'integer'),
136 $this->active_id =
$row[
"active_id"];
137 $this->user_id =
$row[
"user_fi"];
138 $this->anonymous_id =
$row[
"anonymous_id"];
139 $this->test_id =
$row[
"test_fi"];
140 $this->lastsequence =
$row[
"lastindex"];
141 $this->pass =
$row[
"tries"];
142 $this->submitted = (
$row[
"submitted"]) ? TRUE : FALSE;
143 $this->submittedTimestamp =
$row[
"submittimestamp"];
144 $this->tstamp =
$row[
"tstamp"];
162 if (time() -
$_SESSION[
'tst_last_increase_pass'] > 10)
164 $_SESSION[
'tst_last_increase_pass'] = time();
165 $this->tstamp = time();
166 if ($this->active_id > 0)
168 $ilDB->update(
'tst_active',
171 'tries' => array(
'integer', $this->
getPass()),
174 'tstamp' => array(
'integer', time()),
178 'active_id' => array(
'integer', $this->
getActiveId())
183 include_once(
"./Modules/Test/classes/class.ilObjTestAccess.php");
184 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
193 $next_id = $ilDB->nextId(
'tst_active');
194 $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)",
195 array(
'integer',
'integer',
'text',
'integer',
'integer',
'integer',
'integer',
'timestamp',
'integer'),
208 $this->active_id = $next_id;
211 include_once(
"./Modules/Test/classes/class.ilObjTestAccess.php");
212 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
225 if ($this->active_id > 0)
227 $affectedRows = $ilDB->update(
'tst_active',
230 'tries' => array(
'integer', $this->
getPass()),
233 'tstamp' => array(
'integer', time()-10),
237 'active_id' => array(
'integer', $this->
getActiveId())
242 include_once(
"./Modules/Test/classes/class.ilObjTestAccess.php");
243 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
253 $next_id = $ilDB->nextId(
'tst_active');
254 $affectedRows = $ilDB->insert(
'tst_active',
256 'active_id' => array(
'integer', $next_id),
257 'user_fi' => array(
'integer', $this->
getUserId()),
259 'test_fi' => array(
'integer', $this->
getTestId()),
261 'tries' => array(
'integer', $this->
getPass()),
264 'tstamp' => array(
'integer', time()-10),
268 $this->active_id = $next_id;
271 include_once(
"./Modules/Test/classes/class.ilObjTestAccess.php");
272 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
278 include_once(
"./Services/Tracking/classes/class.ilLearningProgress.php");
296 $result = $ilDB->queryF(
"SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
297 array(
'integer',
'integer',
'text'),
303 $result = $ilDB->queryF(
"SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s AND anonymous_id = %s",
304 array(
'integer',
'integer',
'text'),
310 if (
$_SESSION[
"AccountId"] == ANONYMOUS_USER_ID)
314 $result = $ilDB->queryF(
"SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s",
315 array(
'integer',
'integer'),
322 $this->active_id =
$row[
"active_id"];
323 $this->user_id =
$row[
"user_fi"];
324 $this->anonymous_id =
$row[
"anonymous_id"];
325 $this->test_id =
$row[
"test_fi"];
326 $this->lastsequence =
$row[
"lastindex"];
327 $this->pass =
$row[
"tries"];
328 $this->submitted = (
$row[
"submitted"]) ? TRUE : FALSE;
329 $this->submittedTimestamp =
$row[
"submittimestamp"];
330 $this->tstamp =
$row[
"tstamp"];
348 $result = $ilDB->queryF(
"SELECT * FROM tst_active WHERE active_id = %s",
355 $this->active_id =
$row[
"active_id"];
356 $this->user_id =
$row[
"user_fi"];
357 $this->anonymous_id =
$row[
"anonymous_id"];
358 $this->test_id =
$row[
"test_fi"];
359 $this->lastsequence =
$row[
"lastindex"];
360 $this->pass =
$row[
"tries"];
361 $this->submitted = (
$row[
"submitted"]) ? TRUE : FALSE;
362 $this->submittedTimestamp =
$row[
"submittimestamp"];
363 $this->tstamp =
$row[
"tstamp"];
436 $this->submitted = TRUE;
446 $this->submittedTimestamp = strftime(
"%Y-%m-%d %H:%M:%S");
465 array(
'start_lock' => array(
'text', $testStartLock)),
466 array(
'active_id' => array(
'integer', $this->
getActiveId()))
474 $res = $ilDB->queryF(
475 "SELECT start_lock FROM tst_active WHERE active_id = %s",
479 while(
$row = $ilDB->fetchAssoc(
$res))
481 return $row[
'start_lock'];
489 if (!is_array(
$_SESSION[self::ACCESS_CODE_SESSION_INDEX]))
504 if( !is_array(
$_SESSION[self::ACCESS_CODE_SESSION_INDEX]) )
519 if( !is_array(
$_SESSION[self::ACCESS_CODE_SESSION_INDEX]) )
542 $query =
"SELECT anonymous_id FROM tst_active WHERE test_fi = %s AND anonymous_id = %s";
548 return (
$result->numRows() > 0);
562 $index = mt_rand(0, strlen($codestring)-1);
563 $code .= substr($codestring, $index, 1);
571 return $this->
getUserId() == ANONYMOUS_USER_ID;