Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions questionnaire.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down
18 changes: 18 additions & 0 deletions tests/behat/dependency_question.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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?"