Skip to content

Commit

Permalink
MDL-60936 analytics: Timesplittings setting only for evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllaó committed Mar 18, 2019
1 parent ec81914 commit 3576b66
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 13 deletions.
5 changes: 3 additions & 2 deletions admin/settings/analytics.php
Expand Up @@ -83,8 +83,9 @@
foreach ($alltimesplittings as $key => $timesplitting) {
$timesplittingoptions[$key] = $timesplitting->get_name();
}
$settings->add(new admin_setting_configmultiselect('analytics/timesplittings',
new lang_string('enabledtimesplittings', 'analytics'), new lang_string('timesplittingmethod_help', 'analytics'),
$settings->add(new admin_setting_configmultiselect('analytics/defaulttimesplittingsevaluation',
new lang_string('defaulttimesplittingmethods', 'analytics'),
new lang_string('defaulttimesplittingmethods_help', 'analytics'),
$timesplittingdefaults, $timesplittingoptions)
);

Expand Down
4 changes: 2 additions & 2 deletions admin/tool/analytics/lang/en/tool_analytics.php
Expand Up @@ -68,8 +68,8 @@
$string['evaluationinbatches'] = 'The site contents are calculated and stored in batches. The evaluation process may be stopped at any time. The next time it is run, it will continue from the point when it was stopped.';
$string['exportmodel'] = 'Export configuration';
$string['exporttrainingdata'] = 'Export training data';
$string['getpredictionsresultscli'] = 'Results using {$a->name} (id: {$a->id}) course duration splitting';
$string['getpredictionsresults'] = 'Results using {$a->name} course duration splitting';
$string['getpredictionsresultscli'] = 'Results using {$a->name} (id: {$a->id}) time-splitting method';
$string['getpredictionsresults'] = 'Results using {$a->name} time-splitting method';
$string['extrainfo'] = 'Info';
$string['generalerror'] = 'Evaluation error. Status code {$a}';
$string['getpredictions'] = 'Get predictions';
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/analytics/model.php
Expand Up @@ -119,7 +119,7 @@
'id' => $model->get_id(),
'trainedmodel' => $model->is_trained(),
'indicators' => $model->get_potential_indicators(),
'timesplittings' => \core_analytics\manager::get_enabled_time_splitting_methods(),
'timesplittings' => \core_analytics\manager::get_all_time_splittings(),
'predictionprocessors' => \core_analytics\manager::get_all_prediction_processors()
);
$mform = new \tool_analytics\output\form\edit_model(null, $customdata);
Expand Down
17 changes: 16 additions & 1 deletion analytics/classes/manager.php
Expand Up @@ -254,11 +254,26 @@ public static function get_all_time_splittings() {
/**
* Returns the enabled time splitting methods.
*
* @deprecated since Moodle 3.7
* @todo MDL-65086 This will be deleted in Moodle 4.1
* @see \core_analytics\manager::get_time_splitting_methods_for_evaluation
* @return \core_analytics\local\time_splitting\base[]
*/
public static function get_enabled_time_splitting_methods() {
debugging('This function has been deprecated. You can use self::get_time_splitting_methods_for_evaluation if ' .
'you want to get the default time splitting methods for evaluation, or you can use self::get_all_time_splittings if ' .
'you want to get all the time splitting methods available on this site.');
return self::get_time_splitting_methods_for_evaluation();
}

/**
* Returns the default time splitting methods for model evaluation.
*
* @return \core_analytics\local\time_splitting\base[]
*/
public static function get_time_splitting_methods_for_evaluation() {

if ($enabledtimesplittings = get_config('analytics', 'timesplittings')) {
if ($enabledtimesplittings = get_config('analytics', 'defaulttimesplittingsevaluation')) {
$enabledtimesplittings = array_flip(explode(',', $enabledtimesplittings));
}

Expand Down
2 changes: 1 addition & 1 deletion analytics/classes/model.php
Expand Up @@ -289,7 +289,7 @@ protected function init_analyser($options = array()) {
$timesplitting = \core_analytics\manager::get_time_splitting($options['timesplitting']);
$timesplittings = array($timesplitting->get_id() => $timesplitting);
} else {
$timesplittings = \core_analytics\manager::get_enabled_time_splitting_methods();
$timesplittings = \core_analytics\manager::get_time_splitting_methods_for_evaluation();
}
} else {

Expand Down
4 changes: 1 addition & 3 deletions analytics/tests/prediction_test.php
Expand Up @@ -443,7 +443,7 @@ public function test_ml_evaluation_configuration($modelquality, $ncourses, $expe
$sometimesplittings = '\core\analytics\time_splitting\weekly,' .
'\core\analytics\time_splitting\single_range,' .
'\core\analytics\time_splitting\quarters';
set_config('timesplittings', $sometimesplittings, 'analytics');
set_config('defaulttimesplittingsevaluation', $sometimesplittings, 'analytics');

if ($modelquality === 'perfect') {
$model = $this->add_perfect_model();
Expand Down Expand Up @@ -487,8 +487,6 @@ public function test_ml_evaluation_trained_model($predictionsprocessorclass) {
$this->resetAfterTest(true);
$this->setAdminuser();
set_config('enabled_stores', 'logstore_standard', 'tool_log');
set_config('timesplittings',
'\core\analytics\time_splitting\quarters,\core\analytics\time_splitting\quarters_accum', 'analytics');

$model = $this->add_perfect_model();

Expand Down
5 changes: 3 additions & 2 deletions lang/en/analytics.php
Expand Up @@ -30,7 +30,8 @@
$string['analyticslogstore_help'] = 'The log store that will be used by the analytics API to read users\' activity';
$string['analyticssettings'] = 'Analytics settings';
$string['coursetoolong'] = 'The course is too long';
$string['enabledtimesplittings'] = 'Time splitting methods';
$string['defaulttimesplittingmethods'] = 'Default time-splitting methods for model\'s evaluation';
$string['defaulttimesplittingmethods_help'] = 'The time-splitting method divides the course duration into parts; the predictions engine will run at the end of these parts. The model evaluation process will iterate through these time-splitting methods unless a specific time-splitting method is specified (the ability to specify a time-splitting method is only available when evaluating models using the command line script).';
$string['defaultpredictionsprocessor'] = 'Default predictions processor';
$string['defaultpredictoroption'] = 'Default processor ({$a})';
$string['disabledmodel'] = 'Disabled model';
Expand Down Expand Up @@ -121,5 +122,5 @@
$string['processingsitecontents'] = 'Processing site contents';
$string['successfullyanalysed'] = 'Successfully analysed';
$string['timesplittingmethod'] = 'Time-splitting method';
$string['timesplittingmethod_help'] = 'The time-splitting method divides the course duration into parts; the predictions engine will run at the end of these parts. It is recommended that you only enable the time-splitting methods you may be interested in using. The evaluation process will iterate through all enabled time-splitting methods, so the more time-splitting methods enabled, the slower the evaluation process will be.';
$string['timesplittingmethod_help'] = 'The time-splitting method is what defines when the system will calculate predictions and the portion of activity logs that will be considered for those predictions. E.g. They can divide the course duration in parts and generate a prediction at the end of these parts.';
$string['viewprediction'] = 'View prediction details';
12 changes: 12 additions & 0 deletions lib/db/upgrade.php
Expand Up @@ -2905,5 +2905,17 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2019030800.03);
}

if ($oldversion < 2019031500.01) {

$defaulttimesplittings = get_config('analytics', 'timesplittings');
if ($defaulttimesplittings !== false) {
set_config('defaulttimesplittingsevaluation', $defaulttimesplittings, 'analytics');
unset_config('timesplittings', 'analytics');
}

// Main savepoint reached.
upgrade_main_savepoint(true, 2019031500.01);
}

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

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

$version = 2019031500.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2019031500.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.

Expand Down

0 comments on commit 3576b66

Please sign in to comment.