aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php24
1 files changed, 22 insertions, 2 deletions
diff --git a/include/text.php b/include/text.php
index 84f112802..0522dd3c9 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1872,6 +1872,13 @@ function format_poll($item,$s,$opts) {
$output .= '<form id="question-form-' . $item['id'] . '" >';
}
if (array_key_exists('anyOf',$act) && is_array($act['anyOf'])) {
+ $totalResponses = 0;
+ foreach ($act['anyOf'] as $poll) {
+ if (array_path_exists('replies/totalItems',$poll)) {
+ $totalResponses += intval($poll['replies']['totalItems']);
+ }
+ }
+
foreach ($act['anyOf'] as $poll) {
if (array_key_exists('name',$poll) && $poll['name']) {
$text = html2plain(purify_html($poll['name']),256);
@@ -1882,10 +1889,23 @@ function format_poll($item,$s,$opts) {
$total = 0;
}
if ($activated && $commentable) {
- $output .= '<input type="checkbox" name="answer[]" value="' . htmlspecialchars($text) . '"> ' . $text . '</input>' . ' (' . $total . ')' . EOL;
+ //$output .= '<input type="checkbox" name="answer[]" value="' . htmlspecialchars($text) . '"> ' . $text . '</input>' . ' (' . $total . ')' . EOL;
+
+ $output .= '<input type="checkbox" name="answer[]" value="' . htmlspecialchars($text) . '">&nbsp;&nbsp;<strong>' . $text . '</strong>' . EOL;
+ $output .= '<div class="progress bg-secondary bg-opacity-25" style="height: 3px;">';
+ $output .= '<div class="progress-bar bg-info" role="progressbar" style="width: ' . (($totalResponses) ? intval($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 .= EOL;
}
else {
- $output .= '[ ] ' . $text . ' (' . $total . ')' . EOL;
+ //$output .= '[ ] ' . $text . ' (' . $total . ')' . EOL;
+ $output .= '<input type="checkbox" name="answer[]" value="' . htmlspecialchars($text) . '" disabled="disabled">&nbsp;&nbsp;<strong>' . $text . '</strong>' . EOL;
+ $output .= '<div class="progress bg-secondary bg-opacity-25" style="height: 3px;">';
+ $output .= '<div class="progress-bar bg-info" role="progressbar" style="width: ' . (($totalResponses) ? intval($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 .= EOL;
}
}
}