[ Index ]

PHP Cross Reference of Moodle 310

title

Body

[close]

/mod/feedback/tests/behat/ -> templates.feature (source)

   1  @mod @mod_feedback
   2  Feature: Saving, using and deleting feedback templates
   3    In order to quickly create feedbacks
   4    As a manager
   5    I need to be able to create feedback templates
   6  
   7    Background:
   8      Given the following "users" exist:
   9        | username | firstname | lastname |
  10        | teacher  | Teacher   | 1        |
  11        | manager  | Manager   | 1        |
  12      And the following "courses" exist:
  13        | fullname | shortname |
  14        | Course 1 | C1        |
  15        | Course 2 | C2        |
  16      And the following "course enrolments" exist:
  17        | user     | course | role           |
  18        | teacher  | C1     | editingteacher |
  19        | teacher  | C2     | editingteacher |
  20      And the following "system role assigns" exist:
  21        | user    | course               | role    |
  22        | manager | Acceptance test site | manager |
  23      And the following "activities" exist:
  24        | activity   | name                         | course | idnumber    |
  25        | feedback   | Learning experience course 1 | C1     | feedback1   |
  26        | feedback   | Another feedback in course 1 | C1     | feedback2   |
  27        | feedback   | Learning experience course 2 | C2     | feedback3   |
  28      And I am on the "Learning experience course 1" "feedback activity" page logged in as teacher
  29      And I click on "Edit questions" "link" in the "[role=main]" "css_element"
  30      And I add a "Multiple choice" question to the feedback with:
  31        | Question         | this is a multiple choice 1 |
  32        | Label            | multichoice1                |
  33        | Multiple choice type | Multiple choice - single answer |
  34        | Multiple choice values | option a\noption b\noption c  |
  35      And I log out
  36  
  37    Scenario: Teacher can save template and re-use it in the same course only
  38      # Go to feedback templates and make sure none exist yet
  39      When I am on the "Learning experience course 1" "feedback activity" page logged in as teacher
  40      And I follow "Templates"
  41      Then I should see "No templates available yet"
  42      And "Use a template" "field" should not exist
  43      And "Public" "field" should not exist
  44      And I follow "Delete template..."
  45      And "No templates available yet" "text" should exist in the ".coursetemplates" "css_element"
  46      And ".publictemplates" "css_element" should not exist
  47      And I press "Back"
  48      # Save as a course template
  49      And I set the field "Name" to "My first template"
  50      And I press "Save as new template"
  51      And I should see "Template saved"
  52      And the "Use a template" select box should contain "My first template"
  53      # Create a feedback from this template in the same course
  54      And I am on the "Another feedback in course 1" "feedback activity" page
  55      And I follow "Templates"
  56      And I set the field "Use a template" to "My first template"
  57      And I press "Use this template"
  58      And I should see "this is a multiple choice 1"
  59      And I press "Save changes"
  60      And I follow "Edit questions"
  61      And I should see "this is a multiple choice 1"
  62      # Make sure this template is not available in another course
  63      And I am on the "Learning experience course 2" "feedback activity" page
  64      And I follow "Templates"
  65      And "Use a template" "field" should not exist
  66      And I should see "No templates available yet"
  67  
  68    Scenario: Teacher can append template to existing questions or remove them
  69      # Save feedback as a course template
  70      When I am on the "Learning experience course 1" "feedback activity" page logged in as teacher
  71      And I follow "Templates"
  72      And I set the field "Name" to "My first template"
  73      And I press "Save as new template"
  74      # Add questions to another feedback
  75      And I am on the "Another feedback in course 1" "feedback activity" page
  76      And I click on "Edit questions" "link" in the "[role=main]" "css_element"
  77      And I add a "Multiple choice" question to the feedback with:
  78        | Question         | What is your favourite subject |
  79        | Label            | subjectchoice                  |
  80        | Multiple choice type | Multiple choice - single answer   |
  81        | Multiple choice values | Maths\bScience\nEnglish\nOther  |
  82      # Import template appending items
  83      And I follow "Templates"
  84      And I set the field "Use a template" to "My first template"
  85      And I press "Use this template"
  86      And I set the field "Append new items" to "1"
  87      And I press "Save changes"
  88      And I follow "Edit questions"
  89      Then "What is your favourite subject" "text" should appear before "this is a multiple choice 1" "text"
  90      # Import template replacing items
  91      And I follow "Templates"
  92      And I set the field "Use a template" to "My first template"
  93      And I press "Use this template"
  94      And I set the field "Delete old items" to "1"
  95      And I press "Save changes"
  96      And I follow "Edit questions"
  97      And I should not see "What is your favourite subject"
  98      And I should see "this is a multiple choice 1"
  99  
 100    Scenario: Manager can save template as public and it will be available in any course
 101      When I am on the "Learning experience course 1" "feedback activity" page logged in as manager
 102      And I follow "Templates"
 103      And I set the field "Name" to "My first template"
 104      And I set the field "Public" to "1"
 105      And I press "Save as new template"
 106      And I log out
 107      And I am on the "Learning experience course 2" "feedback activity" page logged in as teacher
 108      And I follow "Templates"
 109      And I set the field "Use a template" to "My first template"
 110      And I press "Use this template"
 111      Then I should see "this is a multiple choice 1"
 112      And I press "Save changes"
 113      And I follow "Edit questions"
 114      And I should see "this is a multiple choice 1"
 115  
 116    Scenario: Teacher can delete course templates but can not delete public templates
 117      # Save feedback as both public and course template
 118      When I am on the "Learning experience course 1" "feedback activity" page logged in as manager
 119      And I follow "Templates"
 120      And I set the field "Name" to "My public template"
 121      And I set the field "Public" to "1"
 122      And I press "Save as new template"
 123      And I set the field "Name" to "My course template"
 124      And I press "Save as new template"
 125      And I log out
 126      # Login as teacher and try to delete templates
 127      And I am on the "Another feedback in course 1" "feedback activity" page logged in as teacher
 128      And I follow "Templates"
 129      And I follow "Delete template..."
 130      Then I should not see "My public template"
 131      And ".publictemplates" "css_element" should not exist
 132      And "My course template" "text" should exist in the ".coursetemplates" "css_element"
 133      And I click on "Delete" "link" in the "My course template" "table_row"
 134      And I should see "Template deleted"
 135      And "My course template" "text" should not exist in the ".coursetemplates" "css_element"
 136      And "No templates available yet" "text" should exist in the ".coursetemplates" "css_element"
 137      And I press "Back"
 138      And the "Use a template" select box should not contain "My course template"
 139      And the "Use a template" select box should contain "My public template"
 140  
 141    @javascript
 142    Scenario: Manager can delete both course and public templates
 143      # Save feedback as both public and course template
 144      When I am on the "Learning experience course 1" "feedback activity" page logged in as manager
 145      And I click on "Templates" "link" in the "[role=main]" "css_element"
 146      And I set the field "Name" to "My public template"
 147      And I set the field "Public" to "1"
 148      And I press "Save as new template"
 149      And I set the field "Name" to "My course template"
 150      And I press "Save as new template"
 151      # Delete course template
 152      And I follow "Delete template..."
 153      Then "My public template" "text" should exist in the ".publictemplates" "css_element"
 154      And "My course template" "text" should exist in the ".coursetemplates" "css_element"
 155      And I click on "Delete" "link" in the "My course template" "table_row"
 156      And I should see "Are you sure you want to delete this template?"
 157      And I press "Yes"
 158      And I should see "Template deleted"
 159      And "My course template" "text" should not exist in the ".coursetemplates" "css_element"
 160      And "No templates available yet" "text" should exist in the ".coursetemplates" "css_element"
 161      # Delete public template
 162      And "My public template" "text" should exist in the ".publictemplates" "css_element"
 163      And I click on "Delete" "link" in the "My public template" "table_row"
 164      And I should see "Are you sure you want to delete this template?"
 165      And I press "Yes"
 166      And I should see "Template deleted"
 167      And "My public template" "text" should not exist in the ".publictemplates" "css_element"
 168      And "No templates available yet" "text" should exist in the ".publictemplates" "css_element"
 169      And I press "Back"
 170      And "Use a template" "field" should not exist
 171      And I should see "No templates available yet"


Generated: Wed Jan 22 11:59:49 2025 Cross-referenced by PHPXref 0.7.1