diff options
| author | David Siegfried <david.siegfried@uni-vechta.de> | 2024-11-05 14:48:18 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-11-05 14:48:18 +0000 |
| commit | 5e152fa4fb034e5952dfde30e7f2cd99a6e33b39 (patch) | |
| tree | b086796c5c106d20899f4c3ba508d2fcc2b6bd0f /lib/evaluation | |
| parent | d5327a04059ae4b88a51f0c089370d597717f4e3 (diff) | |
prevent php-warnings, fixes #4829
Merge request studip/studip!3611
Diffstat (limited to 'lib/evaluation')
4 files changed, 25 insertions, 12 deletions
diff --git a/lib/evaluation/classes/EvaluationExportManager.class.php b/lib/evaluation/classes/EvaluationExportManager.class.php index 0c88e7f..08fd5e2 100644 --- a/lib/evaluation/classes/EvaluationExportManager.class.php +++ b/lib/evaluation/classes/EvaluationExportManager.class.php @@ -233,10 +233,14 @@ class EvaluationExportManager extends AuthorObject $file = $GLOBALS['TMP_PATH'] . "/" . $file; $part = pathinfo($file); - if (filemtime($file) < (time() - EVALEXPORT_LIFETIME) && - $part["extension"] == $this->extension && - mb_substr($part["basename"], 0, mb_strlen(EVALEXPORT_PREFIX)) == EVALEXPORT_PREFIX) + if ( + filemtime($file) < (time() - EVALEXPORT_LIFETIME) + && isset($part['extension']) + && $part['extension'] === $this->extension + && mb_substr($part['basename'], 0, mb_strlen(EVALEXPORT_PREFIX)) == EVALEXPORT_PREFIX + ) { unlink($file); + } } $dirhandle->close(); } @@ -264,4 +268,3 @@ class EvaluationExportManager extends AuthorObject } } - diff --git a/lib/evaluation/classes/EvaluationExportManagerCSV.class.php b/lib/evaluation/classes/EvaluationExportManagerCSV.class.php index 4baa3f8..f236457 100644 --- a/lib/evaluation/classes/EvaluationExportManagerCSV.class.php +++ b/lib/evaluation/classes/EvaluationExportManagerCSV.class.php @@ -273,10 +273,14 @@ class EvaluationExportManagerCSV extends EvaluationExportManager { /* Questiontype: pol or likert scale --------------------------- */ if ($type == EVALQUESTION_TYPE_LIKERT || $type == EVALQUESTION_TYPE_POL) { - $hasResidual = $this->evalquestions_residual[$evalquestion->getObjectID()]; + $hasResidual = $this->evalquestions_residual[$evalquestion->getObjectID()] ?? ''; $entry = ""; $residual = 0; - if ($answer = $answers[$evalquestion->getObjectID()][$userID]) { + $answer = []; + if ($evalquestion->getObjectID() && !empty($answers[$evalquestion->getObjectID()])) { + $answer = $answers[$evalquestion->getObjectID()][$userID]; + } + if (!empty($answer)) { if ($answer['residual']) { $residual = 1; } else { @@ -295,7 +299,12 @@ class EvaluationExportManagerCSV extends EvaluationExportManager { /* Questiontype: multiple chioice ------------------------------ */ elseif ($type == EVALQUESTION_TYPE_MC) { if ($evalquestion->isMultiplechoice ()) { - $mc_answers = explode(',', $answers[$evalquestion->getObjectID()][$userID]['evalanswer_id']); + if ($evalquestion->getObjectID()) { + $mc_answers = $answers[$evalquestion->getObjectID()][$userID]['evalanswer_id'] ?? []; + } else { + $mc_answers = []; + } + $mc_answers = explode(',', $mc_answers); while ($answer = &$evalquestion->getNextChild ()) { $this->addCol ((int)in_array($answer->getObjectID(), $mc_answers)); } diff --git a/lib/evaluation/classes/EvaluationTreeEditView.class.php b/lib/evaluation/classes/EvaluationTreeEditView.class.php index 3bfe92a..0fbbe08 100644 --- a/lib/evaluation/classes/EvaluationTreeEditView.class.php +++ b/lib/evaluation/classes/EvaluationTreeEditView.class.php @@ -1210,15 +1210,15 @@ class EvaluationTreeEditView $no_answers++; } if ($no_answers == 1) { - if ($this->msg[$this->itemID]) + if (!empty($this->msg[$this->itemID])) $this->msg[$this->itemID] .= "<br>" . _("Einer Frage wurden noch keine Antwortenmöglichkeiten zugewiesen."); else - $this->msg[$this->itemID] .= "info§" . _("Einer Frage wurden noch keine Antwortenmöglichkeiten zugewiesen."); + $this->msg[$this->itemID] = "info§" . _("Einer Frage wurden noch keine Antwortenmöglichkeiten zugewiesen."); } elseif ($no_answers > 1) { - if ($this->msg[$this->itemID]) + if (!empty($this->msg[$this->itemID])) $this->msg[$this->itemID] .= "<br>" . sprintf(_("%s Fragen wurden noch keine Antwortenmöglichkeiten zugewiesen."), $no_answers); else - $this->msg[$this->itemID] .= "info§" . sprintf(_("%s Fragen wurden noch keine Antwortenmöglichkeiten zugewiesen."), $no_answers); + $this->msg[$this->itemID] = "info§" . sprintf(_("%s Fragen wurden noch keine Antwortenmöglichkeiten zugewiesen."), $no_answers); } } @@ -1507,6 +1507,7 @@ class EvaluationTreeEditView $qgroup = &$this->tree->getGroupObject($this->itemID); $questionsDB = $qgroup->getChildren(); $cmd = Request::optionArray('cmd'); + $delete_empty_questions = 0; if (!empty($cmd)) if (key($cmd) == "UpdateItem") $delete_empty_questions = 1; diff --git a/lib/evaluation/classes/EvaluationTreeShowUser.class.php b/lib/evaluation/classes/EvaluationTreeShowUser.class.php index e999cb5..9968ff0 100644 --- a/lib/evaluation/classes/EvaluationTreeShowUser.class.php +++ b/lib/evaluation/classes/EvaluationTreeShowUser.class.php @@ -507,7 +507,7 @@ class EvaluationTreeShowUser ? "checked" : ""; else - $checked = (is_array($answers[$question->getObjectID()]) && + $checked = (!empty($answers[$question->getObjectID()]) && in_array($answer->getObjectID(), $answers[$question->getObjectID()])) ? "checked" : ""; |
