aboutsummaryrefslogtreecommitdiff
path: root/app/views/questionnaire
diff options
context:
space:
mode:
authorRasmus Fuhse <fuhse@data-quest.de>2024-01-03 15:03:47 +0000
committerRasmus Fuhse <fuhse@data-quest.de>2024-01-03 15:03:47 +0000
commitc3d34bc3c6fbd408e7232918a61bde0211d0ce4e (patch)
tree7207fb01411f1463ca54541ab8ba82789043ddc7 /app/views/questionnaire
parent89c64c3705b29bb93cb3bf5a059cce866341bbf7 (diff)
Resolve "Likertskala und Polskala sollen absolute Zahlen in der Auswertungen anzeigen"
Closes #2911 Merge request studip/studip!1963
Diffstat (limited to 'app/views/questionnaire')
-rw-r--r--app/views/questionnaire/question_types/likert/likert_evaluation.php60
-rw-r--r--app/views/questionnaire/question_types/rangescale/rangescale_evaluation.php88
2 files changed, 129 insertions, 19 deletions
diff --git a/app/views/questionnaire/question_types/likert/likert_evaluation.php b/app/views/questionnaire/question_types/likert/likert_evaluation.php
index ac0a671..fd4eb01 100644
--- a/app/views/questionnaire/question_types/likert/likert_evaluation.php
+++ b/app/views/questionnaire/question_types/likert/likert_evaluation.php
@@ -17,6 +17,12 @@ $options = $vote->questiondata['options'];
</div>
<table class="default nohover">
+ <colgroup>
+ <col>
+ <? foreach ($options as $option) : ?>
+ <col style="width: 70px">
+ <? endforeach ?>
+ </colgroup>
<thead>
<tr>
<th><?= _('Aussage') ?></th>
@@ -34,7 +40,17 @@ $options = $vote->questiondata['options'];
<strong><?= htmlReady($statement) ?></strong>
</td>
- <? foreach($options as $option_index => $option) : ?>
+ <?
+ $average = 0;
+ if (count($answers) > 0) {
+ foreach ($answers as $answer) {
+ $average += $answer['answerdata']['answers'][$key];
+ }
+ $average /= count($answers);
+ }
+ ?>
+
+ <? foreach($options as $option_index => $option) : ?>
<?
$hits = 0;
$names = [];
@@ -46,23 +62,61 @@ $options = $vote->questiondata['options'];
}
}
}
- $color = 'hsl(0 0% '.round(70 + (30 * (1 - ($hits / $countAnswers ?? 1)) )).'%)';
?>
- <td style="background-color: <?= $color ?>;" <?= count($names) > 0 ? 'title="'.htmlReady(implode(', ', $names)).'"' : ''?>>
+ <td <?= count($names) > 0 ? 'title="'.htmlReady(implode(', ', $names)).'"' : ''?>>
+ <? if ($option_index === 0 && count($answers)) : ?>
+ <div class="average" style="margin-left: <?= 80 * $average + 34 ?>px;">
+ Ø<?= htmlReady(str_replace('.', ',', (string) round($average, 2) + 1)) ?>
+ </div>
+ <? endif ?><?
+ $bubble_width = 70;
+ $font_size = 2.5;
+ if ($countAnswers === 1) {
+ $bubble_width /= 3;
+ $font_size /= 3;
+ } elseif ($countAnswers === 2) {
+ $bubble_width /= 2;
+ $font_size /= 2;
+ } elseif ($countAnswers === 3) {
+ $bubble_width /= 1.5;
+ $font_size /= 1.5;
+ }
+ ?>
+ <? if (count($answers) > 0) : ?>
+ <div class="centerline"></div>
+ <? endif ?>
+ <? if ($countAnswers) : ?>
+ <? $bubble_width = $hits > 0 ? ($bubble_width - 14) * $hits / $countAnswers + 14 : 0 ?>
+ <? $font_size = $hits > 0 ? ($font_size - 0.5) * $hits / $countAnswers + 0.5 : 0 ?>
<? if ($filtered !== null && $filtered == $key.'_'.$option_index) : ?>
<a href=""
+ class="questionnaire-evaluation-circle-container"
onclick="STUDIP.Questionnaire.removeFilter('<?= htmlReady($vote['questionnaire_id']) ?>'); return false;"
title="<?= _('Zeige wieder alle Ergebnisse ohne Filterung an.') ?>">
+ <div class="questionnaire-evaluation-circle">
+ <div class="value" style="font-size: <?= $font_size ?>em; max-width: <?= $bubble_width ?>px; max-height: <?= $bubble_width ?>px;">
+ <?= htmlReady($hits) ?>
+ </div>
+ </div>
<?= Icon::create('filter2', Icon::ROLE_CLICKABLE)->asImg(16, ['class' => 'text-bottom']) ?>
<?= round(100 * $hits / $countAnswers) ?>%
</a>
<? else : ?>
<a href=""
+ class="questionnaire-evaluation-circle-container"
onclick="STUDIP.Questionnaire.addFilter('<?= htmlReady($vote['questionnaire_id']) ?>', '<?= htmlReady($vote->getId()) ?>', '<?= $key.'_'.$option_index ?>'); return false;"
title="<?= _('Zeige nur Ergebnisse von Personen an, die diese Option gewählt haben.') ?>">
+ <div class="questionnaire-evaluation-circle">
+ <div class="value" style="font-size: <?= $font_size ?>em; max-width: <?= $bubble_width ?>px; max-height: <?= $bubble_width ?>px;">
+ <?= htmlReady($hits) ?>
+ </div>
+ </div>
<?= round(100 * $hits / $countAnswers) ?>%
</a>
<? endif ?>
+ <? else : ?>
+ 0%
+ <? endif ?>
</td>
<? endforeach ?>
</tr>
diff --git a/app/views/questionnaire/question_types/rangescale/rangescale_evaluation.php b/app/views/questionnaire/question_types/rangescale/rangescale_evaluation.php
index 9fa5748..2715934 100644
--- a/app/views/questionnaire/question_types/rangescale/rangescale_evaluation.php
+++ b/app/views/questionnaire/question_types/rangescale/rangescale_evaluation.php
@@ -17,11 +17,17 @@ $options = range($vote->questiondata['minimum'], $vote->questiondata['maximum'])
</div>
<table class="default nohover">
+ <colgroup>
+ <col>
+ <? foreach ($options as $option) : ?>
+ <col style="width: 70px">
+ <? endforeach ?>
+ </colgroup>
<thead>
<tr>
<th><?= _('Aussage') ?></th>
<? for ($i = $vote->questiondata['minimum'] ?? 1; $i <= $vote->questiondata['maximum']; $i++) : ?>
- <th><?= htmlReady($i) ?></th>
+ <th class="rangescale_center"><?= htmlReady($i) ?></th>
<? endfor ?>
</tr>
</thead>
@@ -33,7 +39,18 @@ $options = range($vote->questiondata['minimum'], $vote->questiondata['maximum'])
<strong><?= htmlReady($statement) ?></strong>
</td>
- <? foreach($options as $option) : ?>
+ <?
+ $average = 0;
+ if (count($answers) > 0) {
+ foreach ($answers as $answer) {
+ $average += $answer['answerdata']['answers'][$key];
+ }
+ $average /= count($answers);
+ $average = round($average, 2);
+ }
+ ?>
+
+ <? foreach($options as $option_index => $option) : ?>
<?
$hits = 0;
$names = [];
@@ -45,22 +62,61 @@ $options = range($vote->questiondata['minimum'], $vote->questiondata['maximum'])
}
}
}
- $color = 'hsl(0 0% '.round(70 + (30 * (1 - ($hits / $countAnswers ?? 1)) )).'%)';
?>
- <td style="background-color: <?= $color ?>;" style="white-space: nowrap;"<?= count($names) > 0 ? 'title="'.htmlReady(implode(', ', $names)).'"' : ''?>>
- <? if ($filtered !== null && $filtered == ($key.'_'.$option)) : ?>
- <a href=""
- onclick="STUDIP.Questionnaire.removeFilter('<?= htmlReady($vote['questionnaire_id']) ?>'); return false;"
- title="<?= _('Zeige wieder alle Ergebnisse ohne Filterung an.') ?>">
- <?= Icon::create('filter2', Icon::ROLE_CLICKABLE)->asImg(16, ['class' => 'text-bottom']) ?>
- <?= round(100 * $hits / $countAnswers) ?>%
- </a>
+ <td style="white-space: nowrap;"<?= count($names) > 0 ? 'title="'.htmlReady(implode(', ', $names)).'"' : ''?>>
+ <? if ($option_index === 0 && count($answers) > 0) : ?>
+ <div class="average" style="margin-left: <?= (count($options) * 80) * $average / $vote->questiondata['maximum'] - $vote->questiondata['minimum'] * 80 + 34 ?>px;">
+ Ø<?= htmlReady(str_replace('.', ',', (string) round($average, 2))) ?>
+ </div>
+ <? endif ?>
+ <?
+ $bubble_width = 70;
+ $font_size = 2.5;
+ if ($countAnswers === 1) {
+ $bubble_width /= 3;
+ $font_size /= 3;
+ } elseif ($countAnswers === 2) {
+ $bubble_width /= 2;
+ $font_size /= 2;
+ } elseif ($countAnswers === 3) {
+ $bubble_width /= 1.5;
+ $font_size /= 1.5;
+ }
+ ?>
+ <? if (count($answers) > 0) : ?>
+ <div class="centerline"></div>
+ <? endif ?>
+ <? if ($countAnswers) : ?>
+ <? $bubble_width = $hits > 0 ? ($bubble_width - 14) * $hits / $countAnswers + 14 : 0 ?>
+ <? $font_size = $hits > 0 ? ($font_size - 0.5) * $hits / $countAnswers + 0.5 : 0 ?>
+ <? if ($filtered !== null && $filtered == ($key.'_'.$option)) : ?>
+ <a href=""
+ class="questionnaire-evaluation-circle-container"
+ onclick="STUDIP.Questionnaire.removeFilter('<?= htmlReady($vote['questionnaire_id']) ?>'); return false;"
+ title="<?= _('Zeige wieder alle Ergebnisse ohne Filterung an.') ?>">
+ <div class="questionnaire-evaluation-circle">
+ <div class="value" style="font-size: <?= $font_size ?>em; max-width: <?= $bubble_width ?>px; max-height: <?= $bubble_width ?>px;">
+ <?= htmlReady($hits) ?>
+ </div>
+ </div>
+ <?= Icon::create('filter2', Icon::ROLE_CLICKABLE)->asImg(16, ['class' => 'text-bottom']) ?>
+ <?= round(100 * $hits / $countAnswers) ?>%
+ </a>
+ <? else : ?>
+ <a href=""
+ class="questionnaire-evaluation-circle-container"
+ onclick="STUDIP.Questionnaire.addFilter('<?= htmlReady($vote['questionnaire_id']) ?>', '<?= htmlReady($vote->getId()) ?>', '<?= $key.'_'.$option ?>'); return false;"
+ title="<?= _('Zeige nur Ergebnisse von Personen an, die diese Option gewählt haben.') ?>">
+ <div class="questionnaire-evaluation-circle">
+ <div class="value" style="font-size: <?= $font_size ?>em; max-width: <?= $bubble_width ?>px; max-height: <?= $bubble_width ?>px;">
+ <?= htmlReady($hits) ?>
+ </div>
+ </div>
+ <?= round(100 * $hits / $countAnswers) ?>%
+ </a>
+ <? endif ?>
<? else : ?>
- <a href=""
- onclick="STUDIP.Questionnaire.addFilter('<?= htmlReady($vote['questionnaire_id']) ?>', '<?= htmlReady($vote->getId()) ?>', '<?= $key.'_'.$option ?>'); return false;"
- title="<?= _('Zeige nur Ergebnisse von Personen an, die diese Option gewählt haben.') ?>">
- <?= round(100 * $hits / $countAnswers) ?>%
- </a>
+ 0%
<? endif ?>
</td>
<? endforeach ?>