Merge branch 'MDL-75211-master' of https://github.com/ferranrecio/moodle

This commit is contained in:
Sara Arjona 2022-10-20 17:58:46 +02:00 committed by Ilya Tregubov
commit 31419c1f28
3 changed files with 38 additions and 1 deletions

View File

@ -115,7 +115,7 @@ class view_footer extends sticky_footer {
$this->baseurl
);
if ($parser->get_template_name() != 'singletemplate' && $canmanageentries) {
if ($parser->get_template_name() != 'singletemplate' && $parser->has_tag('delcheck') && $canmanageentries) {
// Build the select/deselect all control.
$selectallid = 'selectall-listview-entries';
$togglegroup = 'listview-entries';

View File

@ -215,6 +215,16 @@ class template {
$this->tags = $matches['tags'];
}
/**
* Check if a tag is present in the template.
*
* @param bool $tagname the tag to check (without ##)
* @return bool if the tag is present
*/
public function has_tag(string $tagname): bool {
return in_array($tagname, $this->tags);
}
/**
* Return the current template name.
*

View File

@ -130,3 +130,30 @@ Feature: Users can view and search database entries
And I press "Save settings"
And I should not 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 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"