MDL-66392 analytics: make model output directory default to empty.
Falling back to path within $CFG->dataroot/models.
This commit is contained in:
@@ -131,15 +131,10 @@ if ($hassiteconfig && \core_analytics\manager::is_analytics_enabled()) {
|
||||
$timesplittingdefaults, $timesplittingoptions)
|
||||
);
|
||||
|
||||
// Predictions processor output dir.
|
||||
$defaultmodeloutputdir = rtrim($CFG->dataroot, '/') . DIRECTORY_SEPARATOR . 'models';
|
||||
if (empty(get_config('analytics', 'modeloutputdir')) && !file_exists($defaultmodeloutputdir) &&
|
||||
is_writable($defaultmodeloutputdir)) {
|
||||
// Automatically create the dir for them so users don't see the invalid value red cross.
|
||||
mkdir($defaultmodeloutputdir, $CFG->directorypermissions, true);
|
||||
}
|
||||
// Predictions processor output dir - specify default in setting description (used if left blank).
|
||||
$defaultmodeloutputdir = \core_analytics\model::default_output_dir();
|
||||
$settings->add(new admin_setting_configdirectory('analytics/modeloutputdir', new lang_string('modeloutputdir', 'analytics'),
|
||||
new lang_string('modeloutputdirinfo', 'analytics'), $defaultmodeloutputdir));
|
||||
new lang_string('modeloutputdirwithdefaultinfo', 'analytics', $defaultmodeloutputdir), ''));
|
||||
|
||||
// Disable web interface evaluation and get predictions.
|
||||
$settings->add(new admin_setting_configcheckbox('analytics/onlycli', new lang_string('onlycli', 'analytics'),
|
||||
|
||||
@@ -1492,6 +1492,17 @@ class model {
|
||||
$prediction->get_prediction_data()->contextid, $prediction->get_sample_data());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default output directory for prediction processors
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function default_output_dir(): string {
|
||||
global $CFG;
|
||||
|
||||
return $CFG->dataroot . DIRECTORY_SEPARATOR . 'models';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the output directory for prediction processors.
|
||||
*
|
||||
@@ -1506,8 +1517,6 @@ class model {
|
||||
* @return string
|
||||
*/
|
||||
public function get_output_dir($subdirs = array(), $onlymodelid = false) {
|
||||
global $CFG;
|
||||
|
||||
$subdirstr = '';
|
||||
foreach ($subdirs as $subdir) {
|
||||
$subdirstr .= DIRECTORY_SEPARATOR . $subdir;
|
||||
@@ -1516,7 +1525,7 @@ class model {
|
||||
$outputdir = get_config('analytics', 'modeloutputdir');
|
||||
if (empty($outputdir)) {
|
||||
// Apply default value.
|
||||
$outputdir = rtrim($CFG->dataroot, '/') . DIRECTORY_SEPARATOR . 'models';
|
||||
$outputdir = self::default_output_dir();
|
||||
}
|
||||
|
||||
// Append model id.
|
||||
|
||||
@@ -93,7 +93,7 @@ $string['modeinstructionfacetoface'] = 'Face to face';
|
||||
$string['modeinstructionblendedhybrid'] = 'Blended or hybrid';
|
||||
$string['modeinstructionfullyonline'] = 'Fully online';
|
||||
$string['modeloutputdir'] = 'Models output directory';
|
||||
$string['modeloutputdirinfo'] = 'Directory where prediction processors store all evaluation info. Useful for debugging and research.';
|
||||
$string['modeloutputdirwithdefaultinfo'] = 'Directory where prediction processors store all evaluation info. Useful for debugging and research. If empty, then \'<strong>{$a}</strong>\' will be used as default.';
|
||||
$string['modeltimelimit'] = 'Analysis time limit per model';
|
||||
$string['modeltimelimitinfo'] = 'This setting limits the time each model spends analysing the site contents.';
|
||||
$string['neutral'] = 'Neutral';
|
||||
@@ -156,3 +156,6 @@ $string['viewinsight'] = 'View insight';
|
||||
$string['viewinsightdetails'] = 'View insight details';
|
||||
$string['viewprediction'] = 'View prediction details';
|
||||
$string['washelpful'] = 'Was this helpful?';
|
||||
|
||||
// Deprecated since Moodle 3.10.
|
||||
$string['modeloutputdirinfo'] = 'Directory where prediction processors store all evaluation info. Useful for debugging and research.';
|
||||
|
||||
@@ -123,3 +123,4 @@ managelicenses,core_admin
|
||||
userfilterplaceholder,core
|
||||
sitebackpackverify,core_badges
|
||||
filetypesnotwhitelisted,core_form
|
||||
modeloutputdirinfo,core_analytics
|
||||
|
||||
@@ -2815,5 +2815,16 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2021052500.27);
|
||||
}
|
||||
|
||||
if ($oldversion < 2021052500.29) {
|
||||
// Reset analytics model output dir if it's the default value.
|
||||
$modeloutputdir = get_config('analytics', 'modeloutputdir');
|
||||
if (strcasecmp($modeloutputdir, $CFG->dataroot . DIRECTORY_SEPARATOR . 'models') == 0) {
|
||||
set_config('modeloutputdir', '', 'analytics');
|
||||
}
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2021052500.29);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2021052500.28; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2021052500.29; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
$release = '4.0dev (Build: 20201021)'; // Human-friendly version name
|
||||
|
||||
Reference in New Issue
Block a user