Merge branch 'wip-mdl-48290' of https://github.com/rajeshtaneja/moodle
[moodle.git] / question / format / gift / tests / behat / import_export.feature
1 @qformat @qformat_gift
2 Feature: Test importing questions from GIFT format.
3   In order to reuse questions
4   As an teacher
5   I need to be able to import them in GIFT format.
7   Background:
8     Given the following "courses" exist:
9       | fullname | shortname | format |
10       | Course 1 | C1        | topics |
11     And the following "users" exist:
12       | username | firstname |
13       | teacher  | Teacher   |
14     And the following "course enrolments" exist:
15       | user    | course | role           |
16       | teacher | C1     | editingteacher |
17     And I log in as "teacher"
18     And I follow "Course 1"
20   @javascript @_file_upload
21   Scenario: import some GIFT questions
22     When I navigate to "Import" node in "Course administration > Question bank"
23     And I set the field "id_format_gift" to "1"
24     And I upload "question/format/gift/tests/fixtures/questions.gift.txt" file to "Import" filemanager
25     And I press "id_submitbutton"
26     Then I should see "Parsing questions from import file."
27     And I should see "Importing 9 questions from file"
28     And I should see "What's between orange and green in the spectrum?"
29     When I press "Continue"
30     Then I should see "colours"
32     # Now export again.
33     And I navigate to "Export" node in "Course administration > Question bank"
34     And I set the field "id_format_gift" to "1"
35     And I press "Export questions to file"
36     And following "click here" should download between "1550" and "1650" bytes
37     # If the download step is the last in the scenario then we can sometimes run
38     # into the situation where the download page causes a http redirect but behat
39     # has already conducted its reset (generating an error). By putting a logout
40     # step we avoid behat doing the reset until we are off that page.
41     And I log out