From 80d8bd916b2a369c8b3f23447ee9c7ec79bffadc Mon Sep 17 00:00:00 2001 From: "Jason.Platts" Date: Fri, 14 Oct 2022 14:16:34 +0100 Subject: [PATCH] Fix feedback section errors when scorecalculation is empty --- classes/feedback/section.php | 2 +- classes/question/sectiontext.php | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/classes/feedback/section.php b/classes/feedback/section.php index abcad77a..9c927890 100644 --- a/classes/feedback/section.php +++ b/classes/feedback/section.php @@ -97,7 +97,7 @@ public static function new_section($surveyid, $sectionlabel = '') { $newsection->surveyid = $surveyid; $newsection->section = $maxsection + 1; $newsection->sectionlabel = $sectionlabel; - $newsection->scorecalculation = ''; + $newsection->scorecalculation = $newsection->encode_scorecalculation([]); $newsecid = $DB->insert_record(self::TABLE, $newsection); $newsection->id = $newsecid; $newsection->scorecalculation = []; diff --git a/classes/question/sectiontext.php b/classes/question/sectiontext.php index 38135965..5eefde31 100644 --- a/classes/question/sectiontext.php +++ b/classes/question/sectiontext.php @@ -101,9 +101,10 @@ protected function question_survey_display($response, $descendantsdata, $blankqu // In which section(s) is this question? foreach ($fbsections as $key => $fbsection) { - $scorecalculation = unserialize($fbsection->scorecalculation); - if (array_key_exists($this->id, $scorecalculation)) { - array_push($filteredsections, $fbsection->section); + if ($scorecalculation = unserialize($fbsection->scorecalculation)) { + if (array_key_exists($this->id, $scorecalculation)) { + array_push($filteredsections, $fbsection->section); + } } }