Skip to content

Commit

Permalink
Merge branch 'main_MDL-81172' of https://github.com/mattporritt/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
HuongNV13 committed Mar 28, 2024
2 parents cb3494d + 66349ba commit 1320a2a
Show file tree
Hide file tree
Showing 29 changed files with 81 additions and 7 deletions.
2 changes: 2 additions & 0 deletions admin/environment.xml
Expand Up @@ -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>
7 changes: 5 additions & 2 deletions admin/renderer.php
Expand Up @@ -2055,8 +2055,10 @@ public function environment_check_table($result, $environment_results) {
// 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') {
Expand Down Expand Up @@ -2087,7 +2089,8 @@ public function environment_check_table($result, $environment_results) {
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)
Expand Down
4 changes: 2 additions & 2 deletions admin/settings/courses.php
Expand Up @@ -727,12 +727,12 @@
$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(
Expand Down
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions backup/util/ui/tests/behat/backup_courses.feature
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions backup/util/ui/tests/behat/backup_xapistate.feature
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions backup/util/ui/tests/behat/restore_moodle2_courses.feature
Expand Up @@ -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

Expand Down
Expand Up @@ -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 |
Expand Down
2 changes: 2 additions & 0 deletions completion/tests/behat/backup_restore_completion.feature
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions enrol/meta/tests/behat/enrol_meta.feature
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions group/tests/behat/backup_restore_groups.feature
Expand Up @@ -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 |
Expand Down
4 changes: 4 additions & 0 deletions lang/en/admin.php
Expand Up @@ -75,6 +75,9 @@
$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.';
Expand Down Expand Up @@ -631,6 +634,7 @@
$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\'.';
Expand Down
7 changes: 4 additions & 3 deletions lib/environmentlib.php
Expand Up @@ -1251,7 +1251,7 @@ class environment_results {
*/
var $error_code;
/**
* @var string required/optional
* @var string required/optional/recommended.
*/
var $level;
/**
Expand Down Expand Up @@ -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 {
Expand Down
18 changes: 18 additions & 0 deletions lib/upgradelib.php
Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions mod/bigbluebuttonbn/tests/behat/subplugins.feature
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions mod/lti/tests/behat/backup_restore.feature
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions mod/lti/tests/behat/managecoursetools.feature
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions mod/quiz/tests/behat/backup.feature
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions question/type/ddmarker/tests/behat/backup_and_restore.feature
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions question/type/ddwtos/tests/behat/backup_and_restore.feature
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions question/type/essay/tests/behat/backup_and_restore.feature
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions question/type/gapselect/tests/behat/basic_test.feature
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions question/type/match/tests/behat/backup_and_restore.feature
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down

0 comments on commit 1320a2a

Please sign in to comment.