function saveToDb()
 {
     global $ilDB, $ilLog;
     $submitted = $this->isSubmitted() ? 1 : 0;
     if ($this->active_id > 0) {
         $affectedRows = $ilDB->update('tst_active', array('lastindex' => array('integer', $this->getLastSequence()), 'tries' => array('integer', $this->getPass()), 'submitted' => array('integer', $submitted), 'submittimestamp' => array('timestamp', strlen($this->getSubmittedTimestamp()) ? $this->getSubmittedTimestamp() : NULL), 'tstamp' => array('integer', time() - 10), 'taxfilter' => array('text', serialize($this->getQuestionSetFilterSelection()->getTaxonomySelection())), 'answerstatusfilter' => array('text', $this->getQuestionSetFilterSelection()->getAnswerStatusSelection())), array('active_id' => array('integer', $this->getActiveId())));
         // update learning progress
         include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
         include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
         ilLPStatusWrapper::_updateStatus(ilObjTestAccess::_lookupObjIdForTestId($this->getTestId()), ilObjTestAccess::_getParticipantId($this->getActiveId()));
     } else {
         if (!$this->activeIDExists($this->getUserId(), $this->getTestId())) {
             $anonymous_id = $this->getAnonymousId() ? $this->getAnonymousId() : NULL;
             $next_id = $ilDB->nextId('tst_active');
             $affectedRows = $ilDB->insert('tst_active', array('active_id' => array('integer', $next_id), 'user_fi' => array('integer', $this->getUserId()), 'anonymous_id' => array('text', $anonymous_id), 'test_fi' => array('integer', $this->getTestId()), 'lastindex' => array('integer', $this->getLastSequence()), 'tries' => array('integer', $this->getPass()), 'submitted' => array('integer', $submitted), 'submittimestamp' => array('timestamp', strlen($this->getSubmittedTimestamp()) ? $this->getSubmittedTimestamp() : NULL), 'tstamp' => array('integer', time() - 10), 'taxfilter' => array('text', serialize($this->getQuestionSetFilterSelection()->getTaxonomySelection())), 'answerstatusfilter' => array('text', $this->getQuestionSetFilterSelection()->getAnswerStatusSelection())));
             $this->active_id = $next_id;
             // update learning progress
             include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
             include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
             ilLPStatusWrapper::_updateStatus(ilObjTestAccess::_lookupObjIdForTestId($this->getTestId()), $this->getUserId());
         }
     }
     include_once "./Services/Tracking/classes/class.ilLearningProgress.php";
     ilLearningProgress::_tracProgress($this->getUserId(), ilObjTestAccess::_lookupObjIdForTestId($this->getTestId()), $this->getRefId(), 'tst');
 }
 function saveToDb()
 {
     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(), $submitted, 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";
         ilLPStatusWrapper::_updateStatus(ilObjTestAccess::_lookupObjIdForTestId($this->getTestId()), ilObjTestAccess::_getParticipantId($this->getActiveId()));
     } 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(), $anonymous_id, $this->getTestId(), $this->getLastSequence(), $this->getPass(), $submitted, 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";
             ilLPStatusWrapper::_updateStatus(ilObjTestAccess::_lookupObjIdForTestId($this->getTestId()), $this->getUserId());
         }
     }
     include_once "./Services/Tracking/classes/class.ilLearningProgress.php";
     ilLearningProgress::_tracProgress($this->getUserId(), ilObjTestAccess::_lookupObjIdForTestId($this->getTestId()), $this->getRefId(), 'tst');
 }