diff --git a/questionnaire.class.php b/questionnaire.class.php index 004d4609..ae36db8b 100644 --- a/questionnaire.class.php +++ b/questionnaire.class.php @@ -2915,11 +2915,11 @@ public function survey_results($rid = '', $uid=false, $pdf = false, $currentgrou } if (!$pdf) { $this->page->add_to_page('responses', $this->renderer->container_start('qn-container')); - $this->page->add_to_page('responses', $this->renderer->container_start('qn-info')); - if ($question->is_numbered()) { + if ($this->questions_autonumbered() && $question->is_numbered()) { + $this->page->add_to_page('responses', $this->renderer->container_start('qn-info')); $this->page->add_to_page('responses', $this->renderer->heading($qnum, 2, 'qn-number')); + $this->page->add_to_page('responses', $this->renderer->container_end()); // End qn-info. } - $this->page->add_to_page('responses', $this->renderer->container_end()); // End qn-info. $this->page->add_to_page('responses', $this->renderer->container_start('qn-content')); } // If question text is "empty", i.e. 2 non-breaking spaces were inserted, do not display any question text. @@ -2928,7 +2928,7 @@ public function survey_results($rid = '', $uid=false, $pdf = false, $currentgrou } if ($pdf) { $response = new stdClass(); - if ($question->is_numbered()) { + if ($this->questions_autonumbered() && $question->is_numbered()) { $response->qnum = $qnum; } $response->qcontent = format_text(file_rewrite_pluginfile_urls($question->content, 'pluginfile.php', diff --git a/tests/behat/check_responses.feature b/tests/behat/check_responses.feature index 46065874..62224778 100644 --- a/tests/behat/check_responses.feature +++ b/tests/behat/check_responses.feature @@ -121,3 +121,29 @@ Feature: Review responses And I follow "Test questionnaire" And I navigate to "View all responses" in current page administration Then "//b[text()='One']" "xpath_element" should exist + + + Scenario: Check auto numbering setting in responses + Given the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "activities" exist: + | activity | name | description | course | idnumber | + | questionnaire | Test questionnaire | Test questionnaire description | C1 | questionnaire0 | + And "Test questionnaire" has questions and responses + And I am on the "Course 1" "Course" page logged in as "admin" + And I follow "Test questionnaire" + When I navigate to "View all responses" in current page administration + Then ".qn-number" "css_element" should exist + Given I follow "List of responses" + When I follow "Admin User" + Then ".qn-number" "css_element" should exist + # Check auto numbering not show in response when turned off. + Given I navigate to "Settings" in current page administration + And I set the field "Auto numbering" to "Do not number questions or pages" + And I press "Save and display" + When I navigate to "View all responses" in current page administration + Then ".qn-number" "css_element" should not exist + Given I follow "List of responses" + When I follow "Admin User" + Then ".qn-number" "css_element" should not exist