This commit is contained in:
Huong Nguyen 2024-03-28 11:46:51 +07:00
commit 1320a2a397
No known key found for this signature in database
GPG key ID: 40D88AB693A3E72A
29 changed files with 81 additions and 7 deletions

View file

@ -4504,6 +4504,8 @@
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_oracle_usage" level="optional">
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_async_backup" level="recommended">
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
</COMPATIBILITY_MATRIX>

View file

@ -2055,8 +2055,10 @@ class core_admin_renderer extends plugin_renderer_base {
// We are checking installed & enabled things
if ($environment_result->getLevel() == 'required') {
$stringtouse = 'environmentrequirecustomcheck';
} else {
} else if ($environment_result->getLevel() == 'optional') {
$stringtouse = 'environmentrecommendcustomcheck';
} else {
$stringtouse = 'environmentshouldfixcustomcheck';
}
} else if ($environment_result->getPart() == 'php_setting') {
@ -2087,7 +2089,8 @@ class core_admin_renderer extends plugin_renderer_base {
if ($status) { //Handle ok result (ok)
$status = get_string('statusok');
} else {
if ($environment_result->getLevel() == 'optional') {//Handle check result (warning)
// Handle check result (warning).
if (in_array($environment_result->getLevel(), ['optional', 'recommended'])) {
$status = get_string('check');
$warningline = true;
} else { //Handle error result (error)

View file

@ -727,12 +727,12 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
$temp = new admin_settingpage('asyncgeneralsettings', new lang_string('asyncgeneralsettings', 'backup'));
$temp->add(new admin_setting_configcheckbox('enableasyncbackup', new lang_string('enableasyncbackup', 'backup'),
new lang_string('enableasyncbackup_help', 'backup'), 0, 1, 0));
new lang_string('enableasyncbackup_help', 'backup'), 1, 1, 0));
$temp->add(new admin_setting_configcheckbox(
'backup/backup_async_message_users',
new lang_string('asyncemailenable', 'backup'),
new lang_string('asyncemailenabledetail', 'backup'), 0));
new lang_string('asyncemailenabledetail', 'backup'), 1));
$temp->hide_if('backup/backup_async_message_users', 'enableasyncbackup');
$temp->add(new admin_setting_configtext(

View file

@ -5,6 +5,8 @@ Feature: Backup and restore of the question that was tagged
Given the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
@javascript @_file_upload
Scenario: Restore the quiz containing the question that was tagged

View file

@ -13,6 +13,8 @@ Feature: Backup Moodle courses
| activity | course | idnumber | name | intro | section |
| assign | C2 | assign1 | Test assign | Assign description | 1 |
| data | C2 | data1 | Test data | Database description | 2 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
And I log in as "admin"
Scenario: Backup a course providing options

View file

@ -19,6 +19,8 @@ Feature: Backup xAPI states
| course | C1 |
| name | Awesome H5P package |
| packagefilepath | h5p/tests/fixtures/filltheblanks.h5p |
And the following config values are set as admin:
| enableasyncbackup | 0 |
# Save state for the student user.
And I am on the "Awesome H5P package" "h5pactivity activity" page logged in as student1
And I switch to "h5p-player" class iframe

View file

@ -24,6 +24,8 @@ Feature: Restore Moodle 2 course backups
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| activity_modules | Course | C1 | course-view-* | side-pre |
| activity_modules | Course | C5 | course-view-* | side-pre |
And the following config values are set as admin:
| enableasyncbackup | 0 |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on

View file

@ -32,6 +32,8 @@ Feature: Restore Moodle 2 course backups with different user data settings
And the following "mod_data > entries" exist:
| database | user | Test field name |
| data1 | student1 | Student entry |
And the following config values are set as admin:
| enableasyncbackup | 0 |
And I log in as "admin"
And I backup "Course 1" course using this options:
| Initial | Include enrolled users | 1 |

View file

@ -26,6 +26,8 @@ Feature: Backup and restore the activity with the completion
| completionusegrade | 1 |
| gradepass | 50 |
| completionpassgrade | 1 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
And I am on the "Test assignment name" "assign activity" page logged in as student1
And I log out

View file

@ -31,6 +31,8 @@ Feature: Enrolments are synchronised with meta courses
| student2 | C2C2 | student | 0 |
| student1 | C4C4 | student | 0 |
| student2 | C4C4 | student | 1 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
And I log in as "admin"
And I navigate to "Plugins > Enrolments > Manage enrol plugins" in site administration
And I click on "Enable" "link" in the "Course meta link" "table_row"

View file

@ -22,6 +22,8 @@ Feature: Backup and restore a course containing groups
| Not visible | C1 | N | 3 | 0 |
| Visible/Non-Participation | C1 | VN | 0 | 0 |
| Only visible to members/Non-Participation | C1 | MN | 1 | 0 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
And I log in as "admin"
And I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |

View file

@ -75,6 +75,9 @@ $string['alternativefullnameformat_desc'] = 'This defines how names are shown to
$string['always'] = 'Always';
$string['appearance'] = 'Appearance';
$string['aspellpath'] = 'Path to aspell';
$string['asyncbackupdisabled'] = 'Your site is currently configured to use synchronous backups. Asynchronous backups provide a better user experience.
Asynchronous backups will be enabled for all sites from Moodle LMS 4.5 LTS.
Synchronous backups will be removed from Moodle LMS the version after 4.5 LTS';
$string['authentication'] = 'Authentication';
$string['authpreventaccountcreation'] = 'Prevent account creation when authenticating';
$string['authpreventaccountcreation_help'] = 'When a user authenticates, an account on the site is automatically created if it doesn\'t yet exist. If an external database, such as LDAP, is used for authentication, but you wish to restrict access to the site to users with an existing account only, then this option should be enabled. New accounts will need to be created manually or via the upload users feature. Note that this setting doesn\'t apply to MNet authentication.';
@ -631,6 +634,7 @@ $string['environmentrequirecustomcheck'] = 'this test must pass';
$string['environmentrequireinstall'] = 'must be installed and enabled';
$string['environmentrequireversion'] = 'version {$a->needed} is required and you are running {$a->current}';
$string['environmentsettingok'] = 'recommended setting detected';
$string['environmentshouldfixcustomcheck'] = 'should be enabled for best results';
$string['environmentshouldfixsetting'] = 'PHP setting should be changed.';
$string['environmentxmlerror'] = 'Error reading environment data ({$a->error_code})';
$string['environmentmariadbwrongdbtype'] = 'Wrong $CFG->dbtype. You need to change it in your config.php file from \'mysqli\' to \'mariadb\'.';

View file

@ -1251,7 +1251,7 @@ class environment_results {
*/
var $error_code;
/**
* @var string required/optional
* @var string required/optional/recommended.
*/
var $level;
/**
@ -1548,8 +1548,9 @@ function get_level($element) {
$level = 'required';
if (isset($element['@']['level'])) {
$level = $element['@']['level'];
if (!in_array($level, array('required', 'optional'))) {
debugging('The level of a check in the environment.xml file must be "required" or "optional".', DEBUG_DEVELOPER);
if (!in_array($level, ['required', 'optional', 'recommended'])) {
debugging('The level of a check in the environment.xml file must be "required", "optional" or "recommended".',
DEBUG_DEVELOPER);
$level = 'required';
}
} else {

View file

@ -2905,3 +2905,21 @@ function check_oracle_usage(environment_results $result): ?environment_results {
return null;
}
/**
* Check if asynchronous backups are enabled.
*
* @param environment_results $result
* @return environment_results|null
*/
function check_async_backup(environment_results $result): ?environment_results {
global $CFG;
if (!during_initial_install() && empty($CFG->enableasyncbackup)) { // Have to use $CFG as config table may not be available.
$result->setInfo('Asynchronous backups disabled');
$result->setFeedbackStr('asyncbackupdisabled');
return $result;
}
return null;
}

View file

@ -12,6 +12,8 @@ Feature: BigBlueButtonBN Subplugins test
And the following "activities" exist:
| activity | course | name | type |
| bigbluebuttonbn | Test course | BBB Instance name | 0 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
Scenario: Add a subplugin and check that the settings are available
Given I log in as "admin"

View file

@ -13,6 +13,8 @@ Feature: Restoring Moodle 2 backup restores LTI configuration
| user | course | role |
| teacher1 | C1 | editingteacher |
| teacher1 | C2 | editingteacher |
And the following config values are set as admin:
| enableasyncbackup | 0 |
Scenario: Backup and restore course with preconfigured site LTI tool on the same site
Given the following "mod_lti > tool types" exist:

View file

@ -17,6 +17,8 @@ Feature: Manage course tools
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following config values are set as admin:
| enableasyncbackup | 0 |
Scenario: Create a course tool from the zero state
Given I am on the "Course 1" course page logged in as teacher1

View file

@ -11,6 +11,8 @@ Feature: Backup and restore of quizzes
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following config values are set as admin:
| enableasyncbackup | 0 |
And I log in as "admin"
@javascript

View file

@ -19,6 +19,8 @@ Feature: Test duplicating a quiz containing a drag and drop onto image question
| quiz | Test quiz | C1 | quiz1 |
And quiz "Test quiz" contains the following questions:
| Drag onto image | 1 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
@javascript
Scenario: Backup and restore a course containing a drag and drop onto image question

View file

@ -19,6 +19,8 @@ Feature: Test duplicating a quiz containing a drag and drop markers question
| quiz | Test quiz | C1 | quiz1 |
And quiz "Test quiz" contains the following questions:
| Drag markers | 1 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
And I log in as "admin"
And I am on "Course 1" course homepage

View file

@ -19,6 +19,8 @@ Feature: Test duplicating a quiz containing a drag and drop into text question
| quiz | Test quiz | C1 | quiz1 |
And quiz "Test quiz" contains the following questions:
| Drag to text | 1 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
@javascript
Scenario: Backup and restore a course containing a drag and drop into text question

View file

@ -19,6 +19,8 @@ Feature: Test duplicating a quiz containing a Description question
| quiz | Test quiz | C1 | quiz1 |
And quiz "Test quiz" contains the following questions:
| description-001 | 1 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
@javascript
Scenario: Backup and restore a course containing a Description question

View file

@ -23,6 +23,8 @@ Feature: Test duplicating a quiz containing an Essay question
| essay-001 | 1 |
| essay-002 | 1 |
| essay-003 | 1 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
@javascript
Scenario: Backup and restore a course containing 3 Essay questions

View file

@ -13,6 +13,8 @@ Feature: Test all the basic functionality of this question type
And the following "course enrolments" exist:
| user | course | role |
| teacher | C1 | editingteacher |
And the following config values are set as admin:
| enableasyncbackup | 0 |
@javascript
Scenario: Create, edit then preview a gapselect question.

View file

@ -19,6 +19,8 @@ Feature: Test duplicating a quiz containing a Matching question
| quiz | Test quiz | C1 | quiz1 |
And quiz "Test quiz" contains the following questions:
| matching-001 | 1 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
@javascript
Scenario: Backup and restore a course containing a Matching question

View file

@ -19,6 +19,8 @@ Feature: Test duplicating a quiz containing a Multiple choice question
| quiz | Test quiz | C1 | quiz1 |
And quiz "Test quiz" contains the following questions:
| Multi-choice-001 | 1 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
@javascript
Scenario: Backup and restore a course containing a Multiple choice question

View file

@ -19,6 +19,8 @@ Feature: Test duplicating a quiz containing a Numerical question
| quiz | Test quiz | C1 | quiz1 |
And quiz "Test quiz" contains the following questions:
| Numerical-001 | 1 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
@javascript
Scenario: Backup and restore a course containing a Numerical question

View file

@ -19,6 +19,8 @@ Feature: Test duplicating a quiz containing a Short answer question
| quiz | Test quiz | C1 | quiz1 |
And quiz "Test quiz" contains the following questions:
| shortanswer-001 | 1 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
@javascript
Scenario: Backup and restore a course containing a Short answer question

View file

@ -19,6 +19,8 @@ Feature: Test duplicating a quiz containing a True/False question
| quiz | Test quiz | C1 | quiz1 |
And quiz "Test quiz" contains the following questions:
| true-false-001 | 1 |
And the following config values are set as admin:
| enableasyncbackup | 0 |
@javascript
Scenario: Backup and restore a course containing a True/False question