Merge branch 'wip-mdl-48290' of https://github.com/rajeshtaneja/moodle
[moodle.git] / question / format / xml / tests / behat / import_export.feature
1 @qformat @qformat_xml
2 Feature: Test importing questions from Moodle XML format.
3   In order to reuse questions
4   As an teacher
5   I need to be able to import them in XML 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 true/false questions from Moodle XML format
22     When I navigate to "Import" node in "Course administration > Question bank"
23     And I set the field "id_format_xml" to "1"
24     And I upload "question/format/xml/tests/fixtures/truefalse.xml" 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 2 questions from file"
28     And I should see "is an acronym for Modular Object-Oriented Dynamic Learning Education"
29     And I should see "is an acronym for Modular Object-Oriented Dynamic Learning Environment"
30     When I press "Continue"
31     Then I should see "Moodle acronym (False)"
32     Then I should see "Moodle acronym (True)"
34     # Now export again.
35     And I navigate to "Export" node in "Course administration > Question bank"
36     And I set the field "id_format_xml" to "1"
37     And I press "Export questions to file"
38     And following "click here" should download between "57000" and "58000" bytes
39     # If the download step is the last in the scenario then we can sometimes run
40     # into the situation where the download page causes a http redirect but behat
41     # has already conducted its reset (generating an error). By putting a logout
42     # step we avoid behat doing the reset until we are off that page.
43     And I log out
45   @javascript @_file_upload
46   Scenario: import some multiple choice questions from Moodle XML format
47     When I navigate to "Import" node in "Course administration > Question bank"
48     And I set the field "id_format_xml" to "1"
49     And I upload "question/format/xml/tests/fixtures/multichoice.xml" file to "Import" filemanager
50     And I press "id_submitbutton"
51     Then I should see "Parsing questions from import file."
52     And I should see "Importing 1 questions from file"
53     And I should see "What language is being spoken?"
54     When I press "Continue"
55     Then I should see "Greeting"
57   @javascript @_file_upload
58   Scenario: import some multi-answer questions from Moodle XML format
59     When I navigate to "Import" node in "Course administration > Question bank"
60     And I set the field "id_format_xml" to "1"
61     And I upload "question/format/xml/tests/fixtures/multianswer.xml" file to "Import" filemanager
62     And I press "id_submitbutton"
63     Then I should see "Parsing questions from import file."
64     And I should see "Importing 1 questions from file"
65     And I should see "Match the following cities with the correct state,"
66     When I press "Continue"
67     Then I should see "cloze with images"
69   @javascript @_file_upload
70   Scenario: import some questions with legacy-style images from Moodle XML format
71     When I navigate to "Import" node in "Course administration > Question bank"
72     And I set the field "id_format_xml" to "1"
73     And I upload "question/format/xml/tests/fixtures/sample_questions_with_old_image_tag.xml" file to "Import" filemanager
74     And I press "id_submitbutton"
75     Then I should see "Parsing questions from import file."
76     And I should see "Importing 2 questions from file"
77     And I should see "This is a multianswer question with an image in the old"
78     And I should see "This is a multichoice question with an image in the old"
79     When I press "Continue"
80     Then I should see "cloze question with image"
81     Then I should see "mcq with image"