From 53048e848865faa7b2b1cd7845bce6b414867725 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ <olivier@olivierperez.fr> Date: Sat, 27 Dec 2014 00:19:48 +0100 Subject: [PATCH] Fix display of best choices on classic polls --- adminstuds.php | 2 +- .../Framadate/Services/PollService.php | 2 +- studs.php | 2 +- tpl/part/vote_table_classic.tpl | 22 +++++++++---------- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/adminstuds.php b/adminstuds.php index aae0bbd8..d2ad6c5d 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -329,7 +329,7 @@ $smarty->assign('poll', $poll); $smarty->assign('title', _('Poll') . ' - ' . $poll->title); $smarty->assign('slots', $poll->format === 'D' ? $pollService->splitSlots($slots) : $slots); $smarty->assign('votes', $pollService->splitVotes($votes)); -$smarty->assign('best_moments', $pollService->computeBestMoments($votes)); +$smarty->assign('best_choices', $pollService->computeBestChoices($votes)); $smarty->assign('comments', $comments); $smarty->assign('editingVoteId', $editingVoteId); $smarty->assign('message', $message); diff --git a/app/classes/Framadate/Services/PollService.php b/app/classes/Framadate/Services/PollService.php index 7edcdf00..47407f3c 100644 --- a/app/classes/Framadate/Services/PollService.php +++ b/app/classes/Framadate/Services/PollService.php @@ -75,7 +75,7 @@ class PollService { return $this->connect->insertComment($poll_id, $name, $comment); } - function computeBestMoments($votes) { + function computeBestChoices($votes) { $result = []; foreach ($votes as $vote) { $choices = str_split($vote->reponses); diff --git a/studs.php b/studs.php index 7ff18a53..2fbcbf4c 100644 --- a/studs.php +++ b/studs.php @@ -171,7 +171,7 @@ $smarty->assign('poll', $poll); $smarty->assign('title', _('Poll') . ' - ' . $poll->title); $smarty->assign('slots', $poll->format === 'D' ? $pollService->splitSlots($slots) : $slots); $smarty->assign('votes', $pollService->splitVotes($votes)); -$smarty->assign('best_moments', $pollService->computeBestMoments($votes)); +$smarty->assign('best_choices', $pollService->computeBestChoices($votes)); $smarty->assign('comments', $comments); $smarty->assign('editingVoteId', $editingVoteId); $smarty->assign('message', $message); diff --git a/tpl/part/vote_table_classic.tpl b/tpl/part/vote_table_classic.tpl index 7d7e7038..961274da 100644 --- a/tpl/part/vote_table_classic.tpl +++ b/tpl/part/vote_table_classic.tpl @@ -1,5 +1,5 @@ -{if !is_array($best_moments) || empty($best_moments)} - {$best_moments = [0]} +{if !is_array($best_choices) || empty($best_choices)} + {$best_choices = [0]} {/if} <h3>{_('Votes of the poll')}</h3> @@ -138,12 +138,12 @@ {* Line displaying best moments *} {$count_bests = 0} - {$max = max($best_moments)} + {$max = max($best_choices)} {if $max > 0} <tr id="addition"> <td>{_("Addition")}</td> - {foreach $best_moments as $best_moment} - {if $max == $best_moment} + {foreach $best_choices as $best_choice} + {if $max == $best_choice} {$count_bests = $count_bests +1} <td><span class="glyphicon glyphicon-star text-warning"></span><span>{$max}</span></td> {else} @@ -159,7 +159,7 @@ {* Best votes listing *} -{$max = max($best_moments)} +{$max = max($best_choices)} {if $max > 0} <div class="row"> {if $count_bests == 1} @@ -176,12 +176,10 @@ {$i = 0} <ul style="list-style:none"> {foreach $slots as $slot} - {foreach $slot->moments as $moment} - {if $best_moments[$i] == $max} - <li><strong>{$slot->sujet}</strong></li> - {/if} - {$i = $i+1} - {/foreach} + {if $best_choices[$i] == $max} + <li><strong>{$slot->sujet}</strong></li> + {/if} + {$i = $i+1} {/foreach} </ul> <p>{_("with")} <b>{$max}</b> {if $max==1}{_('vote')}{else}{_('votes')}{/if}.</p> -- GitLab