| 1 | efrain | 1 | @mod @mod_questionnaire
 | 
        
           |  |  | 2 | Feature: Questionnaires can use an existing public survey to gather responses in one place.
 | 
        
           |  |  | 3 |   When a student answers the same public questionnaire in two different course instances
 | 
        
           |  |  | 4 |   The answers will be visible only in those course instances.
 | 
        
           |  |  | 5 |   | 
        
           |  |  | 6 |   Background: Add a public questionnaire and use it in two different course.
 | 
        
           |  |  | 7 |     Given the following "users" exist:
 | 
        
           |  |  | 8 |       | username | firstname | lastname | email |
 | 
        
           |  |  | 9 |       | teacher1 | Teacher | 1 | teacher1@example.com |
 | 
        
           |  |  | 10 |       | student1 | Student | 1 | student1@example.com |
 | 
        
           |  |  | 11 |     And the following "courses" exist:
 | 
        
           |  |  | 12 |       | fullname | shortname | category |
 | 
        
           |  |  | 13 |       | Course 1 | C1 | 0 |
 | 
        
           |  |  | 14 |       | Course 2 | C2 | 0 |
 | 
        
           |  |  | 15 |       | Course 3 | C3 | 0 |
 | 
        
           |  |  | 16 |     And the following "course enrolments" exist:
 | 
        
           |  |  | 17 |       | user | course | role |
 | 
        
           |  |  | 18 |       | teacher1 | C1 | manager |
 | 
        
           |  |  | 19 |       | teacher1 | C2 | manager |
 | 
        
           |  |  | 20 |       | student1 | C2 | student |
 | 
        
           |  |  | 21 |       | teacher1 | C3 | manager |
 | 
        
           |  |  | 22 |       | student1 | C3 | student |
 | 
        
           |  |  | 23 |     And the following "activities" exist:
 | 
        
           |  |  | 24 |       | activity | name | description | course | idnumber |
 | 
        
           |  |  | 25 |       | questionnaire | Public questionnaire | Anonymous questionnaire description | C1 | questionnaire0 |
 | 
        
           |  |  | 26 |   | 
        
           |  |  | 27 |   @javascript
 | 
        
           |  |  | 28 |   Scenario: Public questionnaire instances have responses visible in their respective courses
 | 
        
           |  |  | 29 |     And I log in as "teacher1"
 | 
        
           |  |  | 30 |     And I am on "Course 1" course homepage
 | 
        
           |  |  | 31 |     And I follow "Public questionnaire"
 | 
        
           |  |  | 32 |     And I navigate to "Advanced settings" in current page administration
 | 
        
           |  |  | 33 |     And I set the field "realm" to "public"
 | 
        
           |  |  | 34 |     And I press "Save and display"
 | 
        
           |  |  | 35 |     And I navigate to "Questions" in current page administration
 | 
        
           |  |  | 36 |     And I add a "Numeric" question and I fill the form with:
 | 
        
           |  |  | 37 |       | Question Name | Q1 |
 | 
        
           |  |  | 38 |       | Yes | y |
 | 
        
           |  |  | 39 |       | Question Text | Enter a number |
 | 
        
           |  |  | 40 |   | 
        
           |  |  | 41 |     And I am on "Course 2" course homepage with editing mode on
 | 
        
           |  |  | 42 |     And I add a "Questionnaire" to section "1" and I fill the form with:
 | 
        
           |  |  | 43 |       | Name | Questionnaire instance 1 |
 | 
        
           |  |  | 44 |       | Description | Description |
 | 
        
           |  |  | 45 |       | Use public | Public questionnaire [Course 1] |
 | 
        
           |  |  | 46 |     Then I should see "Questionnaire instance 1"
 | 
        
           |  |  | 47 |   | 
        
           |  |  | 48 |     And I am on "Course 3" course homepage with editing mode on
 | 
        
           |  |  | 49 |     And I add a "Questionnaire" to section "1" and I fill the form with:
 | 
        
           |  |  | 50 |       | Name | Questionnaire instance 2 |
 | 
        
           |  |  | 51 |       | Description | Description |
 | 
        
           |  |  | 52 |       | Use public | Public questionnaire [Course 1] |
 | 
        
           |  |  | 53 |     Then I should see "Questionnaire instance 2"
 | 
        
           |  |  | 54 |     And I log out
 | 
        
           |  |  | 55 |   | 
        
           |  |  | 56 |     And I log in as "student1"
 | 
        
           |  |  | 57 |     And I am on "Course 2" course homepage
 | 
        
           |  |  | 58 |     And I follow "Questionnaire instance 1"
 | 
        
           |  |  | 59 |     And I navigate to "Answer the questions..." in current page administration
 | 
        
           |  |  | 60 |     Then I should see "Questionnaire instance 1"
 | 
        
           |  |  | 61 |     And I set the field "Enter a number" to "1"
 | 
        
           |  |  | 62 |     And I press "Submit questionnaire"
 | 
        
           |  |  | 63 |     Then I should see "Thank you for completing this Questionnaire."
 | 
        
           |  |  | 64 |     And I press "Continue"
 | 
        
           |  |  | 65 |     Then I should see "View your response(s)"
 | 
        
           |  |  | 66 |     And I should see "Enter a number"
 | 
        
           |  |  | 67 |     And "//div[contains(@class,'questionnaire_numeric') and contains(@class,'questionnaire_response')]//span[@class='selected' and text()='1']" "xpath_element" should exist
 | 
        
           |  |  | 68 |   | 
        
           |  |  | 69 |     And I am on "Course 3" course homepage
 | 
        
           |  |  | 70 |     And I follow "Questionnaire instance 2"
 | 
        
           |  |  | 71 |     And I should see "Answer the questions..."
 | 
        
           |  |  | 72 |     And I should not see "View your response(s)"
 | 
        
           |  |  | 73 |     And I navigate to "Answer the questions..." in current page administration
 | 
        
           |  |  | 74 |     Then I should see "Questionnaire instance 2"
 | 
        
           |  |  | 75 |     And I set the field "Enter a number" to "2"
 | 
        
           |  |  | 76 |     And I press "Submit questionnaire"
 | 
        
           |  |  | 77 |     Then I should see "Thank you for completing this Questionnaire."
 | 
        
           |  |  | 78 |     And I press "Continue"
 | 
        
           |  |  | 79 |     Then I should see "View your response(s)"
 | 
        
           |  |  | 80 |     And I should see "Enter a number"
 | 
        
           |  |  | 81 |     And "//div[contains(@class,'questionnaire_numeric') and contains(@class,'questionnaire_response')]//span[@class='selected' and text()='2']" "xpath_element" should exist
 | 
        
           |  |  | 82 |   | 
        
           |  |  | 83 |     And I am on "Course 2" course homepage
 | 
        
           |  |  | 84 |     And I follow "Questionnaire instance 1"
 | 
        
           |  |  | 85 |     Then I should see "View your response(s)"
 | 
        
           |  |  | 86 |     And I navigate to "View your response(s)" in current page administration
 | 
        
           |  |  | 87 |     And I should see "Enter a number"
 | 
        
           |  |  | 88 |     And "//div[contains(@class,'questionnaire_numeric') and contains(@class,'questionnaire_response')]//span[@class='selected' and text()='1']" "xpath_element" should exist
 | 
        
           |  |  | 89 |   | 
        
           |  |  | 90 |     And I am on "Course 3" course homepage
 | 
        
           |  |  | 91 |     And I follow "Questionnaire instance 2"
 | 
        
           |  |  | 92 |     Then I should see "View your response(s)"
 | 
        
           |  |  | 93 |     And I navigate to "View your response(s)" in current page administration
 | 
        
           |  |  | 94 |     And I should see "Enter a number"
 | 
        
           |  |  | 95 |     And "//div[contains(@class,'questionnaire_numeric') and contains(@class,'questionnaire_response')]//span[@class='selected' and text()='2']" "xpath_element" should exist
 | 
        
           |  |  | 96 |     And I log out
 |