Пример #1
0
 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);
 }