first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,50 @@
@availability @availability_date
Feature: availability_date
In order to control student access to activities
As a teacher
I need to set date conditions which prevent student access
Background:
Given the following "courses" exist:
| fullname | shortname | format | enablecompletion |
| Course 1 | C1 | topics | 1 |
And the following "users" exist:
| username |
| teacher1 |
| student1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activities" exist:
| activity | course | name |
| page | C1 | Page 1 |
| page | C1 | Page 2 |
@javascript
Scenario: Test condition
# Add a Page with a date condition that does match (from the past).
Given I am on the "Page 1" "page activity editing" page logged in as "teacher1"
And I expand all fieldsets
And I click on "Add restriction..." "button"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
And I click on ".availability-item .availability-eye img" "css_element"
And I set the field "year" to "2013"
And I press "Save and return to course"
# Add a Page with a date condition that doesn't match (until the past).
And I am on the "Page 2" "page activity editing" page
And I expand all fieldsets
And I click on "Add restriction..." "button"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
And I click on ".availability-item .availability-eye img" "css_element"
And I set the field "Direction" to "until"
And I set the field "year" to "2013"
And I press "Save and return to course"
# Log back in as student.
When I am on the "Course 1" "course" page logged in as "student1"
# Page 1 should appear, but page 2 does not.
Then I should see "Page 1" in the "region-main" "region"
And I should not see "Page 2" in the "region-main" "region"
@@ -0,0 +1,105 @@
@availability @availability_date @javascript
Feature: As a teacher I can set availability dates restriction to an activity and see a warning when conflicting dates are set
Background:
Given the following "courses" exist:
| fullname | shortname | format | enablecompletion |
| Course 1 | C1 | topics | 1 |
And the following "users" exist:
| username |
| teacher1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | name | intro | introformat | course | content | contentformat | idnumber |
| page | PageName1 | PageDesc1 | 1 | C1 | Page 1 | 1 | 1 |
Scenario: When I set dates to potential conflicting dates in the same subset, I should see a warning.
Given I am on the PageName1 "page activity editing" page logged in as teacher1
And I expand all fieldsets
And I click on "Add restriction..." "button" in the "root" "core_availability > Availability Button Area"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
And I set the field "year" in the "1" "availability_date > Date Restriction" to "2023"
And I set the field "Month" in the "1" "availability_date > Date Restriction" to "April"
And I set the field "day" in the "1" "availability_date > Date Restriction" to "4"
And I set the field "Direction" in the "1" "availability_date > Date Restriction" to "from"
And I click on "Add restriction..." "button" in the "root" "core_availability > Availability Button Area"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
And I set the field "year" in the "2" "availability_date > Date Restriction" to "2023"
And I set the field "Month" in the "2" "availability_date > Date Restriction" to "April"
And I set the field "day" in the "2" "availability_date > Date Restriction" to "6"
And I set the field "Direction" in the "2" "availability_date > Date Restriction" to "until"
And I click on "Add restriction..." "button" in the "root" "core_availability > Availability Button Area"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
And I set the field "year" in the "3" "availability_date > Date Restriction" to "2023"
And I set the field "Month" in the "3" "availability_date > Date Restriction" to "April"
And I set the field "day" in the "3" "availability_date > Date Restriction" to "6"
When I set the field "Direction" in the "3" "availability_date > Date Restriction" to "from"
Then I should see "Conflicts with other date restrictions"
Scenario: If there are conflicting dates in the same subset, I should not see a warning if condition are separated by "any".
Given I am on the PageName1 "page activity editing" page logged in as teacher1
And I expand all fieldsets
And I click on "Add restriction..." "button" in the "root" "core_availability > Availability Button Area"
And I click on "Restriction set" "button" in the "Add restriction..." "dialogue"
And I click on "Add restriction..." "button" in the "1" "core_availability > Availability Button Area"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
And I set the field "year" in the "1.1" "availability_date > Date Restriction" to "2023"
And I set the field "Month" in the "1.1" "availability_date > Date Restriction" to "April"
And I set the field "day" in the "1.1" "availability_date > Date Restriction" to "4"
And I set the field "Direction" in the "1.1" "availability_date > Date Restriction" to "from"
And I click on "Add restriction..." "button" in the "1" "core_availability > Availability Button Area"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
And I set the field "year" in the "1.2" "availability_date > Date Restriction" to "2023"
And I set the field "Month" in the "1.2" "availability_date > Date Restriction" to "April"
And I set the field "day" in the "1.2" "availability_date > Date Restriction" to "6"
And I set the field "Direction" in the "1.2" "availability_date > Date Restriction" to "until"
And I click on "Add restriction..." "button" in the "1" "core_availability > Availability Button Area"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
And I set the field "year" in the "1.3" "availability_date > Date Restriction" to "2023"
And I set the field "Month" in the "1.3" "availability_date > Date Restriction" to "April"
And I set the field "day" in the "1.3" "availability_date > Date Restriction" to "6"
And I set the field "Direction" in the "1.3" "availability_date > Date Restriction" to "from"
When I set the field "Required restrictions" in the "1" "core_availability > Set Of Restrictions" to "any"
Then I should not see "Conflicts with other date restrictions"
Scenario: There should a conflicting availability dates are in the same subset separated by "all".
Given I am on the PageName1 "page activity editing" page logged in as teacher1
And I expand all fieldsets
# Root level: Student "must" match the following.
And I click on "Add restriction..." "button" in the "root" "core_availability > Availability Button Area"
And I click on "Restriction set" "button" in the "Add restriction..." "dialogue"
# This is the second level: Student "must" match any of the following.
And I click on "Add restriction..." "button" in the "1" "core_availability > Availability Button Area"
And I click on "Restriction set" "button" in the "Add restriction..." "dialogue"
# And now the third and final level.
And I click on "Add restriction..." "button" in the "1.1" "core_availability > Availability Button Area"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
And I set the field "year" in the "1.1.1" "availability_date > Date Restriction" to "2023"
And I set the field "Month" in the "1.1.1" "availability_date > Date Restriction" to "April"
And I set the field "day" in the "1.1.1" "availability_date > Date Restriction" to "2"
And I set the field "Direction" in the "1.1.1" "availability_date > Date Restriction" to "from"
And I click on "Add restriction..." "button" in the "1.1" "core_availability > Availability Button Area"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
And I set the field "year" in the "1.1.2" "availability_date > Date Restriction" to "2023"
And I set the field "Month" in the "1.1.2" "availability_date > Date Restriction" to "April"
And I set the field "day" in the "1.1.2" "availability_date > Date Restriction" to "3"
And I set the field "Direction" in the "1.1.2" "availability_date > Date Restriction" to "until"
# Then add a restriction to the second level.
And I click on "Add restriction..." "button" in the "1" "core_availability > Availability Button Area"
And I click on "Restriction set" "button" in the "Add restriction..." "dialogue"
And I click on "Add restriction..." "button" in the "1.2" "core_availability > Availability Button Area"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
And I set the field "year" in the "1.2.1" "availability_date > Date Restriction" to "2023"
And I set the field "Month" in the "1.2.1" "availability_date > Date Restriction" to "April"
And I set the field "day" in the "1.2.1" "availability_date > Date Restriction" to "4"
And I set the field "Direction" in the "1.2.1" "availability_date > Date Restriction" to "from"
And I click on "Add restriction..." "button" in the "1.2" "core_availability > Availability Button Area"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
And I set the field "year" in the "1.2.2" "availability_date > Date Restriction" to "2023"
And I set the field "Month" in the "1.2.2" "availability_date > Date Restriction" to "April"
And I set the field "day" in the "1.2.2" "availability_date > Date Restriction" to "3"
When I set the field "Direction" in the "1.2.2" "availability_date > Date Restriction" to "until"
# Same subset, we can detect conflicts.
Then I should see "Conflicts with other date restrictions"
@@ -0,0 +1,39 @@
<?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/>.
use Behat\Mink\Element\NodeElement;
/**
* Behat availabilty-related steps definitions.
*
* @package availability_date
* @category test
* @copyright 2023 Laurent David <laurent.david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_availability_date extends behat_base {
/**
* Return the list of partial named selectors.
*
* @return array
*/
public static function get_partial_named_selectors(): array {
return [
new behat_component_named_selector(
'Date Restriction', ["//div[h3[@data-restriction-order=%locator% and contains(text(), 'Date restriction')]]"]
),
];
}
}