MDL-72179 behat: Add activity editing page resolution
This commit is contained in:
@@ -29,6 +29,7 @@ Feature: Use core page resolvers for the I am on the page steps
|
||||
| Course Short name | ECON101 | COURSE | Fundamentals of Economics |
|
||||
| Course idnumber | "2021-econ101" | Course | Fundamentals of Economics |
|
||||
| Forum idnumber | fundamentalsofeconomics | Activity | Add a new discussion |
|
||||
| Generic activity editing | fundamentalsofeconomics | "Activity editing" | Updating: Forum |
|
||||
|
||||
Scenario Outline: When I am on an instance logged in as
|
||||
Given the following "categories" exist:
|
||||
@@ -55,6 +56,7 @@ Feature: Use core page resolvers for the I am on the page steps
|
||||
| Course Short name | ECON101 | COURSE | Fundamentals of Economics |
|
||||
| Course idnumber | "2021-econ101" | Course | Fundamentals of Economics |
|
||||
| Forum idnumber | fundamentalsofeconomics | Activity | Add a new discussion |
|
||||
| Generic activity editing | fundamentalsofeconomics | "Activity editing" | Updating: Forum |
|
||||
|
||||
Scenario Outline: When I am on a named page
|
||||
Given I log in as "admin"
|
||||
|
||||
@@ -8,32 +8,26 @@ Feature: Edit completion settings of an activity
|
||||
Given the following "courses" exist:
|
||||
| fullname | shortname | enablecompletion |
|
||||
| Course 1 | C1 | 1 |
|
||||
And I log in as "admin"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Page" to section "1" and I fill the form with:
|
||||
| Name | TestPage |
|
||||
| Description | x |
|
||||
| Page content | x |
|
||||
| Completion tracking | 2 |
|
||||
| Require view | 1 |
|
||||
And I am on "Course 1" course homepage
|
||||
And the following "activities" exist:
|
||||
| activity | course | idnumber | intro | name | completion | completionview |
|
||||
| page | C1 | p1 | x | TestPage | 2 | 1 |
|
||||
|
||||
Scenario: Completion is not locked when the activity has not yet been viewed
|
||||
Given I click on "Edit settings" "link" in the "TestPage" activity
|
||||
Given I am on the TestPage "Page Activity editing" page logged in as admin
|
||||
When I expand all fieldsets
|
||||
Then I should see "Completion tracking"
|
||||
And I should not see "Completion options locked"
|
||||
|
||||
Scenario: Completion is locked after the activity has been viewed
|
||||
Given I follow "TestPage"
|
||||
When I follow "Edit settings"
|
||||
Given I am on the TestPage "Page Activity" page logged in as admin
|
||||
When I am on the TestPage "Page Activity editing" page
|
||||
And I expand all fieldsets
|
||||
Then I should see "Completion options locked"
|
||||
|
||||
@javascript
|
||||
Scenario: Pressing the unlock button allows the user to edit completion settings
|
||||
Given I follow "TestPage"
|
||||
When I navigate to "Edit settings" in current page administration
|
||||
Given I am on the TestPage "Page Activity" page logged in as admin
|
||||
When I am on the TestPage "Page Activity editing" page
|
||||
And I expand all fieldsets
|
||||
And I press "Unlock completion options"
|
||||
Then I should see "Completion options unlocked"
|
||||
@@ -45,8 +39,8 @@ Feature: Edit completion settings of an activity
|
||||
|
||||
@javascript
|
||||
Scenario: Even when completion is locked, the user can still set the date
|
||||
Given I follow "TestPage"
|
||||
When I navigate to "Edit settings" in current page administration
|
||||
Given I am on the TestPage "Page Activity" page logged in as admin
|
||||
And I am on the TestPage "Page Activity editing" page
|
||||
And I expand all fieldsets
|
||||
When I click on "id_completionexpected_enabled" "checkbox"
|
||||
And I set the field "id_completionexpected_year" to "2013"
|
||||
|
||||
@@ -715,10 +715,17 @@ class behat_navigation extends behat_base {
|
||||
* Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'.
|
||||
*
|
||||
* Recognised page names are:
|
||||
* | Page type | Identifier meaning | description |
|
||||
* | Category | category idnumber | List of courses in that category. |
|
||||
* | Course | course shortname | Main course home pag |
|
||||
* | Activity | activity idnumber | Start page for that activity |
|
||||
* | Page type | Identifier meaning | description |
|
||||
* | Category | category idnumber | List of courses in that category. |
|
||||
* | Course | course shortname | Main course home pag |
|
||||
* | Activity | activity idnumber | Start page for that activity |
|
||||
* | Activity editing | activity idnumber | Edit settings page for that activity |
|
||||
* | [modname] Activity | activity name or idnumber | Start page for that activity |
|
||||
* | [modname] Activity editing | activity name or idnumber | Edit settings page for that activity |
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* When I am on the "Welcome to ECON101" "forum activity" page logged in as student1
|
||||
*
|
||||
* @param string $type identifies which type of page this is, e.g. 'Category page'.
|
||||
* @param string $identifier identifies the particular page, e.g. 'test-cat'.
|
||||
@@ -751,6 +758,15 @@ class behat_navigation extends behat_base {
|
||||
}
|
||||
return $cm->url;
|
||||
|
||||
case 'activity editing':
|
||||
$cm = $this->get_course_module_for_identifier($identifier);
|
||||
if (!$cm) {
|
||||
throw new Exception('The specified activity with idnumber "' . $identifier . '" does not exist');
|
||||
}
|
||||
return new moodle_url('/course/modedit.php', [
|
||||
'update' => $cm->id,
|
||||
]);
|
||||
|
||||
default:
|
||||
throw new Exception('Unrecognised core page type "' . $type . '."');
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ Feature: Teacher can choose whether to allow students to change their choice res
|
||||
As a teacher
|
||||
I need to enable the option to change the choice
|
||||
|
||||
Scenario: Add a choice activity and complete the activity as a student
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
@@ -16,34 +16,38 @@ Feature: Teacher can choose whether to allow students to change their choice res
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Choice" to section "1" and I fill the form with:
|
||||
| Choice name | Choice name |
|
||||
| Description | Choice Description |
|
||||
| Allow choice to be updated | No |
|
||||
| option[0] | Option 1 |
|
||||
| option[1] | Option 2 |
|
||||
And I log out
|
||||
When I log in as "student1"
|
||||
And I am on "Course 1" course homepage
|
||||
|
||||
Scenario: Change a choice response as a student
|
||||
Given the following "activity" exists:
|
||||
| activity | choice |
|
||||
| course | C1 |
|
||||
| idnumber | Choice name |
|
||||
| name | Choice name |
|
||||
| intro | Choice Description |
|
||||
| section | 1 |
|
||||
| option | Option 1, Option 2 |
|
||||
| allowupdate | 0 |
|
||||
When I am on the "Course 1" course page logged in as student1
|
||||
And I choose "Option 1" from "Choice name" choice activity
|
||||
Then I should see "Your selection: Option 1"
|
||||
And I should see "Your choice has been saved"
|
||||
And "Save my choice" "button" should not exist
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Choice name"
|
||||
And I follow "Edit settings"
|
||||
And I set the following fields to these values:
|
||||
| Allow choice to be updated | Yes |
|
||||
And I press "Save and display"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Choice name"
|
||||
And I should see "Your selection: Option 1"
|
||||
And I should see "Your choice has been saved"
|
||||
Then "Save my choice" "button" should not exist
|
||||
|
||||
Scenario: Change a choice response as a student
|
||||
Given the following "activity" exists:
|
||||
| activity | choice |
|
||||
| course | C1 |
|
||||
| idnumber | Choice name |
|
||||
| name | Choice name |
|
||||
| intro | Choice Description |
|
||||
| section | 1 |
|
||||
| option | Option 1, Option 2 |
|
||||
| allowupdate | 1 |
|
||||
When I am on the "Course 1" course page logged in as student1
|
||||
And I choose "Option 1" from "Choice name" choice activity
|
||||
And I should see "Your selection: Option 1"
|
||||
And I should see "Your choice has been saved"
|
||||
Then I should see "Your selection: Option 1"
|
||||
And "Save my choice" "button" should exist
|
||||
And "Remove my choice" "link" should exist
|
||||
And I set the field "Option 2" to "1"
|
||||
|
||||
Reference in New Issue
Block a user