Skip to content

Commit

Permalink
Fix feedback section errors when scorecalculation is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason.Platts authored and mchurchward committed Dec 21, 2022
1 parent d202a7b commit 80d8bd9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion classes/feedback/section.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
7 changes: 4 additions & 3 deletions classes/question/sectiontext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 80d8bd9

Please sign in to comment.