significant rounding errors in poll results

This commit is contained in:
Mike Macgirvin 2023-04-18 20:32:38 +10:00
parent 105d57b1a4
commit b3d781bec3

View file

@ -2007,7 +2007,7 @@ function format_poll($item, $s, $opts)
if ($activated && $commentable) {
$output .= '<input type="checkbox" name="answer[]" value="' . htmlspecialchars($text) . '">&nbsp;&nbsp;<strong>' . $text . '</strong>' . EOL;
$output .= '<div class="progress bg-opacity-25" style="height: 3px; max-width: 75%;">';
$output .= '<div class="progress-bar bg-default" role="progressbar" style="width: ' . (($totalResponses) ? intval($total / $totalResponses * 100) : 0). '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
$output .= '<div class="progress-bar bg-default" role="progressbar" style="width: ' . (($totalResponses) ? round($total / $totalResponses * 100) : 0). '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
$output .= '</div>';
$output .= '<div class="text-muted"><small>' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . '</small></div>';
@ -2015,7 +2015,7 @@ function format_poll($item, $s, $opts)
} else {
$output .= '<input type="checkbox" name="answer[]" value="' . htmlspecialchars($text) . '" disabled="disabled">&nbsp;&nbsp;<strong>' . $text . '</strong>' . EOL;
$output .= '<div class="progress bg-opacity-25" style="height: 3px; max-width: 75%;">';
$output .= '<div class="progress-bar bg-default" role="progressbar" style="width: ' . (($totalResponses) ? intval($total / $totalResponses * 100) : 0). '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
$output .= '<div class="progress-bar bg-default" role="progressbar" style="width: ' . (($totalResponses) ? round($total / $totalResponses * 100) : 0). '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
$output .= '</div>';
$output .= '<div class="text-muted"><small>' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . '</small></div>';
$output .= EOL;
@ -2042,17 +2042,17 @@ function format_poll($item, $s, $opts)
$output .= '<input type="radio" name="answer" value="' . htmlspecialchars($text) . '">&nbsp;&nbsp;<strong>' . $text . '</strong>' . EOL;
$output .= '<div class="progress bg-opacity-25" style="height: 3px; max-width: 75%;">';
$output .= '<div class="progress-bar bg-default" role="progressbar" style="width: ' . (($totalResponses) ? intval($total / $totalResponses * 100) : 0). '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
$output .= '<div class="progress-bar bg-default" role="progressbar" style="width: ' . (($totalResponses) ? round($total / $totalResponses * 100) : 0). '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
$output .= '</div>';
$output .= '<div class="text-muted"><small>' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . '&nbsp;|&nbsp;' . (($totalResponses) ? intval($total / $totalResponses * 100) . '%' : '0%') . '</small></div>';
$output .= '<div class="text-muted"><small>' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . '&nbsp;|&nbsp;' . (($totalResponses) ? round($total / $totalResponses * 100) . '%' : '0%') . '</small></div>';
$output .= EOL;
} else {
$output .= '<input type="radio" name="answer" value="' . htmlspecialchars($text) . '" disabled="disabled">&nbsp;&nbsp;<strong>' . $text . '</strong>' . EOL;
$output .= '<div class="progress bg-opacity-25" style="height: 3px;">';
$output .= '<div class="progress-bar bg-default" role="progressbar" style="width: ' . (($totalResponses) ? intval($total / $totalResponses * 100) : 0) . '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
$output .= '<div class="progress-bar bg-default" role="progressbar" style="width: ' . (($totalResponses) ? round($total / $totalResponses * 100) : 0) . '%;" aria-valuenow="" aria-valuemin="0" aria-valuemax="100"></div>';
$output .= '</div>';
$output .= '<div class="text-muted"><small>' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . '&nbsp;|&nbsp;' . (($totalResponses) ? intval($total / $totalResponses * 100) . '%' : '0%') . '</small></div>';
$output .= '<div class="text-muted"><small>' . sprintf(tt('%d Vote', '%d Votes', $total, 'noun'), $total) . '&nbsp;|&nbsp;' . (($totalResponses) ? round($total / $totalResponses * 100) . '%' : '0%') . '</small></div>';
$output .= EOL;
}
}