diff --git a/questionnaire.class.php b/questionnaire.class.php index 11d5c436..2b9d9739 100644 --- a/questionnaire.class.php +++ b/questionnaire.class.php @@ -423,6 +423,10 @@ public function view_response($rid, $referer= '', $resps = '', $compare = false, } $pdf = ($outputtarget == 'pdf') ? true : false; foreach ($this->questions as $question) { + // Only show eligible questions in the response. + if (!$question->dependency_fulfilled($rid, $this->questions)) { + continue; + } if ($question->type_id < QUESPAGEBREAK) { $i++; } diff --git a/tests/behat/dependency_question.feature b/tests/behat/dependency_question.feature index 8a9a8ccb..a3521389 100644 --- a/tests/behat/dependency_question.feature +++ b/tests/behat/dependency_question.feature @@ -106,3 +106,21 @@ Feature: Questions can be defined to be dependent on answers to multiple previou And I should see "Do you own a dog?" And I should see "Parent Question : position 1 (Q1->Dog) set" And I log out + + @javascript + Scenario: Students can only view answers to questions asked on the individual responses page. + Given I log in as "student1" + And I am on "Course 1" course homepage + And I follow "Test questionnaire" + When I navigate to "Answer the questions..." in current page administration + And I should see "Do you own a car?" + And I click on "Yes" "radio" + And I press "Next Page >>" + And I should see "What colour is the car?" + And I set the field "What colour is the car?" to "Black" + And I press "Next Page >>" + And I press "Submit questionnaire" + And I navigate to "View your response(s)" in current page administration + And I should see "Do you own a car?" + And I should see "What colour is the car?" + Then I should not see "Will you buy a car this year?"