Skip to content

Commit

Permalink
Merge remote-tracking branch 'moodlehq/MOODLE_39_STABLE' into IOMAD_3…
Browse files Browse the repository at this point in the history
…9_STABLE
  • Loading branch information
turf212 committed Apr 24, 2023
2 parents fddb99d + b90b0e6 commit ff44e15
Show file tree
Hide file tree
Showing 38 changed files with 826 additions and 246 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ module.exports = function(grunt) {
const path = require('path');
const tasks = {};
const async = require('async');
const DOMParser = require('xmldom').DOMParser;
const DOMParser = require('@xmldom/xmldom').DOMParser;
const xpath = require('xpath');
const semver = require('semver');
const watchman = require('fb-watchman');
Expand Down
2 changes: 2 additions & 0 deletions admin/environment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4109,6 +4109,8 @@
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_xmlrpc_usage" level="optional">
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mod_assignment" level="required">
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
</COMPATIBILITY_MATRIX>
12 changes: 3 additions & 9 deletions admin/tool/lp/tests/behat/plan_workflow.feature
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ Feature: Manage plan workflow
| name | user | description | status | reviewer |
| Test-Plan3 | user1 | Description of plan 3 for user 1 | active | manager1 |
| Test-Plan4 | user1 | Description of plan 4 for user 1 | active | manager1 |
And I log in as "manager1"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "User 1"
And I am on the "user1" "user > profile" page logged in as "manager1"
And I follow "Learning plans"
And I should see "List of learning plans"
And I follow "Learning plans"
Expand All @@ -163,9 +161,7 @@ Feature: Manage plan workflow
| name | user | description | status | reviewer |
| Test-Plan3 | user1 | Description of plan 3 for user 1 | active | manager1 |
| Test-Plan4 | user1 | Description of plan 4 for user 1 | active | manager1 |
And I log in as "manager1"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "User 1"
And I am on the "user1" "user > profile" page logged in as "manager1"
And I follow "Learning plans"
And I should see "List of learning plans"
And I follow "Learning plans"
Expand All @@ -185,9 +181,7 @@ Feature: Manage plan workflow
| name | user | description | status | reviewer |
| Test-Plan3 | user1 | Description of plan 3 for user 1 | complete | manager1 |
| Test-Plan4 | user1 | Description of plan 4 for user 1 | complete | manager1 |
And I log in as "manager1"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "User 1"
And I am on the "user1" "user > profile" page logged in as "manager1"
And I follow "Learning plans"
And I should see "List of learning plans"
And I follow "Learning plans"
Expand Down
4 changes: 1 addition & 3 deletions admin/tool/policy/tests/behat/acceptances.feature
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,7 @@ Feature: Viewing acceptances reports and accepting on behalf of other users
And I set the field "I agree to the This site policy" to "1"
And I press "Next"
And I log out
And I log in as "admin"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "Manager"
And I am on the "manager" "user > profile" page logged in as "admin"
And I follow "Log in as"
And I press "Continue"
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
Expand Down
7 changes: 2 additions & 5 deletions admin/tool/policy/tests/behat/consent.feature
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | 1 | user1@example.com |
When I log in as "admin"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "User 1"
When I am on the "user1" "user > profile" page logged in as "admin"
And I follow "Log in as"
Then I should see "You are logged in as User 1"
And I press "Continue"
Expand Down Expand Up @@ -603,8 +601,7 @@ Feature: User must accept policy managed by this plugin when logging in and sign
And I set the field "I agree to the This site policy" to "1"
And I set the field "I agree to the This privacy policy" to "1"
And I press "Next"
And I navigate to "Users > Accounts > Browse list of users" in site administration
And I follow "User 1"
And I am on the "user1" "user > profile" page
And I follow "Log in as"
Then I should see "You are logged in as User 1"
And I press "Continue"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ Feature: My overview block pagination
| student1 | C12 | student |
| student1 | C13 | student |
When I log in as "student1"
And I wait until ".block_myoverview [data-control='next']" "css_element" exists
And I click on "[data-control='next']" "css_element" in the "Course overview" "block"
Then the "class" attribute of ".block_myoverview [data-control='next']" "css_element" should contain "disabled"
And I log out
Expand Down
4 changes: 4 additions & 0 deletions config-dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
// can be removed for MySQL (by default it will
// use 'utf8mb4_unicode_ci'. This option should
// be removed for all other databases.
// 'extrainfo' => [], // Extra information for the DB driver, e.g. SQL Server,
// has additional configuration according to its environment,
// which the administrator can specify to alter and
// override any connection options.
// 'fetchbuffersize' => 100000, // On PostgreSQL, this option sets a limit
// on the number of rows that are fetched into
// memory when doing a large recordset query
Expand Down
26 changes: 13 additions & 13 deletions grade/report/grader/tests/behat/switch_views.feature
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,32 @@ Feature: We can change what we are viewing on the grader report
And I click on "Hide" "link" in the "Test assignment name 2" activity
And I am on "Course 1" course homepage
And I navigate to "View > Grader report" in the course gradebook
And I should see "Test assignment name 1"
And I should see "Test assignment name 2"
And I should see "Test assignment name 1" in the "user-grades" "table"
And I should see "Test assignment name 2" in the "user-grades" "table"
And I should see "Manual grade"
And I should see "Course total"
And the following should exist in the "user-grades" table:
| -1- | -4- | -5- | -6- | -7- |
| Student 1 | 80 | 90 | 30 | 170 |
And I click on "Change to aggregates only" "link"
And I should not see "Test assignment name 1"
And I should not see "Test assignment name 2"
And I should not see "Test assignment name 1" in the "user-grades" "table"
And I should not see "Test assignment name 2" in the "user-grades" "table"
And I should not see "Manual grade"
And I should see "Course total"
And the following should exist in the "user-grades" table:
| -1- | -4- |
| Student 1 | 170 |
And I click on "Change to grades only" "link"
And I should see "Test assignment name 1"
And I should see "Test assignment name 2"
And I should see "Test assignment name 1" in the "user-grades" "table"
And I should see "Test assignment name 2" in the "user-grades" "table"
And I should see "Manual grade"
And I should not see "Course total"
And the following should exist in the "user-grades" table:
| -1- | -4- | -5- | -6- |
| Student 1 | 80 | 90 | 30 |

@javascript @skip_chrome_zerosize
Scenario: View and minimise the grader report containing hidden activities without the 'moodle/grade:viewhidden' capability
Scenario: Minimise the grader report containing hidden activities without the 'moodle/grade:viewhidden' capability
When I am on "Course 1" course homepage with editing mode on
And I open "Test assignment name 2" actions menu
And I click on "Hide" "link" in the "Test assignment name 2" activity
Expand All @@ -81,24 +81,24 @@ Feature: We can change what we are viewing on the grader report
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "View > Grader report" in the course gradebook
And I should see "Test assignment name 1"
And I should see "Test assignment name 2"
And I should see "Test assignment name 1" in the "user-grades" "table"
And I should see "Test assignment name 2" in the "user-grades" "table"
And I should see "Manual grade"
And I should see "Course total"
And the following should exist in the "user-grades" table:
| -1- | -4- | -5- | -6- | -7- |
| Student 1 | 80 | - | 30 | 105.71 |
And I click on "Change to aggregates only" "link"
And I should not see "Test assignment name 1"
And I should not see "Test assignment name 2"
And I should not see "Test assignment name 1" in the "user-grades" "table"
And I should not see "Test assignment name 2" in the "user-grades" "table"
And I should not see "Manual grade"
And I should see "Course total"
And the following should exist in the "user-grades" table:
| -1- | -4- |
| Student 1 | 105.71 |
And I click on "Change to grades only" "link"
And I should see "Test assignment name 1"
And I should see "Test assignment name 2"
And I should see "Test assignment name 1" in the "user-grades" "table"
And I should see "Test assignment name 2" in the "user-grades" "table"
And I should see "Manual grade"
And I should not see "Course total"
And the following should exist in the "user-grades" table:
Expand Down
3 changes: 2 additions & 1 deletion lang/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,8 @@
$string['xmlrpcwebserviceenabled'] = 'It has been detected that the XML-RPC Web Service protocol is enabled on your site. This feature relies on the PHP XML-RPC extension which is no longer maintained by PHP.';
$string['yuicomboloading'] = 'YUI combo loading';
$string['ziprequired'] = 'The Zip PHP extension is now required by Moodle, info-ZIP binaries or PclZip library are not used anymore.';

$string['modassignmentinuse'] = 'Your site is still using the Assignment 2.2 plugin. Before upgrading you must 1) backup any Assignment 2.2 activities that you want to keep and restore them as Assignment activities, and 2) delete all Assignment 2.2 data from the database.';
$string['modassignmentsubpluginsexist'] = 'Assignment 2.2. subplugins may be present. The mod/assignment folder and all of its subplugins need to be removed before upgrading.';

$string['caching'] = 'Caching';
$string['cachesettings'] = 'Cache settings';
Expand Down
2 changes: 1 addition & 1 deletion lang/en/currencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,5 @@
$string['XPF'] = 'CFP Franc';
$string['YER'] = 'Yemeni Rial';
$string['ZAR'] = 'South African Rand';
$string['ZMK'] = 'Zambian Kwacha';
$string['ZMW'] = 'Zambian Kwacha';
$string['ZWL'] = 'Zimbabwe Dollar';
1 change: 1 addition & 0 deletions lang/en/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
$string['delete'] = 'Delete';
$string['editors'] = 'Text editors';
$string['editorsettings'] = 'Manage editors';
$string['editorxformat'] = '{$a} format';
$string['enterurlfirst'] = 'You have to enter an URL first';
$string['filebrowser'] = 'File Browser';
$string['findwhat'] = 'Find';
Expand Down
18 changes: 14 additions & 4 deletions lib/behat/classes/behat_config_util.php
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ protected function get_behat_profile($profile, $values) {
[
'capabilities' => [
'extra_capabilities' => [
'chromeOptions' => [
'goog:chromeOptions' => [
'args' => [
'unlimited-storage',
'disable-web-security',
Expand All @@ -678,6 +678,16 @@ protected function get_behat_profile($profile, $values) {
$values
);

// Selenium no longer supports non-w3c browser control.
// Rename chromeOptions to goog:chromeOptions, which is the W3C variant of this.
if (array_key_exists('chromeOptions', $values['capabilities']['extra_capabilities'])) {
$values['capabilities']['extra_capabilities']['goog:chromeOptions'] = array_merge_recursive(
$values['capabilities']['extra_capabilities']['goog:chromeOptions'],
$values['capabilities']['extra_capabilities']['chromeOptions']
);
unset($values['capabilities']['extra_capabilities']['chromeOptions']);
}

// If the mobile app is enabled, check its version and add appropriate tags.
if ($mobiletags = $this->get_mobile_version_tags()) {
if (!empty($values['tags'])) {
Expand All @@ -687,13 +697,13 @@ protected function get_behat_profile($profile, $values) {
}
}

$values['capabilities']['extra_capabilities']['chromeOptions']['args'] = array_map(function($arg): string {
$values['capabilities']['extra_capabilities']['goog:chromeOptions']['args'] = array_map(function($arg): string {
if (substr($arg, 0, 2) === '--') {
return substr($arg, 2);
}
return $arg;
}, $values['capabilities']['extra_capabilities']['chromeOptions']['args']);
sort($values['capabilities']['extra_capabilities']['chromeOptions']['args']);
}, $values['capabilities']['extra_capabilities']['goog:chromeOptions']['args']);
sort($values['capabilities']['extra_capabilities']['goog:chromeOptions']['args']);
}

// Fill tags information.
Expand Down
26 changes: 26 additions & 0 deletions lib/behat/classes/behat_session_trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -1676,4 +1676,30 @@ public static function scope_tags_match(HookScope $scope, callable $callback): b

return !empty($matches);
}

/**
* Get the user id from an identifier.
*
* The user username and email fields are checked.
*
* @param string $identifier The user's username or email.
* @return int|null The user id or null if not found.
*/
protected function get_user_id_by_identifier(string $identifier): ?int {
global $DB;

$sql = <<<EOF
SELECT id
FROM {user}
WHERE username = :username
OR email = :email
EOF;

$result = $DB->get_field_sql($sql, [
'username' => $identifier,
'email' => $identifier,
]);

return $result ?: null;
}
}
8 changes: 8 additions & 0 deletions lib/cronlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ function cron_run_inner_scheduled_task(\core\task\task_base $task) {
$predbqueries = null;
$predbqueries = $DB->perf_get_queries();
$pretime = microtime(1);

// Ensure that we have a clean session with the correct cron user.
cron_setup_user();

try {
get_mailer('buffer');
cron_prepare_core_renderer();
Expand Down Expand Up @@ -325,6 +329,10 @@ function cron_run_inner_adhoc_task(\core\task\adhoc_task $task) {
}

cron_setup_user($user);
} else {
// No user specified, ensure that we have a clean session with the correct cron user.
cron_setup_user();

}

try {
Expand Down
27 changes: 17 additions & 10 deletions lib/dml/sqlsrv_native_moodle_database.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,21 +208,28 @@ public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dbop

$this->store_settings($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);

$options = [
'UID' => $this->dbuser,
'PWD' => $this->dbpass,
'Database' => $this->dbname,
'CharacterSet' => 'UTF-8',
'MultipleActiveResultSets' => true,
'ConnectionPooling' => !empty($this->dboptions['dbpersist']),
'ReturnDatesAsStrings' => true,
];

$dbhost = $this->dbhost;
if (!empty($dboptions['dbport'])) {
$dbhost .= ',' . $dboptions['dbport'];
}

$this->sqlsrv = sqlsrv_connect($dbhost, array
(
'UID' => $this->dbuser,
'PWD' => $this->dbpass,
'Database' => $this->dbname,
'CharacterSet' => 'UTF-8',
'MultipleActiveResultSets' => true,
'ConnectionPooling' => !empty($this->dboptions['dbpersist']),
'ReturnDatesAsStrings' => true,
));
// The sqlsrv_connect() has a lot of connection options to be used.
// Users can add any supported options with the 'extrainfo' key in the dboptions.
if (isset($this->dboptions['extrainfo'])) {
$options = array_merge($options, $this->dboptions['extrainfo']);
}

$this->sqlsrv = sqlsrv_connect($dbhost, $options);

if ($this->sqlsrv === false) {
$this->sqlsrv = null;
Expand Down
2 changes: 1 addition & 1 deletion lib/editor/atto/tests/behat/autosave.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Feature: Atto Autosave
And I click on "Save changes" "button"
And I am on "Course 1" course homepage
And I navigate to "Edit settings" in current page administration
And I set the field with xpath "//select[@name='summary_editor[format]']" to "1"
And I set the field "Course summary format" to "1"
And I click on "Save and display" "button"
And I log out

Expand Down
1 change: 1 addition & 0 deletions lib/form/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ function toHtml() {
$context['id'] = $id;
$context['value'] = $text;
$context['format'] = $format;
$context['formatlabel'] = get_string('editorxformat', 'editor', $this->_label);

if (!is_null($this->getAttribute('onblur')) && !is_null($this->getAttribute('onchange'))) {
$context['changelistener'] = true;
Expand Down
1 change: 1 addition & 0 deletions lib/form/templates/editor_textarea.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
</div>
<div>
{{#hasformats}}
<label for="menu{{name}}format" class="sr-only">{{formatlabel}}</label>
<select name="{{name}}[format]" id="menu{{name}}format" class="custom-select">
{{#formats}}
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{text}}</option>
Expand Down
2 changes: 1 addition & 1 deletion lib/phpunit/classes/advanced_testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ protected function runAdhocTasks($matchclass = '', $matchuserid = null) {
}

cron_prepare_core_renderer();
$this->setUser($user);
cron_setup_user($user);

$task->execute();
\core\task\manager::adhoc_task_complete($task);
Expand Down
Loading

0 comments on commit ff44e15

Please sign in to comment.