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']; ...@@ -27,44 +27,46 @@ $options = $vote->questiondata['options'];
</thead> </thead>
<tbody> <tbody>
<? $countAnswers = $vote->questionnaire->countAnswers() ?> <? $countAnswers = $vote->questionnaire->countAnswers() ?>
<? foreach ($vote->questiondata['statements'] as $key => $statement) : ?> <? if (!empty($vote->questiondata['statements'])) : ?>
<tr> <? foreach ($vote->questiondata['statements'] as $key => $statement) : ?>
<td> <tr>
<strong><?= htmlReady($statement) ?></strong> <td>
</td> <strong><?= htmlReady($statement) ?></strong>
</td>
<? foreach($options as $option_index => $option) : ?> <? foreach($options as $option_index => $option) : ?>
<? <?
$hits = 0; $hits = 0;
$names = []; $names = [];
foreach ($answers as $answer) { foreach ($answers as $answer) {
if ($answer['answerdata']['answers'][$key] == $option_index) { if ($answer['answerdata']['answers'][$key] == $option_index) {
$hits++; $hits++;
if ($answer['user_id'] && $answer['user_id'][0] !== 'q' && $answer['user_id'][0] !== 'n') { if ($answer['user_id'] && $answer['user_id'][0] !== 'q' && $answer['user_id'][0] !== 'n') {
$names[] = $answer->user->getFullName('full'); $names[] = $answer->user->getFullName('full');
}
} }
} }
} $color = 'hsl(0 0% '.round(70 + (30 * (1 - ($hits / $countAnswers ?? 1)) )).'%)';
$color = 'hsl(0 0% '.round(70 + (30 * (1 - ($hits / $countAnswers ?? 1)) )).'%)'; ?>
?> <td style="background-color: <?= $color ?>;" <?= count($names) > 0 ? 'title="'.htmlReady(implode(', ', $names)).'"' : ''?>>
<td style="background-color: <?= $color ?>;" <?= count($names) > 0 ? 'title="'.htmlReady(implode(', ', $names)).'"' : ''?>> <? if ($filtered !== null && $filtered == $key.'_'.$option_index) : ?>
<? if ($filtered !== null && $filtered == $key.'_'.$option_index) : ?> <a href=""
<a href="" onclick="STUDIP.Questionnaire.removeFilter('<?= htmlReady($vote['questionnaire_id']) ?>'); return false;"
onclick="STUDIP.Questionnaire.removeFilter('<?= htmlReady($vote['questionnaire_id']) ?>'); return false;" title="<?= _('Zeige wieder alle Ergebnisse ohne Filterung an.') ?>">
title="<?= _('Zeige wieder alle Ergebnisse ohne Filterung an.') ?>"> <?= Icon::create('filter2', Icon::ROLE_CLICKABLE)->asImg(16, ['class' => 'text-bottom']) ?>
<?= Icon::create('filter2', Icon::ROLE_CLICKABLE)->asImg(16, ['class' => 'text-bottom']) ?> <?= round(100 * $hits / $countAnswers) ?>%
<?= round(100 * $hits / $countAnswers) ?>% </a>
</a> <? else : ?>
<? else : ?> <a href=""
<a href="" onclick="STUDIP.Questionnaire.addFilter('<?= htmlReady($vote['questionnaire_id']) ?>', '<?= htmlReady($vote->getId()) ?>', '<?= $key.'_'.$option_index ?>'); return false;"
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.') ?>">
title="<?= _('Zeige nur Ergebnisse von Personen an, die diese Option gewählt haben.') ?>"> <?= round(100 * $hits / $countAnswers) ?>%
<?= round(100 * $hits / $countAnswers) ?>% </a>
</a> <? endif ?>
<? endif ?> </td>
</td> <? endforeach ?>
<? endforeach ?> </tr>
</tr> <? endforeach ?>
<? endforeach ?> <? endif ?>
</tbody> </tbody>
</table> </table>
...@@ -47,7 +47,7 @@ class LikertScale extends QuestionnaireQuestion implements QuestionType ...@@ -47,7 +47,7 @@ class LikertScale extends QuestionnaireQuestion implements QuestionType
$questiondata['description'] = \Studip\Markup::markAsHtml( $questiondata['description'] = \Studip\Markup::markAsHtml(
\Studip\Markup::purifyHtml($questiondata['description']) \Studip\Markup::purifyHtml($questiondata['description'])
); );
$questiondata['statements'] = array_filter($questiondata['statements']); $questiondata['statements'] = array_filter($questiondata['statements'] ?? []);
return $questiondata; return $questiondata;
} }
......
...@@ -42,7 +42,7 @@ class RangeScale extends QuestionnaireQuestion implements QuestionType ...@@ -42,7 +42,7 @@ class RangeScale extends QuestionnaireQuestion implements QuestionType
$questiondata['description'] = \Studip\Markup::markAsHtml( $questiondata['description'] = \Studip\Markup::markAsHtml(
\Studip\Markup::purifyHtml($questiondata['description']) \Studip\Markup::purifyHtml($questiondata['description'])
); );
$questiondata['statements'] = array_filter($questiondata['statements']); $questiondata['statements'] = array_filter($questiondata['statements'] ?? []);
return $questiondata; return $questiondata;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment