getId(); $query = "SELECT * FROM " . DB_PREFIX . $this->table; $query .= $this->getWhereQuery(); $query .= " ORDER BY {$order} DESC"; $query .= " LIMIT {$limit} OFFSET {$offset}"; $res = query_rows($query); return $res; } function getWhereQuery() { global $TeKe; $query = ""; $query .= " WHERE"; $query .= " deleted=false"; if (!$TeKe->plugin->is_test_constructor()) { $user_id = get_logged_in_user()->getId(); $query .= " AND proctor=".$user_id; } return $query; } function getPageCount($limit=20) { $query = "SELECT * FROM ". DB_PREFIX . $this->table; $query .= $this->getWhereQuery(); $total_count = mysql_num_rows(query($query)); $last_page = ceil($total_count/$limit); return $last_page; } function getCandidateByToken($token) { global $TeKe; $query = "SELECT * FROM ". DB_PREFIX . "candidates WHERE token='".$token."'"; $res = query_row($query); if ($res) { $candidate_id = $res->id; return $candidate_id; } return false; } function getAssessmentByUserToken($token) { global $TeKe; $query = "SELECT * FROM ". DB_PREFIX . "candidates WHERE token='".$token."'"; $res = query_row($query); if ($res) { $assessment_id = $res->assessment; $assessment = $TeKe->plugin->loadType("assessment", $assessment_id); return $assessment; } return false; } function getCandidateAssessment($token) { global $TeKe; $candidate = $this->getCandidateByToken($token); $query = "SELECT * FROM " . DB_PREFIX . "candidate_assessments WHERE candidate=" . $candidate; $res = query_row($query); if ($res) { $id = $res->id; $candidate_assessment = $TeKe->plugin->loadType("candidateAssessment", $id); return $candidate_assessment; } return false; } } ?>