From 224515c2d2061fd7fccee98f9844dd3f69090fb0 Mon Sep 17 00:00:00 2001 From: Tom Speak Date: Thu, 23 Jan 2014 15:31:41 +0000 Subject: [PATCH] FIX Allowing multiple choice votes Currently, if a user selects more than one choice for a multiple choice poll only the first choice is recorded. This is because `PollChoice::addVote()` checks if the user has voted or not and only records the vote if they haven't but then it marks them as having voted and all subsequent choices will be ignored. Now we only execute `Poll::markAsVoted()` after all choices are recorded --- code/PollChoice.php | 1 - code/PollForm.php | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/code/PollChoice.php b/code/PollChoice.php index 1307e45..8d5022d 100644 --- a/code/PollChoice.php +++ b/code/PollChoice.php @@ -52,7 +52,6 @@ function addVote() { if($poll && !$poll->isVoted()) { $this->Votes++; $this->write(); - $poll->markAsVoted(); } } diff --git a/code/PollForm.php b/code/PollForm.php index 075fb80..1e6151d 100644 --- a/code/PollForm.php +++ b/code/PollForm.php @@ -63,6 +63,7 @@ function submitPoll($data, $form) { foreach($choices as $choice) { $choice->addVote(); } + $form->poll->markAsVoted(); } // Redirect back to anchor (partly copied from Director::redirectBack)