Skip to content

Commit c7d8281

Browse files
emanoylovEmanoil Manoylov
andauthored
Questionnaire: Showing warnings when starting Answer the questions OU 900306 (#651)
Co-authored-by: Emanoil Manoylov <[email protected]>
1 parent dd95c27 commit c7d8281

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

questionnaire.class.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ private function has_required($section = 0) {
914914
return true;
915915
}
916916
}
917-
} else {
917+
} else if (key_exists($section, $this->questionsbysec)) {
918918
foreach ($this->questionsbysec[$section] as $questionid) {
919919
if ($this->questions[$questionid]->required()) {
920920
return true;
@@ -1355,21 +1355,23 @@ private function survey_render(&$formdata, $section = 1, $message = '') {
13551355
$this->page->add_to_page('progressbar',
13561356
$this->renderer->render_progress_bar($section, $this->questionsbysec));
13571357
}
1358-
foreach ($this->questionsbysec[$section] as $questionid) {
1359-
if ($this->questions[$questionid]->is_numbered()) {
1360-
$i++;
1361-
}
1362-
// Need questionnaire id to get the questionnaire object in sectiontext (Label) question class.
1363-
$formdata->questionnaire_id = $this->id;
1364-
if (isset($formdata->rid) && !empty($formdata->rid)) {
1365-
$this->add_response($formdata->rid);
1366-
} else {
1367-
$this->add_response_from_formdata($formdata);
1358+
if (key_exists($section, $this->questionsbysec)) {
1359+
foreach ($this->questionsbysec[$section] as $questionid) {
1360+
if ($this->questions[$questionid]->is_numbered()) {
1361+
$i++;
1362+
}
1363+
// Need questionnaire id to get the questionnaire object in sectiontext (Label) question class.
1364+
$formdata->questionnaire_id = $this->id;
1365+
if (isset($formdata->rid) && !empty($formdata->rid)) {
1366+
$this->add_response($formdata->rid);
1367+
} else {
1368+
$this->add_response_from_formdata($formdata);
1369+
}
1370+
$this->page->add_to_page('questions',
1371+
$this->renderer->question_output($this->questions[$questionid],
1372+
(isset($this->responses[$formdata->rid]) ? $this->responses[$formdata->rid] : []),
1373+
$i, $this->usehtmleditor, []));
13681374
}
1369-
$this->page->add_to_page('questions',
1370-
$this->renderer->question_output($this->questions[$questionid],
1371-
(isset($this->responses[$formdata->rid]) ? $this->responses[$formdata->rid] : []),
1372-
$i, $this->usehtmleditor, []));
13731375
}
13741376

13751377
$this->print_survey_end($section, $numsections);

0 commit comments

Comments
 (0)