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,351 @@
@mod @mod_data
Feature: Users can add the ##actionsmenu## replacement to the database templates
In order to display all the actions for entries in templates
As a teacher
I need to edit the templates and add the actionsmenu replacement
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| data | Test database name | Database intro | C1 | data1 |
And the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | field1 | Test field description |
| data1 | text | field2 | Test field 2 description |
And the following "mod_data > templates" exist:
| database | name |
| data1 | singletemplate |
| data1 | listtemplate |
| data1 | addtemplate |
| data1 | asearchtemplate |
| data1 | rsstemplate |
And the following "mod_data > entries" exist:
| database | user | field1 | field2 |
| data1 | student1 | Student entry 1 | Some student content 1 |
| data1 | teacher1 | Teacher entry 1 | Some teacher content 1 |
And I am on the "Test database name" "data activity" page logged in as teacher1
And I navigate to "Templates" in current page administration
And I set the field "Templates tertiary navigation" to "List view template"
And I set the field "Enable code editor" to "0"
And I set the following fields to these values:
| Header | <table> |
| Repeated entry | <tr><td>[[field1]]</td><td>##actionsmenu##</td><tr> |
| Footer | </table> |
And I click on "Save" "button" in the "sticky-footer" "region"
And I set the field "Templates tertiary navigation" to "Single view template"
And I set the following fields to these values:
| Single view template | <table><tr><td>[[field1]]</td><td>[[field2]]</td><td>##actionsmenu##</td><tr></table> |
And I click on "Save" "button" in the "sticky-footer" "region"
@javascript
Scenario: The ##actionsmenu## replacement displays the expected actions with default settings depending on the user permissions
Given I navigate to "Database" in current page administration
# Teachers should be able to edit/delete all the entries.
When I open the action menu in "Student entry 1" "table_row"
Then I should see "Show more"
And I should see "Edit"
And I should see "Delete"
But I should not see "Approve"
And I should not see "Undo approval"
And I should not see "Export to portfolio"
And I press the escape key
And I open the action menu in "Teacher entry 1" "table_row"
And I should see "Show more"
And I should see "Edit"
And I should see "Delete"
# Single view (for teacher).
And I choose "Show more" in the open action menu
And I should see "Teacher entry 1"
And I should see "Some teacher content 1"
And I should not see "Student entry 1"
And I open the action menu in "Teacher entry 1" "table_row"
And I should not see "Show more"
And I should see "Edit"
And I should see "Delete"
And I should not see "Approve"
And I should not see "Undo approval"
And I should not see "Export to portfolio"
And I press the escape key
And I follow "Previous page"
And I should see "Student entry 1"
And I should see "Some student content 1"
And I should not see "Teacher entry 1"
And I open the action menu in "Student entry 1" "table_row"
And I should not see "Show more"
And I should see "Edit"
And I should see "Delete"
And I log out
# Students only should edit/delete their entries.
But I am on the "Test database name" "data activity" page logged in as student1
And I open the action menu in "Student entry 1" "table_row"
And I should see "Show more"
And I should see "Edit"
And I should see "Delete"
And I should not see "Approve"
And I should not see "Undo approval"
And I should not see "Export to portfolio"
And I press the escape key
And I open the action menu in "Teacher entry 1" "table_row"
And I should see "Show more"
And I should not see "Edit"
And I should not see "Delete"
# Single view (for student).
And I choose "Show more" in the open action menu
And I should see "Teacher entry 1"
And I should see "Some teacher content 1"
And I should not see "Student entry 1"
And I should not see "Actions" in the "Teacher entry 1" "table_row"
And I follow "Previous page"
And I should see "Student entry 1"
And I should see "Some student content 1"
And I should not see "Teacher entry 1"
And I open the action menu in "Student entry 1" "table_row"
And I should not see "Show more"
And I should see "Edit"
And I should see "Delete"
And I should not see "Approve"
And I should not see "Undo approval"
And I should not see "Export to portfolio"
@javascript
Scenario: The ##actionsmenu## replacement displays the Approval/Undo approval options
Given I navigate to "Settings" in current page administration
And I follow "Entries"
And I set the field "Approval required" to "Yes"
And I press "Save and display"
When I navigate to "Database" in current page administration
# Teachers should be able to approve/unapprove all the entries from list view.
And I open the action menu in "Student entry 1" "table_row"
Then I should see "Approve"
And I should not see "Undo approval"
And I choose "Approve" in the open action menu
And I should see "Entry approved"
And I press "Dismiss this notification"
And I open the action menu in "Student entry 1" "table_row"
And I should see "Undo approval"
And I should not see "Approve" in the ".menu-action-text" "css_element"
And I press the escape key
And I open the action menu in "Teacher entry 1" "table_row"
And I should see "Undo approval"
And I should not see "Approve" in the ".menu-action-text" "css_element"
# Single view (for teacher).
And I choose "Show more" in the open action menu
And I should see "Teacher entry 1"
And I open the action menu in "Teacher entry 1" "table_row"
And I should see "Undo approval"
And I should not see "Approve"
And I press the escape key
And I follow "Previous page"
And I should see "Student entry 1"
And I open the action menu in "Student entry 1" "table_row"
And I should not see "Approve"
And I should see "Undo approval"
# Check entries can be approved/unapproved from single view too.
And I choose "Undo approval" in the open action menu
And I should see "Entry unapproved"
And I press "Dismiss this notification"
And I open the action menu in "Student entry 1" "table_row"
And I should see "Approve"
And I should not see "Undo approval"
And I log out
# Students should not see the Approve/Undo approval options.
But I am on the "Test database name" "data activity" page logged in as student1
And I open the action menu in "Teacher entry 1" "table_row"
And I should not see "Approve"
And I should not see "Undo approval"
And I press the escape key
And I open the action menu in "Student entry 1" "table_row"
And I should not see "Approve"
And I should not see "Undo approval"
# Single view (for student).
And I choose "Show more" in the open action menu
And I should see "Student entry 1"
And I open the action menu in "Student entry 1" "table_row"
And I should not see "Approve"
And I should not see "Undo approval"
And I follow "Next page"
And I should see "Teacher entry 1"
And I should not see "Actions" in the "Teacher entry 1" "table_row"
@javascript
Scenario: The ##actionsmenu## replacement displays the Export to portfolio options
Given I log in as "admin"
And the following config values are set as admin:
| enableportfolios | 1 |
And I navigate to "Plugins > Portfolios > Manage portfolios" in site administration
And I set portfolio instance "File download" to "Enabled and visible"
And I click on "Save" "button"
And I log out
And I am on the "Test database name" "data activity" page logged in as teacher1
# Teachers should be able to export to portfolio all the entries from list view.
When I open the action menu in "Student entry 1" "table_row"
Then I should see "Export to portfolio"
And I choose "Export to portfolio" in the open action menu
And I should see "Configure exported data"
And I press "Cancel"
And I click on "Yes" "button" in the "Confirm" "dialogue"
And I open the action menu in "Teacher entry 1" "table_row"
And I should see "Export to portfolio"
# Single view (for teacher).
And I choose "Show more" in the open action menu
And I should see "Teacher entry 1"
And I open the action menu in "Teacher entry 1" "table_row"
And I should see "Export to portfolio"
And I press the escape key
And I follow "Previous page"
And I should see "Student entry 1"
And I open the action menu in "Student entry 1" "table_row"
And I should see "Export to portfolio"
# Check entries can be exported from single view too.
And I choose "Export to portfolio" in the open action menu
And I should see "Configure exported data"
And I log out
# Students should only export their entries.
But I am on the "Test database name" "data activity" page logged in as student1
And I open the action menu in "Teacher entry 1" "table_row"
And I should not see "Export to portfolio"
And I press the escape key
And I open the action menu in "Student entry 1" "table_row"
And I should see "Export to portfolio"
And I choose "Export to portfolio" in the open action menu
And I should see "Configure exported data"
And I press "Cancel"
And I click on "Yes" "button" in the "Confirm" "dialogue"
And I open the action menu in "Teacher entry 1" "table_row"
# Single view (for student).
And I choose "Show more" in the open action menu
And I should see "Teacher entry 1"
And I should not see "Actions" in the "Teacher entry 1" "table_row"
And I follow "Previous page"
And I should see "Student entry 1"
And I open the action menu in "Student entry 1" "table_row"
And I should see "Export to portfolio"
And I choose "Export to portfolio" in the open action menu
And I should see "Configure exported data"
@javascript
Scenario: The ##actionsmenu## replacement does not display the Export to portfolio option when there are no portfolios enabled
Given I log in as "admin"
And the following config values are set as admin:
| enableportfolios | 1 |
And I log out
And I am on the "Test database name" "data activity" page logged in as teacher1
When I open the action menu in "Student entry 1" "table_row"
Then I should not see "Export to portfolio"
And I log out
# If we enable, at least, one portfolio, the Export to portfolio option should be displayed.
But I log in as "admin"
And I navigate to "Plugins > Portfolios > Manage portfolios" in site administration
And I set portfolio instance "File download" to "Enabled and visible"
And I click on "Save" "button"
And I log out
And I am on the "Test database name" "data activity" page logged in as teacher1
And I open the action menu in "Student entry 1" "table_row"
And I should see "Export to portfolio"
@javascript
Scenario: The Edit option in the ##actionsmenu## replacement is working
Given I navigate to "Database" in current page administration
# Teachers should be able to edit any entry.
And I open the action menu in "Student entry 1" "table_row"
When I choose "Edit" in the open action menu
And I set the field "field2" to "Some MODIFIED BY THE TEACHER student content 1"
And I click on "Save" "button"
# Single view (for teacher).
Then I should see "Some MODIFIED BY THE TEACHER student content 1"
And I should not see "Some student content 1"
And I open the action menu in "Student entry 1" "table_row"
And I choose "Edit" in the open action menu
And I set the field "field2" to "Some MORE TEACHER MODIFICATIONS FOR student content 1"
And I click on "Save" "button"
And I should see "Some MORE TEACHER MODIFICATIONS FOR student content 1"
And I should not see "Some MODIFIED BY THE TEACHER student content 1"
And I log out
# Students only should edit their entries.
But I am on the "Test database name" "data activity" page logged in as student1
And I open the action menu in "Student entry 1" "table_row"
And I choose "Edit" in the open action menu
And I set the field "field2" to "Some MODIFIED student content 1"
And I click on "Save" "button"
# Single view (for student).
And I should see "Some MODIFIED student content 1"
And I should not see "Some MORE TEACHER MODIFICATIONS FOR student content 1"
And I open the action menu in "Student entry 1" "table_row"
And I choose "Edit" in the open action menu
And I set the field "field2" to "Some MORE MODIFICATIONS FOR student content 1"
And I click on "Save" "button"
And I should see "Some MORE MODIFICATIONS FOR student content 1"
And I should not see "Some MODIFIED student content 1"
@javascript
Scenario: The Delete option in the ##actionsmenu## replacement is working
Given the following "mod_data > entries" exist:
| database | user | field1 | field2 |
| data1 | student1 | Student entry 2 | Some student content 2 |
| data1 | teacher1 | Teacher entry 2 | Some teacher content 2 |
And I navigate to "Database" in current page administration
# Teachers should be able to delete any entry.
And I open the action menu in "Student entry 1" "table_row"
When I choose "Delete" in the open action menu
Then I should see "Delete entry"
# Cancel doesn't delete the entry.
And I click on "Cancel" "button" in the "Confirm" "dialogue"
And I open the action menu in "Teacher entry 1" "table_row"
# But Delete removes the entry.
And I choose "Delete" in the open action menu
And I should see "Delete entry"
And I click on "Delete" "button" in the "Confirm" "dialogue"
And I should see "Entry deleted"
And I should not see "Teacher entry 1"
And I should see "Teacher entry 2"
And I should see "Student entry 1"
And I should see "Student entry 2"
# Single view (for teacher).
And I open the action menu in "Teacher entry 2" "table_row"
And I choose "Delete" in the open action menu
And I should see "Delete entry"
And I click on "Delete" "button" in the "Confirm" "dialogue"
And I should see "Entry deleted"
And I should not see "Teacher entry 1"
And I should not see "Teacher entry 2"
And I should see "Student entry 1"
And I should see "Student entry 2"
And I log out
# Students only should edit their entries.
But I am on the "Test database name" "data activity" page logged in as student1
And I open the action menu in "Student entry 1" "table_row"
When I choose "Delete" in the open action menu
Then I should see "Delete entry"
# Cancel doesn't delete the entry.
And I click on "Cancel" "button" in the "Confirm" "dialogue"
And I open the action menu in "Student entry 1" "table_row"
# But Delete removes the entry.
And I choose "Delete" in the open action menu
And I should see "Delete entry"
And I click on "Delete" "button" in the "Confirm" "dialogue"
And I should see "Entry deleted"
And I should not see "Teacher entry 1"
And I should not see "Teacher entry 2"
And I should not see "Student entry 1"
And I should see "Student entry 2"
# Single view (for student).
And I open the action menu in "Student entry 2" "table_row"
And I choose "Delete" in the open action menu
And I should see "Delete entry"
And I click on "Delete" "button" in the "Confirm" "dialogue"
And I should see "Entry deleted"
And I should not see "Teacher entry 1"
And I should not see "Teacher entry 2"
And I should not see "Student entry 1"
And I should not see "Student entry 2"
+155
View File
@@ -0,0 +1,155 @@
@mod @mod_data
Feature: Users can add entries to database activities
In order to populate databases
As a user
I need to add entries to databases
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| data | Test database name | n | C1 | data1 |
@javascript
Scenario: Students can add entries to a database
Given the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | Test field name | Test field description |
| data1 | text | Test field 2 name | Test field 2 description |
And the following "mod_data > templates" exist:
| database | name |
| data1 | singletemplate |
| data1 | listtemplate |
| data1 | addtemplate |
| data1 | asearchtemplate |
| data1 | rsstemplate |
And the following "mod_data > entries" exist:
| database | user | Test field name | Test field 2 name |
| data1 | student1 | Student original entry | Student original entry 2 |
And I am on the "data1" Activity page logged in as student1
And I open the action menu in "#data-listview-content" "css_element"
And I choose "Edit" in the open action menu
And I set the following fields to these values:
| Test field name | Student original entry |
| Test field 2 name | |
And I press "Save"
Then I should not see "Student original entry 2"
And I open the action menu in "#data-singleview-content" "css_element"
And I choose "Edit" in the open action menu
And I set the following fields to these values:
| Test field name | Student edited entry |
And I press "Save"
And I should see "Student edited entry"
And the following "mod_data > entries" exist:
| database | user | Test field name | Test field 2 name |
| data1 | student1 | Student second entry | |
| data1 | student1 | Student third entry | |
And I am on the "data1" Activity page logged in as student1
And I should see "Student edited entry"
And I should see "Student second entry"
And I should see "Student third entry"
# Will delete the first one.
And I open the action menu in ".defaulttemplate-listentry" "css_element"
And I choose "Delete" in the open action menu
And I press "Delete"
And I should not see "Student edited entry"
And I should see "Student second entry"
And I should see "Student third entry"
@javascript
Scenario: If a new text area entry is added, the filepicker is displayed in the H5P editor dialogue
Given the following "mod_data > fields" exist:
| database | type | name |
| data1 | textarea | Textarea field name |
And the following "mod_data > templates" exist:
| database | name |
| data1 | singletemplate |
| data1 | listtemplate |
| data1 | addtemplate |
| data1 | asearchtemplate |
| data1 | rsstemplate |
And I am on the "Course 1" course page logged in as teacher1
When I click on "Test database name" "link"
And I click on "Add entry" "button"
And I click on "Configure H5P content" "button"
Then I should see "Browse repositories..." in the "Insert H5P content" "dialogue"
@javascript
Scenario: If maximum number of entries is set other than None then add entries should be seen only if number of entries is less than it
Given the following "mod_data > fields" exist:
| database | type | name |
| data1 | text | Test1 |
And the following "mod_data > templates" exist:
| database | name |
| data1 | singletemplate |
| data1 | listtemplate |
| data1 | addtemplate |
| data1 | asearchtemplate |
| data1 | rsstemplate |
And the following "mod_data > entries" exist:
| database | user | Test1 |
| data1 | student1 | foo |
| data1 | student1 | bar |
And I am on the "Test database name" "data activity" page logged in as teacher1
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And I set the following fields to these values:
| Maximum number of entries | 2 |
And I press "Save and display"
And I log out
When I am on the "Test database name" "data activity" page logged in as student1
Then I should not see "Add entry"
And I log out
And I am on the "Test database name" "data activity" page logged in as teacher1
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And I set the following fields to these values:
| Maximum number of entries | 3 |
And I press "Save and display"
And I log out
And I am on the "Test database name" "data activity" page logged in as student1
And I should see "Add entry"
@javascript
Scenario: Guest user cannot add entries to a database
Given the following "mod_data > fields" exist:
| database | type | name |
| data1 | text | Textarea field name |
And the following "mod_data > templates" exist:
| database | name |
| data1 | singletemplate |
| data1 | listtemplate |
| data1 | addtemplate |
| data1 | asearchtemplate |
| data1 | rsstemplate |
And I am on the "Course 1" "enrolment methods" page logged in as teacher1
And I click on "Enable" "link" in the "Guest access" "table_row"
And I log out
When I am on the "Test database name" "data activity" page logged in as "guest"
Then I should not see "Add entry"
@javascript
Scenario Outline: Users see the Add entry button in the view page when some field has been created only.
Given I am on the "Test database name" "data activity" page logged in as <user>
And I should not see "Add entry"
And I log out
When the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | Test field name | Test field description |
Then I am on the "Test database name" "data activity" page logged in as <user>
And I should see "Add entry"
Examples:
| user |
| teacher1 |
| student1 |
@@ -0,0 +1,82 @@
@mod @mod_data
Feature: Database entries can be searched using an advanced search form.
In order to find an entry
As a user
I need to have an advanced search form
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| data | Test database name | n | C1 | data1 |
And the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | My Field | Field 1 description |
| data1 | text | Their field | Field 2 description |
And the following "mod_data > entries" exist:
| database | user | My Field | Their field |
| data1 | teacher1 | First content | Owned content |
| data1 | teacher1 | Second content | Authored content |
And I am on the "Test database name" "data activity" page logged in as teacher1
And I should see "First content"
And I should see "Second content"
@javascript
Scenario: Content can be searched using advanced search
Given I click on "Advanced search" "checkbox"
And I should see "My Field" in the "data_adv_form" "region"
And I should see "Their field" in the "data_adv_form" "region"
When I set the field "My Field" to "First"
And I click on "Save settings" "button" in the "data_adv_form" "region"
Then I should see "First content"
And I should not see "Second content"
@javascript
Scenario: Advanced search template can use field information tags
Given I navigate to "Templates" in current page administration
And I set the field "Templates tertiary navigation" to "Advanced search template"
And I set the following fields to these values:
| Advanced search template | The test is on [[My Field#name]], [[My Field#description]], and the input [[My Field]] |
And I click on "Save" "button" in the "sticky-footer" "region"
And I navigate to "Database" in current page administration
And I should see "First content"
And I should see "Second content"
And I click on "Advanced search" "checkbox"
And I should see "The test is on My Field, Field 1 description, and the input" in the "data_adv_form" "region"
And I should not see "Their field" in the "data_adv_form" "region"
When I set the field "My Field" to "First"
And I click on "Save settings" "button" in the "data_adv_form" "region"
Then I should see "First content"
And I should not see "Second content"
@javascript
Scenario: Advanced search can use otherfields tag
Given I navigate to "Templates" in current page administration
And I set the field "Templates tertiary navigation" to "Advanced search template"
And I set the following fields to these values:
| Advanced search template | Main search [[My Field]], Other fields ##otherfields## |
And I click on "Save" "button" in the "sticky-footer" "region"
And I navigate to "Database" in current page administration
And I should see "First content"
And I should see "Second content"
And I click on "Advanced search" "checkbox"
And I should see "Main search" in the "data_adv_form" "region"
And I should see "Other fields" in the "data_adv_form" "region"
And I should see "Their field" in the "data_adv_form" "region"
When I set the field "My Field" to "First"
And I click on "Save settings" "button" in the "data_adv_form" "region"
Then I should see "First content"
And I should not see "Second content"
And I set the field "My Field" to ""
And I set the field "Their field" to "Authored content"
And I click on "Save settings" "button" in the "data_adv_form" "region"
And I should not see "First content"
And I should see "Second content"
+66
View File
@@ -0,0 +1,66 @@
<?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/>.
/**
* Steps definitions related with the database activity.
*
* @package mod_data
* @category test
* @copyright 2014 David Monllaó
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');
use Behat\Gherkin\Node\TableNode as TableNode;
/**
* Database-related steps definitions.
*
* @package mod_data
* @category test
* @copyright 2014 David Monllaó
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_mod_data extends behat_base {
/**
* Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'.
*
* Recognised page names are:
* | pagetype | name meaning | description |
* | Add entry | Database name | Add an entry page (view.php) |
*
* @param string $type identifies which type of page this is, e.g. 'Add entry'.
* @param string $identifier identifies the particular page, e.g. 'My database name'.
* @return moodle_url the corresponding URL.
* @throws Exception with a meaningful error message if the specified page cannot be found.
*/
protected function resolve_page_instance_url(string $type, string $identifier): moodle_url {
global $DB;
switch (strtolower($type)) {
case 'add entry':
return new moodle_url('/mod/data/edit.php', [
'd' => $this->get_cm_by_activity_name('data', $identifier)->instance,
]);
default:
throw new Exception("Unrecognised page type '{$type}'");
}
}
}
@@ -0,0 +1,99 @@
<?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.
use Behat\Gherkin\Node\TableNode as TableNode;
require_once(__DIR__ . '/../../../../lib/behat/behat_deprecated_base.php');
/**
* Steps definitions that are now deprecated and will be removed in the next releases.
*
* This file only contains the steps that previously were in the behat_*.php files in the SAME DIRECTORY.
* When deprecating steps from other components or plugins, create a behat_COMPONENT_deprecated.php
* file in the same directory where the steps were defined.
*
* @package mod_data
* @category test
* @copyright 2024 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_mod_data_deprecated extends behat_deprecated_base
{
/**
* Adds a new field to a database
*
* @Given /^I add a "(?P<fieldtype_string>(?:[^"]|\\")*)" field to "(?P<activityname_string>(?:[^"]|\\")*)" database and I fill the form with:$/
*
* @param string $fieldtype
* @param string $activityname
* @param TableNode $fielddata
* @todo MDL-79721 This will be deleted in Moodle 4.8.
*
* @deprecated since 4.4
*/
public function i_add_a_field_to_database_and_i_fill_the_form_with($fieldtype, $activityname, TableNode $fielddata)
{
$this->deprecated_message([
'behat_mod_data::i_add_a_field_to_database_and_i_fill_the_form_with is deprecated',
'mod_data > fields generator',
]);
$this->execute('behat_navigation::i_am_on_page_instance', [$this->escape($activityname), 'data activity']);
$fieldsstr = get_string('fields', 'mod_data');
$this->execute("behat_navigation::i_navigate_to_in_current_page_administration", $fieldsstr);
$this->execute('behat_general::i_click_on', [get_string('newfield', 'mod_data'), "button"]);
$this->execute('behat_general::i_click_on_in_the',
[$this->escape($fieldtype), "link", "#action_bar", "css_element"]
);
if (!$this->running_javascript()) {
$this->execute('behat_general::i_click_on_in_the',
array(get_string('go'), "button", ".fieldadd", "css_element")
);
}
$this->execute("behat_forms::i_set_the_following_fields_to_these_values", $fielddata);
$this->execute('behat_forms::press_button', get_string('save'));
}
/**
* Adds an entry to a database.
*
* @Given /^I add an entry to "(?P<activityname_string>(?:[^"]|\\")*)" database with:$/
*
* @param string $activityname
* @param TableNode $entrydata
* @deprecated since 4.4
* @todo MDL-79721 This will be deleted in Moodle 4.8.
*
*/
public function i_add_an_entry_to_database_with($activityname, TableNode $entrydata)
{
$this->deprecated_message([
'behat_mod_data::i_add_an_entry_to_database_with is deprecated',
'mod_data > entries generator',
]);
$this->execute('behat_navigation::i_am_on_page_instance', [$this->escape($activityname), 'mod_data > add entry']);
$this->execute("behat_forms::i_set_the_following_fields_to_these_values", $entrydata);
}
}
@@ -0,0 +1,44 @@
@mod @mod_data
Feature: Teachers can enable comments only if comments are enabled at site level
In order to enable comments on entries
As an admin
I need to enable comments at site level
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I turn editing mode on
@javascript
Scenario: Teacher can enable comments if they are enabled at site level
Given I press "Add an activity or resource"
And I click on "Add a new Database" "link" in the "Add an activity or resource" "dialogue"
When I expand all fieldsets
And "Allow comments on entries" "field" should exist
And I set the field "Name" to "Test Database name"
And I set the field "Allow comments on entries" to "Yes"
And I press "Save and return to course"
And I should see "Test Database name"
@javascript
Scenario: Teacher cannot enable comments if they are disabled at site level
# Disable comments in site config.
Given the following config values are set as admin:
| usecomments | 0 |
And I press "Add an activity or resource"
And I click on "Add a new Database" "link" in the "Add an activity or resource" "dialogue"
When I expand all fieldsets
And I set the field "Name" to "Test Database name 2"
And "Allow comments on entries" "field" should not exist
Then I should see "No" in the "//*[@id=\"fitem_id_comments\"]/*[@data-fieldtype=\"selectyesno\"]" "xpath_element"
And I press "Save and return to course"
And I should see "Test Database name 2"
@@ -0,0 +1,42 @@
@mod @mod_data
Feature: Users can view the list of data activities and their formatted descriptions
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Bob | 1 | student1@example.com |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| data | Test database 1 | This is an intro without an image | C1 | data1 |
| data | Test database 2 | This is an intro with an image: <img src="@@PLUGINFILE@@/some_image.jpg"> | C1 | data2 |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| activity_modules | Course | C1 | course-view-* | side-pre |
Scenario: Teachers can view the list of data activities and their formatted descriptions
Given I am on the "Course 1" course page logged in as teacher1
When I follow "Databases"
Then I should see "Test database 1"
And I should see "Test database 2"
And I should see "This is an intro without an image"
And I should see "This is an intro with an image: "
And "//img[contains(@src, 'some_image.jpg')]" "xpath_element" should exist
And "//img[contains(@src, '@@PLUGINFILE@@/some_image.jpg')]" "xpath_element" should not exist
Scenario: Students can view the list of data activities and their formatted descriptions
Given I am on the "Course 1" course page logged in as student1
When I follow "Databases"
Then I should see "Test database 1"
And I should see "Test database 2"
And I should see "This is an intro without an image"
And I should see "This is an intro with an image: "
And "//img[contains(@src, 'some_image.jpg')]" "xpath_element" should exist
And "//img[contains(@src, '@@PLUGINFILE@@/some_image.jpg')]" "xpath_element" should not exist
@@ -0,0 +1,112 @@
@mod @mod_data @core_completion @javascript
Feature: View activity completion in the database activity
In order to have visibility of database completion requirements
As a student
I need to be able to view my database completion progress
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Vinnie | Student1 | student1@example.com |
| teacher1 | Darrell | Teacher1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | enablecompletion | showcompletionconditions |
| Course 1 | C1 | 1 | 1 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| teacher1 | C1 | editingteacher |
And the following "activity" exists:
| activity | data |
| course | C1 |
| idnumber | mh1 |
| name | Music history |
| section | 1 |
| completionentriesenabled | 1 |
| completionentries | 2 |
And the following "mod_data > fields" exist:
| database | type | name |
| mh1 | text | Instrument types |
And the following "mod_data > templates" exist:
| database | name |
| mh1 | singletemplate |
| mh1 | listtemplate |
| mh1 | addtemplate |
| mh1 | asearchtemplate |
| mh1 | rsstemplate |
Given I am on the "Music history" "data activity editing" page logged in as teacher1
And I expand all fieldsets
And I set the following fields to these values:
| Aggregate type | Average of ratings |
| scale[modgrade_type] | Point |
| scale[modgrade_point] | 100 |
| Add requirements | 1 |
| View the activity | 1 |
| Receive a grade | 1 |
| Any grade | 1 |
And I press "Save and display"
And I log out
Scenario: View automatic completion items as a teacher
# We add an entry to let the user change to a different view.
Given the following "mod_data > entries" exist:
| database | user | Instrument types |
| mh1 | teacher1 | Drums |
When I am on the "Music history" "data activity" page logged in as teacher1
Then "Music history" should have the "View" completion condition
And "Music history" should have the "Make entries: 2" completion condition
And "Music history" should have the "Receive a grade" completion condition
And I select "Single view" from the "jump" singleselect
And "Music history" should have the "View" completion condition
And "Music history" should have the "Make entries: 2" completion condition
And "Music history" should have the "Receive a grade" completion condition
Scenario: View automatic completion items as a student
Given I am on the "Music history" "data activity" page logged in as student1
And the "View" completion condition of "Music history" is displayed as "done"
And the "Make entries: 2" completion condition of "Music history" is displayed as "todo"
And the "Receive a grade" completion condition of "Music history" is displayed as "todo"
And the following "mod_data > entries" exist:
| database | user | Instrument types |
| mh1 | student1 | Drums |
And I am on "Course 1" course homepage
# One entry is not enough to mark as complete.
And the "View" completion condition of "Music history" is displayed as "done"
And the "Make entries: 2" completion condition of "Music history" is displayed as "todo"
And the "Receive a grade" completion condition of "Music history" is displayed as "todo"
And the following "mod_data > entries" exist:
| database | user | Instrument types |
| mh1 | student1 | Hurdygurdy |
And I am on "Course 1" course homepage
Then the "View" completion condition of "Music history" is displayed as "done"
And the "Make entries: 2" completion condition of "Music history" is displayed as "done"
And the "Receive a grade" completion condition of "Music history" is displayed as "todo"
And I log out
And I am on the "Music history" "data activity" page logged in as teacher1
And I select "Single view" from the "jump" singleselect
And I set the field "rating" to "3"
And I log out
When I am on the "Music history" "data activity" page logged in as student1
Then the "View" completion condition of "Music history" is displayed as "done"
And the "Make entries: 2" completion condition of "Music history" is displayed as "done"
And the "Receive a grade" completion condition of "Music history" is displayed as "done"
And I log out
When I am on the "Course 1" course page logged in as teacher1
And "Vinnie Student1" user has completed "Music history" activity
@javascript
Scenario: Use manual completion
Given I am on the "Music history" "data activity editing" page logged in as teacher1
And I expand all fieldsets
And I set the field "Students must manually mark the activity as done" to "1"
And I press "Save and display"
# Teacher view.
And the manual completion button for "Music history" should be disabled
And I log out
# Student view.
When I am on the "Music history" "data activity" page logged in as student1
Then the manual completion button of "Music history" is displayed as "Mark as done"
And I toggle the manual completion state of "Music history"
And the manual completion button of "Music history" is displayed as "Done"
@@ -0,0 +1,141 @@
@mod @mod_data @core_completion
Feature: Completion pass grade
View activity completion in the database activity
In order to have visibility of database completion requirements
As a student
I need to be able to view my database completion progress
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Vinnie | Student1 | student1@example.com |
| student2 | Vinnie | Student2 | student2@example.com |
| teacher1 | Darrell | Teacher1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category | enablecompletion |
| Course 1 | C1 | 0 | 1 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student2 | C1 | student |
| teacher1 | C1 | editingteacher |
And the following "activity" exists:
| activity | data |
| course | C1 |
| idnumber | mh1 |
| name | Music history |
| section | 1 |
And the following "mod_data > fields" exist:
| database | type | name |
| mh1 | text | Instrument types |
And I am on the "Music history" "data activity" page logged in as teacher1
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And I set the following fields to these values:
| Aggregate type | Average of ratings |
| scale[modgrade_type] | Point |
| scale[modgrade_point] | 100 |
| gradepass | 50 |
| Add requirements | 1 |
| View the activity | 1 |
| Receive a grade | 1 |
| Passing grade | 1 |
| completionentriesenabled | 1 |
| completionentries | 2 |
And I press "Save and display"
And I log out
@javascript
Scenario: View automatic completion items as a teacher
# We add an entry to let the user change to a different view.
Given the following "mod_data > entries" exist:
| database | user | Instrument types |
| mh1 | teacher1 | Drums |
When I am on the "Music history" "data activity" page logged in as teacher1
Then "Music history" should have the "View" completion condition
And "Music history" should have the "Make entries: 2" completion condition
And "Music history" should have the "Receive a grade" completion condition
And "Music history" should have the "Receive a passing grade" completion condition
And I select "Single view" from the "jump" singleselect
And "Music history" should have the "View" completion condition
And "Music history" should have the "Make entries: 2" completion condition
And "Music history" should have the "Receive a grade" completion condition
And "Music history" should have the "Receive a passing grade" completion condition
@javascript
Scenario: View automatic completion items as a failing student
Given I am on the "Music history" "data activity" page logged in as student1
And the "View" completion condition of "Music history" is displayed as "done"
And the "Make entries: 2" completion condition of "Music history" is displayed as "todo"
And the "Receive a grade" completion condition of "Music history" is displayed as "todo"
And the "Receive a passing grade" completion condition of "Music history" is displayed as "todo"
And the following "mod_data > entries" exist:
| database | user | Instrument types |
| mh1 | student1 | Drums |
And I am on "Course 1" course homepage
# One entry is not enough to mark as complete.
And the "View" completion condition of "Music history" is displayed as "done"
And the "Make entries: 2" completion condition of "Music history" is displayed as "todo"
And the "Receive a grade" completion condition of "Music history" is displayed as "todo"
And the "Receive a passing grade" completion condition of "Music history" is displayed as "todo"
And the following "mod_data > entries" exist:
| database | user | Instrument types |
| mh1 | student1 | Hurdygurdy |
And I am on "Course 1" course homepage
Then the "View" completion condition of "Music history" is displayed as "done"
And the "Make entries: 2" completion condition of "Music history" is displayed as "done"
And the "Receive a grade" completion condition of "Music history" is displayed as "todo"
And the "Receive a passing grade" completion condition of "Music history" is displayed as "todo"
And I log out
And I am on the "Music history" "data activity" page logged in as teacher1
And I select "Single view" from the "jump" singleselect
And I set the field "rating" to "3"
And I log out
When I am on the "Music history" "data activity" page logged in as student1
Then the "View" completion condition of "Music history" is displayed as "done"
And the "Make entries: 2" completion condition of "Music history" is displayed as "done"
And the "Receive a grade" completion condition of "Music history" is displayed as "done"
And the "Receive a passing grade" completion condition of "Music history" is displayed as "failed"
And I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage
And "Vinnie Student1" user has completed "Music history" activity
@javascript
Scenario: View automatic completion items as a passing student
Given I am on the "Music history" "data activity" page logged in as student1
And the "View" completion condition of "Music history" is displayed as "done"
And the "Make entries: 2" completion condition of "Music history" is displayed as "todo"
And the "Receive a grade" completion condition of "Music history" is displayed as "todo"
And the "Receive a passing grade" completion condition of "Music history" is displayed as "todo"
And the following "mod_data > entries" exist:
| database | user | Instrument types |
| mh1 | student1 | Drums |
And I am on "Course 1" course homepage
# One entry is not enough to mark as complete.
And the "View" completion condition of "Music history" is displayed as "done"
And the "Make entries: 2" completion condition of "Music history" is displayed as "todo"
And the "Receive a grade" completion condition of "Music history" is displayed as "todo"
And the "Receive a passing grade" completion condition of "Music history" is displayed as "todo"
And the following "mod_data > entries" exist:
| database | user | Instrument types |
| mh1 | student1 | Hurdygurdy |
And I am on "Course 1" course homepage
And the "View" completion condition of "Music history" is displayed as "done"
And the "Make entries: 2" completion condition of "Music history" is displayed as "done"
And the "Receive a grade" completion condition of "Music history" is displayed as "todo"
And the "Receive a passing grade" completion condition of "Music history" is displayed as "todo"
And I log out
And I am on the "Music history" "data activity" page logged in as teacher1
And I select "Single view" from the "jump" singleselect
And I set the field "rating" to "60"
And I log out
When I am on the "Music history" "data activity" page logged in as student1
Then the "View" completion condition of "Music history" is displayed as "done"
And the "Make entries: 2" completion condition of "Music history" is displayed as "done"
And the "Receive a grade" completion condition of "Music history" is displayed as "done"
And the "Receive a passing grade" completion condition of "Music history" is displayed as "done"
And I log out
And I log in as "teacher1"
And I am on "Course 1" course homepage
And "Vinnie Student1" user has completed "Music history" activity
@@ -0,0 +1,53 @@
@mod @mod_data
Feature: Enable activity rating according to chosen grading scale
In order to have ratings appear in the course gradebook
As a teacher
I need to enable activity rating according to chosen grading scale
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | One | teacher1@example.com |
| student1 | Student | One | student1@example.com |
| student2 | Student | Two | student2@example.com |
And the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
And the following "activities" exist:
| activity | course | name | idnumber |
| data | C1 | DB activity 1 | db1 |
And the following "mod_data > fields" exist:
| database | type | name |
| db1 | text | DB field |
@javascript
Scenario: View ratings in the course gradebook
Given I am on the "DB activity 1" "data activity editing" page logged in as teacher1
And I expand all fieldsets
And I set the following fields to these values:
| Aggregate type | Count of ratings |
| scale[modgrade_type] | Point |
| scale[modgrade_point] | 10 |
And I press "Save and display"
And the following "mod_data > entries" exist:
| database | user | DB field |
| db1 | student1 | S1 entry 1 |
| db1 | student1 | S1 entry 2 |
| db1 | student2 | S2 entry 1 |
And I am on the "DB activity 1" "data activity" page
And I select "Single view" from the "jump" singleselect
And I set the field "rating" to "5"
And I follow "Next page"
And I set the field "rating" to "7"
And I follow "Next page"
And I set the field "rating" to "10"
When I am on the "Course 1" "grades > Grader report > View" page
Then the following should exist in the "user-grades" table:
| -1- | -2- | -3- |
| Student One | student1@example.com | 2.00 |
| Student Two | student2@example.com | 1.00 |
@@ -0,0 +1,33 @@
@mod @mod_data
Feature: Control database activity entry based on read-only dates
In order to restrict or allow student entries based on specific dates
As a teacher
I need to be able to set read-only dates for the database activity
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
Scenario Outline: Student can add entries only when the current date falls outside the read-only date range
Given the following "activities" exist:
| activity | course | name | idnumber | timeviewfrom | timeviewto |
| data | C1 | Data Activity 1 | DB1 | <viewfrom> | <viewto> |
And the following "mod_data > fields" exist:
| database | type | name |
| DB1 | text | DB Field 1 |
When I am on the "Data Activity 1" "data activity" page logged in as student1
# The "Add entry" button is visible only when the current date falls outside the read-only date range.
Then "Add entry" "button" <btnvisibility> exist
Examples:
| viewfrom | viewto | btnvisibility |
| ##yesterday## | ##tomorrow## | should not |
| ##tomorrow## | ##tomorrow +1day## | should |
| ##1 week ago## | ##yesterday## | should |
@@ -0,0 +1,42 @@
@mod @mod_data
Feature: Students can view upcoming data activities in the timeline block
In order for student to see upcoming data activities in timeline block
As a teacher
I should be able to set the availability dates of data activities
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | One | student1@example.com |
And the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
@javascript
Scenario Outline: Student can view upcoming data activities in the timeline block
Given the following "activities" exist:
| activity | course | name | id_timeavailablefrom_enabled | timeavailablefrom | id_timeavailableto_enabled | timeavailableto |
| data | C1 | DB Past | 1 | <pastfrom> | 1 | <pastto> |
| data | C1 | DB Future | 1 | <futurefrom> | 1 | <futureto> |
| data | C1 | DB No date | 0 | | 0 | |
# Confirm that student can see future but not past db activity in the timeline block
When I log in as "student 1"
Then I should not see "DB Past" in the "Timeline" "block"
# Also confirm that student can't see db activity where availability is disabled
And I should not see "DB No Date" in the "Timeline" "block"
And I should see "DB Future" in the "Timeline" "block"
# Confirm link works and redirects to db activity
And I click on "DB Future" "link" in the "Timeline" "block"
And the activity date in "DB Future" should contain "Opens:"
And the activity date in "DB Future" should contain "<futurefrom>%A, %d %B %Y, %I:%M##"
And the activity date in "DB Future" should contain "Closes:"
And the activity date in "DB Future" should contain "<futureto>%A, %d %B %Y, %I:%M##"
Examples:
| pastfrom | pastto | futurefrom | futureto |
| ##1 month ago## | ##yesterday## | ##tomorrow## | ##tomorrow +1day## |
| ##yesterday## | ##yesterday +3hours## | ##tomorrow noon## | ##tomorrow noon +3hours## |
| ##6 months ago## | ##1 week ago## | ##tomorrow +5days## | ##tomorrow +6days## |
@@ -0,0 +1,61 @@
@mod @mod_data
Feature: Database with no calendar capabilites
In order to allow work effectively
As a teacher
I need to be able to create databases even when I cannot edit calendar events
Background:
Given the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "admin"
And I am on the "Course 1" "permissions" page
And I override the system permissions of "Teacher" role with:
| capability | permission |
| moodle/calendar:manageentries | Prohibit |
And I log out
Scenario: Editing a database
Given I log in as "admin"
And the following "activities" exist:
| activity | name | intro | course | section | idnumber |
| data | Test database name | Test database description | C1 | 1 | data1 |
And I am on "Course 1" course homepage
And I follow "Test database name"
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| id_timeavailablefrom_enabled | 1 |
| id_timeavailablefrom_day | 1 |
| id_timeavailablefrom_month | 1 |
| id_timeavailablefrom_year | 2017 |
| id_timeavailableto_enabled | 1 |
| id_timeavailableto_day | 1 |
| id_timeavailableto_month | 4 |
| id_timeavailableto_year | 2017 |
| id_timeviewfrom_enabled | 1 |
| id_timeviewfrom_day | 1 |
| id_timeviewfrom_month | 3 |
| id_timeviewfrom_year | 2017 |
| id_timeviewto_enabled | 1 |
| id_timeviewto_day | 1 |
| id_timeviewto_month | 4 |
| id_timeviewto_year | 2017 |
And I press "Save and return to course"
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I follow "Test database name"
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| id_timeavailablefrom_year | 2018 |
| id_timeavailableto_year | 2018 |
| id_timeviewfrom_year | 2018 |
| id_timeviewto_year | 2018 |
And I press "Save and return to course"
Then I should see "Test database name"
+353
View File
@@ -0,0 +1,353 @@
@mod @mod_data
Feature: Users can view and manage data presets
In order to use presets
As a user
I need to view, manage and use presets
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| data | Mountain landscapes | n | C1 | data1 |
And the following "mod_data > presets" exist:
| database | name | description | user |
| data1 | Saved preset 1 | The preset1 has description | admin |
| data1 | Saved preset 2 | | admin |
| data1 | Saved preset by teacher1 | This preset has also a description | teacher1 |
@javascript
Scenario: Admins can delete saved presets
Given I am on the "Mountain landscapes" "data activity" page logged in as admin
When I follow "Presets"
Then I should see "Choose a preset to use as a starting point."
And I should see "Image gallery"
And I should see "Saved preset 1"
And I should see "Saved preset 2"
And I should see "Saved preset by teacher1"
# Plugin presets can't be removed.
And I should not see "Actions" in the "Image gallery" "table_row"
# The admin should be able to delete saved presets.
But I open the action menu in "Saved preset 1" "table_row"
And I should see "Delete"
And I press the escape key
And I open the action menu in "Saved preset 2" "table_row"
And I should see "Delete"
And I press the escape key
And I open the action menu in "Saved preset by teacher1" "table_row"
And I should see "Delete"
@javascript
Scenario: Teachers can see and use presets
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
When I follow "Presets"
Then I should see "Choose a preset to use as a starting point."
And I should see "Image gallery"
And I should see "Use this preset to collect images." in the "Image gallery" "table_row"
And I should see "Saved preset 1"
And I should see "The preset1 has description" in the "Saved preset 1" "table_row"
And I should see "Saved preset 2"
And I should see "Saved preset by teacher1"
And I should see "This preset has also a description" in the "Saved preset by teacher1" "table_row"
# Plugin presets can't be removed.
And I should not see "Actions" in the "Image gallery" "table_row"
# Teachers should be able to delete their saved presets.
And I open the action menu in "Saved preset by teacher1" "table_row"
And I should see "Delete"
# Teachers can't delete the presets they haven't created.
And I should not see "Actions" in the "Saved preset 1" "table_row"
# The "Use this preset" button should be enabled only when a preset is selected.
And the "Use this preset" "button" should be disabled
And I click on "fullname" "radio" in the "Image gallery" "table_row"
And the "Use this preset" "button" should be enabled
@javascript
Scenario: Only users with the viewalluserpresets capability can see presets created by other users
Given the following "permission override" exists:
| role | editingteacher |
| capability | mod/data:viewalluserpresets |
| permission | Prohibit |
| contextlevel | System |
| reference | |
When I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
Then I should see "Image gallery"
And I should not see "Saved preset 1"
And I should not see "Saved preset 2"
But I should see "Saved preset by teacher1"
@javascript
Scenario: Teachers can save presets
Given the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | Test field name | Test field description |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Templates"
When I click on "Actions" "button"
And I choose "Publish preset on this site" in the open action menu
Then I should see "Name" in the "Save all fields and templates and publish as preset on this site" "dialogue"
And I should see "Description" in the "Save all fields and templates and publish as preset on this site" "dialogue"
And "Replace existing preset with this name and overwrite its contents" "checkbox" should not be visible
# Teacher should be able to save preset.
And I set the field "Name" to "New saved preset"
And I set the field "Description" to "My funny description goes here."
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
And I should see "Preset saved."
And I follow "Presets"
And I should see "New saved preset"
And I should see "My funny description goes here." in the "New saved preset" "table_row"
# Teacher can't overwrite an existing preset that they haven't created.
And I follow "Templates"
And I click on "Actions" "button"
And I choose "Publish preset on this site" in the open action menu
And I set the field "Name" to "Saved preset 1"
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
And I should see "A preset with this name already exists. Choose a different name."
And "Replace existing preset with this name and overwrite its contents" "checkbox" should not be visible
# Teacher can overwrite existing presets created by them, but they are not overwritten if the checkbox is not marked.
And I set the field "Name" to "New saved preset"
And I set the field "Description" to "This is a new description that shouldn't be saved."
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
And I should see "A preset with this name already exists."
And "Replace existing preset with this name and overwrite its contents" "checkbox" should be visible
# Confirm the checkbox is still displayed and nothing happens if it's not checked and no change is done in the name.
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
And I should see "A preset with this name already exists."
And "Replace existing preset with this name and overwrite its contents" "checkbox" should be visible
And I click on "Cancel" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
And I follow "Presets"
And I should see "New saved preset"
And I should see "My funny description goes here." in the "New saved preset" "table_row"
And I should not see "This is a new description that shouldn't be saved."
# But teacher can overwrite existing presets created by them.
But I follow "Templates"
And I click on "Actions" "button"
And I choose "Publish preset on this site" in the open action menu
And I set the field "Name" to "New saved preset"
And I set the field "Description" to "This is a new description that will be overwritten."
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
And I should see "A preset with this name already exists."
And "Replace existing preset with this name and overwrite its contents" "checkbox" should be visible
And I click on "Replace existing preset with this name and overwrite its contents" "checkbox" in the "Save all fields and templates and publish as preset on this site" "dialogue"
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
And I should see "Preset saved."
And I follow "Presets"
And I should see "New saved preset"
And I should see "This is a new description that will be overwritten." in the "New saved preset" "table_row"
And I should not see "My funny description goes here." in the "New saved preset" "table_row"
@javascript
Scenario: Teachers can edit presets
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
When I follow "Presets"
# Plugin presets can't be edited.
Then I should not see "Actions" in the "Image gallery" "table_row"
# Teachers can't edit the presets they haven't created.
And I should not see "Actions" in the "Saved preset 1" "table_row"
# Teachers should be able to edit their saved presets.
And I open the action menu in "Saved preset by teacher1" "table_row"
And I choose "Edit" in the open action menu
And I set the field "Name" to "RENAMED preset by teacher1"
And I set the field "Description" to "My funny description goes here."
And I click on "Save" "button" in the "Edit preset" "dialogue"
And I should see "Preset saved."
And I should see "RENAMED preset by teacher1"
And I should see "My funny description goes here." in the "RENAMED preset by teacher1" "table_row"
And I should not see "Saved preset by teacher1"
And I should not see "This preset has also a description"
@javascript
Scenario: Nothing happens when teachers edit a preset and do not change anything
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
When I follow "Presets"
And I open the action menu in "Saved preset by teacher1" "table_row"
And I choose "Edit" in the open action menu
And I click on "Save" "button" in the "Edit preset" "dialogue"
Then I should not see "Preset saved."
And I should see "Saved preset by teacher1"
@javascript
Scenario: Teachers can edit presets and overwrite them if they are the authors
Given the following "mod_data > preset" exists:
| database | data1 |
| name | Another preset created by teacher1 |
| description | This description will be overwritten |
| user | teacher1 |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
When I follow "Presets"
And I open the action menu in "Saved preset by teacher1" "table_row"
And I choose "Edit" in the open action menu
And I set the field "Name" to "Another preset created by teacher1"
And I click on "Save" "button" in the "Edit preset" "dialogue"
Then I should see "A preset with this name already exists."
And "Replace existing preset with this name and overwrite its contents" "checkbox" should be visible
# If the checkbox is not selected, the preset shoudn't be saved.
And I click on "Save" "button" in the "Edit preset" "dialogue"
And I should see "A preset with this name already exists."
# But when I select the overwrite checkbox, the preset should be overwritten.
But I click on "Replace existing preset with this name and overwrite its contents" "checkbox" in the "Edit preset" "dialogue"
And I click on "Save" "button" in the "Edit preset" "dialogue"
And I should see "Preset saved."
And I should see "Another preset created by teacher1"
And I should see "This preset has also a description" in the "Another preset created by teacher1" "table_row"
And I should not see "Saved preset by teacher1"
And I should not see "This description will be overwritten"
@javascript
Scenario: Teachers cannot overwrite presets if they are not the authors
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
When I follow "Presets"
And I open the action menu in "Saved preset by teacher1" "table_row"
And I choose "Edit" in the open action menu
And I set the field "Name" to "Saved preset 1"
And I click on "Save" "button" in the "Edit preset" "dialogue"
Then I should see " A preset with this name already exists. Choose a different name."
And "Replace existing preset with this name and overwrite its contents" "checkbox" should not be visible
# If the teacher clicks again the Save button, the preset shoudn't be saved.
And I click on "Save" "button" in the "Edit preset" "dialogue"
And I should see " A preset with this name already exists. Choose a different name."
# But if they set a different name (which doesn't exist), the preset should be saved.
And I set the field "Name" to "New saved preset"
And I click on "Save" "button" in the "Edit preset" "dialogue"
And I should see "Preset saved."
And I should see "New saved preset"
And I should see "This preset has also a description" in the "New saved preset" "table_row"
And I should not see "Saved preset by teacher1"
@javascript
Scenario: Admins can overwrite presets even if they are not the authors
Given I am on the "Mountain landscapes" "data activity" page logged in as admin
When I follow "Presets"
And I open the action menu in "Saved preset by teacher1" "table_row"
And I choose "Edit" in the open action menu
And I set the field "Name" to "Saved preset 1"
And I click on "Save" "button" in the "Edit preset" "dialogue"
Then I should see " A preset with this name already exists."
And "Replace existing preset with this name and overwrite its contents" "checkbox" should be visible
# But when admin selects the overwrite checkbox, the preset should be overwritten.
But I click on "Replace existing preset with this name and overwrite its contents" "checkbox" in the "Edit preset" "dialogue"
And I click on "Save" "button" in the "Edit preset" "dialogue"
And I should see "Preset saved."
And I should see "Saved preset 1"
And I should see "This preset has also a description" in the "Saved preset 1" "table_row"
And I should not see "Saved preset by teacher1"
And I should not see "The preset1 has description"
@javascript
Scenario: Teachers can delete their own presets
Given the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | Test field name | Test field description |
And the following "mod_data > presets" exist:
| database | name | description | user |
| data1 | Saved preset by teacher1 | My funny description goes here. | teacher1 |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
When I follow "Presets"
And I should see "Image gallery"
And I should see "Saved preset 1"
And I should see "Saved preset by teacher1"
# Plugin presets can't be removed.
And I should not see "Actions" in the "Image gallery" "table_row"
# The teacher should not be able to delete presets saved by others.
And I should not see "Actions" in the "Saved preset 1" "table_row"
# The teacher should be able to delete their own preset.
And I open the action menu in "Saved preset by teacher" "table_row"
And I follow "Delete"
And I click on "Delete" "button" in the "Delete preset Saved preset by teacher1?" "dialogue"
And I should see "Preset deleted"
And I should not see "Saved preset by teacher1"
@javascript
Scenario: Teachers can preview a saved preset from the notification
Given the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | Test field name | Test field description |
And the following "mod_data > templates" exist:
| database | name |
| data1 | singletemplate |
| data1 | listtemplate |
| data1 | addtemplate |
| data1 | asearchtemplate |
| data1 | rsstemplate |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Templates"
And I click on "Actions" "button"
And I choose "Publish preset on this site" in the open action menu
And I set the field "Name" to "New saved preset"
And I set the field "Description" to "My funny description goes here."
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
And I should see "Preset saved"
When I click on "Preview preset" "link"
Then I should see "Preview"
And I should see "New saved preset"
And I should see "Test field name"
And I should see "This is a short text"
Then "Use this preset" "button" should exist
Scenario: Teachers can export any saved preset
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
When I follow "Presets"
# Plugin presets can't be exported.
And I should not see "Actions" in the "Image gallery" "table_row"
# The teacher should be able to export any saved preset.
And I open the action menu in "Saved preset by teacher1" "table_row"
Then I should see "Export"
And following "Export" in the "Saved preset by teacher1" "table_row" should download a file that:
| Contains file in zip | preset.xml |
And I open the action menu in "Saved preset 1" "table_row"
And I should see "Export"
And following "Export" in the "Saved preset 1" "table_row" should download a file that:
| Contains file in zip | preset.xml |
@javascript @_file_upload
Scenario Outline: Admins and Teachers can load a preset from a file
Given I am on the "Mountain landscapes" "data activity" page logged in as <user>
When I follow "Presets"
Then I click on "Actions" "button"
And I choose "Import preset" in the open action menu
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
Then I click on "Import preset and apply" "button" in the ".modal-dialog" "css_element"
Then I should see "Preset applied"
# I am on the field page.
And I should see "Manage fields"
Then I should see "Preset applied"
Examples:
| user |
| admin |
| teacher1 |
@javascript
Scenario Outline: Teachers can use "Use this preset" actions menu next to each preset.
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
And I open the action menu in "<Preset Name>" "table_row"
When I click on "Use this preset" "link" in the "<Preset Name>" "table_row"
Then I should see "Preset applied"
Examples:
| Preset Name |
| Image gallery |
| Saved preset 1 (Admin User) |
| Saved preset by teacher1 (Teacher 1) |
@javascript
Scenario Outline: Teachers can use "Preview" actions menu next to each preset.
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
And I open the action menu in "<Preset Name>" "table_row"
When I click on "Preview" "link" in the "<Preset Name>" "table_row"
Then I should see "Preview of <Preset preview name>"
Examples:
| Preset Name | Preset preview name |
| Image gallery | Image gallery |
| Saved preset 1 (Admin User) | Saved preset 1 |
| Saved preset by teacher1 (Teacher 1) | Saved preset by teacher1 |
@@ -0,0 +1,162 @@
@mod @mod_data
Feature: Users can use mod_data without editing the templates
In order to use the database module
As a teacher
I need to manage fields and entries using always the default templates.
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| data | Test database name | Database intro | C1 | data1 |
And the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | field1 | Test field description |
| data1 | text | field2 | Test field 2 description |
And the following "mod_data > entries" exist:
| database | field1 | field2 |
| data1 | Student entry 1 | Some content 1 |
| data1 | Student entry 2 | Some content 2 |
And I am on the "Test database name" "data activity" page logged in as teacher1
@javascript
Scenario: The default view templates should be updated when a field is added.
Given I navigate to "Database" in current page administration
And I should see "field1"
And I should see "field2"
And I should see "Student entry 1"
And I should see "Some content 1"
And I should see "Student entry 2"
And I should see "Some content 2"
And I set the field "View mode tertiary navigation" to "Single view"
And I should see "field1"
And I should see "field2"
And I should see "Student entry 1"
And I should see "Some content 1"
And I should not see "Student entry 2"
And I should not see "Some content 2"
When the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | field3 | Test field 3 description |
Then I navigate to "Database" in current page administration
And I should see "field1"
And I should see "field2"
And I should see "field3"
And I should see "Student entry 1"
And I should see "Some content 1"
And I should see "Student entry 2"
And I should see "Some content 2"
And I set the field "View mode tertiary navigation" to "Single view"
And I should see "field1"
And I should see "field2"
And I should see "field3"
And I should see "Student entry 1"
And I should see "Some content 1"
And I should not see "Student entry 2"
And I should not see "Some content 2"
Scenario: The default add templates should be updated when a field is added.
Given I navigate to "Database" in current page administration
And I click on "Add entry" "button"
And I should see "field1"
And I should see "field2"
When the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | field3 | Test field 3 description |
Then I navigate to "Database" in current page administration
And I click on "Add entry" "button"
And I should see "field1"
And I should see "field2"
And I should see "field3"
@javascript
Scenario: The default view templates should be updated when a field is deleted.
Given I navigate to "Database" in current page administration
And I should see "field1"
And I should see "field2"
And I should see "Student entry 1"
And I should see "Some content 1"
And I should see "Student entry 2"
And I should see "Some content 2"
And I set the field "View mode tertiary navigation" to "Single view"
And I should see "field1"
And I should see "field2"
And I should see "Student entry 1"
And I should see "Some content 1"
And I should not see "Student entry 2"
And I should not see "Some content 2"
When I navigate to "Fields" in current page administration
And I click on "Actions" "button" in the "field2" "table_row"
And I choose "Delete" in the open action menu
And I click on "Continue" "button"
Then I navigate to "Database" in current page administration
And I should see "field1"
And I should not see "field2"
And I should see "Student entry 1"
And I should not see "Some content 1"
And I should see "Student entry 2"
And I should not see "Some content 2"
And I set the field "View mode tertiary navigation" to "Single view"
And I should see "field1"
And I should not see "field2"
And I should see "Student entry 1"
And I should not see "Some content 1"
And I should not see "Student entry 2"
And I should not see "Some content 2"
Scenario: The default add templates should be updated when a field is deleted.
Given I navigate to "Database" in current page administration
And I click on "Add entry" "button"
And I should see "field1"
And I should see "field2"
When I navigate to "Fields" in current page administration
And I click on "Delete" "link" in the "field2" "table_row"
And I click on "Continue" "button"
Then I navigate to "Database" in current page administration
And I click on "Add entry" "button"
And I should see "field1"
And I should not see "field2"
@javascript
Scenario: The dynamic default templates can be reset after a manual edition.
Given I navigate to "Templates" in current page administration
And I set the field "Templates tertiary navigation" to "List view template"
And I set the following fields to these values:
| Header | New header! |
| Repeated entry | This is the template content |
| Footer | New footer! |
And I click on "Save" "button" in the "sticky-footer" "region"
And I navigate to "Database" in current page administration
And I should see "New header!"
And I should see "This is the template content"
And I should see "New footer!"
And I should not see "Student entry 1"
And I should not see "Some content 1"
When I navigate to "Templates" in current page administration
And I set the field "Templates tertiary navigation" to "List view template"
And I click on "Actions" "button"
And I choose "Reset current template" in the open action menu
And I click on "Reset" "button" in the "Reset template?" "dialogue"
And I should see "Template reset"
And I navigate to "Database" in current page administration
And I should not see "New header!"
And I should not see "This is the template content"
And I should not see "New footer!"
And I should see "Student entry 1"
And I should see "Some content 1"
Then the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | field3 | Test field 3 description |
And I navigate to "Database" in current page administration
And I click on "Add entry" "button"
And I should see "field1"
And I should see "field2"
And I should see "field3"
+215
View File
@@ -0,0 +1,215 @@
@mod @mod_data
Feature: Users can edit the database templates
In order to use custom templates for entries
As a teacher
I need to edit the templates html
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| data | Test database name | Database intro | C1 | data1 |
And the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | field1 | Test field description |
| data1 | text | field2 | Test field 2 description |
And the following "mod_data > entries" exist:
| database | field1 | field2 |
| data1 | Student entry 1 | Some content 1 |
And I am on the "Test database name" "data activity" page logged in as teacher1
And I navigate to "Templates" in current page administration
And I set the field "Templates tertiary navigation" to "List view template"
@javascript
Scenario: Edit list template
Given I set the following fields to these values:
| Header | New header! |
| Repeated entry | [[field1]] and [[field2]]! |
| Footer | New footer! |
And I click on "Save" "button" in the "sticky-footer" "region"
When I navigate to "Database" in current page administration
Then I should see "New header!"
And I should see "Student entry 1 and Some content 1!"
And I should see "New footer!"
@javascript
Scenario: Edit single template
Given I set the field "Templates tertiary navigation" to "Single view template"
And I set the following fields to these values:
| Single view template | [[field1]] and [[field2]] details! |
And I click on "Save" "button" in the "sticky-footer" "region"
When I navigate to "Database" in current page administration
And I set the field "View mode tertiary navigation" to "Single view"
Then I should see "Student entry 1 and Some content 1 details!"
@javascript
Scenario: Edit add entry template
Given I set the field "Templates tertiary navigation" to "Add entry template"
And I set the following fields to these values:
| Add entry template | [[field1]] [[field2]] Form extra! |
And I click on "Save" "button" in the "sticky-footer" "region"
When I navigate to "Database" in current page administration
And I click on "Add entry" "button"
Then I should see "Form extra!"
@javascript
Scenario: Edit advanced search template
Given I set the field "Templates tertiary navigation" to "Advanced search template"
And I set the following fields to these values:
| Advanced search template | New advanced search template! |
And I click on "Save" "button" in the "sticky-footer" "region"
When I navigate to "Database" in current page administration
And I click on "Advanced search" "checkbox"
Then I should see "New advanced search template!"
@javascript
Scenario: Edit without the wysiwyg editor
Given I click on "Enable code editor" "checkbox"
And I set the following fields to these values:
| Repeated entry | <span class="d-none">Nope</span>Yep! |
And I click on "Save" "button" in the "sticky-footer" "region"
When I navigate to "Database" in current page administration
Then I should not see "Nope"
And I should see "Yep!"
@javascript
Scenario: Edit CSS teamplate
Given I click on "Enable code editor" "checkbox"
And I set the following fields to these values:
| Repeated entry | <span class="hideme">Nope</span>Yep! |
And I click on "Save" "button" in the "sticky-footer" "region"
And I set the field "Templates tertiary navigation" to "Custom CSS"
And I set the following fields to these values:
| Custom CSS | .hideme {display: none;} |
And I click on "Save" "button" in the "sticky-footer" "region"
When I navigate to "Database" in current page administration
Then I should not see "Nope"
And I should see "Yep!"
@javascript
Scenario: Edit Custom JavaScript
Given I click on "Enable code editor" "checkbox"
And I set the following fields to these values:
| Repeated entry | <span id="hideme">Nope</span>Yep! |
And I click on "Save" "button" in the "sticky-footer" "region"
And I set the field "Templates tertiary navigation" to "Custom JavaScript"
And I set the following fields to these values:
| Custom JavaScript | window.onload = () => document.querySelector('#hideme').style.display = 'none'; |
And I click on "Save" "button" in the "sticky-footer" "region"
When I navigate to "Database" in current page administration
Then I should not see "Nope"
And I should see "Yep!"
@javascript
Scenario: Reset database activity template
Given I set the following fields to these values:
| Header | New header! |
| Repeated entry | This is the template content |
| Footer | New footer! |
And I click on "Save" "button" in the "sticky-footer" "region"
And I navigate to "Database" in current page administration
And I should see "New header!"
And I should see "This is the template content"
And I should see "New footer!"
And I should not see "Student entry 1"
And I should not see "Some content 1"
When I navigate to "Templates" in current page administration
And I set the field "Templates tertiary navigation" to "List view template"
And I click on "Actions" "button"
And I choose "Reset current template" in the open action menu
And I should see "This will permanently remove the List view template for your current preset."
And I click on "Reset" "button" in the "Reset template?" "dialogue"
Then I should see "Template reset"
And I navigate to "Database" in current page administration
And I should not see "New header!"
And I should not see "This is the template content"
And I should not see "New footer!"
And I should see "Student entry 1"
And I should see "Some content 1"
@javascript
Scenario: Reset all database templates using the action menu
Given the following "mod_data > templates" exist:
| database | name | content |
| data1 | singletemplate | Initial single |
| data1 | listtemplate | Initial list |
| data1 | addtemplate | Initial add |
| data1 | asearchtemplate | Initial search |
And I navigate to "Database" in current page administration
And I should see "Initial list"
And I should not see "Student entry 1"
And I should not see "Some content 1"
And I click on "Advanced search" "checkbox"
And I should see "Initial search"
And I set the field "View mode tertiary navigation" to "Single view"
And I should see "Initial single"
And I should not see "Student entry 1"
And I should not see "Some content 1"
And I click on "Add entry" "button"
And I should see "Initial add"
When I navigate to "Templates" in current page administration
And I click on "Actions" "button"
And I choose "Reset all templates" in the open action menu
And I should see "You're about to remove all templates for your current preset."
And I click on "Reset" "button" in the "Reset all templates?" "dialogue"
Then I should see "All templates reset"
And I navigate to "Database" in current page administration
And I should not see "Initial list"
And I should see "Student entry 1"
And I should see "Some content 1"
And I click on "Advanced search" "checkbox"
And I should not see "Initial search"
And I set the field "View mode tertiary navigation" to "Single view"
And I should not see "Initial single"
And I should see "Student entry 1"
And I should see "Some content 1"
And I click on "Add entry" "button"
And I should not see "Initial add"
@javascript
Scenario: Reset all database templates using the reset template button
Given the following "mod_data > templates" exist:
| database | name | content |
| data1 | singletemplate | Initial single |
| data1 | listtemplate | Initial list |
| data1 | addtemplate | Initial add |
| data1 | asearchtemplate | Initial search |
And I navigate to "Database" in current page administration
And I should see "Initial list"
And I should not see "Student entry 1"
And I should not see "Some content 1"
And I click on "Advanced search" "checkbox"
And I should see "Initial search"
And I set the field "View mode tertiary navigation" to "Single view"
And I should see "Initial single"
And I should not see "Student entry 1"
And I should not see "Some content 1"
And I click on "Add entry" "button"
And I should see "Initial add"
When I navigate to "Templates" in current page administration
And I click on "Actions" "button"
And I choose "Reset current template" in the open action menu
And I should see "This will permanently remove the Add entry template for your current preset."
And I click on "Reset all templates" "checkbox"
And I click on "Reset" "button" in the "Reset template?" "dialogue"
Then I should see "All templates reset"
And I navigate to "Database" in current page administration
And I should not see "Initial list"
And I should see "Student entry 1"
And I should see "Some content 1"
And I click on "Advanced search" "checkbox"
And I should not see "Initial search"
And I set the field "View mode tertiary navigation" to "Single view"
And I should not see "Initial single"
And I should see "Student entry 1"
And I should see "Some content 1"
And I click on "Add entry" "button"
And I should not see "Initial add"
@@ -0,0 +1,50 @@
@mod @mod_data
Feature: User can see the entry approval status on the single view and list view
in the default template.
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | idnumber | approval |
| data | Test database name | Database intro | C1 | data1 | 1 |
And the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | field1 | Test field description |
| data1 | text | field2 | Test field 2 description |
And the following "mod_data > templates" exist:
| database | name |
| data1 | singletemplate |
| data1 | listtemplate |
| data1 | addtemplate |
| data1 | asearchtemplate |
| data1 | rsstemplate |
And the following "mod_data > entries" exist:
| database | user | field1 | field2 |
| data1 | student1 | Student entry 1 | Some student content 1 |
| data1 | teacher1 | Teacher entry 1 | Some teacher content 1 |
@javascript
Scenario Outline: The approval status is displayed in the single view and list view next to the action menu
# List view.
Given I am on the "Test database name" "data activity" page logged in as <user>
Then I should see "Pending approval" in the "region-main" "region"
# Single view.
And I select "Single view" from the "jump" singleselect
And I should see "Pending approval" in the "region-main" "region"
And I click on "2" "link" in the ".pagination" "css_element"
And I should not see "Pending approval" in the "region-main" "region"
And I should not see "Approved" in the "region-main" "region"
Examples:
| user |
| student1 |
| teacher1 |
+110
View File
@@ -0,0 +1,110 @@
@mod @mod_data
Feature: Group data activity
In order to create a database with my group
As a student
I need to add and view entries for the groups I am a member of
Background:
And the following "courses" exist:
| fullname | shortname |
| Test Course 1 | C1 |
And the following "groups" exist:
| name | course | idnumber | participation |
| Group 1 | C1 | G1 | 1 |
| Group 2 | C1 | G2 | 1 |
| Group 3 | C1 | G3 | 0 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | TeacherG1 | 1 | teacher1@example.com |
| user1 | User1G1 | 1 | user1@example.com |
| user2 | User2G2 | 2 | user2@example.com |
| user3 | User3None | 3 | user3@example.com |
| user4 | User4NPgroup | 4 | user4@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| user1 | C1 | student |
| user2 | C1 | student |
| user3 | C1 | student |
| user4 | C1 | student |
And the following "group members" exist:
| user | group |
| teacher1 | G1 |
| user1 | G1 |
| user2 | G2 |
| user4 | G3 |
And the following "activities" exist:
| activity | name | intro | course | idnumber | groupmode |
| data | Separate data | Data with separate groups | C1 | data1 | 1 |
| data | Visible data | Data with visible groups | C1 | data2 | 2 |
And the following "mod_data > fields" exist:
| database | type | name |
| data1 | shorttext | separatetext |
| data2 | shorttext | visibletext |
And the following "mod_data > entries" exist:
| database | user | group | separatetext |
| data1 | user1 | G1 | I am user 1 |
| data1 | user2 | G2 | I am user 2 |
And the following "mod_data > entries" exist:
| database | user | separatetext |
| data1 | user3 | I am user 3 |
And the following "mod_data > entries" exist:
| database | user | group | visibletext |
| data2 | user1 | G1 | I am user 1 |
| data2 | user2 | G2 | I am user 2 |
And the following "mod_data > entries" exist:
| database | user | visibletext |
| data2 | user3 | I am user 3 |
| data2 | user4 | I am user 4 |
Scenario Outline: Users should see their own participation groups in "separate groups" mode, and all
participation groups in "visible groups" mode.
Given I am on the "<data>" "data activity" page logged in as "<user>"
Then I <all> "All participants"
And I <G1> "Group 1"
And I <user1> "I am user 1"
And I <G2> "Group 2"
And I <user2> "I am user 2"
# All users should see entries with no group.
And I should see "I am user 3"
# No-one should see non-participation groups.
And I should not see "Group 3"
Examples:
| data | user | all | G1 | G2 | user1 | user2 |
| data1 | teacher1 | should see | should see | should see | should see | should see |
| data1 | user1 | should not see | should see | should not see | should see | should not see |
| data1 | user2 | should not see | should not see | should see | should not see | should see |
| data1 | user3 | should see | should not see | should not see | should not see | should not see |
| data1 | user4 | should see | should not see | should not see | should not see | should not see |
| data2 | teacher1 | should see | should see | should see | should see | should see |
| data2 | user1 | should see | should see | should see | should see | should not see |
| data2 | user2 | should see | should see | should see | should not see | should see |
| data2 | user3 | should see | should see | should see | should see | should not see |
| data2 | user4 | should see | should see | should see | should see | should not see |
Scenario Outline: When viewing a database in visible groups mode,
a user should only have the "Add entry" button for their own participation groups
Given I am on the "data2" "data activity" page logged in as "<user>"
And I select "<mygroup>" from the "group" singleselect
And I should see "Add entry"
When I select "<othergroup>" from the "group" singleselect
Then I should not see "Add entry"
Examples:
| user | mygroup | othergroup |
| user1 | Group 1 | Group 2 |
| user2 | Group 2 | Group 1 |
| user1 | All participants | Group 2 |
| user2 | All participants | Group 1 |
Scenario Outline: Users in no groups or non-participation groups should not be able to add entries
Given I am on the "<data>" "data activity" page logged in as "<user>"
Then I should not see "Add entry"
Examples:
| data | user |
| data1 | user3 |
| data1 | user4 |
| data2 | user3 |
| data2 | user4 |
+180
View File
@@ -0,0 +1,180 @@
@mod @mod_data @javascript @_file_upload
Feature: Users can import presets
In order to use presets
As a user
I need to import and apply presets from zip files
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| data | Mountain landscapes | n | C1 | data1 |
Scenario: Teacher can import from preset page on an empty database
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
And I choose the "Import preset" item in the "Action" action menu
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
When I click on "Import preset and apply" "button"
Then I should not see "Field mappings"
And I should see "Image" in the "image" "table_row"
Scenario: Teacher can import from preset page on a database with fields
Given the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | Test field name | Test field description |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
And I choose the "Import preset" item in the "Action" action menu
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
When I click on "Import preset and apply" "button"
Then I should see "Field mappings"
And I should see "image"
And I should see "Create a new field" in the "image" "table_row"
Scenario: Teacher can import from preset page on a database with entries
And the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | field1 | Test field description |
And the following "mod_data > templates" exist:
| database | name |
| data1 | singletemplate |
| data1 | listtemplate |
| data1 | addtemplate |
| data1 | asearchtemplate |
| data1 | rsstemplate |
And the following "mod_data > entries" exist:
| database | field1 |
| data1 | Student entry 1 |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
And I choose the "Import preset" item in the "Action" action menu
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
When I click on "Import preset and apply" "button"
Then I should see "Field mappings"
And I should see "image"
And I should see "Create a new field" in the "image" "table_row"
Scenario: Teacher can import from field page on a database with entries
And the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | field1 | Test field description |
And the following "mod_data > templates" exist:
| database | name |
| data1 | singletemplate |
| data1 | listtemplate |
| data1 | addtemplate |
| data1 | asearchtemplate |
| data1 | rsstemplate |
And the following "mod_data > entries" exist:
| database | field1 |
| data1 | Student entry 1 |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
And I choose the "Import preset" item in the "Action" action menu
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
When I click on "Import preset and apply" "button"
Then I should see "Field mappings"
And I should see "title"
And I should see "Create a new field" in the "title" "table_row"
# We map existing field to keep the entry data
And I set the field "id_title" to "Map to field1"
And I click on "Continue" "button"
And I follow "Database"
And I should see "Student entry"
Scenario: Teacher can import from zero state page on an empty database
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I click on "Import a preset" "button"
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
When I click on "Import preset and apply" "button"
Then I should not see "Field mappings"
And I should see "Image" in the "image" "table_row"
Scenario: Importing a preset could create new fields
Given the following "mod_data > fields" exist:
| database | type | name |
| data1 | text | title |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Fields"
And I should see "title"
And I should not see "Description"
And I should not see "image"
And I follow "Presets"
And I choose the "Import preset" item in the "Action" action menu
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
When I click on "Import preset and apply" "button"
And I click on "Continue" "button"
And I should see "Preset applied"
Then I should see "title"
And I should see "description" in the "description" "table_row"
And I should see "image" in the "image" "table_row"
Scenario: Importing a preset could create map fields
Given the following "mod_data > fields" exist:
| database | type | name |
| data1 | text | oldtitle |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Fields"
And I should see "oldtitle"
And I should not see "Description"
And I should not see "image"
And I follow "Presets"
And I choose the "Import preset" item in the "Action" action menu
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
When I click on "Import preset and apply" "button"
# Let's map a field that is not mapped by default
And I should see "Create a new field" in the "oldtitle" "table_row"
And I set the field "id_title" to "Map to oldtitle"
And I click on "Continue" "button"
And I should see "Preset applied"
Then I should not see "oldtitle"
And I should see "title"
And I should see "description" in the "description" "table_row"
And I should see "image" in the "image" "table_row"
Scenario: Importing same preset twice doesn't show mapping dialogue
# Importing a preset on an empty database doesn't show the mapping dialogue, so we add a field for the database
# not to be empty.
Given the following "mod_data > fields" exist:
| database | type | name |
| data1 | text | title |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
And I choose the "Import preset" item in the "Action" action menu
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
When I click on "Import preset and apply" "button"
And I should see "Field mappings"
And I click on "Continue" "button"
And I should see "Preset applied"
And I follow "Presets"
And I choose the "Import preset" item in the "Action" action menu
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
And I click on "Import preset and apply" "button"
Then I should not see "Field mappings"
And I should see "Preset applied"
Scenario: Teacher can import from field page on a non-empty database and previous fields will be removed
Given the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | Test field name | Test field description |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
And I click on "Actions" "button"
And I choose "Import preset" in the open action menu
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
When I click on "Import preset and apply" "button"
And I click on "Continue" "button"
Then I should see "Preset applied."
And I follow "Fields"
And I should see "image"
And I should see "title"
And I should not see "Test field name"
@@ -0,0 +1,83 @@
@mod @mod_data
Feature: Users can edit approved entries in database activities
In order to control whether approved database entries can be changed
As a teacher
I need to be able to enable or disable management of approved entries
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
@javascript
Scenario: Students can manage their approved entries to a database
Given the following "activity" exists:
| activity | data |
| course | C1 |
| idnumber | Test database name |
| name | Test database name |
| approval | 1 |
| manageapproved | 1 |
And the following "mod_data > fields" exist:
| database | type | name | description |
| Test database name | text | Test field name | Test field description |
And the following "mod_data > templates" exist:
| database | name |
| Test database name | singletemplate |
| Test database name | listtemplate |
| Test database name | addtemplate |
| Test database name | asearchtemplate |
| Test database name | rsstemplate |
And the following "mod_data > entries" exist:
| database | user | Test field name |
| Test database name | student1 | Student entry |
# Approve the student's entry as a teacher.
And I am on the "Test database name" "data activity" page logged in as teacher1
And I open the action menu in ".defaulttemplate-listentry" "css_element"
And I choose "Approve" in the open action menu
And I log out
# Make sure the student can still edit their entry after it's approved.
When I am on the "Test database name" "data activity" page logged in as student1
Then I should see "Student entry"
And "Edit" "link" should exist
@javascript
Scenario: Students can not manage their approved entries to a database
# Create database activity and don't allow editing of approved entries.
Given the following "activity" exists:
| activity | data |
| course | C1 |
| idnumber | Test database name |
| name | Test database name |
| approval | 1 |
| manageapproved | 0 |
And the following "mod_data > fields" exist:
| database | type | name | description |
| Test database name | text | Test field name | Test field description |
And the following "mod_data > templates" exist:
| database | name |
| Test database name | singletemplate |
| Test database name | listtemplate |
| Test database name | addtemplate |
| Test database name | asearchtemplate |
| Test database name | rsstemplate |
And the following "mod_data > entries" exist:
| database | user | Test field name |
| Test database name | student1 | Student entry |
# Approve the student's entry as a teacher.
And I am on the "Test database name" "data activity" page logged in as teacher1
And I open the action menu in ".defaulttemplate-listentry" "css_element"
And I choose "Approve" in the open action menu
And I log out
# Make sure the student isn't able to edit their entry after it's approved.
When I am on the "Test database name" "data activity" page logged in as student1
Then "Edit" "link" should not exist
And I should see "Student entry"
+165
View File
@@ -0,0 +1,165 @@
@mod @mod_data
Feature: Users can preview presets
In order to find the preset I am looking for
As a teacher
I need to preview the database activity presets
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "tags" exist:
| name | isstandard |
| Tag1 | 1 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| data | Test database name | Database intro | C1 | data1 |
And I am on the "Test database name" "data activity" page logged in as teacher1
@javascript @_file_upload
Scenario: Preview a user preset as list view template in database
Given I follow "Presets"
And I click on "Actions" "button"
And I choose "Import preset" in the open action menu
And I upload "mod/data/tests/fixtures/behat_preset.zip" file to "Preset file" filemanager
When I click on "Import preset and apply" "button"
And I follow "Templates"
And I click on "Actions" "button"
And I choose "Publish preset on this site" in the open action menu
And I set the field "Name" to "Saved preset by teacher1"
And I set the field "Description" to "Behat test preset"
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
When I follow "Presets"
And I click on "Saved preset by teacher1" "link"
# Check list template preview fields.
Then I should see "Saved preset by teacher1"
And I should see "List header" in the "template-preview" "region"
And I should see "List footer" in the "template-preview" "region"
And I should see "List template content" in the "template-preview" "region"
And I should see "My text field" in the "template-preview" "region"
And I should see "This is a short text" in the "template-preview" "region"
And I should see "My multiple selection" in the "template-preview" "region"
And I should see "Multi 1" in the "template-preview" "region"
And I should see "My date field" in the "template-preview" "region"
And I should see "My checkbox field" in the "template-preview" "region"
And I should see "Check 2" in the "template-preview" "region"
And I should see "My geo field" in the "template-preview" "region"
And I should see "41.3912°N 2.1639°E" in the "template-preview" "region"
And I should see "My menu field" in the "template-preview" "region"
And I should see "Menu 2" in the "template-preview" "region"
And I should see "My number field" in the "template-preview" "region"
And I should see "1234" in the "template-preview" "region"
And I should see "My radio field" in the "template-preview" "region"
And I should see "Radio 2" in the "template-preview" "region"
And I should see "My text area field" in the "template-preview" "region"
And I should see "This is a text area" in the "template-preview" "region"
And I should see "My URL field" in the "template-preview" "region"
And I should see "https://example.com" in the "template-preview" "region"
And I should see "My file field" in the "template-preview" "region"
And "Comma-separated values" "icon" should exist in the "template-preview" "region"
And I should see "samplefile.csv" in the "template-preview" "region"
And I should see "My picture field" in the "template-preview" "region"
# Test CSS and JS templates.
And I should not see "This content should not be displayed" in the "template-preview" "region"
And I should not see "This text should change" in the "template-preview" "region"
And I should see "New value" in the "template-preview" "region"
@javascript @_file_upload
Scenario: Preview a user preset as single view template in database
Given I follow "Presets"
And I click on "Actions" "button"
And I choose "Import preset" in the open action menu
And I upload "mod/data/tests/fixtures/behat_preset.zip" file to "Preset file" filemanager
When I click on "Import preset and apply" "button"
And I follow "Templates"
And I click on "Actions" "button"
And I choose "Publish preset on this site" in the open action menu
And I set the field "Name" to "Saved preset by teacher1"
And I set the field "Description" to "Behat test preset"
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
When I follow "Presets"
And I click on "Saved preset by teacher1" "link"
And I set the field "Templates tertiary navigation" to "Single view template"
# Check single view template preview fields.
Then I should see "Saved preset by teacher1"
And I should see "Single template content" in the "template-preview" "region"
And I should see "My text field" in the "template-preview" "region"
And I should see "This is a short text" in the "template-preview" "region"
And I should see "My multiple selection" in the "template-preview" "region"
And I should see "Multi 2" in the "template-preview" "region"
And I should see "My date field" in the "template-preview" "region"
And I should see "My checkbox field" in the "template-preview" "region"
And I should see "Check 2" in the "template-preview" "region"
And I should see "My geo field" in the "template-preview" "region"
And I should see "41.3912°N 2.1639°E" in the "template-preview" "region"
And I should see "My menu field" in the "template-preview" "region"
And I should see "Menu 2" in the "template-preview" "region"
And I should see "My number field" in the "template-preview" "region"
And I should see "1234" in the "template-preview" "region"
And I should see "My radio field" in the "template-preview" "region"
And I should see "Radio 2" in the "template-preview" "region"
And I should see "My text area field" in the "template-preview" "region"
And I should see "This is a text area" in the "template-preview" "region"
And I should see "My URL field" in the "template-preview" "region"
And I should see "https://example.com" in the "template-preview" "region"
And I should see "My file field" in the "template-preview" "region"
And "Comma-separated values" "icon" should exist in the "template-preview" "region"
And I should see "samplefile.csv" in the "template-preview" "region"
And I should see "My picture field" in the "template-preview" "region"
# Test CSS and JS templates.
And I should not see "This content should not be displayed" in the "template-preview" "region"
And I should not see "This text should change" in the "template-preview" "region"
And I should see "New value" in the "template-preview" "region"
@javascript
Scenario: Preview a plugin preset in database
Given I follow "Presets"
When I click on "Journal" "link"
Then I should see "Journal"
And I should see "This is a short text"
And I should see "This is a text area"
And I select "Single view template" from the "Templates tertiary navigation" singleselect
And I should see "This is a short text"
And I should see "This is a text area"
And I should see "This is a short text" in the "template-preview" "region"
@javascript
Scenario: Use back button to return to the presets page in database
Given I follow "Presets"
And I click on "Image gallery" "link"
And I should see "Image gallery"
When I click on "Back" "button"
Then I should see "Choose a preset to use as a starting point."
@javascript
Scenario: Apply plugin preset from preview in database
Given I follow "Presets"
And I click on "Image gallery" "link"
When I click on "Use this preset" "button"
Then I should see "image"
And I should see "title"
@javascript @_file_upload
Scenario: Apply user preset from preview in database
Given I follow "Presets"
And I click on "Actions" "button"
And I choose "Import preset" in the open action menu
And I upload "mod/data/tests/fixtures/behat_preset.zip" file to "Preset file" filemanager
When I click on "Import preset and apply" "button"
And I follow "Templates"
And I click on "Actions" "button"
And I choose "Publish preset on this site" in the open action menu
And I set the field "Name" to "Saved preset by teacher1"
And I set the field "Description" to "Behat test preset"
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
When I follow "Presets"
And I click on "Saved preset by teacher1" "link"
And I click on "Use this preset" "button"
Then I should see "Preset applied"
And I should see "My URL field"
@@ -0,0 +1,169 @@
@mod @mod_data
Feature: Users can be required to specify certain fields when adding entries to database activities
In order to constrain user input
As a teacher
I need to specify certain fields as required when I add entries to databases
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| data | Test database name | n | C1 | data1 |
And the following "mod_data > fields" exist:
| database | type | name | required | description | param1 |
| data1 | text | Base Text input | 1 | Base Text input | |
| data1 | checkbox | Required Checkbox | 1 | Base Text input | Required Checkbox Option 1 |
| data1 | checkbox | Required Two-Option Checkbox | 1 | Required Two-Option Checkbox | RTOC Option 1\nRTOC Option 2 |
| data1 | latlong | Required Coordinates | 1 | Required Coordinates | |
| data1 | menu | Required Menu | 1 | Required Menu | Option 1 |
| data1 | number | Required Number | 1 | Required Number | |
| data1 | radiobutton | Required Radio | 1 | Required Radio | Required Radio Option 1 |
| data1 | text | Required Text input | 1 | Required Text input | |
| data1 | textarea | Required Text area | 1 | Required Text area | |
| data1 | url | Required URL | 1 | Required URL | |
| data1 | multimenu | Required Multimenu | 1 | Required Multimenu | Option 1 |
| data1 | multimenu | Required Two-Option Multimenu | 1 | Required Two-Option Multimenu | Option 1\nOption 2 |
| data1 | checkbox | Not required Checkbox | 0 | Not required Checkbox | Not required Checkbox Option 1 |
| data1 | latlong | Not required Coordinates | 0 | Not required Coordinates | |
| data1 | menu | Not required Menu | 0 | Not required Menu | Option 1 |
| data1 | number | Not required Number | 0 | Not required Number | |
| data1 | radiobutton | Not required Radio | 0 | Not required Radio | Not required Radio Option 1 |
| data1 | text | Not required Text input | 0 | Not required Text input | |
| data1 | textarea | Not required Text area | 0 | Not required Text area | |
| data1 | url | Not required URL | 0 | Not required URL | |
| data1 | multimenu | Not required Multimenu | 0 | Not required Multimenu | Option 1 |
Scenario: Students receive errors for empty required fields but not for optional fields
Given I am on the "Test database name" "data activity" page logged in as student1
And I click on "Add entry" "button"
And I set the field "Base Text input" to "Some input to allow us to submit the otherwise empty form"
When I press "Save"
# Then ".alert" "css_element" should exist in the "//div[contains(@id,'defaulttemplate-addentry']//div[position()=1]]" "xpath_element"
Then ".alert" "css_element" should appear after "Checkbox" "text"
And ".alert" "css_element" should appear before "Required Checkbox" "text"
And ".alert" "css_element" should appear after "Two-Option Checkbox" "text"
And ".alert" "css_element" should appear before "Required Two-Option Checkbox" "text"
And ".alert" "css_element" should appear after "Coordinates" "text"
And ".alert" "css_element" should appear before "Required Coordinates" "text"
And ".alert" "css_element" should appear after "Menu" "text"
And ".alert" "css_element" should appear before "Required Menu" "text"
And ".alert" "css_element" should appear after "Radio" "text"
And ".alert" "css_element" should appear before "Required Radio" "text"
And ".alert" "css_element" should appear after "Text input" "text"
And ".alert" "css_element" should appear before "Required Text input" "text"
And ".alert" "css_element" should appear after "Text area" "text"
And ".alert" "css_element" should appear before "Required Text area" "text"
And ".alert" "css_element" should appear after "URL" "text"
And ".alert" "css_element" should appear before "Required URL" "text"
And ".alert" "css_element" should appear after "Multimenu" "text"
And ".alert" "css_element" should appear before "Required Multimenu" "text"
And ".alert" "css_element" should appear after "Two-Option Multimenu" "text"
And ".alert" "css_element" should appear before "Required Two-Option Multimenu" "text"
And I am on "Course 1" course homepage
And I follow "Test database name"
And I should see "No entries yet"
Scenario: Students receive no error for filled in required fields
Given I am on the "Test database name" "data activity" page logged in as student1
And I click on "Add entry" "button"
And I set the following fields to these values:
| Base Text input | Some input to allow us to submit the otherwise empty form |
| Required Checkbox Option 1 | 1 |
| RTOC Option 1 | 1 |
| Latitude | 0 |
| Longitude | 0 |
| Required Menu | 1 |
| Required Number | 1 |
| Required Radio Option 1 | 1 |
| Required Text input | New entry text |
| Required Text area | More text |
| Required URL | http://example.com/ |
| Required Multimenu | 1 |
| Required Two-Option Multimenu | 1 |
When I press "Save"
And I select "List view" from the "jump" singleselect
Then I should not see "No entries in database"
And I should see "New entry text"
Scenario: Fields refill with data after having an error
Given I am on the "Test database name" "data activity" page logged in as student1
And I click on "Add entry" "button"
And I set the following fields to these values:
| RTOC Option 1 | 1 |
| Latitude | 0 |
| Longitude | 0 |
| Required Menu | 1 |
| Required Number | 1 |
| Required Radio Option 1 | 1 |
| Required Text input | New entry text |
| Required Text area | More text |
| Required URL | http://example.com/ |
| Required Multimenu | 1 |
| Required Two-Option Multimenu | 1 |
When I press "Save"
Then the following fields match these values:
| Base Text input | |
| Latitude | 0 |
| Longitude | 0 |
| Required Menu | Option 1 |
| Required Number | 1 |
| Required Radio Option 1 | 1 |
| Required Text input | New entry text |
| Required Text area | More text |
| Required URL | http://example.com/ |
| Required Multimenu | Option 1 |
| Required Two-Option Multimenu | Option 1 |
@javascript
Scenario: A student fills in Latitude but not Longitude will see an error
Given I am on the "Test database name" "data activity" page logged in as student1
And I click on "Add entry" "button"
And I set the following fields to these values:
| Base Text input | Some input to allow us to submit the otherwise empty form |
| Required Checkbox Option 1 | 1 |
| RTOC Option 1 | 1 |
| Latitude | 24 |
| Required Menu | 1 |
| Required Number | 1 |
| Required Radio Option 1 | 1 |
| Required Text input | New entry text |
| Required Text area | More text |
| Required URL | http://example.com/ |
| Required Multimenu | 1 |
| Required Two-Option Multimenu | 1 |
| Latitude | 20 |
When I press "Save"
Then I should see "Both latitude and longitude are required."
Scenario: A student filling in number and text fields with zero will not see an error.
Scenario: A student fills in Latitude but not Longitude will see an error
Given I am on the "Test database name" "data activity" page logged in as student1
And I click on "Add entry" "button"
And I set the following fields to these values:
| Base Text input | Some input to allow us to submit the otherwise empty form |
| Required Checkbox Option 1 | 1 |
| RTOC Option 1 | 1 |
| Latitude | 0 |
| Longitude | 0 |
| Required Menu | 1 |
| Required Number | 0 |
| Required Radio Option 1 | 1 |
| Required Text input | 0 |
| Required Text area | 0 |
| Required URL | http://example.com/ |
| Required Multimenu | 1 |
| Required Two-Option Multimenu | 1 |
When I press "Save"
And I select "List view" from the "jump" singleselect
Then I should not see "No entries in database"
And I should see "Some input to allow us to submit the otherwise empty form"
@@ -0,0 +1,129 @@
@mod @mod_data
Feature: Users can navigate through the database activity using the tertiary navigation
In order to use the database module
As a user
I need to navigate using the tertiary navigation.
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| data | Test database name | Database intro | C1 | data1 |
| data | Database without fields | Database intro | C1 | data2 |
And the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | field1 | Test field description |
| data1 | text | field2 | Test field 2 description |
And the following "mod_data > entries" exist:
| database | user | field1 | field2 |
| data1 | teacher1 | Teacher entry 1 | Some content 1 |
| data1 | teacher1 | Teacher entry 2 | Some content 2 |
And the following "mod_data > presets" exist:
| database | name | description | user |
| data1 | Saved preset by teacher1 | This preset has also a description | teacher1 |
And I log in as "admin"
And the following config values are set as admin:
| enableportfolios | 1 |
And I navigate to "Plugins > Portfolios > Manage portfolios" in site administration
And I set portfolio instance "File download" to "Enabled and visible"
And I click on "Save" "button"
And I log out
And I am on the "Test database name" "data activity" page logged in as teacher1
@javascript
Scenario: The tertiary navigation in the Database page.
Given I navigate to "Database" in current page administration
# Teacher: List view.
And I should not see "List view" in the "data-listview-content" "region"
When I click on "Actions" "button"
Then I should see "Import entries" in the ".entriesactions" "css_element"
And I should see "Export entries" in the ".entriesactions" "css_element"
And I should see "Export to portfolio" in the ".entriesactions" "css_element"
And I press the escape key
# Teacher: Single view.
And I set the field "View mode tertiary navigation" to "Single view"
And I should not see "Single view" in the "data-singleview-content" "region"
And I click on "Actions" "button"
And I should see "Import entries" in the ".entriesactions" "css_element"
And I should see "Export entries" in the ".entriesactions" "css_element"
And I should not see "Export to portfolio" in the ".entriesactions" "css_element"
# Teacher: Database without fields.
And I am on the "Database without fields" "data activity" page
And I should not see "Actions"
# Student without entries: List view.
And I am on the "Test database name" "data activity" page logged in as student1
And I should not see "Actions"
# Student without entries: Single view.
And I set the field "View mode tertiary navigation" to "Single view"
And I should not see "Actions"
# Student with entries: Single view.
But the following "mod_data > entries" exist:
| database | user | field1 | field2 |
| data1 | student1 | Student entry 3 | Some content 3 |
And I should not see "Actions"
# Student with entries: List view.
And I set the field "View mode tertiary navigation" to "List view"
And I click on "Actions" "button"
And I should not see "Import entries" in the ".entriesactions" "css_element"
And I should not see "Export entries" in the ".entriesactions" "css_element"
And I should see "Export to portfolio" in the ".entriesactions" "css_element"
@javascript
Scenario: The tertiary navigation in the Presets page.
Given I navigate to "Presets" in current page administration
When I click on "Actions" "button"
Then I should see "Import preset" in the ".presetsactions" "css_element"
And I should see "Export preset" in the ".presetsactions" "css_element"
And I should see "Publish preset on this site" in the ".presetsactions" "css_element"
And I press the escape key
# Database without fields.
But I am on the "Database without fields" "data activity" page
And I navigate to "Presets" in current page administration
And I click on "Actions" "button"
And I should see "Import preset" in the ".presetsactions" "css_element"
And I should not see "Export preset" in the ".presetsactions" "css_element"
And I should not see "Publish preset on this site" in the ".presetsactions" "css_element"
Scenario: The tertiary navigation in the Presets preview page.
Given I navigate to "Presets" in current page administration
When I follow "Saved preset by teacher1"
Then I should see "Preview of Saved preset by teacher1"
And "Use this preset" "button" should exist
# Single view
And I set the field "Templates tertiary navigation" to "Single view template"
And I should see "Preview of Saved preset by teacher1"
And "Use this preset" "button" should exist
@javascript
Scenario: The tertiary navigation in the Fields page.
Given I navigate to "Fields" in current page administration
When I open the action menu in "field1" "table_row"
Then I should see "Edit"
And I should see "Delete"
And I press the escape key
And I should not see "Actions"
@javascript
Scenario: The tertiary navigation in the Templates page.
Given I navigate to "Templates" in current page administration
When I click on "Actions" "button"
Then I should see "Export preset" in the ".presetsactions" "css_element"
And I should see "Publish preset on this site" in the ".presetsactions" "css_element"
And I press the escape key
And I should see "Add entry template"
# List template.
And I set the field "Templates tertiary navigation" to "List view template"
And I should not see "Add entry template"
And I should see "Header"
And I should see "Repeated entry"
And I should see "Footer"
+254
View File
@@ -0,0 +1,254 @@
@mod @mod_data @javascript
Feature: Users can use predefined presets
In order to use presets
As a user
I need to select an existing preset
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| data | Mountain landscapes | introduction... | C1 | data1 |
And the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | Test field name | Test field description |
Scenario: Using a preset on a non empty database could create new fields
Given the following "mod_data > fields" exist:
| database | type | name |
| data1 | text | title |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Fields"
And I should see "title"
And I should not see "Description"
And I should not see "image"
And I follow "Presets"
And I click on "fullname" "radio" in the "Image gallery" "table_row"
And I click on "Use this preset" "button"
And I should see "Apply preset Image gallery"
And I click on "Map fields" "button"
And I should see "Field mappings"
When I click on "Continue" "button"
And I should see "Preset applied"
Then I should see "title"
And I should see "description" in the "description" "table_row"
And I should see "image" in the "image" "table_row"
Scenario: Using a preset on a non-empty database could show the option to map fields
Given the following "mod_data > fields" exist:
| database | type | name |
| data1 | text | oldtitle |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Fields"
And I should see "oldtitle"
And I should not see "Description"
And I should not see "image"
And I follow "Presets"
And I click on "fullname" "radio" in the "Image gallery" "table_row"
And I click on "Use this preset" "button"
# Let's map a field that is not mapped by default
And I should see "Apply preset Image gallery"
And I should see "Fields to be created: image, title, description"
And I should see "Existing fields to be deleted: Test field name, oldtitle"
When I click on "Map fields" "button"
And I should see "Create a new field" in the "oldtitle" "table_row"
And I set the field "id_title" to "Map to oldtitle"
And I click on "Continue" "button"
And I should see "Preset applied"
Then I should not see "oldtitle"
And I should see "title"
And I should see "description" in the "description" "table_row"
And I should see "image" in the "image" "table_row"
Scenario: Teacher can use a preset from presets page on a database with existing entries
# Creating an entry to test use a preset feature with databases with entries.
Given the following "mod_data > entries" exist:
| database | Test field name |
| data1 | Student entry 1 |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
And I click on "fullname" "radio" in the "Image gallery" "table_row"
And the "Use this preset" "button" should be enabled
When I click on "Use this preset" "button"
And I should see "Apply preset Image gallery"
And I click on "Map fields" "button"
Then I should see "Field mappings"
And I should see "title"
And I should see "Create a new field" in the "title" "table_row"
# We map existing field to keep the entry data
And I set the field "id_title" to "Map to Test field name"
And I click on "Continue" "button"
And I should see "Preset applied"
And I follow "Fields"
And I should see "title"
And I follow "Database"
And I should see "Student entry 1"
Scenario: Using same preset twice doesn't show mapping dialogue and applies the preset directly
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
And I click on "fullname" "radio" in the "Image gallery" "table_row"
When I click on "Use this preset" "button"
And I should see "Apply preset"
And I click on "Map fields" "button"
And I set the field "id_title" to "Map to Test field name"
And I click on "Continue" "button"
And I should see "Preset applied"
And I follow "Presets"
And I click on "fullname" "radio" in the "Image gallery" "table_row"
And I click on "Use this preset" "button"
Then I should not see "Apply preset Image gallery"
And I should see "Preset applied"
Scenario: Using a preset from preset preview page on a non empty database could create new fields
Given the following "mod_data > fields" exist:
| database | type | name |
| data1 | text | title |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Fields"
And I should see "title"
And I should not see "Description"
And I should not see "image"
And I follow "Presets"
And I click on "Image gallery" "link"
And I click on "Use this preset" "button"
And I should see "Apply preset Image gallery"
When I click on "Apply preset" "button"
And I should see "Preset applied"
And I follow "Fields"
Then I should see "title"
And I should see "description" in the "description" "table_row"
And I should see "image" in the "image" "table_row"
Scenario: Using a preset from preset preview page on a non-empty database could show the option to map fields
Given the following "mod_data > fields" exist:
| database | type | name |
| data1 | text | oldtitle |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Fields"
And I should see "oldtitle"
And I should not see "Description"
And I should not see "image"
And I follow "Presets"
And I click on "Image gallery" "link"
And I click on "Use this preset" "button"
# Let's map a field that is not mapped by default
And I should see "Apply preset Image gallery"
And I should see "Fields to be created: image, title, description"
And I should see "Existing fields to be deleted: Test field name, oldtitle"
When I click on "Map fields" "button"
And I should see "Create a new field" in the "oldtitle" "table_row"
And I set the field "id_title" to "Map to oldtitle"
And I click on "Continue" "button"
And I should see "Preset applied"
Then I should not see "oldtitle"
And I should see "title"
And I should see "description" in the "description" "table_row"
And I should see "image" in the "image" "table_row"
Scenario: Teacher can use a preset from preset preview page on a database with existing entries
# Creating an entry to test use a preset feature with databases with entries.
Given the following "mod_data > entries" exist:
| database | Test field name |
| data1 | Student entry 1 |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
And I click on "Image gallery" "link"
And the "Use this preset" "button" should be enabled
When I click on "Use this preset" "button"
And I should see "Apply preset Image gallery"
And I click on "Map fields" "button"
Then I should see "Field mappings"
And I should see "title"
And I should see "Create a new field" in the "title" "table_row"
# We map existing field to keep the entry data
And I set the field "id_title" to "Map to Test field name"
And I click on "Continue" "button"
And I should see "Preset applied"
And I follow "Fields"
And I should see "title"
And I follow "Database"
And I should see "Student entry 1"
Scenario: Using same preset twice from preset preview page doesn't show mapping dialogue and applies the preset
directly
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
And I click on "Image gallery" "link"
When I click on "Use this preset" "button"
And I should see "Apply preset Image gallery"
And I click on "Map fields" "button"
And I should see "Field mappings"
And I set the field "id_title" to "Map to Test field name"
And I click on "Continue" "button"
And I should see "Preset applied"
And I follow "Presets"
And I click on "Image gallery" "link"
And I click on "Use this preset" "button"
Then I should not see "Field mappings"
And I should see "Preset applied"
Scenario: Apply preset dialogue should show helpful information to the user
Given the following "activities" exist:
| activity | name | intro | course | idnumber |
| data | Sea landscapes | introduction... | C1 | data2 |
And the following "mod_data > fields" exist:
| database | type | name |
| data2 | text | title |
And I am on the "Sea landscapes" "data activity" page logged in as teacher1
And I follow "Presets"
And I click on "Image gallery" "link"
When I click on "Use this preset" "button"
And I should see "Apply preset Image gallery"
# Fields to be created only.
Then I should see "Fields to be created: image, description"
And I should not see "If fields to be deleted are of the same type as fields to be created"
And I should not see "If fields to be deleted are of the same type as new fields in the preset"
And I click on "Cancel" "button" in the "Apply preset Image gallery?" "dialogue"
And I follow "Presets"
And the following "mod_data > fields" exist:
| database | type | name |
| data2 | number | number |
And I click on "Image gallery" "link"
And I click on "Use this preset" "button"
And I should see "Apply preset Image gallery"
# Fields to be created and fields to be deleted.
And I should see "Fields to be created: image, description"
And I should see "Existing fields to be deleted: number"
And I should see "If fields to be deleted are of the same type as fields to be created"
And I should not see "If fields to be deleted are of the same type as new fields in the preset"
And I click on "Cancel" "button" in the "Apply preset Image gallery?" "dialogue"
And I follow "Presets"
And the following "mod_data > fields" exist:
| database | type | name |
| data2 | textarea | description |
| data2 | picture | image |
And I click on "Image gallery" "link"
And I click on "Use this preset" "button"
And I should see "Apply preset Image gallery"
# Fields to be deleted only.
And I should see "Existing fields to be deleted: number"
And I should not see "If fields to be deleted are of the same type as fields to be created"
And I should see "If fields to be deleted are of the same type as new fields in the preset"
Scenario: Teacher can use a preset on a non-empty database and previous fields will be removed
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
And I follow "Fields"
And I should see "Test field name"
And I follow "Presets"
And I click on "fullname" "radio" in the "Image gallery" "table_row"
And I click on "Use this preset" "button"
And I should see "Existing fields to be deleted: Test field name"
When I click on "Apply preset" "button"
Then I should see "Preset applied."
And I should see "image"
And I should see "title"
And I should not see "Test field name"
+200
View File
@@ -0,0 +1,200 @@
@mod @mod_data
Feature: Users can view and search database entries
In order to find the database entries that I am looking for
As a user
I need to list and search the database entries
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Bob | 1 | student1@example.com |
| student2 | Alice | 2 | student2@example.com |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "tags" exist:
| name | isstandard |
| Tag1 | 1 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| data | Test database name | Database intro | C1 | data1 |
And the following "mod_data > fields" exist:
| database | type | name | description |
| data1 | text | Test field name | Test field description |
| data1 | text | Test field 2 name | Test field 2 description |
| data1 | url | Test field 3 name | Test field 3 description |
@javascript
Scenario: Students can view, list and search entries
Given the following "mod_data > entries" exist:
| database | Test field name | Test field 2 name | Test field 3 name |
| data1 | Student entry 1 | | https://moodledev.io |
| data1 | Student entry 2 | | |
| data1 | Student entry 3 | | |
When I log in as "student1"
And I am on the "Test database name" "data activity" page
Then I should see "Student entry 1"
# Confirm that the URL field is displayed as a link.
And "https://moodledev.io" "link" should exist
And I should see "Student entry 2"
And I should see "Student entry 3"
And I select "Single view" from the "jump" singleselect
And I should see "Student entry 1"
# Confirm that the URL field is displayed as a link.
And "https://moodledev.io" "link" should exist
And I should not see "Student entry 2"
And "2" "link" should exist
And "3" "link" should exist
And I follow "Next"
And I should see "Student entry 2"
And I should not see "Student entry 1"
And I click on "3" "link" in the "region-main" "region"
And I should see "Student entry 3"
And I should not see "Student entry 2"
And I follow "Previous"
And I should see "Student entry 2"
And I should not see "Student entry 1"
And I should not see "Student entry 3"
And I select "List view" from the "jump" singleselect
And I click on "Advanced search" "checkbox"
And I set the field "Test field name" to "Student entry 1"
And I click on "Save settings" "button" in the "data_adv_form" "region"
And I should see "Student entry 1"
And I should not see "Student entry 2"
And I should not see "Student entry 3"
And I set the field "Test field name" to "Student entry"
And I set the field "Order" to "Descending"
And I click on "Save settings" "button" in the "data_adv_form" "region"
And "Student entry 3" "text" should appear before "Student entry 2" "text"
And "Student entry 2" "text" should appear before "Student entry 1" "text"
@javascript
Scenario: Check that searching by tags works as expected
Given the following "mod_data > entries" exist:
| database | user | Test field name | Test field 2 name | Test field 3 name |
| data1 | student1 | Student original entry untagged | Student original entry untagged 2 | |
And I am on the "Test database name" "data activity" page logged in as student1
And I click on "Add entry" "button"
# This is required for now to prevent the tag suggestion menu from overlapping over the Save & view button.
And I change window size to "large"
And I set the following fields to these values:
| Test field name | Student original entry tagged |
| Test field 2 name | Student original entry tagged 2 |
And I set the field with xpath "//div[@class='datatagcontrol']//input[@type='text']" to "Tag1"
And I press "Save"
And I should see "Student original entry"
And I should see "Tag1" in the "div.tag_list" "css_element"
And I open the action menu in "#defaulttemplate-single" "css_element"
And I choose "Edit" in the open action menu
And I should see "Tag1" in the ".form-autocomplete-selection" "css_element"
And I follow "Cancel"
And I select "List view" from the "jump" singleselect
And I should see "Tag1" in the "div.tag_list" "css_element"
And I click on "Advanced search" "checkbox"
And I set the field with xpath "//div[@class='datatagcontrol']//input[@type='text']" to "Tag1"
And I click on "#page-content" "css_element"
When I click on "Save settings" "button" in the "data_adv_form" "region"
Then I should see "Student original entry tagged"
And I should see "Student original entry tagged 2"
And I should not see "Student original entry untagged"
And I should not see "Student original entry untagged 2"
@javascript
Scenario: Check that searching by first and last name works as expected
Given the following "mod_data > entries" exist:
| database | user | Test field name | Test field 2 name | Test field 3 name |
| data1 | student1 | Student entry 1 | | |
| data1 | student2 | Student entry 2 | | |
When I am on the "Test database name" "data activity" page logged in as teacher1
And I click on "Advanced search" "checkbox"
And I set the field "First name" to "Bob"
And I click on "Save settings" "button" in the "data_adv_form" "region"
Then I should see "Found 1 out of 2 records."
And I should see "Student entry 1"
And I should not see "Student entry 2"
And I set the field "First name" to ""
And I set the field "Last name" to "2"
And I click on "Save settings" "button" in the "data_adv_form" "region"
And I should see "Found 1 out of 2 records."
And I should not see "Student entry 1"
And I should see "Student entry 2"
# Search: no records found.
But I set the field "Last name" to ""
And I set the field "Test field name" to "Student entry 0"
And I click on "Save settings" "button" in the "data_adv_form" "region"
And I should see "No records found."
And I should not see "Student entry 1"
And I should not see "Student entry 2"
# Search all the entries.
And I set the field "Test field name" to "Student entry"
And I click on "Save settings" "button" in the "data_adv_form" "region"
And I should not see "Found 2 out of 2 records."
And I should see "Student entry 1"
And I should see "Student entry 2"
@javascript
Scenario: Database entries can be deleted in batch if delcheck is present
Given the following "mod_data > entries" exist:
| database | user | Test field name | Test field 2 name | Test field 3 name |
| data1 | student1 | Student entry 1 | Some student content 1 | http://moodle.com |
| data1 | teacher1 | Teacher entry 2 | Some teacher content 2 | http://moodle.com |
And I am on the "Test database name" "data activity" page logged in as teacher1
And I navigate to "Templates" in current page administration
And I set the field "Templates tertiary navigation" to "List view template"
And I set the following fields to these values:
| Repeated entry | ##delcheck##[[Test field name]]! |
And I click on "Save" "button" in the "sticky-footer" "region"
When I navigate to "Database" in current page administration
When I click on "Select all" "button"
And I click on "Delete selected" "button"
And I press "Delete"
And I should see "No entries yet"
@javascript
Scenario: Database entries cannot be deleted in batch if delcheck is not present
Given the following "mod_data > entries" exist:
| database | user | Test field name | Test field 2 name | Test field 3 name |
| data1 | student1 | Student entry 1 | Some student content 1 | http://moodle.com |
| data1 | teacher1 | Teacher entry 2 | Some teacher content 2 | http://moodle.com |
And I am on the "Test database name" "data activity" page logged in as teacher1
Then I should not see "Select all"
And I should not see "Delete selected"
Scenario Outline: Entries are linked based on autolink and open in new window settings
# Param1 refers to `Autolink`, param3 refers to `Open in new window`.
Given the following "mod_data > fields" exist:
| database | type | name | param1 | param3 |
| data1 | url | URL field name | <param1> | <param3> |
And the following "mod_data > entries" exist:
| database | user | Test field name | Test field 2 name | Test field 3 name | URL field name |
| data1 | teacher1 | Test field entry | Test field 2 entry | http://example.com/ | www.moodle.org |
When I am on the "Test database name" "data activity" page logged in as teacher1
Then "www.moodle.org" "link" <autolink> exist
# Verify that the URL field is rendered as a link with the correct href attribute and target set to _blank.
And "a[target='_blank'][href='http://www.moodle.org']" "css_element" <autolink> exist
Examples:
| param1 | param3 | autolink |
| 0 | 0 | should not |
| 1 | 1 | should |
@javascript @accessibility
Scenario: Check the accessibility of the database entries page (zero state)
When I am on the "Test database name" "data activity" page logged in as "teacher1"
Then I should see "No entries yet"
And the page should meet accessibility standards
@javascript @accessibility
Scenario: Check the accessibility of the database entries page
Given the following "mod_data > entries" exist:
| database | user | Test field name | Test field 2 name | Test field 3 name |
| data1 | student1 | Student entry 1 | Some student content 1 | http://moodle.com |
| data1 | teacher1 | Teacher entry 2 | Some teacher content 2 | http://moodle.com |
When I am on the "Test database name" "data activity" page logged in as teacher1
Then the page should meet accessibility standards
+73
View File
@@ -0,0 +1,73 @@
@mod @mod_data
Feature: Zero state page (no fields created)
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | name | intro | course | idnumber |
| data | Test database name | n | C1 | data1 |
Scenario: Teachers see buttons to manage database when there is no field created on view page
Given I am on the "Test database name" "data activity" page logged in as "teacher1"
And "Import a preset" "button" should exist
And I am on the "Test database name" "data activity" page
And "Create a field" "button" should exist
And I click on "Create a field" "button"
And I click on "Short text" "link"
And I should see "Create a field"
And I am on the "Test database name" "data activity" page
And "Use a preset" "button" should exist
And I click on "Use a preset" "button"
And I should see "Presets"
@javascript
Scenario: Teachers see buttons to manage database when there is no field created on templates page
Given I am on the "Test database name" "data activity" page logged in as "teacher1"
And "Import a preset" "button" should exist
When I click on "Import a preset" "button"
Then I should see "Preset file"
And I am on the "Test database name" "data activity" page
And I click on "Templates" "link"
And "Create a field" "button" should exist
And I click on "Create a field" "button"
And I click on "Short text" "link"
And I should see "Create a field"
And I am on the "Test database name" "data activity" page
And I click on "Templates" "link"
And "Use a preset" "button" should exist
And I click on "Use a preset" "button"
And I should see "Presets"
@javascript @_file_upload
Scenario: Teachers can import preset from the zero state page
Given I am on the "Test database name" "data activity" page logged in as "teacher1"
And "Import a preset" "button" should exist
When I click on "Import a preset" "button"
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
Then I click on "Import preset and apply" "button" in the ".modal-dialog" "css_element"
And I should see "Manage fields"
Then I should see "Preset applied"
@javascript
Scenario: Teacher can use a preset from zero state page on an empty database
Given I am on the "Test database name" "data activity" page logged in as "teacher1"
And I click on "Use a preset" "button"
And I click on "fullname" "radio" in the "Image gallery" "table_row"
And the "Use this preset" "button" should be enabled
Then I click on "Use this preset" "button"
And I should not see "Field mappings"
And I should see "Image" in the "image" "table_row"
@javascript @accessibility
Scenario: Check the accessibility of the database activity zero state
When I am on the "Test database name" "data activity" page logged in as "teacher1"
Then I should see "Start building your activity"
And the page should meet accessibility standards