2018-08-13 17:02:06 +02:00
|
|
|
<?php
|
2018-08-13 21:25:14 +02:00
|
|
|
$chart_colors_number = count($chart_colors);
|
2018-08-13 17:02:06 +02:00
|
|
|
$total_votes = 0;
|
|
|
|
foreach ($poll->options as $option)
|
|
|
|
$total_votes += $option->votes;
|
|
|
|
?>
|
|
|
|
<h1 class="poll"><?= $poll->title ?></h1>
|
|
|
|
<main class="results">
|
|
|
|
<div class="options">
|
|
|
|
<table>
|
2018-08-13 21:25:14 +02:00
|
|
|
<?php foreach ($poll->options as $index => $option): ?>
|
2018-08-13 17:02:06 +02:00
|
|
|
<tr>
|
|
|
|
<td class="number"><?= $option->votes ?></td>
|
2019-05-04 11:53:21 +02:00
|
|
|
<td style="color: <?= $chart_colors[$index%$chart_colors_number] ?>"><?= htmlspecialchars($option->label) ?></td>
|
2018-08-26 12:06:30 +02:00
|
|
|
<td><?= $total_votes == 0 ? 0 : round($option->votes / $total_votes, 3)*100 ?>%</td>
|
2018-08-13 17:02:06 +02:00
|
|
|
</tr>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class="chart">
|
|
|
|
<?= $results_chart ?>
|
|
|
|
</div>
|
|
|
|
</main>
|