Compare commits

..

43 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
Jun Pataleta 34077a9190 MDL-82948 theme_boost: Make <blockquote>'s border a bit darker 2024-08-29 16:04:52 +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
47 changed files with 549 additions and 87 deletions
@@ -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 |
@@ -55,7 +55,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 |
And I wait "1" seconds
@@ -90,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 |
@@ -128,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 |
+2 -1
View File
@@ -146,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"
+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');
@@ -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
+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
@@ -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}';
+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(),
);
}
}
}
+19 -5
View File
@@ -1652,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.
@@ -1682,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.
*
@@ -1715,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.
*
@@ -1722,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])) {
+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,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
@@ -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
@@ -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 */
+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 = 2022112813.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.13 (Build: 20240902)'; // 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.