function tests() { $user_id = $_GET['id']; $user = new User(); $user->createFromID($user_id); $lists_array = array(); foreach ($user->getOwnLists() as $list_row) { $list = new QList(); $list->createFromID($list_row['id']); $lists_array[] = $list; } $this->set('lists_array', $lists_array); }
function test() { if (isset($_GET['id'])) { $id = $_GET['id']; } else { $id = 0; } if (isset($_GET['type'])) { $type = $_GET['type']; } else { $type = 'auto'; } if ($type == 'manual' || $type == 'user') { $type = 'list'; } $this->set('test_id', $id); $this->set('type', $type); if (isset($_GET['limit'])) { $limit = $_GET['limit']; } else { $limit = 0; } $this->set('limit', $limit); if (isset($_GET['mode'])) { $mode = $_GET['mode']; } else { $mode = 1; } $this->set('mode', $mode); $questions = array(); $user_id = $this->getCurrentUserID(); if (isset($_GET['type']) && $type == 'list') { $test = new QList(); $test->createFromID($id, $limit, $mode); $questions = $test->questions; $test->getMaxForUser($user_id); $attempt = $test->evaluation($limit, $mode, $user_id); $this->set('test_title', $test->title); } else { $test = new Test(); $test->createFromItem($id, $limit, $mode); $this->set('test_title', $test->title); $slug_title = $test->sluggify($test->title); $this->set('slug_title', $slug_title); //$this->set('deck_slides', $deck->slides); $attempt = $test->evaluation($limit, $mode, $user_id); $test->getMaxForUser($user_id); $questions = $test->getAllQuestions($mode); } $this->set('test', json_encode($test)); $this->set('questions', $questions); $count = count($questions); $this->set('count', $count); $this->set('attempt', $attempt); }