コード例 #1
0
ファイル: UserController.php プロジェクト: TBoonX/SlideWiki
 function scores()
 {
     //authorize user
     $id = $_GET['id'];
     if ($this->_user['is_authorized']) {
         if (!($this->_user['id'] == $id)) {
             $this->set('authorized', false);
             die('You are not allowed to view this page!');
         } else {
             $this->set('authorized', true);
         }
     } else {
         $this->set('authorized', false);
         die('You are not allowed to view this page!');
     }
     $testsArray = array();
     $testsTable = array();
     $listsArray = array();
     $listsTable = array();
     $timestampRow = array();
     $user = new User();
     $user->createFromID($id);
     foreach ($user->getTests() as $testRow) {
         $test = new Test();
         $test->createFromItem($testRow['item_id']);
         $type = $test->type;
         $timestampRow = $test->getLast($id, $type);
         $test->getMaxForUser($id, $type);
         $testsArray['title'] = $test->title;
         $testsArray['max_score'] = $test->max_for_user * 100;
         $testsArray['timestamp'] = $timestampRow['timestamp'];
         $testsArray['count'] = $test->getCountForUser($id, $type);
         $testsArray['item_id'] = $testRow['item_id'];
         $testsTable[] = $testsArray;
     }
     foreach ($user->getLists() as $listRow) {
         $list = new QList();
         $list->createFromID($listRow['item_id']);
         $type = $list->type;
         $timestampRow = $list->getLast($id, $type);
         $maxForUser = $list->getMaxForUser($id, $type);
         $listsArray['title'] = $listRow['title'];
         $listsArray['max_score'] = $maxForUser * 100;
         $listsArray['timestamp'] = $timestampRow['timestamp'];
         $listsArray['count'] = $list->getCountForUser($id, $type);
         $listsArray['item_id'] = $listRow['item_id'];
         $listsTable[] = $listsArray;
     }
     $this->set("testsTable", $testsTable);
     $this->set("listsTable", $listsTable);
     $this->set('user_obj', $user);
 }
コード例 #2
0
ファイル: MainController.php プロジェクト: TBoonX/SlideWiki
 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);
 }