45 if(!$this->unvotedShow && !$this->getIsVoted() && !$this->firstResult) {
49 ->with(array(
'answers' => array(
'condition' =>
'active = true',
'with' => array(
'userAnswersCount'))))
50 ->findByPk($this->
id);
51 $answers = $question->answers;
52 usort($answers,
function($a, $b){
return $a->order - $b->order;});
53 $statistics = array();
55 foreach($answers as $answ) {
56 $totalAnswers += $answ->userAnswersCount;
57 $statistics[] = array(
'title' => $answ->text,
'value' => (
int)$answ->userAnswersCount);
59 if($this->inPercents) {
60 foreach($statistics as &$row) {
61 $row[
'value'] = round($totalAnswers === 0 ? 0 : ($row[
'value'] / $totalAnswers * 100), $this->precision);
64 $this->render(
'ResultsWidget', array(
'question' => $question,
'statistics' => $statistics));
67 public function getIsVoted()
69 return Yii::app()->user->getState(
'vote-voted-'.$this->
id) ===
true;