examinee = get_examinee(); if (isset($this->examinee) AND $this->examinee->getId() > 0) { $this->test = $this->findTest(); if ($this->test) { $this->answer = $this->findAnswer(); $this->answer->setTest($this->test->getId()); $this->chapter_object = $this->loadType("TestFolder", $this->getChapter()); if ($this->chapter_object) { if ($this->getAnswer()->hasChapter($this->getChapter())) { if ($asset_d = $this->chapter_object->getContent($this->getCurrentPage())) { $this->asset = $this->loadType($asset_d->type, $asset_d->id); } else { $this->answer->resetChapter(); forward(WWW_ROOT."test"); } } } } } } function actionCentral($page) { if (count($page>1)){ if ($page[0]=="TestFolder") { if ($this->getAnswer()->getId() <= 0) { $this->startAnswer(); $this->answer = $this->findAnswer(); } $this->nextChapter($page[1]); forward(WWW_ROOT."test"); } } } function findTest() { $groups = $this->examinee->getGroups(); $test_ids = array(); foreach ($groups as $group) { foreach (query_rows("SELECT test_id FROM " . DB_PREFIX . "test_groups g LEFT JOIN " . DB_PREFIX . "test t ON g.test_id=t.id WHERE g.group_id=".$group." AND t.active") as $t) { $test_ids []= $t->test_id; } } if (count($test_ids)>0) { // XXX if more than one first is popped return new Test($test_ids[0]); } return false; } function findAnswer() { if ($this->test) { $answer = query_row("SELECT id FROM " . DB_PREFIX . "answer WHERE test=".$this->test->getId()." AND examinee=".$this->examinee->getId()); if ($answer) { return new TestAnswer($answer->id); } } return new TestAnswer(); } public function getAnswer() { return $this->answer; } public function getTest() { return $this->test; } public function getTestNumbered() { return $this->getTest()->getNumbered(); } public function getExaminee() { return $this->examinee; } public function getCurrentPage() { if (isset($this->answer)) { return $this->answer->getCurrentPage(); } return false; } public function getLastPage() { if (isset($this->answer)) { return $this->answer->getLastPage(); } return false; } public function goStart($chap) { if (isset($this->answer) && $chap) { return $this->answer->createChapter($chap); } return false; } public function goNext($data) { if (isset($this->answer)) { if ($this->asset->answer($data)) { return $this->answer->nextPage(); } } return false; } public function startAnswer() { if (isset($this->answer)) { return $this->answer->create(); } return false; } public function stopAnswer() { if (isset($this->answer)) { return $this->answer->stop(); } return false; } public function nextChapter($chap) { if (isset($this->answer)) { return $this->answer->nextChapter($chap); } return false; } public function getChapter() { if (isset($this->answer)) { return $this->answer->getChapter(); } return false; } public function getChapterObject() { return $this->chapter_object; } public function getChapterNr() { return $this->chapter_object->getPosition(); } public function getPageNr() { return $this->getCurrentPage() + 1; } public function getAsset() { return $this->asset; } function loadType($type, $id = false) { if ($id) { if (is_file(dirname(__FILE__)."/".$type.".php")) { require_once(dirname(__FILE__)."/".$type.".php"); return new $type($id); } } return false; } } ?>