Skip to content

Commit

Permalink
Merge branch 'MDL-66392-38' of https://github.com/paulholden/moodle i…
Browse files Browse the repository at this point in the history
…nto MOODLE_38_STABLE
  • Loading branch information
stronk7 committed Oct 21, 2020
2 parents b98729c + 4051117 commit 988f42c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
11 changes: 3 additions & 8 deletions admin/settings/analytics.php
Expand Up @@ -131,15 +131,10 @@
$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'),
Expand Down
15 changes: 12 additions & 3 deletions analytics/classes/model.php
Expand Up @@ -1492,6 +1492,17 @@ public function prediction_sample_description(\core_analytics\prediction $predic
$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.
*
Expand All @@ -1506,8 +1517,6 @@ public function prediction_sample_description(\core_analytics\prediction $predic
* @return string
*/
public function get_output_dir($subdirs = array(), $onlymodelid = false) {
global $CFG;

$subdirstr = '';
foreach ($subdirs as $subdir) {
$subdirstr .= DIRECTORY_SEPARATOR . $subdir;
Expand All @@ -1516,7 +1525,7 @@ public function get_output_dir($subdirs = array(), $onlymodelid = false) {
$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.
Expand Down
1 change: 1 addition & 0 deletions lang/en/analytics.php
Expand Up @@ -94,6 +94,7 @@
$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';
Expand Down
11 changes: 11 additions & 0 deletions lib/db/upgrade.php
Expand Up @@ -3981,5 +3981,16 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2019111805.10);
}

if ($oldversion < 2019111805.12) {
// 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, 2019111805.12);
}

return true;
}
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -29,7 +29,7 @@

defined('MOODLE_INTERNAL') || die();

$version = 2019111805.11; // 20191118 = branching date YYYYMMDD - do not modify!
$version = 2019111805.12; // 20191118 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '3.8.5+ (Build: 20201021)'; // Human-friendly version name
Expand Down

0 comments on commit 988f42c

Please sign in to comment.