MDL-86724 hub: Registration collects disk usage data
This commit is contained in:
@@ -47,6 +47,7 @@ $string['coursesnumber'] = 'Number of courses ({$a})';
|
||||
$string['dbtype'] = 'Database type ({$a})';
|
||||
$string['demourl'] = 'Demo URL';
|
||||
$string['demourl_help'] = 'Enter the demo URL of your course. By default it is the URL of your course. The demo URL is displayed as a link in a search result.';
|
||||
$string['diskusagesize'] = 'Disk usage size ({$a} MB)';
|
||||
$string['downloadable'] = 'Downloadable';
|
||||
$string['educationallevel'] = 'Educational level';
|
||||
$string['educationallevel_help'] = 'Select the most appropriate educational level that the course fits into.';
|
||||
|
||||
@@ -68,6 +68,8 @@ class registration {
|
||||
2023072300 => ['pluginusage'],
|
||||
// AI usage added in Moodle 4.5.
|
||||
2023081200 => ['aiusage'],
|
||||
// Disk usage added in Moodle 5.2.
|
||||
2025100900 => ['diskusage'],
|
||||
];
|
||||
|
||||
/** @var string Site privacy: not displayed */
|
||||
@@ -209,6 +211,9 @@ class registration {
|
||||
$aiusagedata = self::get_ai_usage_data();
|
||||
$siteinfo['aiusage'] = !empty($aiusagedata) ? json_encode($aiusagedata) : '';
|
||||
|
||||
// Disk usage size.
|
||||
$siteinfo['diskusage'] = self::get_dataroot_size() ?? 0;
|
||||
|
||||
// Primary auth type.
|
||||
$primaryauthsql = 'SELECT auth, count(auth) as tc FROM {user} GROUP BY auth ORDER BY tc DESC';
|
||||
$siteinfo['primaryauthtype'] = $DB->get_field_sql($primaryauthsql, null, IGNORE_MULTIPLE);
|
||||
@@ -299,6 +304,7 @@ class registration {
|
||||
'primaryauthtype' => get_string('primaryauthtype', 'hub', $siteinfo['primaryauthtype']),
|
||||
'pluginusage' => get_string('pluginusagedata', 'hub', $pluginusagelinks),
|
||||
'aiusage' => $OUTPUT->render_from_template('core/ai_usage_data', ['aiusagedata' => self::show_ai_usage()]),
|
||||
'diskusage' => get_string('diskusagesize', 'hub', $siteinfo['diskusage']),
|
||||
];
|
||||
|
||||
foreach ($senddata as $key => $str) {
|
||||
@@ -942,4 +948,17 @@ class registration {
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Measure the size of the dataroot directory.
|
||||
*
|
||||
* @return float MB to 3 decimal places.
|
||||
*/
|
||||
public static function get_dataroot_size(): float {
|
||||
global $CFG;
|
||||
$size = get_directory_size($CFG->dataroot);
|
||||
// Convert bytes to megabytes.
|
||||
$size = $size / (1024 * 1024);
|
||||
return round($size, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ final class registration_test extends \advanced_testcase {
|
||||
$this->assertEquals($CFG->dbtype, $siteinfo['dbtype']);
|
||||
$this->assertEquals('manual', $siteinfo['primaryauthtype']);
|
||||
$this->assertEquals(1, $siteinfo['coursesnodates']);
|
||||
$this->assertGreaterThan(0, $siteinfo['diskusage']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user