diff --git a/questionnaire.class.php b/questionnaire.class.php index 5fd3bebe..97383cf3 100644 --- a/questionnaire.class.php +++ b/questionnaire.class.php @@ -885,7 +885,7 @@ private function has_required($section = 0) { return true; } } - } else { + } else if (key_exists($section, $this->questionsbysec)) { foreach ($this->questionsbysec[$section] as $questionid) { if ($this->questions[$questionid]->required()) { return true; @@ -1326,21 +1326,23 @@ private function survey_render(&$formdata, $section = 1, $message = '') { $this->page->add_to_page('progressbar', $this->renderer->render_progress_bar($section, $this->questionsbysec)); } - foreach ($this->questionsbysec[$section] as $questionid) { - if ($this->questions[$questionid]->is_numbered()) { - $i++; - } - // Need questionnaire id to get the questionnaire object in sectiontext (Label) question class. - $formdata->questionnaire_id = $this->id; - if (isset($formdata->rid) && !empty($formdata->rid)) { - $this->add_response($formdata->rid); - } else { - $this->add_response_from_formdata($formdata); + if (key_exists($section, $this->questionsbysec)) { + foreach ($this->questionsbysec[$section] as $questionid) { + if ($this->questions[$questionid]->is_numbered()) { + $i++; + } + // Need questionnaire id to get the questionnaire object in sectiontext (Label) question class. + $formdata->questionnaire_id = $this->id; + if (isset($formdata->rid) && !empty($formdata->rid)) { + $this->add_response($formdata->rid); + } else { + $this->add_response_from_formdata($formdata); + } + $this->page->add_to_page('questions', + $this->renderer->question_output($this->questions[$questionid], + (isset($this->responses[$formdata->rid]) ? $this->responses[$formdata->rid] : []), + $i, $this->usehtmleditor, [])); } - $this->page->add_to_page('questions', - $this->renderer->question_output($this->questions[$questionid], - (isset($this->responses[$formdata->rid]) ? $this->responses[$formdata->rid] : []), - $i, $this->usehtmleditor, [])); } $this->print_survey_end($section, $numsections);