Skip to content
Snippets Groups Projects
Commit 57e27803 authored by David Siegfried's avatar David Siegfried
Browse files

prevent php8-warnings, closes #3475

Closes #3475

Merge request studip/studip!2371
parent 792057b4
No related branches found
No related tags found
No related merge requests found
......@@ -27,44 +27,46 @@ $options = $vote->questiondata['options'];
</thead>
<tbody>
<? $countAnswers = $vote->questionnaire->countAnswers() ?>
<? foreach ($vote->questiondata['statements'] as $key => $statement) : ?>
<tr>
<td>
<strong><?= htmlReady($statement) ?></strong>
</td>
<? if (!empty($vote->questiondata['statements'])) : ?>
<? foreach ($vote->questiondata['statements'] as $key => $statement) : ?>
<tr>
<td>
<strong><?= htmlReady($statement) ?></strong>
</td>
<? foreach($options as $option_index => $option) : ?>
<?
$hits = 0;
$names = [];
foreach ($answers as $answer) {
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');
<? foreach($options as $option_index => $option) : ?>
<?
$hits = 0;
$names = [];
foreach ($answers as $answer) {
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');
}
}
}
}
$color = 'hsl(0 0% '.round(70 + (30 * (1 - ($hits / $countAnswers ?? 1)) )).'%)';
?>
<td style="background-color: <?= $color ?>;" <?= count($names) > 0 ? 'title="'.htmlReady(implode(', ', $names)).'"' : ''?>>
<? if ($filtered !== null && $filtered == $key.'_'.$option_index) : ?>
<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>
<? else : ?>
<a href=""
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.') ?>">
<?= round(100 * $hits / $countAnswers) ?>%
</a>
<? endif ?>
</td>
<? endforeach ?>
</tr>
<? endforeach ?>
$color = 'hsl(0 0% '.round(70 + (30 * (1 - ($hits / $countAnswers ?? 1)) )).'%)';
?>
<td style="background-color: <?= $color ?>;" <?= count($names) > 0 ? 'title="'.htmlReady(implode(', ', $names)).'"' : ''?>>
<? if ($filtered !== null && $filtered == $key.'_'.$option_index) : ?>
<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>
<? else : ?>
<a href=""
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.') ?>">
<?= round(100 * $hits / $countAnswers) ?>%
</a>
<? endif ?>
</td>
<? endforeach ?>
</tr>
<? endforeach ?>
<? endif ?>
</tbody>
</table>
......@@ -47,7 +47,7 @@ class LikertScale extends QuestionnaireQuestion implements QuestionType
$questiondata['description'] = \Studip\Markup::markAsHtml(
\Studip\Markup::purifyHtml($questiondata['description'])
);
$questiondata['statements'] = array_filter($questiondata['statements']);
$questiondata['statements'] = array_filter($questiondata['statements'] ?? []);
return $questiondata;
}
......
......@@ -42,7 +42,7 @@ class RangeScale extends QuestionnaireQuestion implements QuestionType
$questiondata['description'] = \Studip\Markup::markAsHtml(
\Studip\Markup::purifyHtml($questiondata['description'])
);
$questiondata['statements'] = array_filter($questiondata['statements']);
$questiondata['statements'] = array_filter($questiondata['statements'] ?? []);
return $questiondata;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment