Compare commits

...

77 Commits

Author SHA1 Message Date
Jun Pataleta d56aa41e9e Moodle release 4.1.14 2024-10-05 14:46:30 +08:00
AMOS bot 5778558dae Automatically generated installer lang files 2024-10-05 00:07:35 +00:00
Huong Nguyen b7bf868042 weekly release 4.1.13+ 2024-10-04 20:48:25 +07:00
Huong Nguyen 06c20c4675 Merge branch 'install_401_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_401_STABLE 2024-10-04 20:48:23 +07:00
AMOS bot f30a2bb18e Automatically generated installer lang files 2024-10-04 00:07:34 +00:00
Michael Hawkins 92a2dcc96a MDL-83352 message: Update usercantbemessaged string 2024-10-03 17:48:46 +07:00
Shamim Rezaie 3a694fd6bf Merge branch 'MDL-83332-401' of https://github.com/meirzamoodle/moodle into MOODLE_401_STABLE 2024-10-03 02:25:33 +10:00
Paul Holden bb6a65da42 MDL-83180 reportbuilder: correct access check for viewing schedules. 2024-10-02 16:50:08 +08:00
meirzamoodle a11ffea697 MDL-83332 environment: Reverts the slashargument removal on MDL-62640
We are encountering Behat failures on MacOS and possibly Windows.

This reverts commit 3202109780.
2024-10-02 13:32:43 +07:00
Paul Holden 90d7307872 MDL-83181 reportbuilder: ensure audience correctness before delete. 2024-09-30 15:34:03 +07:00
Paul Holden 453dfc4f94 MDL-82386 block_rss_client: user access checks for feed edit/delete. 2024-09-27 11:50:19 +00:00
Huong Nguyen 75bffe9d96 weekly release 4.1.13+ 2024-09-27 18:44:25 +07:00
Huong Nguyen 22dc6301f0 Merge branch 'install_401_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_401_STABLE 2024-09-27 18:44:23 +07:00
AMOS bot 7266fa1524 Automatically generated installer lang files 2024-09-27 00:07:35 +00:00
Jun Pataleta e0a09f31b1 Merge branch 'MDL-79288-401_blockaccessreview_colourcontrastcheck' of https://github.com/brickfield/moodle into MOODLE_401_STABLE 2024-09-26 19:45:12 +08:00
Michael Pound 72526c6f49 MDL-79288 block_accessreview: Improve heatmap colour contrast. 2024-09-26 08:14:55 +00:00
Huong Nguyen 5c0f33209e Merge branch 'MDL-62640-401' of https://github.com/meirzamoodle/moodle into MOODLE_401_STABLE 2024-09-26 11:08:03 +07:00
Sara Arjona 943ee4d484 weekly release 4.1.13+ 2024-09-24 16:52:22 +02:00
meirzamoodle acd31294f4 MDL-62640 environment: Remove the deprecated slash argument check 2024-09-23 13:08:45 +07:00
Sara Arjona b409287479 Merge branch 'MDL-81612_401' of https://github.com/timhunt/moodle into MOODLE_401_STABLE 2024-09-23 07:35:48 +02:00
Sara Arjona 13d98b9f6e weekly release 4.1.13+ 2024-09-20 16:36:32 +02:00
Sara Arjona 2b19e45d49 Merge branch 'install_401_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_401_STABLE 2024-09-20 16:36:25 +02:00
Tim Hunt 7bde04468b MDL-81612 assign: test generation of extensions
Also, some other improvements.

* In Behat you can now use either idnumber of name to identify an
  assignment you are generating things for.
* create_submission generator methods now wants the cmid in $data['cmid']
  not the confusingly named 'assignid'. The old name is accepted, but
  generates a debugging warning. (That will fail the test, but in a way
  that explains how to fix it.)
2024-09-19 16:09:12 +01:00
AMOS bot 80b23a2afd Automatically generated installer lang files 2024-09-19 00:09:22 +00:00
Huong Nguyen da8e201e17 Merge branch 'MDL-81278-401' of https://github.com/mickhawkins/moodle into MOODLE_401_STABLE 2024-09-18 16:09:39 +07:00
AMOS bot d6950db0d9 Automatically generated installer lang files 2024-09-18 00:07:33 +00:00
Sara Arjona 661d66b452 Merge branch 'MDL-83076-401-v2' of https://github.com/lameze/moodle into MOODLE_401_STABLE 2024-09-17 17:21:40 +02:00
Simey Lameze 74a5cc0965 MDL-83076 behat: workaround Firefox 130.0 failure 2024-09-17 11:08:24 +08:00
Michael Hawkins 768a82b583 MDL-81278 core: Update security.txt expiry 2024-09-16 14:51:06 +08:00
AMOS bot 04d3db34ee Automatically generated installer lang files 2024-09-12 00:07:33 +00:00
AMOS bot c871b4d5f8 Automatically generated installer lang files 2024-09-11 00:07:36 +00:00
Huong Nguyen d3749a82ab weekly release 4.1.13+ 2024-09-10 20:03:11 +07:00
Huong Nguyen d7610a257f Merge branch 'MDL-83047-401' of https://github.com/junpataleta/moodle into MOODLE_401_STABLE 2024-09-10 10:48:21 +07:00
Jun Pataleta 62b840648d MDL-83047 theme_boost: Add upgrade note for theme plugins 2024-09-10 10:34:15 +08:00
Jun Pataleta 5f93e6ab03 MDL-83047 theme_boost: Apply background colour only on select layouts
* Apply the styling of `background-color` for `.page-header-headings`
only in the maintenance and secure layouts.
2024-09-09 17:01:33 +08:00
Jun Pataleta 69beec3d2a weekly release 4.1.13+ 2024-09-07 06:45:53 +08:00
Jun Pataleta d2c9c79c0e Merge branch 'MDL-63399-401' of https://github.com/lameze/moodle into MOODLE_401_STABLE 2024-09-06 12:29:34 +08:00
Simey Lameze 1ce15ab9b1 MDL-63399 behat: update existing tests to use the better download steps
Co-authored-by: Tim Hunt <T.J.Hunt@open.ac.uk>
2024-09-06 12:19:56 +08:00
Simey Lameze a24d8a0d2a MDL-63399 behat: new steps to verify downloads
Co-authored-by: Tim Hunt <T.J.Hunt@open.ac.uk>
2024-09-06 12:18:26 +08:00
Huong Nguyen 8835ecef16 Merge branch 'MDL-82948-401' of https://github.com/junpataleta/moodle into MOODLE_401_STABLE 2024-09-06 11:01:41 +07:00
Huong Nguyen 86c79ed091 Merge branch 'MDL-82677-401' of https://github.com/junpataleta/moodle into MOODLE_401_STABLE 2024-09-06 10:51:25 +07:00
Huong Nguyen d4f5e92ee1 Moodle release 4.1.13 2024-08-30 13:50:56 +07:00
Huong Nguyen 2c58f9533b weekly release 4.1.12+ 2024-08-29 18:10:13 +07:00
Jun Pataleta 34077a9190 MDL-82948 theme_boost: Make <blockquote>'s border a bit darker 2024-08-29 16:04:52 +08:00
Paul Holden 42726d645c MDL-82365 mod_lesson: stricter equality checks of activity password. 2024-08-29 12:13:57 +08:00
Jun Pataleta 02d08d2e4d Merge branch 'MDL-82651-401' of https://github.com/lameze/moodle into MOODLE_401_STABLE 2024-08-29 11:59:49 +08:00
Jun Pataleta 9b90cf6584 Merge branch 'MDL-82802-401' of https://github.com/paulholden/moodle into MOODLE_401_STABLE 2024-08-29 11:40:09 +08:00
Huong Nguyen bdbc077efc Merge branch 'MDL-82898-401' of https://github.com/andelacruz/moodle into MOODLE_401_STABLE 2024-08-29 09:50:58 +07:00
Paul Holden fb06894e75 MDL-76962 auth_oauth2: users can only delete their own linked logins. 2024-08-29 10:33:39 +08:00
Simey Lameze 6b4946e0a8 MDL-82651 behat: remove unnecessary steps 2024-08-28 13:10:20 +08:00
Simey Lameze 057f63909f MDL-82651 behat: wait for button to exist before clicking 2024-08-28 13:10:20 +08:00
Angelia Dela Cruz ea84a13152 MDL-82898 enrol_self: Behat to test student enrolment using key 2024-08-28 12:14:27 +08:00
Marina Glancy 9639feb9a3 MDL-82567 core: Add has_capability method
Co-authored-by: David Woloszyn <david.woloszyn@moodle.com>
Co-authored-by: Jun Pataleta <jun@moodle.com>
2024-08-24 06:30:25 +00:00
Shamim Rezaie f009e2621e Merge branch 'MDL-82006-401' of https://github.com/paulholden/moodle into MOODLE_401_STABLE 2024-08-24 16:21:45 +10:00
Sara Arjona 3449379bca weekly release 4.1.12+ 2024-08-23 16:04:18 +02:00
Sara Arjona c77d6a79ec Merge branch 'install_401_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_401_STABLE 2024-08-23 16:04:13 +02:00
Jake Dallimore d8558b1d42 Merge branch 'MDL-82787-401' of https://github.com/andrewnicols/moodle into MOODLE_401_STABLE 2024-08-23 11:52:07 +08:00
Huong Nguyen b8614dee98 Merge branch 'MDL-82841-401' of https://github.com/andelacruz/moodle into MOODLE_401_STABLE 2024-08-22 08:44:26 +07:00
Sara Arjona b852d34285 Merge branch 'MDL-82655-401' of https://github.com/andelacruz/moodle into MOODLE_401_STABLE 2024-08-21 15:54:42 +02:00
Angelia Dela Cruz 250ef211f0 MDL-82841 mod_workshop: Behat for submissions with set # of attachments 2024-08-21 19:28:12 +08:00
Angelia Dela Cruz 2ebcdda606 MDL-82655 mod_workshop: Behat test for manual and random allocation 2024-08-21 18:21:57 +08:00
Andrew Nicols ce89c63b0b MDL-82787 behat: Correct stop of webdriver on failure 2024-08-21 08:46:34 +08:00
AMOS bot 8acc343fb8 Automatically generated installer lang files 2024-08-19 00:07:37 +00:00
Huong Nguyen 15a54747b9 weekly release 4.1.12+ 2024-08-16 08:40:46 +07:00
Paul Holden 7666131199 MDL-82006 reportbuilder: move filter Behat scenarios inside component. 2024-08-15 13:54:13 +01:00
Paul Holden 8b54213ad0 MDL-82802 tool_xmldb: allow numeric characters in table names. 2024-08-15 12:00:51 +01:00
Jun Pataleta 561a371423 Merge branch 'MDL-82782-401' of https://github.com/andrewnicols/moodle into MOODLE_401_STABLE 2024-08-15 11:48:17 +08:00
Jun Pataleta 6cc39f8e94 Merge branch 'MDL-82798-401' of https://github.com/HuongNV13/moodle into MOODLE_401_STABLE 2024-08-15 11:12:43 +08:00
Huong Nguyen 58e54a3d33 Merge branch 'MDL-82758-401' of https://github.com/junpataleta/moodle into MOODLE_401_STABLE 2024-08-15 09:38:41 +07:00
Huong Nguyen eb1c1e79a1 MDL-82798 qtype_ddmarker: Fix Behat failure 2024-08-15 09:17:41 +07:00
Jun Pataleta e7c973a195 Merge branch 'MDL-82792-401' of https://github.com/sarjona/moodle into MOODLE_401_STABLE 2024-08-15 10:14:24 +08:00
Andrew Nicols a982ebad0c MDL-82782 behat: Support runtime scaling of Behat windows 2024-08-14 21:51:36 +08:00
Sara Arjona 27692e70b5 MDL-82792 h5p: Fix random behat failures
We've started seeing various failures in Firefox and Classic.
Increasing the default window size fixes them.
2024-08-14 12:18:47 +02:00
Sara Arjona 05db16c24d Merge branch 'MDL-82682-401' of https://github.com/lameze/moodle into MOODLE_401_STABLE 2024-08-14 09:13:41 +02:00
Simey Lameze 0aaf7fe953 MDL-82682 behat: increase window size to avoid fails 2024-08-14 10:02:20 +08:00
Jun Pataleta 05fe39a88f MDL-82758 gha: Remove reference to the master branch 2024-08-09 16:18:06 +08:00
Jun Pataleta 7ad936dcbf MDL-82677 theme: Set a background colour for page heading
* Set a background colour for the .page-header-headings class.
* Assign the .page-header-headings class to the maintenance mode
template's page header div.
2024-08-02 17:25:12 +08:00
80 changed files with 915 additions and 175 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ name: Core
on:
push:
branches-ignore:
- master
- main
- MOODLE_[0-9]+_STABLE
tags-ignore:
- v[0-9]+.[0-9]+.[0-9]+*
-22
View File
@@ -48,25 +48,3 @@ Feature: View task logs report and use its filters
| operator | shouldornotsee |
| Less than | should not see |
| Greater than | should see |
@javascript
Scenario: Reset task log filters
Given I log in as "admin"
And I change window size to "large"
And I navigate to "Server > Tasks > Task logs" in site administration
When I click on "Filters" "button"
And I set the following fields in the "Result" "core_reportbuilder > Filter" to these values:
| Result operator | Is equal to |
| Result value | Fail |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
Then I should see "Filters applied"
And I should see "Filters (1)" in the "#dropdownFiltersButton" "css_element"
And I should see "Nothing to display"
And I click on "Reset all" "button" in the "[data-region='report-filters']" "css_element"
And I should see "Filters reset"
And I should not see "Filters (1)" in the "#dropdownFiltersButton" "css_element"
And I should see "Filters" in the "#dropdownFiltersButton" "css_element"
And "[data-region='report-filters']" "css_element" should be visible
And the following fields in the "Result" "core_reportbuilder > Filter" match these values:
| Result operator | Is any value |
And I should not see "Nothing to display"
@@ -5,16 +5,18 @@ Feature: I can download a preset
| name |
| Custom preset |
@javascript
Scenario: Custom preset settings can be downloaded
Given I log in as "admin"
And I navigate to "Site admin presets" in site administration
When I open the action menu in "Custom preset" "table_row"
Then following "Download" "link" in the "Custom preset" "table_row" should download between "0" and "5000" bytes
Then following "Download" in the "Custom preset" "table_row" should download a file that:
| Has mimetype | text/xml |
| Contains text in xml element | Custom preset |
@javascript
Scenario: Core preset settings can be downloaded
Given I log in as "admin"
And I navigate to "Site admin presets" in site administration
When I open the action menu in "Starter" "table_row"
Then following "Download" "link" in the "Starter" "table_row" should download between "0" and "5000" bytes
Then following "Download" in the "Starter" "table_row" should download a file that:
| Has mimetype | text/xml |
| Contains text in xml element | Starter |
@@ -54,6 +54,7 @@ Feature: Data delete from the privacy API
And I should see "Awaiting approval" in the "Victim User 1" "table_row"
And I open the action menu in "Victim User 1" "table_row"
And I follow "Approve request"
And I wait until "Approve request" "button" exists
And I press "Approve request"
And I should see "Approved" in the "Victim User 1" "table_row"
And I run all adhoc tasks
@@ -80,6 +81,7 @@ Feature: Data delete from the privacy API
And I navigate to "Users > Privacy and policies > Data requests" in site administration
And I open the action menu in "Victim User 1" "table_row"
And I follow "Approve request"
And I wait until "Approve request" "button" exists
And I press "Approve request"
And I log out
@@ -115,6 +117,7 @@ Feature: Data delete from the privacy API
And I navigate to "Users > Privacy and policies > Data requests" in site administration
And I open the action menu in "Victim User 1" "table_row"
And I follow "Approve request"
And I wait until "Approve request" "button" exists
And I press "Approve request"
And I log out
@@ -48,13 +48,15 @@ Feature: Data export from the privacy API
And I should see "Awaiting approval" in the "Victim User 1" "table_row"
And I open the action menu in "Victim User 1" "table_row"
And I follow "Approve request"
And I wait until "Approve request" "button" exists
And I press "Approve request"
And I should see "Approved" in the "Victim User 1" "table_row"
And I run all adhoc tasks
And I reload the page
And I should see "Download ready" in the "Victim User 1" "table_row"
And I open the action menu in "Victim User 1" "table_row"
And following "Download" should download between "1" and "150000" bytes
And following "Download" should download a file that:
| Contains file in zip | index.html |
And the following config values are set as admin:
| privacyrequestexpiry | 1 | tool_dataprivacy |
And I wait "1" seconds
@@ -89,7 +91,8 @@ Feature: Data export from the privacy API
And I reload the page
And I should see "Download ready" in the "Export all of my personal data" "table_row"
And I open the action menu in "Victim User 1" "table_row"
And following "Download" should download between "1" and "155000" bytes
And following "Download" should download a file that:
| Contains file in zip | index.html |
And the following config values are set as admin:
| privacyrequestexpiry | 1 | tool_dataprivacy |
@@ -115,6 +118,7 @@ Feature: Data export from the privacy API
And I navigate to "Users > Privacy and policies > Data requests" in site administration
And I open the action menu in "Victim User 1" "table_row"
And I follow "Approve request"
And I wait until "Approve request" "button" exists
And I press "Approve request"
And I log out
@@ -126,7 +130,8 @@ Feature: Data export from the privacy API
And I reload the page
And I should see "Download ready" in the "Victim User 1" "table_row"
And I open the action menu in "Victim User 1" "table_row"
And following "Download" should download between "1" and "150000" bytes
And following "Download" should download a file that:
| Contains file in zip | index.html |
And the following config values are set as admin:
| privacyrequestexpiry | 1 | tool_dataprivacy |
@@ -170,6 +170,7 @@ Feature: Viewing acceptances reports and accepting on behalf of other users
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "Actions" "link_or_button" in the "This privacy policy" "table_row"
And I click on "Set status to \"Active\"" "link" in the "This privacy policy" "table_row"
And I wait until "Activate" "button" exists
And I press "Activate"
And I log out
When I log in as "manager"
@@ -260,6 +261,7 @@ Feature: Viewing acceptances reports and accepting on behalf of other users
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "Actions" "link_or_button" in the "This privacy policy" "table_row"
And I click on "Set status to \"Active\"" "link" in the "This privacy policy" "table_row"
And I wait until "Activate" "button" exists
And I press "Activate"
And I log out
When I log in as "manager"
@@ -129,8 +129,8 @@ class new_table_from_mysql extends XMLDBAction {
// go to the table edit action
} else {
// Get some params (table is mandatory here).
$tableparam = required_param('table', PARAM_ALPHAEXT);
$afterparam = required_param('after', PARAM_ALPHAEXT);
$tableparam = required_param('table', PARAM_ALPHANUMEXT);
$afterparam = required_param('after', PARAM_ALPHANUMEXT);
if (empty($tableparam) || empty($afterparam)) {
throw new moodle_exception('Invalid param value detected.');
+3 -1
View File
@@ -114,6 +114,7 @@ Feature: Manage analytics models
And I should see "Read actions amount"
And I click on "Select Student 6 for bulk action" "checkbox" in the "Student 6" "table_row"
And I click on "Accept" "button"
And I wait until "Confirm" "button" exists
And I click on "Confirm" "button" in the "Accept" "dialogue"
And I click on "View prediction details" "icon" in the "Student 5" "table_row"
And I click on "Select Student 5 for bulk action" "checkbox" in the "Student 5" "table_row"
@@ -145,7 +146,8 @@ Feature: Manage analytics models
When I open the action menu in "Students at risk of not meeting the course completion conditions" "table_row"
And I choose "Export" in the open action menu
And I click on "Actions" "link" in the "Students at risk of not meeting the course completion conditions" "table_row"
And following "Export" should download between "100" and "500" bytes
And following "Export" should download a file that:
| Contains file in zip | model-config.json |
Scenario: Check invalid site elements
When I open the action menu in "Students at risk of not meeting the course completion conditions" "table_row"
+9 -4
View File
@@ -345,7 +345,7 @@ class api {
}
/**
* Delete linked login
* Delete a users own linked login
*
* Requires auth/oauth2:managelinkedlogins capability at the user context.
*
@@ -353,14 +353,19 @@ class api {
* @return boolean
*/
public static function delete_linked_login($linkedloginid) {
$login = new linked_login($linkedloginid);
$userid = $login->get('userid');
global $USER;
if (\core\session\manager::is_loggedinas()) {
throw new moodle_exception('notwhileloggedinas', 'auth_oauth2');
}
$context = context_user::instance($userid);
$login = linked_login::get_record([
'id' => $linkedloginid,
'userid' => $USER->id,
'confirmtoken' => '',
], MUST_EXIST);
$context = context_user::instance($login->get('userid'));
require_capability('auth/oauth2:managelinkedlogins', $context);
$login->delete();
+25
View File
@@ -137,6 +137,7 @@ class api_test extends \advanced_testcase {
$issuer = \core\oauth2\api::create_standard_issuer('google');
$user = $this->getDataGenerator()->create_user();
$this->setUser($user);
$info = [];
$info['username'] = 'banana';
@@ -169,6 +170,30 @@ class api_test extends \advanced_testcase {
$this->assertEquals($newuser->id, $match->get('userid'));
}
/**
* Test that we cannot deleted a linked login for another user
*/
public function test_delete_linked_login_other_user(): void {
$this->resetAfterTest();
$this->setAdminUser();
$issuer = \core\oauth2\api::create_standard_issuer('google');
$user = $this->getDataGenerator()->create_user();
api::link_login([
'username' => 'banana',
'email' => 'banana@example.com',
], $issuer, $user->id);
/** @var linked_login $linkedlogin */
$linkedlogin = api::get_linked_logins($user->id)[0];
// We are logged in as a different user, so cannot delete this.
$this->expectException(\dml_missing_record_exception::class);
api::delete_linked_login($linkedlogin->get('id'));
}
/**
* Test that is_enabled correctly identifies when the plugin is enabled.
*/
+7 -7
View File
@@ -1,22 +1,22 @@
.block_accessreview_success,
.block_accessreview.block_accessreview_success.hasinfo {
color: #1e451e;
background: #d7e6d7;
border-color: #c8ddc8;
background: #eff5ef;
box-shadow: 0 0 2px 2px #619a61;
}
.block_accessreview_danger,
.block_accessreview.block_accessreview_danger.hasinfo {
color: #6e211e;
background: #f6d9d8;
border-color: #f3c9c8;
background: #fdf7f7;
box-shadow: 0 0 2px 2px #da6960;
}
.block_accessreview_warning,
.block_accessreview.block_accessreview_warning.hasinfo {
color: #7d5a29;
background: #fcefdc;
border-color: #fbe8cd;
color: #694b21;
background: #fdf2e3;
box-shadow: 0 0 2px 2px #c97a0e;
}
.block_accessreview_table {
+12 -1
View File
@@ -180,7 +180,18 @@ $PAGE->set_pagelayout('admin');
if ($rssid) {
$isadding = false;
$rssrecord = $DB->get_record('block_rss_client', array('id' => $rssid), '*', MUST_EXIST);
if ($managesharedfeeds) {
$select = 'id = :id AND (userid = :userid OR shared = 1)';
} else {
$select = 'id = :id AND userid = :userid';
}
$rssrecord = $DB->get_record_select('block_rss_client', $select, [
'id' => $rssid,
'userid' => $USER->id,
], '*', MUST_EXIST);
} else {
$isadding = true;
$rssrecord = new stdClass;
+14 -7
View File
@@ -61,20 +61,27 @@ if ($returnurl) {
$baseurl = new moodle_url('/blocks/rss_client/managefeeds.php', $urlparams);
$PAGE->set_url($baseurl);
if ($managesharedfeeds) {
$select = '(userid = :userid OR shared = 1)';
} else {
$select = 'userid = :userid';
}
// Process any actions
if ($deleterssid && confirm_sesskey()) {
$DB->delete_records('block_rss_client', array('id'=>$deleterssid));
$deleterssid = $DB->get_field_select('block_rss_client', 'id', "id = :id AND {$select}", [
'id' => $deleterssid,
'userid' => $USER->id
], MUST_EXIST);
$DB->delete_records('block_rss_client', ['id' => $deleterssid]);
redirect($PAGE->url, get_string('feeddeleted', 'block_rss_client'));
}
// Display the list of feeds.
if ($managesharedfeeds) {
$select = '(userid = ' . $USER->id . ' OR shared = 1)';
} else {
$select = 'userid = ' . $USER->id;
}
$feeds = $DB->get_records_select('block_rss_client', $select, null, $DB->sql_order_by_text('title'));
$feeds = $DB->get_records_select('block_rss_client', $select, ['userid' => $USER->id], $DB->sql_order_by_text('title'));
$strmanage = get_string('managefeeds', 'block_rss_client');
@@ -5,7 +5,7 @@ Feature: Edit activities in main menu block
I need to add and edit activities there
@javascript
Scenario: Edit name of acitivity in-place in site main menu block
Scenario: Edit name of activity in-place in site main menu block
Given the following "activity" exists:
| activity | forum |
| course | Acceptance test site |
@@ -36,6 +36,7 @@ Feature: Edit activities in main menu block
| forum | Acceptance test site | 0 | Visible forum |
| forum | Acceptance test site | 0 | My forum name |
And I log in as "admin"
And I change window size to "large"
And I am on site homepage
And I turn editing mode on
And "My forum name" activity in site main menu block should have "Hide" editing icon
@@ -33,11 +33,6 @@ Feature: Course activity controls works as expected
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I click on <targetpage> "link" in the "region-main" "region"
And I add the "Recent activity" block
And I open the action menu in "Recent activity" "block"
And I click on "Delete Recent activity block" "link"
And I click on "Delete" "button" in the "Delete block?" "dialogue"
And <belowpage> "section" <should_see_other_sections> exist
And <belowpage> "section" <should_see_other_sections> exist
And I open "Test forum name 1" actions menu
And I click on "Edit settings" "link" in the "Test forum name 1" activity
@@ -100,10 +95,6 @@ Feature: Course activity controls works as expected
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I click on <targetpage> "link" in the "region-main" "region"
And I add the "Recent activity" block
And I open the action menu in "Recent activity" "block"
And I click on "Delete Recent activity block" "link"
And I press "Yes"
And <belowpage> "section" <should_see_other_sections> exist
And I click on "Edit settings" "link" in the "Test forum name 1" activity
And I should see "Updating Forum"
+15 -4
View File
@@ -9,6 +9,7 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
And the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
@@ -64,13 +65,13 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe
Scenario: Self-enrolment enabled requiring a group enrolment key
Given I log in as "teacher1"
When I add "Self enrolment" enrolment method in "Course 1" with:
| Custom instance name | Test student enrolment |
| Enrolment key | moodle_rules |
| Use group enrolment keys | Yes |
| Custom instance name | Test student enrolment |
| Enrolment key | moodle_rules |
| Use group enrolment keys | Yes |
And I am on the "Course 1" "groups" page
And I press "Create group"
And I set the following fields to these values:
| Group name | Group 1 |
| Group name | Group 1 |
| Enrolment key | Test-groupenrolkey1 |
And I press "Save changes"
And I log out
@@ -82,6 +83,16 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe
Then I should see "Topic 1"
And I should not see "Enrolment options"
And I should not see "Enrol me in this course"
And I am on the "Course 1" course page logged in as student2
And I set the following fields to these values:
| Enrolment key | moodle_rules |
And I press "Enrol me"
And I am on the "Course 1" course page logged in as teacher1
And I navigate to course participants
And the following should exist in the "participants" table:
| First name | Email address | Roles | Groups |
| Student 1 | student1@example.com | Student | Group 1 |
| Student 2 | student2@example.com | Student | No groups |
@javascript
Scenario: Edit a self-enrolled user's enrolment from the course participants page
@@ -68,9 +68,9 @@ Feature: Using the AJAX grading feature of Grader report to update grades and fe
And I should not see a feedback field for "Student 2" and grade item "Item VU"
And I click on student "Student 3" for grade item "Item SU"
And I set the field "ajaxgrade" to "Very good"
And I press the shift tab key
And I press the tab key
And I press the shift tab key
# Workaround for the Firefox 130.0 issue with the enter key and the old ajax grader element.
And I click on student "Student 3" for grade item "Item SU"
And I press the enter key
And I click on student "Student 3" for grade item "Item VU"
And I set the field "ajaxgrade" to "50"
And I press the enter key
+2 -6
View File
@@ -50,14 +50,14 @@ Feature: We can use calculated grade totals
| Test assignment nine | student1 | 5.00 |
And I am on the "Course 1" "grades > Grader report > View" page logged in as "teacher1"
And I turn editing mode on
And I change window size to "large"
# Change window size to ultra-wide to avoid 'out-of-bounds' random failures.
And I change window size to "5120x2160"
And I set the following settings for grade item "Test assignment two":
| Hidden | 1 |
And I set the following settings for grade item "Test assignment five":
| Hidden | 1 |
And I set the following settings for grade item "Test assignment eight":
| Hidden | 1 |
And I change window size to "medium"
And I navigate to "Setup > Course grade settings" in the course gradebook
And I set the field "Grade display type" to "Real (percentage)"
And I press "Save changes"
@@ -421,8 +421,6 @@ Feature: We can use calculated grade totals
| Rescale existing grades | No |
| Maximum grade | 200 |
| Extra credit | 0 |
# Change window size to ultra-wide to avoid 'out-of-bounds' random failures.
And I change window size to "5120x2160"
And I give the grade "21.00" to the user "Student 1" for the grade item "Manual item 2"
And I press "Save changes"
And I give the grade "20.00" to the user "Student 1" for the grade item "Manual item 2"
@@ -434,8 +432,6 @@ Feature: We can use calculated grade totals
| Rescale existing grades | No |
| Maximum grade | 100 |
| Extra credit | 0 |
# Change window size to ultra-wide to avoid 'out-of-bounds' random failures.
And I change window size to "5120x2160"
And I give the grade "21.00" to the user "Student 1" for the grade item "Manual item 2"
And I press "Save changes"
And I give the grade "20.00" to the user "Student 1" for the grade item "Manual item 2"
@@ -1,4 +1,4 @@
@core @core_grades @javascript
@core @core_grades
Feature: Changing the aggregation of an item affects its weight and extra credit definition
In order to switch to another aggregation method
As an teacher
@@ -31,7 +31,8 @@ Feature: Changing the aggregation of an item affects its weight and extra credit
| Item b3 | C1 | Cat natural & | 1 | 0.10 | 1 |
| Item b4 | C1 | Cat natural & | 1 | 0 | 0 |
And I log in as "admin"
And I change window size to "large"
# Change window size to ultra-wide to avoid 'out-of-bounds' random failures.
And I change window size to "5120x2160"
And I set the following administration settings values:
| grade_aggregations_visible | Mean of grades,Weighted mean of grades,Simple weighted mean of grades,Mean of grades (with extra credits),Median of grades,Lowest grade,Highest grade,Mode of grades,Natural |
And I am on the "Course 1" "grades > Grader report > View" page
@@ -54,8 +55,12 @@ Feature: Changing the aggregation of an item affects its weight and extra credit
| Weight | 0 |
| Extra credit | 1 |
And I press "Save changes"
And I follow "Edit Item a1"
And the field "Weight adjusted" matches value "0"
Scenario: Verify grade item values
Given I am on the "Course 1" "grades > Grader report > View" page logged in as "admin"
And I turn editing mode on
When I follow "Edit Item a1"
Then the field "Weight adjusted" matches value "0"
And the field "Extra credit" matches value "0"
And I press "Cancel"
And I follow "Edit Item a2"
@@ -331,6 +336,7 @@ Feature: Changing the aggregation of an item affects its weight and extra credit
And the field "Extra credit" matches value "0"
And I press "Cancel"
@javascript
Scenario: Switching grade items between categories
# Move to same aggregation (Natural).
Given I navigate to "Setup > Gradebook setup" in the course gradebook
@@ -46,6 +46,7 @@ Feature: Student and teacher's view of aggregated grade items is consistent when
And I give the grade "50.00" to the user "Student 1" for the grade item "Test assignment one"
And I give the grade "50.00" to the user "Student 1" for the grade item "Test assignment three"
And I press "Save changes"
And I change window size to "large"
And I set the following settings for grade item "Test assignment four":
| Hidden | 1 |
And I press "Save changes"
+8
View File
@@ -31,3 +31,11 @@ defined('MOODLE_INTERNAL') || die();
$string['clianswerno'] = 'n';
$string['cliansweryes'] = 's';
$string['cliincorrectvalueerror'] = 'Error, valor incorrecte "{$a->value}" for "{$a->option}"';
$string['cliincorrectvalueretry'] = 'Valor incorrecte, per favor essaya novemente';
$string['clitypevalue'] = 'valor de typo';
$string['clitypevaluedefault'] = 'valor de typo,pressa Enter per usar le vaor predefinite ({$a})';
$string['cliunknowoption'] = 'Uotiones non recognoscite:
{$a}
Per favor usa le option --help.';
$string['cliyesnoprompt'] = 'typa s (significa si) o n (significa no)';
+36
View File
@@ -0,0 +1,36 @@
<?php
// This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>.
/**
* Automatically generated strings for Moodle installer
*
* Do not edit this file manually! It contains just a subset of strings
* needed during the very first steps of installation. This file was
* generated automatically by export-installer.php (which is part of AMOS
* {@link http://docs.moodle.org/dev/Languages/AMOS}) using the
* list of strings defined in /install/stringnames.txt.
*
* @package installer
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$string['language'] = 'Linguage';
$string['moodlelogo'] = 'Logo de Moodle';
$string['next'] = 'Proxime';
$string['previous'] = 'Previe';
$string['reload'] = 'Recarga';
+1 -1
View File
@@ -41,4 +41,4 @@ Te rugăm folosește--opţiunea Ajutor.';
$string['cliyesnoprompt'] = 'tastează d (pentru \'da\') sau \'n\' (pentru \'nu\')';
$string['environmentrequireinstall'] = 'trebuie instalat şi activat';
$string['environmentrequireversion'] = 'versiuna necesară este {$a->needed} în timp ce dumneavoastră rulaţi versiunea {$a->current}';
$string['upgradekeyset'] = 'Actualizează cheie (lăsați gol pentru a nu fi setat)';
$string['upgradekeyset'] = 'Actualizează cheie (lăsați necompletat pentru a nu fi setat)';
+1 -1
View File
@@ -36,7 +36,7 @@ $string['cannotcreatelangdir'] = '无法创建 lang 目录。';
$string['cannotcreatetempdir'] = '无法创建 temp 目录。';
$string['cannotdownloadcomponents'] = '无法下载组件';
$string['cannotdownloadzipfile'] = '无法下载 ZIP 文件。';
$string['cannotfindcomponent'] = '找不到组件';
$string['cannotfindcomponent'] = '找不到组件';
$string['cannotsavemd5file'] = '无法保存 md5 文件';
$string['cannotsavezipfile'] = '无法保存 ZIP 文件';
$string['cannotunzipfile'] = '无法解压文件';
+1 -1
View File
@@ -263,7 +263,7 @@ $string['unreadnotifications'] = 'There are {$a} unread notifications';
$string['unreadnewgroupconversationmessage'] = 'New message from {$a->name} in {$a->conversationname}';
$string['unreadnewmessage'] = 'New message from {$a}';
$string['useentertosend'] = 'Use enter to send';
$string['usercantbemessaged'] = 'You can\'t message {$a} due to their message preferences. Try adding them as a contact.';
$string['usercantbemessaged'] = 'You can\'t message this user due to their message preferences. Try adding them as a contact.';
$string['userwouldliketocontactyou'] = '{$a} would like to contact you';
$string['viewfullnotification'] = 'View full notification';
$string['viewmessageswith'] = 'View messages with {$a}';
+16 -1
View File
@@ -761,9 +761,14 @@ trait behat_session_trait {
*
* @param string $windowsize size of window.
* @param bool $viewport If true, changes viewport rather than window size
* @param bool $scalesize Whether to scale the size by the WINDOWSCALE environment variable
* @throws ExpectationException
*/
protected function resize_window($windowsize, $viewport = false) {
protected function resize_window(
string $windowsize,
bool $viewport = false,
bool $scalesize = true
): void {
global $CFG;
// Non JS don't support resize window.
@@ -807,6 +812,16 @@ trait behat_session_trait {
$height *= $CFG->behat_window_size_modifier;
}
if ($scalesize) {
// Scale the window size by the WINDOWSCALE environment variable.
// This is intended to be used for Behat reruns to negate the impact of browser window size issues.
// This allows a per-run, runtime configuration of the scaling, unlike behat_window_size_modifier which
// typically applies to all runs.
$scalefactor = getenv('WINDOWSCALE') ? floatval(getenv('WINDOWSCALE')) : 1;
$width *= $scalefactor;
$height *= $scalefactor;
}
if ($viewport) {
// When setting viewport size, we set it so that the document width will be exactly
// as specified, assuming that there is a vertical scrollbar. (In cases where there is
@@ -87,7 +87,8 @@ class WebDriver extends UpstreamDriver {
parent::stop();
} catch (DriverException $e) {
error_log($e->getMessage());
$this->webDriver = null;
$rcp = new \ReflectionProperty(parent::class, 'webDriver');
$rcp->setValue($this, null);
}
}
}
+3
View File
@@ -41,4 +41,7 @@ namespace core_table;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
interface dynamic {
// Classes implementing this interface must define function `public has_capability(): bool`
// If it is not defined, the web service `core_table_get_dynamic_table_content` will check capability
// 'moodle/site:config' in the system context, allowing only admins to access the table data.
}
+7
View File
@@ -228,6 +228,13 @@ class get extends external_api {
$instance = new $tableclass($uniqueid);
$instance->set_filterset($filterset);
self::validate_context($instance->get_context());
if (!method_exists($instance, 'has_capability')) {
// Method \core_table\dynamic::has_capability() will be added in Moodle 4.5. Until then if it is not
// implemented, we will require the admin capability.
require_capability('moodle/site:config', \context_system::instance());
} else if (!$instance->has_capability()) {
throw new \moodle_exception('nopermissiontoaccesspage');
}
$instance->set_sortdata($sortdata);
$alphabet = get_string('alphabet', 'langconfig');
+15
View File
@@ -203,6 +203,21 @@ class flexible_table {
TABLE_VAR_RESET => 'treset',
TABLE_VAR_DIR => 'tdir',
);
static $notified = [];
if (!(defined('AJAX_SCRIPT') && AJAX_SCRIPT) &&
$this instanceof \core_table\dynamic &&
!method_exists($this, 'has_capability') &&
empty($notified[get_class($this)])) {
// Classes implementing \core_table\dynamic must have a method has_capability():bool .
// This will be enforced in Moodle 4.5.
\core\notification::add(
get_string('codingerror', 'debug',
'Error in class '.get_class($this).'. Some functionality may be available to admins only.'),
\core\notification::WARNING
);
$notified[get_class($this)] = true;
}
}
/**
+211
View File
@@ -0,0 +1,211 @@
<?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 to verify a downloaded file.
*
* @package core
* @category test
* @copyright 2024 Simey Lameze <simey@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use Behat\Gherkin\Node\TableNode;
use Behat\Mink\Exception\ExpectationException;
require_once(__DIR__ . '/../../behat/behat_base.php');
/**
* Steps definitions to verify a downloaded file.
*
* @package core
* @category test
* @copyright 2024 Simey Lameze <simey@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_download extends behat_base {
/**
* Downloads the file from a link on the page and verify the type and content.
*
* @Then following :link_text should download a file that:
*
* @param string $linktext the text of the link.
* @param TableNode $table the table of assertions to use the check the file contents.
* @throws ExpectationException if the file cannot be downloaded, or if the download does not pass all the checks.
*/
public function following_should_download_a_file_that(string $linktext, TableNode $table): void {
$this->following_in_element_should_download_a_file_that($linktext, '', '', $table);
}
/**
* Downloads the file from a link on the page and verify the type and content.
*
* @Then following :link_text in the :element_container_string :text_selector_string should download a file that:
*
* @param string $linktext the text of the link.
* @param string $containerlocator the container element.
* @param string $containertype the container selector type.
* @param TableNode $table the table of assertions to use the check the file contents.
* @throws ExpectationException if the file cannot be downloaded, or if the download does not pass all the checks.
*/
public function following_in_element_should_download_a_file_that(string $linktext, string $containerlocator,
string $containertype, TableNode $table): void {
$filecontent = $this->download_file($linktext, $containerlocator, $containertype);
$this->verify_file_content($filecontent, $table);
}
/**
* Download a file from the given link.
*
* @param string $linktext the text of the link.
* @param string $containerlocator the container element.
* @param string $containertype the container selector type.
* @return string the file contents.
* @throws ExpectationException if the download fails.
*/
protected function download_file(string $linktext, string $containerlocator, string $containertype): string {
return behat_context_helper::get('behat_general')->download_file_from_link($linktext, $containerlocator, $containertype);
}
/**
* Checks the content of the downloaded file.
*
* @param string $filecontent the content of the file.
* @param TableNode $table the table of assertions to check.
* @throws ExpectationException if the file content does not pass all the checks.
*/
private function verify_file_content(string $filecontent, TableNode $table): void {
foreach ($table->getRows() as $row) {
switch (strtolower(trim($row[0]))) {
case 'contains text':
$this->verify_file_contains_text($filecontent, $row[1]);
break;
case 'contains text in xml element':
$this->verify_xml_element_contains($filecontent, $row[1]);
break;
case 'has mimetype':
$this->verify_file_mimetype($filecontent, $row[1]);
break;
case 'contains file in zip':
$this->verify_zip_file_content($filecontent, $row[1]);
break;
default:
throw new ExpectationException(
'Invalid type of file assertion: ' . $row[0], $this->getSession());
}
}
}
/**
* Validates the downloaded file appears to be of the mimetype.
*
* @param string $filecontent the content of the file.
* @param string $expectedmimetype the expected file mimetype e.g. 'application/xml'.
* @throws ExpectationException if the file does not appear to be of the expected type.
*/
protected function verify_file_mimetype(string $filecontent, string $expectedmimetype): void {
$finfo = new finfo(FILEINFO_MIME_TYPE);
$actualmimetype = $finfo->buffer($filecontent);
if ($actualmimetype !== $expectedmimetype) {
throw new ExpectationException(
"The file downloaded should have been a $expectedmimetype file, " .
"but got $actualmimetype instead.",
$this->getSession(),
);
}
}
/**
* Asserts that the given string is present in the file content.
*
* @param string $filecontent the content of the file.
* @param string $expectedcontent the string to search for.
* @throws ExpectationException if verification fails.
*/
protected function verify_file_contains_text(string $filecontent, string $expectedcontent): void {
if (!str_contains($filecontent, $expectedcontent)) {
throw new ExpectationException(
"The string '$expectedcontent' was not found in the file content.",
$this->getSession(),
);
}
}
/**
* Asserts that the given XML file is valid and contains the expected string.
*
* @param string $filecontent the content of the file.
* @param string $expectedcontent the string to search for.
* @throws ExpectationException
*/
protected function verify_xml_element_contains(string $filecontent, string $expectedcontent): void {
$xml = new SimpleXMLElement($filecontent);
$result = $xml->xpath("//*[contains(text(), '$expectedcontent')]");
if (empty($result)) {
throw new ExpectationException(
"The string '$expectedcontent' was not found in the content of any element in this XML file.",
$this->getSession(),
);
}
}
/**
* Save the downloaded file to tempdir and return the path.
*
* @param string $filecontent the content of the file.
* @param string $fileextension the expected file type, given as a file extension, e.g. 'txt', 'xml'.
* @return string path where the file was saved temporarily.
*/
protected function save_to_temp_file(string $filecontent, string $fileextension): string {
// Then perform additional image-specific validations.
$tempdir = make_request_directory();
$filepath = $tempdir . '/downloaded.' . $fileextension;
file_put_contents($filepath, $filecontent);
return $filepath;
}
/**
* Asserts that the given zip archive contains the expected file(s).
*
* @param string $filecontent the content of the file.
* @param string $expectedfile the name of the file to search for.
* @throws ExpectationException if the zip file does not contain the expected files.
*/
protected function verify_zip_file_content(string $filecontent, string $expectedfile): void {
$zip = new ZipArchive();
$res = $zip->open($this->save_to_temp_file($filecontent, 'zip'));
if ($res !== true) {
throw new ExpectationException(
"Failed to open zip file.",
$this->getSession(),
);
}
if ($zip->locateName($expectedfile) === false) {
throw new ExpectationException(
"The file '$expectedfile' was not found in the downloaded zip archive.",
$this->getSession(),
);
}
}
}
+33 -9
View File
@@ -1335,12 +1335,22 @@ EOF;
* browser window has same viewport size even when you run Behat on multiple operating systems.
*
* @throws ExpectationException
* @Then /^I change (window|viewport) size to "(mobile|tablet|small|medium|large|\d+x\d+)"$/
* @Then /^I change the (window|viewport) size to "(mobile|tablet|small|medium|large|\d+x\d+)"$/
* @Then /^I change (window|viewport) size to "(mobile|tablet|small|medium|large|\d+x\d+)"( without runtime scaling)?$/
* @Then /^I change the (window|viewport) size to "(mobile|tablet|small|medium|large|\d+x\d+)"( without runtime scaling)?$/
* @param string $windowviewport Whether this is a window or viewport size hcange
* @param string $windowsize size of the window (mobile|tablet|small|medium|large|wxh).
* @param null|string $scale whether to lock runtime scaling (string) or to allow it (null)
*/
public function i_change_window_size_to($windowviewport, $windowsize) {
$this->resize_window($windowsize, $windowviewport === 'viewport');
public function i_change_window_size_to(
$windowviewport,
$windowsize,
?string $scale = null
): void {
$this->resize_window(
$windowsize,
$windowviewport === 'viewport',
$scale === null,
);
}
/**
@@ -1642,15 +1652,24 @@ EOF;
/**
* Given the text of a link, download the linked file and return the contents.
*
* This is a helper method used by {@link following_should_download_bytes()}
* and {@link following_should_download_between_and_bytes()}
* A helper method used by the steps in {@see behat_download}, and the legacy
* {@see following_should_download_bytes()} and {@see following_should_download_between_and_bytes()}.
*
* @param string $link the text of the link.
* @param string $containerlocator optional container element locator.
* @param string $containertype optional container element selector type.
*
* @return string the content of the downloaded file.
*/
public function download_file_from_link($link) {
public function download_file_from_link(string $link, string $containerlocator = '', string $containertype = ''): string {
// Find the link.
$linknode = $this->find_link($link);
if ($containerlocator !== '' && $containertype !== '') {
$linknode = $this->get_node_in_container('link', $link, $containertype, $containerlocator);
} else {
$linknode = $this->find_link($link);
}
$this->ensure_node_is_visible($linknode);
// Get the href and check it.
@@ -1672,6 +1691,8 @@ EOF;
/**
* Downloads the file from a link on the page and checks the size.
*
* Not recommended any more. The steps in {@see behat_download} are much better!
*
* Only works if the link has an href attribute. Javascript downloads are
* not supported. Currently, the href must be an absolute URL.
*
@@ -1705,6 +1726,8 @@ EOF;
/**
* Downloads the file from a link on the page and checks the size is in a given range.
*
* Not recommended any more. The steps in {@see behat_download} are much better!
*
* Only works if the link has an href attribute. Javascript downloads are
* not supported. Currently, the href must be an absolute URL.
*
@@ -1712,10 +1735,11 @@ EOF;
* be between "5" and "10" bytes, and between "10" and "20" bytes.
*
* @Then /^following "(?P<link_string>[^"]*)" should download between "(?P<min_bytes>\d+)" and "(?P<max_bytes>\d+)" bytes$/
* @throws ExpectationException
*
* @param string $link the text of the link.
* @param number $minexpectedsize the minimum expected file size in bytes.
* @param number $maxexpectedsize the maximum expected file size in bytes.
* @throws ExpectationException
*/
public function following_should_download_between_and_bytes($link, $minexpectedsize, $maxexpectedsize) {
// If the minimum is greater than the maximum then swap the values.
+1 -1
View File
@@ -205,7 +205,7 @@ class core_message_external extends external_api {
// Check if the recipient can be messaged by the sender.
if ($success && !\core_message\api::can_send_message($tousers[$message['touserid']]->id, $USER->id)) {
$success = false;
$errormessage = get_string('usercantbemessaged', 'message', fullname(\core_user::get_user($message['touserid'])));
$errormessage = get_string('usercantbemessaged', 'message');
}
// Now we can send the message (at least try).
+3 -3
View File
@@ -127,7 +127,7 @@ class externallib_test extends externallib_advanced_testcase {
$sentmessages = core_message_external::send_instant_messages($messages);
$sentmessages = \external_api::clean_returnvalue(core_message_external::send_instant_messages_returns(), $sentmessages);
$this->assertEquals(
get_string('usercantbemessaged', 'message', fullname(\core_user::get_user($message1['touserid']))),
get_string('usercantbemessaged', 'message'),
array_pop($sentmessages)['errormessage']
);
@@ -223,7 +223,7 @@ class externallib_test extends externallib_advanced_testcase {
$sentmessage = reset($sentmessages);
$this->assertEquals(get_string('usercantbemessaged', 'message', fullname($user2)), $sentmessage['errormessage']);
$this->assertEquals(get_string('usercantbemessaged', 'message'), $sentmessage['errormessage']);
$this->assertEquals(0, $DB->count_records('messages'));
}
@@ -259,7 +259,7 @@ class externallib_test extends externallib_advanced_testcase {
$sentmessage = reset($sentmessages);
$this->assertEquals(get_string('usercantbemessaged', 'message', fullname($user2)), $sentmessage['errormessage']);
$this->assertEquals(get_string('usercantbemessaged', 'message'), $sentmessage['errormessage']);
$this->assertEquals(0, $DB->count_records('messages'));
}
+1 -1
View File
@@ -116,7 +116,7 @@ class downloader_test extends \advanced_testcase {
}
$datagenerator->create_submission([
'userid' => $user->id,
'assignid' => $cm->id,
'cmid' => $cm->id,
'file' => implode(',', $files),
]);
}
@@ -37,16 +37,22 @@ class behat_mod_assign_generator extends behat_generator_base {
'required' => ['assign', 'user'],
'switchids' => ['assign' => 'assignid', 'user' => 'userid'],
],
'extensions' => [
'singular' => 'extension',
'datagenerator' => 'extension',
'required' => ['assign', 'user', 'extensionduedate'],
'switchids' => ['assign' => 'cmid', 'user' => 'userid'],
],
];
}
/**
* Get the assignment CMID using an activity idnumber.
* Get the assignment cmid using an activity name or idnumber.
*
* @param string $idnumber
* @param string $identifier activity name or idnumber
* @return int The cmid
*/
protected function get_assign_id(string $idnumber): int {
return $this->get_activity_id($idnumber);
protected function get_assign_id(string $identifier): int {
return $this->get_cm_by_activity_name('assign', $identifier)->id;
}
}
+32 -4
View File
@@ -77,11 +77,22 @@ class mod_assign_generator extends testing_module_generator {
/**
* Create an assignment submission.
*
* @param array $data
* @param array $data with keys userid, cmid and
* then data for each assignsubmission plugin used.
* For backwards compatibility, you can pass cmid as 'assignid' but that generates a warning.
*/
public function create_submission(array $data): void {
global $USER;
if (array_key_exists('assignid', $data)) {
debugging(
'The cmid passed to create_submission should have array key cmid, not assignid.',
DEBUG_DEVELOPER,
);
$data['cmid'] = $data['assignid'];
unset($data['assignid']);
}
$currentuser = $USER;
$user = \core_user::get_user($data['userid']);
$this->set_user($user);
@@ -90,7 +101,7 @@ class mod_assign_generator extends testing_module_generator {
'userid' => $user->id,
];
[$course, $cm] = get_course_and_cm_from_cmid($data['assignid'], 'assign');
[$course, $cm] = get_course_and_cm_from_cmid($data['cmid'], 'assign');
$context = context_module::instance($cm->id);
$assign = new assign($context, $cm, $course);
@@ -102,11 +113,28 @@ class mod_assign_generator extends testing_module_generator {
}
}
$assign->save_submission((object) $submission, $notices);
$assign->save_submission($submission, $notices);
$this->set_user($currentuser);
}
/**
* Create an assignment extension.
*
* @param array $data must have keys cmid, userid, extensionduedate.
*/
public function create_extension(array $data): void {
$user = \core_user::get_user($data['userid'], '*', MUST_EXIST);
[$course, $cm] = get_course_and_cm_from_cmid($data['cmid'], 'assign');
$context = context_module::instance($cm->id);
$assign = new assign($context, $cm, $course);
if (!$assign->save_user_extension($user->id, $data['extensionduedate'] ?: null)) {
throw new \core\exception\coding_exception('The requested extension could not be created.');
}
}
/**
* Gets the grouping id from it's idnumber.
*
@@ -119,7 +147,7 @@ class mod_assign_generator extends testing_module_generator {
// Do not fetch grouping ID for empty grouping idnumber.
if (empty($idnumber)) {
return null;
throw new \core\exception\coding_exception('idnumber cannot be empty');
}
if (!$id = $DB->get_field('groupings', 'id', ['idnumber' => $idnumber])) {
@@ -42,6 +42,7 @@ Feature: Manage and list recordings
And I select "Test Course 1 (C1)" from the "sourcecourseid" singleselect
And I select "RoomRecordings" from the "sourcebn" singleselect
# add the first recording
And I change window size to "large"
And I click on "a.action-icon" "css_element" in the "Recording 1" "table_row"
# add the second recording
And I click on "a.action-icon" "css_element" in the "Recording 2" "table_row"
@@ -84,6 +85,7 @@ Feature: Manage and list recordings
Scenario: I check that I can import recordings from a deleted instance into the Recording activity and then if I delete them
they are back into the pool to be imported again
Given I log in as "admin"
And I change window size to "large"
When I am on "Test Course 1" course homepage with editing mode on
And I delete "RoomRecordings" activity
# The activity is deleted asynchroneously.
+4 -3
View File
@@ -291,7 +291,6 @@ Feature: Users can view and manage data presets
And I should see "This is a short text"
Then "Use this preset" "button" should exist
@javascript
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"
@@ -300,10 +299,12 @@ Feature: Users can view and manage data presets
# 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" "link" in the "Saved preset by teacher1" "table_row" should download between "1" and "5000" bytes
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" "link" in the "Saved preset 1" "table_row" should download between "1" and "5000" bytes
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
@@ -36,5 +36,8 @@ Feature: Files added in folder activity are visible in the recent activity block
And "//img[@alt='empty.txt']" "xpath_element" should exist
And "//img[contains(@src, 'preview=tinyicon')]" "xpath_element" should exist
# Confirm files are downloadable
And following "empty.txt" should download between "1" and "3000" bytes
And following "gd-logo.png" should download between "1" and "3000" bytes
And following "empty.txt" should download a file that:
| Has mimetype | text/plain |
| Contains text | empty file for testing purposes |
And following "gd-logo.png" should download a file that:
| Has mimetype | image/png |
@@ -44,5 +44,6 @@ Feature: Create a glossary entry.
# Confirm you can download attachment from student's entry as teacher
When I am on the "Test glossary" "glossary activity" page logged in as teacher1
Then I should see "Entry 1"
And I should see "musicians.xml"
And following "musicians.xml" should download between "1" and "3000" bytes
And following "musicians.xml" should download a file that:
| Has mimetype | text/xml |
| Contains text in xml element | Paul McCartney |
@@ -26,7 +26,8 @@ Feature: View activity completion information in the h5p activity
| packagefilepath | h5p/tests/fixtures/filltheblanks.h5p |
Scenario: View automatic completion items
Given I am on the "Music history" "h5pactivity activity" page logged in as teacher1
Given I change window size to "large"
And I am on the "Music history" "h5pactivity activity" page logged in as teacher1
# Teacher view.
And "Music history" should have the "View" completion condition
And "Music history" should have the "Receive a grade" completion condition
@@ -30,7 +30,8 @@ Feature: Pass grade activity completion information in the h5p activity
Scenario: View automatic completion items
# Teacher view.
Given I am on the "Music history" "h5pactivity activity" page logged in as teacher1
Given I change window size to "large"
And I am on the "Music history" "h5pactivity activity" page logged in as teacher1
And "Music history" should have the "View" 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
+5 -3
View File
@@ -2886,15 +2886,17 @@ class lesson extends lesson_base {
if ($this->properties->usepassword && empty($USER->lessonloggedin[$this->id])) {
$correctpass = false;
if (!empty($userpassword) &&
(($this->properties->password == md5(trim($userpassword))) || ($this->properties->password == trim($userpassword)))) {
$userpassword = trim((string) $userpassword);
if ($userpassword !== '' &&
($this->properties->password === md5($userpassword) || $this->properties->password === $userpassword)) {
// With or without md5 for backward compatibility (MDL-11090).
$correctpass = true;
$USER->lessonloggedin[$this->id] = true;
} else if (isset($this->properties->extrapasswords)) {
// Group overrides may have additional passwords.
foreach ($this->properties->extrapasswords as $password) {
if (strcmp($password, md5(trim($userpassword))) === 0 || strcmp($password, trim($userpassword)) === 0) {
if ($password === md5($userpassword) || $password === $userpassword) {
$correctpass = true;
$USER->lessonloggedin[$this->id] = true;
}
@@ -36,6 +36,7 @@ Feature: In a lesson activity, a teacher can duplicate a lesson page
| id_answer_editor_1 | Previous page |
| id_jumpto_1 | Previous page |
And I click on "Image" "button" in the "Page contents" "form_row"
And I wait until "Browse repositories..." "button" exists
And I click on "Browse repositories..." "button"
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
And I click on "moodle_logo.jpg" "link"
@@ -70,6 +71,7 @@ Feature: In a lesson activity, a teacher can duplicate a lesson page
| id_jumpto_1 | This page |
| id_score_1 | 0 |
And I click on "Image" "button" in the "//*[@id='id_answer_editor_0']/ancestor::*[@data-fieldtype='editor']" "xpath_element"
And I wait until "Browse repositories..." "button" exists
And I click on "Browse repositories..." "button"
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
And I click on "moodle_logo.jpg" "link"
@@ -107,6 +109,7 @@ Feature: In a lesson activity, a teacher can duplicate a lesson page
| id_jumpto_1 | This page |
| id_score_1 | 0 |
And I click on "Image" "button" in the "//*[@id='id_response_editor_0']/ancestor::*[@data-fieldtype='editor']" "xpath_element"
And I wait until "Browse repositories..." "button" exists
And I click on "Browse repositories..." "button"
And I click on "Private files" "link" in the ".fp-repo-area" "css_element"
And I click on "moodle_logo.jpg" "link"
@@ -0,0 +1,74 @@
@mod @mod_workshop
Feature: Teacher can allocate submissions randomly or manually
In order to manage submissions
As a teacher
I should be able to allocate workshop submissions randomly or manually
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | One | student1@example.com |
| student2 | Student | Two | student2@example.com |
| student3 | Student | Three | student3@example.com |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
| teacher1 | C1 | editingteacher |
And the following "activities" exist:
| activity | name | course | submissiontypetext |
| workshop | Workshop 1 | C1 | 2 |
And I am on the "Course 1" course page logged in as teacher1
And I edit assessment form in workshop "Workshop 1" as:
| id_description__idx_0_editor | Aspect 1 |
| id_description__idx_1_editor | Aspect 2 |
| id_description__idx_2_editor | Aspect 3 |
And I change phase in workshop "Workshop 1" to "Submission phase"
And I am on the "Workshop 1" "workshop activity" page logged in as student1
And I add a submission in workshop "Workshop 1" as:
| Title | Submitted by s1 |
| Submission content | Some content by s1 |
And I am on the "Workshop 1" "workshop activity" page logged in as student2
And I add a submission in workshop "Workshop 1" as:
| Title | Submitted by s2 |
| Submission content | Some content by s2 |
And I am on the "Workshop 1" "workshop activity" page logged in as student3
And I add a submission in workshop "Workshop 1" as:
| Title | Submitted by s3 |
| Submission content | Some content by s3 |
Scenario: Teacher can allocate workshop submissions randomly
Given I am on the "Workshop 1" "workshop activity" page logged in as teacher1
And I click on "Submissions allocation" "link"
# Allocate submissions randomly.
When I select "Random allocation" from the "jump" singleselect
And I set the following fields to these values:
| numofreviews | 3 |
And I press "Save changes"
# Confirm that random allocations was successful.
Then I should see "Trying to allocate 3 review(s) per author"
And I should see "Randomly assigning 6 allocations"
And I should see "New assessment to be done: Student Three is reviewer of Student One"
And I should see "New assessment to be done: Student Two is reviewer of Student One"
And I should see "New assessment to be done: Student Two is reviewer of Student Three"
And I should see "New assessment to be done: Student One is reviewer of Student Three"
And I should see "New assessment to be done: Student One is reviewer of Student Two"
And I should see "New assessment to be done: Student Three is reviewer of Student Two"
Scenario: Teacher can allocate workshop submissions manually
# Allocate submissions manually.
Given I am on the "Workshop 1" "workshop activity" page logged in as teacher1
When I allocate submissions in workshop "Workshop 1" as:
| Participant | Reviewer |
| Student Two | Student One |
# Remove submission allocation.
And I click on "//li[contains(text(), 'Student One')]/a[contains(@class, 'action-icon')]" "xpath_element"
Then I should see "Are you sure you want to deallocate the selected assessment?"
And I press "Yes, I am sure"
# Confirm submission allocation was removed.
And I should see "Assessment deallocated"
@@ -0,0 +1,45 @@
@mod @mod_workshop
Feature: Student can upload a set number of attachments in submission
In order to create a submission with a set number of attachments
As a teacher
I should be able to set the number of attachments
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 |
| Course 1 | C1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activities" exist:
| activity | name | course | nattachments |
| workshop | Workshop 1 | C1 | 2 |
And I am on the "Workshop 1" "workshop activity" page logged in as teacher1
And I edit assessment form in workshop "Workshop 1" as:
| id_description__idx_0_editor | Aspect1 |
| id_description__idx_1_editor | Aspect2 |
| id_description__idx_2_editor | Aspect3 |
And I change phase in workshop "Workshop 1" to "Submission phase"
@javascript @_file_upload
Scenario: Student can create submission with set number of attachments
Given I am on the "Workshop 1" "workshop activity" page logged in as student1
When I press "Add submission"
# Add... button is visible initially because there are no attachments yet.
Then "Add..." "button" should be visible
# Add 2 attachments - the set number of attachments.
And I upload "mod/workshop/tests/fixtures/moodlelogo.png" file to "Attachment" filemanager
And I upload "lib/tests/fixtures/gd-logo.png" file to "Attachment" filemanager
# Confirm that Add... button is not visible after set number of attachments is met.
And "Add..." "button" should not be visible
# Delete one attachment.
And I click on "gd-logo.png" "link"
And I click on "Delete" "button" in the "Edit gd-logo.png" "dialogue"
And I click on "OK" "button" in the "Confirm" "dialogue"
# Confirm that Add... button is visible again after 1 attachment is deleted.
And "Add..." "button" should be visible
@@ -26,7 +26,9 @@ Feature: Test exporting questions using Aiken format.
When I am on the "Course 1" "core_question > course question export" page logged in as "teacher1"
And I set the field "id_format_aiken" to "1"
When I press "Export questions to file"
Then following "click here" should download between "68" and "70" bytes
Then following "click here" should download a file that:
| Has mimetype | text/plain |
| Contains text | Which is the oddest number? |
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
@@ -31,7 +31,9 @@ Feature: Test importing questions from GIFT format.
And I am on the "Course 1" "core_question > course question export" page
And I set the field "id_format_gift" to "1"
And I press "Export questions to file"
And following "click here" should download between "1500" and "1800" bytes
And following "click here" should download a file that:
| Has mimetype | text/plain |
| Contains text | What's between orange and green in the spectrum? |
@javascript @_file_upload
Scenario: import a GIFT file which specifies the category
@@ -34,7 +34,10 @@ Feature: Test importing questions from Moodle XML format.
And I set the field "id_format_xml" to "1"
And I set the field "Export category" to "TrueFalse"
And I press "Export questions to file"
Then following "click here" should download between "57100" and "58150" bytes
Then following "click here" should download a file that:
| Has mimetype | text/xml |
| Contains text in xml element | Moodle acronym (True) |
| Contains text in xml element | Moodle acronym (False) |
@javascript @_file_upload
Scenario: import some multiple choice questions from Moodle XML format
@@ -26,7 +26,9 @@ Feature: Test exporting drag and drop onto image questions
When I am on the "Course 1" "core_question > course question export" page logged in as teacher
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "18600" and "19150" bytes
Then following "click here" should download a file that:
| Has mimetype | text/xml |
| Contains text in xml element | Drag onto image |
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
@@ -68,31 +68,37 @@ class behat_qtype_ddmarker extends behat_base {
// DOM node so that its centre is over the centre of anothe DOM node.
// Therefore to make it drag to the specified place, we have to add
// a target div.
// We also need to scroll the marker into view so we can calculate the correct offsetHeight and offsetWidth.
$markerxpath = $this->marker_xpath($marker);
$this->execute_script("
(function() {
if (document.getElementById('target-{$x}-{$y}')) {
return;
}
var image = document.querySelector('.dropbackground');
var target = document.createElement('div');
target.setAttribute('id', 'target-{$x}-{$y}');
var container = document.querySelector('.droparea');
container.insertBefore(target, image);
var widthRatio = image.offsetWidth / image.naturalWidth;
var heightRatio = image.offsetHeight / image.naturalHeight;
var marker = document.evaluate('{$markerxpath}', document, null, XPathResult.ANY_TYPE, null).iterateNext();
var xadjusted = {$x} * widthRatio
+ (container.offsetWidth - image.offsetWidth) / 2
+ marker.offsetWidth / 2;
var yadjusted = {$y} * heightRatio
+ (container.offsetHeight - image.offsetHeight) / 2
+ marker.offsetHeight / 2;
target.style.setProperty('position', 'absolute');
target.style.setProperty('left', xadjusted + 'px');
target.style.setProperty('top', yadjusted + 'px');
target.style.setProperty('width', '1px');
target.style.setProperty('height', '1px');
require(['core/pending'], function(Pending) {
if (document.getElementById('target-{$x}-{$y}')) {
return;
}
const pendingPromise = new Pending('qtype_ddmarker:drag-drop');
const image = document.querySelector('.dropbackground');
const target = document.createElement('div');
target.setAttribute('id', 'target-{$x}-{$y}');
const container = document.querySelector('.droparea');
container.insertBefore(target, image);
const widthRatio = image.offsetWidth / image.naturalWidth;
const heightRatio = image.offsetHeight / image.naturalHeight;
const marker = document.evaluate('{$markerxpath}', document, null, XPathResult.ANY_TYPE, null).iterateNext();
marker.scrollIntoView();
const xadjusted = {$x} * widthRatio
+ (container.offsetWidth - image.offsetWidth) / 2
+ marker.offsetWidth / 2;
const yadjusted = {$y} * heightRatio
+ (container.offsetHeight - image.offsetHeight) / 2
+ marker.offsetHeight / 2;
target.style.setProperty('position', 'absolute');
target.style.setProperty('left', xadjusted + 'px');
target.style.setProperty('top', yadjusted + 'px');
target.style.setProperty('width', '1px');
target.style.setProperty('height', '1px');
pendingPromise.resolve();
});
}())"
);
@@ -26,7 +26,9 @@ Feature: Test exporting drag and drop markers questions
When I am on the "Course 1" "core_question > course question export" page logged in as teacher
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "233700" and "233950" bytes
Then following "click here" should download a file that:
| Has mimetype | text/xml |
| Contains text in xml element | Drag markers |
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
@@ -26,7 +26,9 @@ Feature: Test exporting drag and drop into text questions
When I am on the "Course 1" "core_question > course question export" page logged in as teacher
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
And following "click here" should download between "1550" and "1700" bytes
And following "click here" should download a file that:
| Has mimetype | text/xml |
| Contains text in xml element | Drag to text |
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
@@ -25,7 +25,9 @@ Feature: Test exporting Description questions
When I am on the "Course 1" "core_question > course question export" page logged in as teacher
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "650" and "900" bytes
Then following "click here" should download a file that:
| Has mimetype | text/xml |
| Contains text in xml element | description-001 |
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
@@ -27,7 +27,11 @@ Feature: Test exporting Essay questions
When I am on the "Course 1" "core_question > course question export" page logged in as teacher
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "3000" and "3500" bytes
Then following "click here" should download a file that:
| Has mimetype | text/xml |
| Contains text in xml element | essay-001 |
| Contains text in xml element | essay-002 |
| Contains text in xml element | essay-003 |
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
@@ -32,7 +32,9 @@ Feature: Import and export select missing words questions
And I am on the "Course 1" "core_question > course question export" page logged in as teacher
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
And following "click here" should download between "1650" and "1800" bytes
And following "click here" should download a file that:
| Has mimetype | text/xml |
| Contains text in xml element | Select missing words 001 |
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
@@ -25,7 +25,9 @@ Feature: Test exporting Matching questions
When I am on the "Course 1" "core_question > course question export" page logged in as teacher
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "1600" and "1750" bytes
Then following "click here" should download a file that:
| Has mimetype | text/xml |
| Contains text in xml element | matching-001 |
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
@@ -26,7 +26,10 @@ Feature: Test exporting Multiple choice questions
When I am on the "Course 1" "core_question > course question export" page logged in as teacher
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "3900" and "4100" bytes
Then following "click here" should download a file that:
| Has mimetype | text/xml |
| Contains text in xml element | Multi-choice-001 |
| Contains text in xml element | Multi-choice-002 |
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
@@ -26,7 +26,10 @@ Feature: Test exporting Numerical questions
When I am on the "Course 1" "core_question > course question export" page logged in as teacher
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "3650" and "3750" bytes
Then following "click here" should download a file that:
| Has mimetype | text/xml |
| Contains text in xml element | Numerical-001 |
| Contains text in xml element | Numerical-002 |
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
@@ -25,7 +25,9 @@ Feature: Test exporting Short answer questions
When I am on the "Course 1" "core_question > course question export" page logged in as teacher
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "1200" and "1450" bytes
Then following "click here" should download a file that:
| Has mimetype | text/xml |
| Contains text in xml element | shortanswer-001 |
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
@@ -25,7 +25,9 @@ Feature: Test exporting True/False questions
When I am on the "Course 1" "core_question > course question export" page logged in as teacher
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "1000" and "1200" bytes
Then following "click here" should download a file that:
| Has mimetype | text/xml |
| Contains text in xml element | true-false-001 |
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
+2 -9
View File
@@ -18,10 +18,10 @@ declare(strict_types=1);
namespace core_reportbuilder\external\audiences;
use core_reportbuilder\local\audiences\base;
use external_api;
use external_function_parameters;
use external_value;
use core_reportbuilder\local\helpers\audience;
use core_reportbuilder\manager;
use core_reportbuilder\permission;
@@ -74,14 +74,7 @@ class delete extends external_api {
self::validate_context($report->get_context());
permission::require_can_edit_report($report->get_report_persistent());
$baseinstance = base::instance($instanceid);
if ($baseinstance && $baseinstance->user_can_edit()) {
$persistent = $baseinstance->get_persistent();
$persistent->delete();
return true;
}
return false;
return audience::delete_report_audience($reportid, $instanceid);
}
/**
@@ -26,6 +26,7 @@ use core_component;
use core_plugin_manager;
use core_reportbuilder\local\audiences\base;
use core_reportbuilder\local\models\audience as audience_model;
use invalid_parameter_exception;
/**
* Class containing report audience helper methods
@@ -233,6 +234,30 @@ class audience {
return [$wheres, $params];
}
/**
* Delete given audience from report
*
* @param int $reportid
* @param int $audienceid
* @return bool
* @throws invalid_parameter_exception
*/
public static function delete_report_audience(int $reportid, int $audienceid): bool {
$audience = audience_model::get_record(['id' => $audienceid, 'reportid' => $reportid]);
if ($audience === false) {
throw new invalid_parameter_exception('Invalid audience');
}
$instance = base::instance(0, $audience->to_record());
if ($instance && $instance->user_can_edit()) {
$persistent = $instance->get_persistent();
$persistent->delete();
return true;
}
return false;
}
/**
* Returns the list of audiences types in the system.
*
@@ -91,7 +91,10 @@ class report_schedules extends system_report {
* @return bool
*/
protected function can_view(): bool {
return permission::can_view_reports_list();
$reportid = $this->get_parameter('reportid', 0, PARAM_INT);
$report = report::get_record(['id' => $reportid], MUST_EXIST);
return permission::can_edit_report($report);
}
/**
+4
View File
@@ -71,6 +71,8 @@ abstract class system_report extends base {
* This is necessary to implement independently of the page that would typically embed the report because
* subsequent pages are requested via AJAX requests, and access should be validated each time
*
* Report parameters should also be considered when implementing this method
*
* @return bool
*/
abstract protected function can_view(): bool;
@@ -201,6 +203,8 @@ abstract class system_report extends base {
/**
* Return specific report parameter
*
* Capability/permission checks relating to parameters retrieved here should also be considered in your {@see can_view} method
*
* @param string $param
* @param mixed $default
* @param string $type
@@ -386,4 +386,13 @@ class custom_report_table extends base_report_table {
return !empty($CFG->customreportsliveediting);
}
/**
* Check if the user has the capability to access this table.
*
* @return bool Return true if capability check passed.
*/
public function has_capability(): bool {
return \core_reportbuilder\permission::can_edit_report($this->persistent);
}
}
@@ -74,4 +74,13 @@ class custom_report_table_view extends custom_report_table {
return '';
}
/**
* Check if the user has the capability to access this table.
*
* @return bool Return true if capability check passed.
*/
public function has_capability(): bool {
return \core_reportbuilder\permission::can_view_report($this->persistent);
}
}
@@ -280,4 +280,18 @@ class system_report_table extends base_report_table {
return '';
}
/**
* Check if the user has the capability to access this table.
*
* @return bool Return true if capability check passed.
*/
public function has_capability(): bool {
try {
$this->report->require_can_view();
return true;
} catch (\core_reportbuilder\report_access_exception $e) {
return false;
}
}
}
@@ -164,6 +164,28 @@ Feature: Manage custom reports
| Name | My users |
| Report source | Users |
Scenario: Reset filters in system report
Given the following "core_reportbuilder > Report" exists:
| name | My report |
| source | core_user\reportbuilder\datasource\users |
And I log in as "admin"
When I navigate to "Reports > Report builder > Custom reports" in site administration
And I click on "Filters" "button"
And I set the following fields in the "Name" "core_reportbuilder > Filter" to these values:
| Name operator | Contains |
| Name value | Lionel |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
And I should see "Filters (1)" in the "#dropdownFiltersButton" "css_element"
And I should see "Nothing to display"
And I click on "Reset all" "button" in the "[data-region='report-filters']" "css_element"
And I should not see "Filters (1)" in the "#dropdownFiltersButton" "css_element"
And I should see "Filters" in the "#dropdownFiltersButton" "css_element"
And "[data-region='report-filters']" "css_element" should be visible
Then I should see "Filters reset"
And the following fields in the "Name" "core_reportbuilder > Filter" match these values:
| Name operator | Is any value |
And I should see "My report" in the "reportbuilder-table" "table"
Scenario: Delete custom report
Given the following "core_reportbuilder > Reports" exist:
| name | source |
@@ -92,7 +92,7 @@ Feature: Manage custom report filters
And I should see "There are no filters selected" in the "[data-region='active-filters']" "css_element"
And I should not see "Email address" in the "[data-region='active-filters']" "css_element"
Scenario: Reset filters in report
Scenario: Reset filters in custom report
Given the following "core_reportbuilder > Reports" exist:
| name | source |
| My report | core_user\reportbuilder\datasource\users |
@@ -102,8 +102,12 @@ Feature: Manage custom report filters
| Full name operator | Contains |
| Full name value | Lionel |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
And I should see "Filters (1)" in the "#dropdownFiltersButton" "css_element"
And I should see "Nothing to display"
And I click on "Reset all" "button" in the "[data-region='report-filters']" "css_element"
And I should not see "Filters (1)" in the "#dropdownFiltersButton" "css_element"
And I should see "Filters" in the "#dropdownFiltersButton" "css_element"
And "[data-region='report-filters']" "css_element" should be visible
Then I should see "Filters reset"
And the following fields in the "Full name" "core_reportbuilder > Filter" match these values:
| Full name operator | Is any value |
@@ -22,7 +22,9 @@ use advanced_testcase;
use context_system;
use core_reportbuilder_generator;
use core_reportbuilder\reportbuilder\audience\manual;
use core_reportbuilder\local\models\audience as audience_model;
use core_user\reportbuilder\datasource\users;
use invalid_parameter_exception;
/**
* Unit tests for audience helper
@@ -297,4 +299,51 @@ class audience_test extends advanced_testcase {
$reports = $DB->get_fieldset_sql("SELECT r.id FROM {reportbuilder_report} r WHERE {$where}", $params);
$this->assertEmpty($reports);
}
/**
* Testing deleting report audience
*/
public function test_delete_report_audience(): void {
$this->resetAfterTest();
$this->setAdminUser();
/** @var core_reportbuilder_generator $generator */
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
$report = $generator->create_report(['name' => 'My report', 'source' => users::class, 'default' => false]);
$audienceone = $generator->create_audience(['reportid' => $report->get('id'), 'configdata' => []]);
$audiencetwo = $generator->create_audience(['reportid' => $report->get('id'), 'configdata' => []]);
$audiences = audience_model::get_records(['reportid' => $report->get('id')]);
$this->assertCount(2, $audiences);
// Delete the first audience.
$result = audience::delete_report_audience($report->get('id'), $audienceone->get_persistent()->get('id'));
$this->assertTrue($result);
// We should be left with only the second audience.
$audiences = audience_model::get_records(['reportid' => $report->get('id')]);
$this->assertCount(1, $audiences);
$this->assertEquals($audiencetwo->get_persistent()->get('id'), reset($audiences)->get('id'));
}
/**
* Testing deleting invalid report audience
*/
public function test_delete_report_audience_invalid(): void {
$this->resetAfterTest();
$this->setAdminUser();
/** @var core_reportbuilder_generator $generator */
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
$reportone = $generator->create_report(['name' => 'Report one', 'source' => users::class, 'default' => false]);
$audienceone = $generator->create_audience(['reportid' => $reportone->get('id'), 'configdata' => []]);
$reporttwo = $generator->create_report(['name' => 'Report two', 'source' => users::class, 'default' => false]);
$this->expectException(invalid_parameter_exception::class);
$this->expectExceptionMessage('Invalid audience');
audience::delete_report_audience($reporttwo->get('id'), $audienceone->get_persistent()->get('id'));
}
}
+1 -1
View File
@@ -15,4 +15,4 @@ Policy: https://moodledev.io/general/development/process/security
# Expiry date of this document
# This information is considered current and up to date until 3 weeks after the next major Moodle LMS release
Expires: 2024-10-28T01:00:00.000Z
Expires: 2025-05-05T01:00:00.000Z
+8 -1
View File
@@ -3059,7 +3059,14 @@ blockquote {
margin: 0 0.5rem 1rem;
padding-left: 1rem;
color: $gray-700;
border-left: 5px solid $gray-400;
border-left: 5px solid $gray-500;
}
.pagelayout-maintenance,
.pagelayout-secure {
.page-header-headings {
background-color: $body-bg;
}
}
/* Prevent long strings exceeding page width */
+6 -1
View File
@@ -15764,7 +15764,12 @@ blockquote {
margin: 0 0.5rem 1rem;
padding-left: 1rem;
color: #495057;
border-left: 5px solid #ced4da;
border-left: 5px solid #8f959e;
}
.pagelayout-maintenance .page-header-headings,
.pagelayout-secure .page-header-headings {
background-color: #fff;
}
/* Prevent long strings exceeding page width */
+1 -1
View File
@@ -51,7 +51,7 @@
<div id="page" class="container pb-3">
<div class="row">
<div class="col-12 py-3">
<div class="col-12 py-3 page-header-headings">
{{{ output.page_heading }}}
</div>
</div>
+6
View File
@@ -1,6 +1,12 @@
This file describes API changes in /theme/boost
information provided here is intended especially for theme designers.
=== 4.1.14 ===
* The `.page-header-headings` CSS class now has a background colour applied to the maintenance and secure layouts.
You may need to override this class in your maintenance and secure layouts if both of the following are true:
* Your theme plugin inherits from `theme_boost` and uses this CSS class
* Your theme plugin applies a different styling for the page header for the maintenance and secure layouts
=== 4.0 ===
* Following the adopted standards, breadcrumbs have been removed for pages that reside on the 1st level within a course
e.g. participants, grades, settings, reports.
+6 -1
View File
@@ -15764,7 +15764,12 @@ blockquote {
margin: 0 0.5rem 1rem;
padding-left: 1rem;
color: #495057;
border-left: 5px solid #ced4da;
border-left: 5px solid #8f959e;
}
.pagelayout-maintenance .page-header-headings,
.pagelayout-secure .page-header-headings {
background-color: #fff;
}
/* Prevent long strings exceeding page width */
+13
View File
@@ -483,4 +483,17 @@ class participants extends \table_sql implements dynamic_table {
public function get_context(): context {
return $this->context;
}
/**
* Check if the user has the capability to access this table.
*
* @return bool Return true if capability check passed.
*/
public function has_capability(): bool {
global $CFG;
require_once($CFG->dirroot . '/course/lib.php');
$context = $this->course->id == SITEID ? \context_system::instance() : $this->get_context();
return course_can_view_participants($context);
}
}
+5 -5
View File
@@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* MOODLE VERSION INFORMATION
* MOODLE VERSION INFORMATION.
*
* This file defines the current version of the core Moodle code being used.
* This is compared against the values stored in the database to determine
@@ -29,9 +29,9 @@
defined('MOODLE_INTERNAL') || die();
$version = 2022112812.00; // 20221128 = branching date YYYYMMDD - do not modify!
$version = 2022112814.00; // 20221128 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.1.12 (Build: 20240812)'; // Human-friendly version name
$branch = '401'; // This version's branch.
$maturity = MATURITY_STABLE; // This version's maturity level.
$release = '4.1.14 (Build: 20241007)'; // Human-friendly version name
$branch = '401'; // This version's branch.
$maturity = MATURITY_STABLE; // This version's maturity level.