159 lines
3.1 KiB
PHP
159 lines
3.1 KiB
PHP
|
<?php
|
||
|
include_once('class.Database.php');
|
||
|
class Vote extends database
|
||
|
{
|
||
|
public $id;
|
||
|
public $question;
|
||
|
public $answer;
|
||
|
|
||
|
// Constructor for Initilization of Data Members
|
||
|
public function __construct()
|
||
|
{
|
||
|
$this->id = '';
|
||
|
$this->question='';
|
||
|
$this->answer='';
|
||
|
}
|
||
|
|
||
|
public function saveQuestionAnswer()
|
||
|
{
|
||
|
$qry="INSERT INTO tbl_question_answer
|
||
|
SET
|
||
|
tbl_question_answer.QuestionId='".$this->question."',
|
||
|
tbl_question_answer.Answer='".$this->answer."'";
|
||
|
|
||
|
parent::executeQuery($qry);
|
||
|
}
|
||
|
|
||
|
public function loadQuestions()
|
||
|
{
|
||
|
$qry="SELECT * FROM tbl_questions ORDER BY tbl_questions.Id ASC";
|
||
|
|
||
|
parent::executeQuery($qry);
|
||
|
$qryRes=parent::asObject();
|
||
|
|
||
|
if($qryRes)
|
||
|
{
|
||
|
return $qryRes;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function getQuestionData()
|
||
|
{
|
||
|
$qry="SELECT tbl_questions.Question,tbl_questions.Heading
|
||
|
FROM tbl_questions
|
||
|
WHERE tbl_questions.Id='".$this->question."'";
|
||
|
|
||
|
parent::executeQuery($qry);
|
||
|
$qryRes=parent::asObject();
|
||
|
|
||
|
if($qryRes)
|
||
|
{
|
||
|
return $qryRes;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function updateStatus($status)
|
||
|
{
|
||
|
$qry="UPDATE tbl_question_answer
|
||
|
SET
|
||
|
tbl_question_answer.PriorityBit='$status'
|
||
|
WHERE tbl_question_answer.Id='".$this->question."'";
|
||
|
|
||
|
parent::executeQuery($qry);
|
||
|
}
|
||
|
|
||
|
public function checkSkipAnswer($id)
|
||
|
{
|
||
|
$qry="SELECT tbl_question_answer.Answer
|
||
|
FROM tbl_question_answer
|
||
|
WHERE tbl_question_answer.Id='$id'";
|
||
|
|
||
|
parent::executeQuery($qry);
|
||
|
$qryRes=parent::asObject();
|
||
|
|
||
|
if($qryRes[0]->Answer=='S')
|
||
|
{
|
||
|
return TRUE;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return FALSE;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function getVoterResponses($id)
|
||
|
{
|
||
|
$qry="SELECT tbl_question_answer.QuestionId,
|
||
|
tbl_question_answer.Answer,
|
||
|
tbl_question_answer.PriorityBit
|
||
|
FROM tbl_question_answer
|
||
|
WHERE tbl_question_answer.Id='$id'";
|
||
|
|
||
|
parent::executeQuery($qry);
|
||
|
$qryRes=parent::asObject();
|
||
|
|
||
|
if($qryRes)
|
||
|
{
|
||
|
return $qryRes;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function getAllParties()
|
||
|
{
|
||
|
$qry="SELECT * FROM tbl_candidate";
|
||
|
|
||
|
parent::executeQuery($qry);
|
||
|
$qryRes=parent::asObject();
|
||
|
|
||
|
if($qryRes)
|
||
|
{
|
||
|
return $qryRes;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function getPartyRespones($id,$quest)
|
||
|
{
|
||
|
$qry="SELECT tbl_party_response.Id,
|
||
|
tbl_party_response.CandidateId,
|
||
|
tbl_party_response.QuestionId,
|
||
|
tbl_party_response.Answer,
|
||
|
tbl_party_response.PriorityBit
|
||
|
FROM tbl_party_response
|
||
|
WHERE tbl_party_response.CandidateId='$id' AND tbl_party_response.QuestionId='$quest'";
|
||
|
|
||
|
parent::executeQuery($qry);
|
||
|
$qryRes=parent::asObject();
|
||
|
|
||
|
if($qryRes)
|
||
|
{
|
||
|
return $qryRes;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function updatePoints($id,$points)
|
||
|
{
|
||
|
$qry="UPDATE tbl_candidate
|
||
|
SET
|
||
|
tbl_candidate.Points='$points'
|
||
|
WHERE tbl_candidate.Id='$id'";
|
||
|
|
||
|
parent::executeQuery($qry);
|
||
|
}
|
||
|
|
||
|
public function getPartyData($id)
|
||
|
{
|
||
|
$qry="SELECT * FROM tbl_candidate
|
||
|
WHERE tbl_candidate.Id='$id'";
|
||
|
|
||
|
parent::executeQuery($qry);
|
||
|
$qryRes=parent::asObject();
|
||
|
|
||
|
if($qryRes)
|
||
|
{
|
||
|
return $qryRes;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
?>
|