forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MDL-78530-master' of https://github.com/aanabit/moodle …
…into MDL-78530-master-clr
- Loading branch information
Showing
12 changed files
with
222 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
completion/tests/behat/site_default_activity_completion.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
@core @core_completion | ||
Feature: Allow admins to edit the default activity completion rules at site level. | ||
In order to set the activity completion defaults for new activities | ||
As an admin | ||
I need to be able to edit the completion rules for a group of activities at site level. | ||
|
||
Background: | ||
Given the following "courses" exist: | ||
| fullname | shortname | category | enablecompletion | | ||
| Course 1 | C1 | 0 | 1 | | ||
And I log in as "admin" | ||
|
||
@javascript | ||
Scenario: Default activity completion rules with no site or course default completion | ||
Given the following "activity" exists: | ||
| activity | assign | | ||
| course | C1 | | ||
| name | Test assignment one | | ||
| completion | 1 | | ||
And I am on "Course 1" course homepage with editing mode on | ||
And I press "Add an activity or resource" | ||
When I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue" | ||
And I expand all fieldsets | ||
# Completion tracking 0 = Do not indicate activity completion. | ||
Then the field "Completion tracking" matches value "0" | ||
# Default values don't affect existing activities. | ||
But I am on the "Test assignment one" Activity page | ||
And I navigate to "Settings" in current page administration | ||
And I expand all fieldsets | ||
And the field "Completion tracking" matches value "1" | ||
|
||
@javascript | ||
Scenario: Default activity completion rules with site default completion but with no course default completion | ||
Given the following "activity" exists: | ||
| activity | assign | | ||
| course | C1 | | ||
| name | Test assignment one | | ||
| completion | 0 | | ||
And the following "core_completion > Course default" exist: | ||
| course | module | completion | completionview | completionusegrade | completionsubmit | | ||
| Acceptance test site | assign | 2 | 0 | 1 | 1 | | ||
And I am on "Course 1" course homepage with editing mode on | ||
And I press "Add an activity or resource" | ||
When I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue" | ||
And I expand all fieldsets | ||
Then the field "Completion tracking" matches value "2" | ||
And the field "completionview" matches value "0" | ||
And the field "completionusegrade" matches value "1" | ||
And the field "completionsubmit" matches value "1" | ||
# Default values don't affect existing activities. | ||
But I am on the "Test assignment one" Activity page | ||
And I navigate to "Settings" in current page administration | ||
And I expand all fieldsets | ||
And the field "Completion tracking" matches value "0" | ||
|
||
@javascript | ||
Scenario: Default activity completion rules with site default completion and course default completion | ||
Given the following "activity" exists: | ||
| activity | assign | | ||
| course | C1 | | ||
| name | Test assignment one | | ||
| completion | 0 | | ||
And the following "core_completion > Course defaults" exist: | ||
| course | module | completion | completionview | completionusegrade | completionsubmit | | ||
| Acceptance test site | assign | 2 | 0 | 1 | 1 | | ||
| C1 | assign | 2 | 1 | 0 | 1 | | ||
And I am on "Course 1" course homepage with editing mode on | ||
And I press "Add an activity or resource" | ||
When I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue" | ||
And I expand all fieldsets | ||
Then the field "Completion tracking" matches value "2" | ||
And the field "completionview" matches value "1" | ||
And the field "completionusegrade" matches value "0" | ||
And the field "completionsubmit" matches value "1" | ||
# Default values don't affect existing activities. | ||
But I am on the "Test assignment one" Activity page | ||
And I navigate to "Settings" in current page administration | ||
And I expand all fieldsets | ||
And the field "Completion tracking" matches value "0" |
59 changes: 59 additions & 0 deletions
59
completion/tests/generator/behat_core_completion_generator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Completion test generator for Behat | ||
* | ||
* @package core_completion | ||
* @copyright 2023 Amaia Anabitarte <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class behat_core_completion_generator extends behat_generator_base { | ||
|
||
/** | ||
* Get a list of the entities that can be created for completion | ||
* | ||
* @return array[] | ||
*/ | ||
protected function get_creatable_entities(): array { | ||
return [ | ||
'Course defaults' => [ | ||
'singular' => 'Course default', | ||
'datagenerator' => 'default_completion', | ||
'required' => [ | ||
'course', | ||
'module', | ||
], | ||
'switchids' => [ | ||
'course' => 'course', | ||
'module' => 'module', | ||
], | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Look up module ID from given name | ||
* | ||
* @param string $name | ||
* @return int | ||
*/ | ||
protected function get_module_id(string $name): int { | ||
global $DB; | ||
|
||
return (int) $DB->get_field('modules', 'id', ['name' => $name], MUST_EXIST); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Completion test generator | ||
* | ||
* @package core_completion | ||
* @copyright 2023 Amaia Anabitarte <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class core_completion_generator extends component_generator_base { | ||
|
||
/** | ||
* Create default completion | ||
* | ||
* @param array|stdClass $record | ||
* @return stdClass | ||
*/ | ||
public function create_default_completion($record): stdClass { | ||
global $DB; | ||
|
||
$record = (array) $record; | ||
|
||
$record = (object) array_merge([ | ||
'completion' => 0, | ||
'completionview' => 0, | ||
'completionusegrade' => 0, | ||
'completionpassgrade' => 0, | ||
'completionexpected' => 0, | ||
'customrules' => '', | ||
], $record); | ||
|
||
$record->id = $DB->insert_record('course_completion_defaults', $record); | ||
|
||
return $record; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters