Skip to content

Commit e401ba3

Browse files
toanlamttoanlamt
andauthored
Questionnaire: All branching shown in View your response (#616)
* Questionnaire: All branching shown in View your response --------- Co-authored-by: toanlamt <[email protected]>
1 parent 2c457ae commit e401ba3

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

questionnaire.class.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,10 @@ public function view_response($rid, $referer= '', $resps = '', $compare = false,
423423
}
424424
$pdf = ($outputtarget == 'pdf') ? true : false;
425425
foreach ($this->questions as $question) {
426+
// Only show eligible questions in the response.
427+
if (!$question->dependency_fulfilled($rid, $this->questions)) {
428+
continue;
429+
}
426430
if ($question->type_id < QUESPAGEBREAK) {
427431
$i++;
428432
}

tests/behat/dependency_question.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,21 @@ Feature: Questions can be defined to be dependent on answers to multiple previou
106106
And I should see "Do you own a dog?"
107107
And I should see "Parent Question : position 1 (Q1->Dog) set"
108108
And I log out
109+
110+
@javascript
111+
Scenario: Students can only view answers to questions asked on the individual responses page.
112+
Given I log in as "student1"
113+
And I am on "Course 1" course homepage
114+
And I follow "Test questionnaire"
115+
When I navigate to "Answer the questions..." in current page administration
116+
And I should see "Do you own a car?"
117+
And I click on "Yes" "radio"
118+
And I press "Next Page >>"
119+
And I should see "What colour is the car?"
120+
And I set the field "What colour is the car?" to "Black"
121+
And I press "Next Page >>"
122+
And I press "Submit questionnaire"
123+
And I navigate to "View your response(s)" in current page administration
124+
And I should see "Do you own a car?"
125+
And I should see "What colour is the car?"
126+
Then I should not see "Will you buy a car this year?"

0 commit comments

Comments
 (0)