MDL-71912 mod_lesson: New step definitions for behat.
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
|
||||
// For that reason, we can't even rely on $CFG->admin being available here.
|
||||
|
||||
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');
|
||||
|
||||
use Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
|
||||
use Behat\Mink\Exception\ExpectationException as ExpectationException;
|
||||
|
||||
/**
|
||||
* Step definitions related mod_lesson.
|
||||
*
|
||||
* @package mod_lesson
|
||||
* @category test
|
||||
* @copyright 2021 Adrian Greeve <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class behat_mod_lesson_behat extends behat_base {
|
||||
|
||||
/**
|
||||
* Select the lesson edit type [Collapsed|Expanded]
|
||||
*
|
||||
* @Given i select edit type :edittype
|
||||
*
|
||||
* @param string $edittype The edit type of either Collapsed or Expanded
|
||||
*/
|
||||
public function i_select_edit_type(string $edittype): void {
|
||||
|
||||
$typestring = ($edittype == 'Collapsed') ? get_string('collapsed', 'mod_lesson') : get_string('full', 'mod_lesson');
|
||||
try {
|
||||
$this->execute("behat_forms::i_select_from_the_singleselect", [$typestring, 'jump']);
|
||||
} catch (ElementNotFoundException $e) {
|
||||
$this->execute("behat_general::click_link", [$typestring]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Go to the lesson essay grading page.
|
||||
*
|
||||
* @Given i grade lesson essays
|
||||
*/
|
||||
public function i_grade_lesson_essays(): void {
|
||||
try {
|
||||
$this->execute("behat_general::i_click_on", [get_string('manualgrading', 'mod_lesson'), 'button']);
|
||||
} catch (ElementNotFoundException $e) {
|
||||
$this->execute("behat_general::click_link", [get_string('manualgrading', 'mod_lesson')]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Go to the lesson edit page.
|
||||
*
|
||||
* @Given i edit the lesson
|
||||
*/
|
||||
public function i_edit_the_lesson(): void {
|
||||
try {
|
||||
$this->execute("behat_general::click_link", [get_string('edit', 'mod_lesson')]);
|
||||
} catch (ElementNotFoundException $e) {
|
||||
$this->execute("behat_general::i_click_on", [get_string('edit', 'mod_lesson'), 'button']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
@mod @mod_lesson @skip_interim
|
||||
@mod @mod_lesson
|
||||
Feature: In a lesson activity, teacher can delete question answers and
|
||||
branch table contents
|
||||
In order to modify an existing lesson
|
||||
@@ -47,7 +47,7 @@ branch table contents
|
||||
| id_jumpto_1 | First page name |
|
||||
| id_score_1 | 0 |
|
||||
And I press "Save page"
|
||||
And I select "Expanded" from the "jump" singleselect
|
||||
And I select edit type "Expanded"
|
||||
|
||||
Scenario: Edit lesson content page
|
||||
Given I click on "//th[normalize-space(.)='First page name']/descendant::a[3]" "xpath_element"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@mod @mod_lesson @skip_interim
|
||||
@mod @mod_lesson
|
||||
Feature: In a lesson activity, teacher can edit a cluster page
|
||||
In order to modify an existing lesson and change navigation
|
||||
As a teacher
|
||||
@@ -29,7 +29,7 @@ Feature: In a lesson activity, teacher can edit a cluster page
|
||||
| id_answer_editor_0 | Next page |
|
||||
| id_jumpto_0 | Next page |
|
||||
And I press "Save page"
|
||||
And I select "Expanded" from the "jump" singleselect
|
||||
And I select edit type "Expanded"
|
||||
And I click on "Add a cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][2]" "xpath_element"
|
||||
And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][3]" "xpath_element"
|
||||
And I set the field "Select a question type" to "Multichoice"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@mod @mod_lesson @skip_interim
|
||||
@mod @mod_lesson
|
||||
Feature: In a lesson activity, teacher can edit lesson's pages
|
||||
In order to modify an existing lesson
|
||||
As a teacher
|
||||
@@ -38,7 +38,7 @@ Feature: In a lesson activity, teacher can edit lesson's pages
|
||||
| id_answer_editor_1 | Next page |
|
||||
| id_jumpto_1 | Next page |
|
||||
And I press "Save page"
|
||||
And I select "Expanded" from the "jump" singleselect
|
||||
And I select edit type "Expanded"
|
||||
And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][3]" "xpath_element"
|
||||
And I set the field "Select a question type" to "Numerical"
|
||||
And I press "Add a question page"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@mod @mod_lesson @_file_upload @skip_interim
|
||||
@mod @mod_lesson @_file_upload
|
||||
Feature: In a lesson activity, teacher can add an essay question
|
||||
As a teacher
|
||||
I need to add an essay question in a lesson and grade student attempts
|
||||
@@ -47,7 +47,7 @@ Feature: In a lesson activity, teacher can add an essay question
|
||||
And I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test lesson name"
|
||||
And I click on "Grade essays" "button"
|
||||
And I grade lesson essays
|
||||
And I should see "Student 1"
|
||||
And I should see "Essay question"
|
||||
And I follow "Essay question"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@mod @mod_lesson @skip_interim
|
||||
@mod @mod_lesson
|
||||
Feature: In a lesson activity, students can exit and re-enter the activity when it consists only of cluster pages
|
||||
As a student
|
||||
I need to exit and re-enter a lesson out and into clusters.
|
||||
@@ -28,7 +28,7 @@ Feature: In a lesson activity, students can exit and re-enter the activity when
|
||||
| id_answer_editor_0 | Next page |
|
||||
| id_jumpto_0 | Next page |
|
||||
And I press "Save page"
|
||||
And I select "Expanded" from the "jump" singleselect
|
||||
And I select edit type "Expanded"
|
||||
And I click on "Add a cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][2]" "xpath_element"
|
||||
And I follow "Update page: Cluster"
|
||||
And I set the following fields to these values:
|
||||
|
||||
@@ -18,7 +18,6 @@ Feature: In a lesson activity, students can navigate through a series of pages i
|
||||
| student1 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
|
||||
@skip_interim
|
||||
Scenario: Student navigation with pages and questions
|
||||
Given the following "activities" exist:
|
||||
| activity | name | intro | course | idnumber |
|
||||
@@ -41,7 +40,7 @@ Feature: In a lesson activity, students can navigate through a series of pages i
|
||||
| id_answer_editor_1 | Next page |
|
||||
| id_jumpto_1 | Next page |
|
||||
And I press "Save page"
|
||||
And I select "Expanded" from the "jump" singleselect
|
||||
And I select edit type "Expanded"
|
||||
And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][3]" "xpath_element"
|
||||
And I set the field "Select a question type" to "Numerical"
|
||||
And I press "Add a question page"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@mod @mod_lesson @skip_interim
|
||||
@mod @mod_lesson
|
||||
Feature: In Dashboard, teacher can see the number of student attempts to lessons
|
||||
In order to know the number of student attempts to a lesson
|
||||
As a teacher
|
||||
@@ -68,7 +68,7 @@ Feature: In Dashboard, teacher can see the number of student attempts to lessons
|
||||
| id_response_editor_1 | Wrong |
|
||||
| id_jumpto_1 | This page |
|
||||
And I press "Save page"
|
||||
And I select "Expanded" from the "jump" singleselect
|
||||
And I select edit type "Expanded"
|
||||
And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][3]" "xpath_element"
|
||||
And I set the field "Select a question type" to "True/false"
|
||||
And I press "Add a question page"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@mod @mod_lesson @skip_interim
|
||||
@mod @mod_lesson
|
||||
Feature: In a lesson activity, I need to edit pages in the lesson taking into account locale settings
|
||||
|
||||
Background:
|
||||
@@ -43,7 +43,7 @@ Feature: In a lesson activity, I need to edit pages in the lesson taking into ac
|
||||
Given I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I follow "Test lesson name"
|
||||
And I click on "Edit" "button" in the "region-main" "region"
|
||||
And I edit the lesson
|
||||
And I follow "Hardest question ever"
|
||||
Then I should see "2#87"
|
||||
And I should see "2#1:2#8"
|
||||
@@ -53,8 +53,8 @@ Feature: In a lesson activity, I need to edit pages in the lesson taking into ac
|
||||
Given I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I follow "Test lesson name"
|
||||
And I click on "Edit" "button" in the "region-main" "region"
|
||||
And I select "Expanded" from the "jump" singleselect
|
||||
And I edit the lesson
|
||||
And I select edit type "Expanded"
|
||||
Then I should see "2#87"
|
||||
And I should see "2#1:2#8"
|
||||
And I log out
|
||||
@@ -115,7 +115,7 @@ Feature: In a lesson activity, I need to edit pages in the lesson taking into ac
|
||||
| core_langconfig | decsep | , |
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I follow "Test lesson name"
|
||||
Then I click on "Edit" "button" in the "region-main" "region"
|
||||
Then I edit the lesson
|
||||
And I follow "Hardest question ever"
|
||||
Then I should see "2,87"
|
||||
And I should see "2,1:2,8"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@mod @mod_lesson @skip_interim
|
||||
@mod @mod_lesson
|
||||
Feature: In a lesson activity, students can see their progress viewing a progress bar.
|
||||
In order to create a lesson with conditional paths
|
||||
As a teacher
|
||||
@@ -43,7 +43,7 @@ Feature: In a lesson activity, students can see their progress viewing a progres
|
||||
| id_answer_editor_1 | Next page |
|
||||
| id_jumpto_1 | Next page |
|
||||
And I press "Save page"
|
||||
And I select "Expanded" from the "jump" singleselect
|
||||
And I select edit type "Expanded"
|
||||
And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][3]" "xpath_element"
|
||||
And I set the field "Select a question type" to "Numerical"
|
||||
And I press "Add a question page"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@mod @mod_lesson @skip_interim
|
||||
@mod @mod_lesson
|
||||
Feature: In a lesson activity, students can see questions in random order
|
||||
In order to create a lesson with clusters
|
||||
As a teacher
|
||||
@@ -40,7 +40,7 @@ Feature: In a lesson activity, students can see questions in random order
|
||||
| id_answer_editor_1 | Next page |
|
||||
| id_jumpto_1 | Next page |
|
||||
And I press "Save page"
|
||||
And I select "Expanded" from the "jump" singleselect
|
||||
And I select edit type "Expanded"
|
||||
And I click on "Add a cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][3]" "xpath_element"
|
||||
And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][4]" "xpath_element"
|
||||
And I set the field "Select a question type" to "Multichoice"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@mod @mod_lesson @skip_interim
|
||||
@mod @mod_lesson
|
||||
Feature: In a lesson activity, students can see questions in random order and a single question drawn from a branch
|
||||
In order to create a lesson with a cluster and a subcluster
|
||||
As a teacher
|
||||
@@ -31,7 +31,7 @@ Feature: In a lesson activity, students can see questions in random order and a
|
||||
| id_answer_editor_0 | Next page |
|
||||
| id_jumpto_0 | Next page |
|
||||
And I press "Save page"
|
||||
And I select "Expanded" from the "jump" singleselect
|
||||
And I select edit type "Expanded"
|
||||
And I click on "Add a cluster" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][2]" "xpath_element"
|
||||
And I click on "Add a question page here" "link" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' addlinks ')][3]" "xpath_element"
|
||||
And I set the field "Select a question type" to "Multichoice"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@mod @mod_lesson @skip_interim
|
||||
@mod @mod_lesson
|
||||
Feature: In a lesson activity, a non editing teacher can grade essay questions
|
||||
As a non editing teacher
|
||||
I need to grade student answers to essay questions in lesson
|
||||
@@ -69,7 +69,7 @@ Feature: In a lesson activity, a non editing teacher can grade essay questions
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test lesson name"
|
||||
Then I should see "Grade essays"
|
||||
And I click on "Grade essays" "button"
|
||||
And I grade lesson essays
|
||||
And I should see "Student 1"
|
||||
And I should see "Student 2"
|
||||
And I should see "Essay question"
|
||||
@@ -94,6 +94,6 @@ Feature: In a lesson activity, a non editing teacher can grade essay questions
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test lesson name"
|
||||
Then I should see "Grade essays"
|
||||
And I click on "Grade essays" "button"
|
||||
And I grade lesson essays
|
||||
And I should not see "Student 1"
|
||||
And I should see "Student 2"
|
||||
|
||||
Reference in New Issue
Block a user