Skip to content

Commit

Permalink
Merge branch 'MDL-66392' of https://github.com/paulholden/moodle into…
Browse files Browse the repository at this point in the history
… master
  • Loading branch information
stronk7 committed Oct 21, 2020
2 parents a3039fd + cecd90f commit 284d0ae
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
11 changes: 3 additions & 8 deletions admin/settings/analytics.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
5 changes: 4 additions & 1 deletion lang/en/analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
$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';
Expand Down Expand Up @@ -156,3 +156,6 @@
$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.';
1 change: 1 addition & 0 deletions lang/en/deprecated.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,4 @@ managelicenses,core_admin
userfilterplaceholder,core
sitebackpackverify,core_badges
filetypesnotwhitelisted,core_form
modeloutputdirinfo,core_analytics
11 changes: 11 additions & 0 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2851,5 +2851,16 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2021052500.29);
}

if ($oldversion < 2021052500.30) {
// 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.30);
}

return true;
}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

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

$version = 2021052500.29; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2021052500.30; // 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
Expand Down

0 comments on commit 284d0ae

Please sign in to comment.