Skip to content

Commit

Permalink
Merge branch 'MDL-65639_master' of git://github.com/dmonllao/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed Jun 10, 2019
2 parents 27e2aba + 692d691 commit 317950f
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 68 deletions.
9 changes: 5 additions & 4 deletions admin/tool/analytics/classes/output/models_list.php
Expand Up @@ -156,7 +156,7 @@ public function export_for_template(\renderer_base $output) {
$modeldata->timesplittinghelp = $helpicon->export_for_template($output);
} else {
// We really want to encourage developers to add help to their time splitting methods.
debugging("The time splitting method '{$modeldata->timesplitting}' should include a '{$identifier}_help'
debugging("The analysis interval '{$modeldata->timesplitting}' should include a '{$identifier}_help'
string to describe its purpose.", DEBUG_DEVELOPER);
}
} else {
Expand Down Expand Up @@ -216,10 +216,11 @@ public function export_for_template(\renderer_base $output) {

// Get predictions.
if (!$onlycli && $modeldata->enabled && !empty($modeldata->timesplitting)) {
$urlparams['action'] = 'getpredictions';
$urlparams['action'] = 'scheduledanalysis';
$url = new \moodle_url('model.php', $urlparams);
$icon = new \action_menu_link_secondary($url, new \pix_icon('i/notifications',
get_string('getpredictions', 'tool_analytics')), get_string('getpredictions', 'tool_analytics'));
$icon = new \action_menu_link_secondary($url,
new \pix_icon('i/notifications', get_string('executescheduledanalysis', 'tool_analytics')),
get_string('executescheduledanalysis', 'tool_analytics'));
$actionsmenu->add($icon);
}

Expand Down
4 changes: 2 additions & 2 deletions admin/tool/analytics/classes/output/renderer.php
Expand Up @@ -90,9 +90,9 @@ public function render_evaluate_results($results, $logs = array()) {
$langstrdata = (object)array('name' => $timesplitting->get_name(), 'id' => $timesplittingid);

if (CLI_SCRIPT) {
$output .= $OUTPUT->heading(get_string('getpredictionsresultscli', 'tool_analytics', $langstrdata), 3);
$output .= $OUTPUT->heading(get_string('scheduledanalysisresultscli', 'tool_analytics', $langstrdata), 3);
} else {
$output .= $OUTPUT->heading(get_string('getpredictionsresults', 'tool_analytics', $langstrdata), 3);
$output .= $OUTPUT->heading(get_string('scheduledanalysisresults', 'tool_analytics', $langstrdata), 3);
}
}

Expand Down
16 changes: 8 additions & 8 deletions admin/tool/analytics/cli/enable_model.php
Expand Up @@ -32,20 +32,20 @@
Options:
--modelid Model id
--list List models
--timesplitting Time splitting method full class name
--analysisinterval Time splitting method full class name
-h, --help Print out this help
Example:
\$ php admin/tool/analytics/cli/enable_model.php --modelid=1 --timesplitting=\"\\core\\analytics\\time_splitting\\quarters\"
\$ php admin/tool/analytics/cli/enable_model.php --modelid=1 --analysisinterval=\"\\core\\analytics\\time_splitting\\quarters\"
";

// Now get cli options.
list($options, $unrecognized) = cli_get_params(
array(
'help' => false,
'list' => false,
'modelid' => false,
'timesplitting' => false
'help' => false,
'list' => false,
'modelid' => false,
'analysisinterval' => false
),
array(
'h' => 'help',
Expand All @@ -62,7 +62,7 @@
exit(0);
}

if ($options['timesplitting'] === false) {
if ($options['analysisinterval'] === false) {
echo $help;
exit(0);
}
Expand All @@ -73,7 +73,7 @@
$model = new \core_analytics\model($options['modelid']);

// Evaluate its suitability to predict accurately.
$model->enable($options['timesplitting']);
$model->enable($options['analysisinterval']);

cli_heading(get_string('success'));
exit(0);
12 changes: 6 additions & 6 deletions admin/tool/analytics/cli/evaluate_model.php
Expand Up @@ -33,7 +33,7 @@
--modelid Model id
--list List models
--non-interactive Not interactive questions
--timesplitting Restrict the evaluation to 1 single time splitting method (Optional)
--analysisinterval Restrict the evaluation to 1 single analysis interval (Optional)
--filter Analyser dependant. e.g. A courseid would evaluate the model using a single course (Optional)
--mode 'configuration' or 'trainedmodel'. You can only use mode=trainedmodel when the trained" .
" model was imported" . "
Expand All @@ -42,7 +42,7 @@
-h, --help Print out this help
Example:
\$ php admin/tool/analytics/cli/evaluate_model.php --modelid=1 --timesplitting='\\core\\analytics\\time_splitting\\quarters' --filter=123,321
\$ php admin/tool/analytics/cli/evaluate_model.php --modelid=1 --analysisinterval='\\core\\analytics\\time_splitting\\quarters' --filter=123,321
";

// Now get cli options.
Expand All @@ -51,7 +51,7 @@
'help' => false,
'modelid' => false,
'list' => false,
'timesplitting' => false,
'analysisinterval' => false,
'mode' => 'configuration',
'reuse-prev-analysed' => true,
'non-interactive' => false,
Expand Down Expand Up @@ -87,8 +87,8 @@
cli_error('Error: The provided mode is not supported');
}

if ($options['mode'] == 'trainedmodel' && $options['timesplitting']) {
cli_error('Sorry, no time splitting method can be specified when using \'trainedmodel\' mode.');
if ($options['mode'] == 'trainedmodel' && $options['analysisinterval']) {
cli_error('Sorry, no analysis interval can be specified when using \'trainedmodel\' mode.');
}

// We need admin permissions.
Expand All @@ -104,7 +104,7 @@

$analyseroptions = array(
'filter' => $options['filter'],
'timesplitting' => $options['timesplitting'],
'timesplitting' => $options['analysisinterval'],
'reuseprevanalysed' => $options['reuse-prev-analysed'],
'mode' => $options['mode'],
);
Expand Down
1 change: 1 addition & 0 deletions admin/tool/analytics/lang/en/deprecated.txt
@@ -0,0 +1 @@
getpredictions,tool_analytics
32 changes: 18 additions & 14 deletions admin/tool/analytics/lang/en/tool_analytics.php
Expand Up @@ -24,31 +24,32 @@

$string['accuracy'] = 'Accuracy';
$string['allpredictions'] = 'All predictions';
$string['alltimesplittingmethods'] = 'All time-splitting methods';
$string['alltimesplittingmethods'] = 'All analysis intervals';
$string['analysingsitedata'] = 'Analysing the site';
$string['analysis'] = 'Analysis';
$string['analyticmodels'] = 'Analytics models';
$string['bettercli'] = 'Evaluating models and generating predictions may involve heavy processing. It is recommended to run these actions from the command line.';
$string['cantguessstartdate'] = 'Can\'t guess the start date';
$string['cantguessenddate'] = 'Can\'t guess the end date';
$string['classdoesnotexist'] = 'Class {$a} does not exist';
$string['clearpredictions'] = 'Clear predictions';
$string['clearmodelpredictions'] = 'Are you sure you want to clear all "{$a}" predictions?';
$string['clienablemodel'] = 'You can enable the model by selecting a time-splitting method by its ID. Note that you can also enable it later using the web interface (\'none\' to exit).';
$string['clienablemodel'] = 'You can enable the model by selecting an analysis interval by its ID. Note that you can also enable it later using the web interface (\'none\' to exit).';
$string['clievaluationandpredictions'] = 'A scheduled task iterates through enabled models and gets predictions. Models evaluation via the web interface is disabled. You can allow these processes to be executed manually via the web interface by disabling the <a href="{$a}">\'onlycli\'</a> analytics setting.';
$string['clievaluationandpredictionsnoadmin'] = 'A scheduled task iterates through enabled models and gets predictions. Models evaluation via the web interface is disabled. It may be enabled by a site administrator.';
$string['component'] = 'Component';
$string['componentcore'] = 'Core';
$string['componentselect'] = 'Select all models provided by the component \'{$a}\'';
$string['componentselectnone'] = 'Unselect all';
$string['createmodel'] = 'Create model';
$string['currenttimesplitting'] = 'Current time-splitting method';
$string['currenttimesplitting'] = 'Current analysis interval';
$string['delete'] = 'Delete';
$string['deletemodelconfirmation'] = 'Are you sure you want to delete "{$a}"? These changes cannot be reverted.';
$string['disabled'] = 'Disabled';
$string['editmodel'] = 'Edit "{$a}" model';
$string['edittrainedwarning'] = 'This model has already been trained. Note that changing its indicators or its time-splitting method will delete its previous predictions and start generating new predictions.';
$string['edittrainedwarning'] = 'This model has already been trained. Note that changing its indicators or its analysis interval will delete its previous predictions and start generating new predictions.';
$string['enabled'] = 'Enabled';
$string['errorcantenablenotimesplitting'] = 'You need to select a time-splitting method before enabling the model';
$string['errorcantenablenotimesplitting'] = 'You need to select an analysis interval before enabling the model';
$string['errornoenabledandtrainedmodels'] = 'There are no enabled and trained models to predict.';
$string['errornoenabledmodels'] = 'There are no enabled models to train.';
$string['errornoexport'] = 'Only trained models can be exported';
Expand All @@ -71,15 +72,13 @@
$string['evaluationmodecolconfiguration'] = 'Configuration';
$string['evaluationmodeconfiguration'] = 'Evaluate the model configuration';
$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['executescheduledanalysis'] = 'Execute scheduled analysis';
$string['export'] = 'Export';
$string['exportincludeweights'] = 'Include the weights of the trained model';
$string['exportmodel'] = 'Export configuration';
$string['exporttrainingdata'] = 'Export training data';
$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';
$string['goodmodel'] = 'This is a good model for using to obtain predictions. Enable it to start obtaining predictions.';
$string['importmodel'] = 'Import model';
$string['indicators'] = 'Indicators';
Expand All @@ -103,12 +102,12 @@
$string['modelinvalidanalysables'] = 'Invalid analysable elements for "{$a}" model';
$string['modelname'] = 'Model name';
$string['modelresults'] = '{$a} results';
$string['modeltimesplitting'] = 'Time splitting';
$string['modeltimesplitting'] = 'Analysis interval';
$string['newmodel'] = 'New model';
$string['nextpage'] = 'Next page';
$string['nodatatoevaluate'] = 'There is no data to evaluate the model';
$string['nodatatopredict'] = 'No new elements to get predictions for';
$string['nodatatotrain'] = 'There is no new data that can be used for training';
$string['nodatatopredict'] = 'No new elements to get predictions for.';
$string['nodatatotrain'] = 'There is no new data that can be used for training.';
$string['noinvalidanalysables'] = 'This site does not contain any invalid analysable element.';
$string['notdefined'] = 'Not yet defined';
$string['pluginname'] = 'Analytic models';
Expand All @@ -125,12 +124,14 @@
$string['restoredefaultsubmit'] = 'Restore selected';
$string['samestartdate'] = 'Current start date is good';
$string['sameenddate'] = 'Current end date is good';
$string['selecttimesplittingforevaluation'] = 'Select the time-splitting method you want to use to evaluate the model configuration.';
$string['scheduledanalysisresults'] = 'Results using {$a->name} analysis interval';
$string['scheduledanalysisresultscli'] = 'Results using {$a->name} (id: {$a->id}) analysis interval';
$string['selecttimesplittingforevaluation'] = 'Select the analysis interval you want to use to evaluate the model configuration.';
$string['target'] = 'Target';
$string['target_help'] = 'The target is what the model will predict.';
$string['target_link'] = 'Targets';
$string['timesplittingnotdefined'] = 'Time splitting is not defined.';
$string['timesplittingnotdefined_help'] = 'You need to select a time-splitting method before enabling the model.';
$string['timesplittingnotdefined'] = 'No analysis interval is defined.';
$string['timesplittingnotdefined_help'] = 'You need to select an analysis interval before enabling the model.';
$string['trainandpredictmodel'] = 'Training model and calculating predictions';
$string['trainingprocessfinished'] = 'Training process finished';
$string['trainingresults'] = 'Training results';
Expand All @@ -140,3 +141,6 @@
$string['weeksenddateautomaticallyset'] = 'End date automatically set based on start date and the number of sections';
$string['weeksenddatedefault'] = 'End date automatically calculated from the course start date.';
$string['privacy:metadata'] = 'The Analytic models plugin does not store any personal data.';

// Deprecated since Moodle 3.8.
$string['getpredictions'] = 'Get predictions';
6 changes: 3 additions & 3 deletions admin/tool/analytics/model.php
Expand Up @@ -45,8 +45,8 @@
case 'evaluate':
$title = get_string('evaluatemodel', 'tool_analytics');
break;
case 'getpredictions':
$title = get_string('getpredictions', 'tool_analytics');
case 'scheduledanalysis':
$title = get_string('analysis', 'tool_analytics');
break;
case 'log':
$title = get_string('viewlog', 'tool_analytics');
Expand Down Expand Up @@ -200,7 +200,7 @@
echo $renderer->render_evaluate_results($results, $model->get_analyser()->get_logs());
break;

case 'getpredictions':
case 'scheduledanalysis':
confirm_sesskey();

if ($onlycli) {
Expand Down
6 changes: 6 additions & 0 deletions analytics/upgrade.txt
@@ -1,6 +1,12 @@
This files describes API changes in analytics sub system,
information provided here is intended especially for developers.

=== 3.8 ===

* "Time-splitting method" have been replaced by "Analysis interval" for the language strings that are
displayed in the Moodle UI. The name of several time-splitting methods have been updated according
to the new description of the field.

=== 3.7 ===

* \core_analytics\regressor::evaluate_regression and \core_analytics\classifier::evaluate_classification
Expand Down

0 comments on commit 317950f

Please sign in to comment.