public function choices($reload = false) { if ($reload or !$this->choices_cache) { $id = mysql_real_escape_string($this->id); $this->choices_cache = SurveyAnswerChoice::find_all("survey_answers.id = '{$id}'"); } return $this->choices_cache; }
public function total_percentage() { $question_id = mysql_real_escape_string($this->question->id); $percent = count($this->choices()) / count(SurveyAnswerChoice::find_all("survey_questions.id = '{$question_id}'")); $percent *= 100; return round($percent); }