Skip to content

Commit

Permalink
594 Fix formChild is null (#595)
Browse files Browse the repository at this point in the history
When a student completed a questionnaire then shown the "Thank you for
completing this Questionnaire" page there was a JavaScript error:

  Uncaught TypeError: formChild is null

This was because the JavaScript for the questions form was being
inadvertently loaded for the Thank you page where this form is not
present.
  • Loading branch information
leonstr authored Aug 29, 2024
1 parent 5c0dbe8 commit de5227b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
1 change: 1 addition & 0 deletions classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public function complete_formstart($action, $hiddeninputs=[]) {
foreach ($hiddeninputs as $name => $value) {
$output .= \html_writer::empty_tag('input', ['type' => 'hidden', 'name' => $name, 'value' => $value]) . "\n";
}
$this->page->requires->js_init_call('M.mod_questionnaire.init_attempt_form', null, false, questionnaire_get_js_module());
return $output;
}

Expand Down
4 changes: 0 additions & 4 deletions questionnaire.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,6 @@ public function view() {

$PAGE->set_title(format_string($this->name));
$PAGE->set_heading(format_string($this->course->fullname));

// Initialise the JavaScript.
$PAGE->requires->js_init_call('M.mod_questionnaire.init_attempt_form', null, false, questionnaire_get_js_module());

$message = $this->user_access_messages($USER->id, true);
if ($message !== false) {
$this->page->add_to_page('notifications', $message);
Expand Down

0 comments on commit de5227b

Please sign in to comment.