Skip to content
Snippets Groups Projects
Commit 13c303d4 authored by Rasmus Fuhse's avatar Rasmus Fuhse
Browse files

Resolve "Probleme mit Nicht-Pflicht-Fragen bei Likert- und Polskalen"

Closes #4908

Merge request studip/studip!3683
parent 7abf792f
No related branches found
No related tags found
No related merge requests found
......@@ -43,10 +43,16 @@ $options = $vote->questiondata['options'];
<?
$average = 0;
if (count($answers) > 0) {
$countableAnswers = 0;
foreach ($answers as $answer) {
$average += $answer['answerdata']['answers'][$key];
if ($answer['answerdata']['answers'][$key] !== null) {
$countableAnswers++;
}
}
if ($countableAnswers > 0) {
$average /= $countableAnswers;
}
$average /= count($answers);
}
?>
......@@ -55,7 +61,7 @@ $options = $vote->questiondata['options'];
$hits = 0;
$names = [];
foreach ($answers as $answer) {
if ($answer['answerdata']['answers'][$key] == $option_index) {
if ($answer['answerdata']['answers'][$key] === $option_index) {
$hits++;
if ($answer['user_id'] && $answer['user_id'][0] !== 'q' && $answer['user_id'][0] !== 'n') {
$names[] = $answer->user->getFullName('full');
......@@ -64,7 +70,7 @@ $options = $vote->questiondata['options'];
}
?>
<td <?= count($names) > 0 ? 'title="'.htmlReady(implode(', ', $names)).'"' : ''?>>
<? if ($option_index === 0 && count($answers)) : ?>
<? if ($option_index === 0 && count($answers) && $average > 0) : ?>
<div class="average" style="margin-left: <?= 80 * $average + 34 ?>px;">
Ø<?= htmlReady(str_replace('.', ',', (string) round($average, 2) + 1)) ?>
</div>
......
......@@ -42,10 +42,16 @@ $options = range($vote->questiondata['minimum'], $vote->questiondata['maximum'])
<?
$average = 0;
if (count($answers) > 0) {
$countableAnswers = 0;
foreach ($answers as $answer) {
$average += $answer['answerdata']['answers'][$key];
if ($answer['answerdata']['answers'][$key] !== null) {
$countableAnswers++;
}
}
if ($countableAnswers > 0) {
$average /= $countableAnswers;
}
$average /= count($answers);
$average = round($average, 2);
}
?>
......@@ -64,7 +70,7 @@ $options = range($vote->questiondata['minimum'], $vote->questiondata['maximum'])
}
?>
<td style="white-space: nowrap;"<?= count($names) > 0 ? 'title="'.htmlReady(implode(', ', $names)).'"' : ''?>>
<? if ($option_index === 0 && count($answers) > 0) : ?>
<? if ($option_index === 0 && count($answers) > 0 && $average > 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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment