protected function performTestPassFinishedTasks($finishedPass) { if (!$this->testSession->isSubmitted()) { $this->testSession->setSubmitted(1); $this->testSession->setSubmittedTimestamp(date('Y-m-d H:i:s')); $this->testSession->saveToDb(); } if ($this->object->getEnableArchiving()) { $this->archiveParticipantSubmission($this->testSession->getActiveId(), $finishedPass); } }
function createRandomSolutions($number) { global $ilDB; // 1. get a user $query = "SELECT usr_id FROM usr_data"; $result = $ilDB->query($query); while ($data = $ilDB->fetchAssoc($result)) { $activequery = sprintf("SELECT user_fi FROM tst_active WHERE test_fi = %s AND user_fi = %s", $ilDB->quote($this->getTestId()), $ilDB->quote($data['usr_id'])); $activeresult = $ilDB->query($activequery); if ($activeresult->numRows() == 0) { $user_id = $data['usr_id']; if ($user_id != 13) { include_once "./Modules/Test/classes/class.ilTestSession.php"; $testSession = FALSE; $testSession = new ilTestSession(); $testSession->setRefId($this->getRefId()); $testSession->setTestId($this->getTestId()); $testSession->setUserId($user_id); $testSession->saveToDb(); $passes = $this->getNrOfTries() ? $this->getNrOfTries() : 10; $nr_of_passes = rand(1, $passes); $active_id = $testSession->getActiveId(); for ($pass = 0; $pass < $nr_of_passes; $pass++) { include_once "./Modules/Test/classes/class.ilTestSequence.php"; $testSequence = new ilTestSequence($active_id, $pass, $this->isRandomTest()); if (!$testSequence->hasSequence()) { $testSequence->createNewSequence($this->getQuestionCount(), $shuffle); $testSequence->saveToDb(); } for ($seq = 1; $seq <= count($this->questions); $seq++) { $question_id = $testSequence->getQuestionForSequence($seq); $objQuestion = ilObjTest::_instanciateQuestion($question_id); $objQuestion->createRandomSolution($testSession->getActiveId(), $pass); } if ($pass < $nr_of_passes - 1) { $testSession->increasePass(); $testSession->setLastSequence(0); $testSession->saveToDb(); } else { $testSession->setSubmitted(1); $testSession->setSubmittedTimestamp(date('Y-m-d H:i:s')); $testSession->saveToDb(); } } $number--; if ($number == 0) { return; } } } } }