Merge branch 'MDL-59657_master' of git://github.com/dmonllao/moodle

This commit is contained in:
Dan Poltawski 2017-09-04 10:23:24 +01:00 committed by David Monllao
commit 2d64ffeb6b
7 changed files with 47 additions and 6 deletions

View File

@ -97,5 +97,9 @@ if ($hassiteconfig) {
}
$settings->add(new admin_setting_configdirectory('analytics/modeloutputdir', new lang_string('modeloutputdir', 'analytics'),
new lang_string('modeloutputdirinfo', 'analytics'), $defaultmodeloutputdir));
// Disable web interface evaluation and get predictions.
$settings->add(new admin_setting_configcheckbox('analytics/onlycli', new lang_string('onlycli', 'analytics'),
new lang_string('onlycliinfo', 'analytics'), 1));
}
}

View File

@ -62,6 +62,12 @@ class models_list implements \renderable, \templatable {
$data = new \stdClass();
$onlycli = get_config('analytics', 'onlycli');
if ($onlycli === false) {
// Default applied if no config found.
$onlycli = 1;
}
$data->models = array();
foreach ($this->models as $model) {
$modeldata = $model->export();
@ -182,7 +188,7 @@ class models_list implements \renderable, \templatable {
$actionsmenu->add($icon);
// Evaluate machine-learning-based models.
if ($model->get_indicators() && !$model->is_static()) {
if (!$onlycli && $model->get_indicators() && !$model->is_static()) {
$url = new \moodle_url('model.php', array('action' => 'evaluate', 'id' => $model->get_id()));
$icon = new \action_menu_link_secondary($url, new \pix_icon('i/calc', get_string('evaluate', 'tool_analytics')),
get_string('evaluate', 'tool_analytics'));
@ -190,7 +196,7 @@ class models_list implements \renderable, \templatable {
}
// Get predictions.
if ($modeldata->enabled && !empty($modeldata->timesplitting)) {
if (!$onlycli && $modeldata->enabled && !empty($modeldata->timesplitting)) {
$url = new \moodle_url('model.php', array('action' => 'getpredictions', 'id' => $model->get_id()));
$icon = new \action_menu_link_secondary($url, new \pix_icon('i/notifications',
get_string('getpredictions', 'tool_analytics')), get_string('getpredictions', 'tool_analytics'));
@ -218,9 +224,18 @@ class models_list implements \renderable, \templatable {
$data->models[] = $modeldata;
}
$data->warnings = array(
(object)array('message' => get_string('bettercli', 'tool_analytics'), 'closebutton' => true)
);
if (!$onlycli) {
$data->warnings = array(
(object)array('message' => get_string('bettercli', 'tool_analytics'), 'closebutton' => true)
);
} else {
$url = new \moodle_url('/admin/settings.php', array('section' => 'analyticssettings'),
'id_s_analytics_onlycli');
$data->infos = array(
(object)array('message' => get_string('clievaluationandpredictions', 'tool_analytics', $url->out()),
'closebutton' => true)
);
}
return $data;
}

View File

@ -30,6 +30,7 @@ $string['bettercli'] = 'Evaluating models and generating predictions may involve
$string['cantguessstartdate'] = 'Can\'t guess the start date';
$string['cantguessenddate'] = 'Can\'t guess the end date';
$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['clievaluationandpredictions'] = 'A cron task iterates through enabled models and gets predictions. Models evaluation via command line is disabled. You can allow these processes to be executed manually via web interface by enabling <a href="{$a}">\'onlycli\' analytics setting</a>';
$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 the new ones';
$string['enabled'] = 'Enabled';
@ -40,6 +41,7 @@ $string['errornoexport'] = 'Only trained models can be exported';
$string['errornostaticedit'] = 'Models based on assumptions can not be edited';
$string['errornostaticevaluated'] = 'Models based on assumptions can not be evaluated, they are always 100% correct according to how they were defined';
$string['errornostaticlog'] = 'Models based on assumptions can not be evaluated, there is no preformance log';
$string['erroronlycli'] = 'Execution only allowed via command line';
$string['errortrainingdataexport'] = 'The model training data could not be exported';
$string['evaluate'] = 'Evaluate';
$string['evaluatemodel'] = 'Evaluate model';

View File

@ -71,6 +71,12 @@ $PAGE->set_pagelayout('report');
$PAGE->set_title($title);
$PAGE->set_heading($title);
$onlycli = get_config('analytics', 'onlycli');
if ($onlycli === false) {
// Default applied if no config found.
$onlycli = 1;
}
switch ($action) {
case 'enable':
@ -131,6 +137,10 @@ switch ($action) {
throw new moodle_exception('errornostaticevaluate', 'tool_analytics');
}
if ($onlycli) {
throw new moodle_exception('erroronlycli', 'tool_analytics');
}
// Web interface is used by people who can not use CLI nor code stuff, always use
// cached stuff as they will change the model through the web interface as well
// which invalidates the previously analysed stuff.
@ -142,6 +152,10 @@ switch ($action) {
case 'getpredictions':
echo $OUTPUT->header();
if ($onlycli) {
throw new moodle_exception('erroronlycli', 'tool_analytics');
}
$trainresults = $model->train();
$trainlogs = $model->get_analyser()->get_logs();

View File

@ -105,6 +105,10 @@
{{#warnings}}
{{> core/notification_warning}}
{{/warnings}}
{{#infos}}
{{> core/notification_info}}
{{/infos}}
<div class="box">
<table class="generaltable fullwidth">
<caption>{{#str}}modelslist, tool_analytics{{/str}}</caption>

View File

@ -73,6 +73,8 @@ $string['noranges'] = 'No predictions yet';
$string['notrainingbasedassumptions'] = 'Models based on assumptions do not need training';
$string['novaliddata'] = 'No valid data available';
$string['novalidsamples'] = 'No valid samples available';
$string['onlycli'] = 'Analytics processes execution via command line only';
$string['onlycliinfo'] = 'Analytics processes like evaluating models, training machine learning algorithms or getting predictions can take some time, they will run as cron tasks and they can be forced via command line. Disable this setting if you want your site managers to be able to run these processes manually via web interface';
$string['predictionsprocessor'] = 'Predictions processor';
$string['predictionsprocessor_help'] = 'Prediction processors are the machine learning backends that process the datasets generated by calculating models\' indicators and targets.';
$string['processingsitecontents'] = 'Processing site contents';

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2017090100.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2017090400.00; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.