From 28ea07fbef7454a65ec0e0fda35e9e0844f23532 Mon Sep 17 00:00:00 2001 From: David Siegfried <david.siegfried@uni-vechta.de> Date: Tue, 7 Mar 2023 09:17:45 +0000 Subject: [PATCH] prevent php-warnings, refs #2277 Merge request studip/studip!1502 --- lib/models/Vote.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/models/Vote.php b/lib/models/Vote.php index 9c81b2dc868..d3d6d75c01b 100644 --- a/lib/models/Vote.php +++ b/lib/models/Vote.php @@ -5,7 +5,7 @@ class Vote extends QuestionnaireQuestion implements QuestionType { public static function getIcon(bool $active = false) : Icon { - return Icon::create(static::getIconShape(), $active ? 'clickable' : 'info'); + return Icon::create(static::getIconShape(), $active ? Icon::ROLE_CLICKABLE : Icon::ROLE_INFO); } /** @@ -32,7 +32,7 @@ class Vote extends QuestionnaireQuestion implements QuestionType $questiondata['description'] = \Studip\Markup::markAsHtml( \Studip\Markup::purifyHtml($questiondata['description']) ); - $questiondata['options'] = array_filter($questiondata['options']); + $questiondata['options'] = array_filter($questiondata['options'] ?? []); return $questiondata; } @@ -49,6 +49,7 @@ class Vote extends QuestionnaireQuestion implements QuestionType $answer = $this->getMyAnswer(); $answers = Request::getArray('answers'); + $userAnswer = 0; if (array_key_exists($this->getId(), $answers)) { $userAnswer = $answers[$this->getId()]['answerdata']['answers']; if (is_array($userAnswer)) { -- GitLab