Merge branch 'MDL-64996-master-untrainedstaticmodels' of git://github.com/mudrd8mz/moodle

This commit is contained in:
Eloy Lafuente (stronk7)
2019-03-27 23:45:15 +01:00
4 changed files with 35 additions and 2 deletions
+4 -1
View File
@@ -1626,7 +1626,10 @@ class model {
// 1 db read per context.
$this->purge_insights_cache();
$this->model->trained = 0;
if (!$this->is_static()) {
$this->model->trained = 0;
}
$this->model->timemodified = time();
$this->model->usermodified = $USER->id;
$DB->update_record('analytics_models', $this->model);
+24
View File
@@ -169,10 +169,34 @@ class analytics_model_testcase extends advanced_testcase {
$this->assertEmpty($DB->count_records('analytics_predict_samples'));
$this->assertEmpty($DB->count_records('analytics_used_files'));
// Check that the model is marked as not trained after clearing (as it is not a static one).
$this->assertEquals(0, $DB->get_field('analytics_models', 'trained', array('id' => $this->modelobj->id)));
set_config('enabled_stores', '', 'tool_log');
get_log_manager(true);
}
/**
* Test behaviour of {\core_analytics\model::clear()} for static models.
*/
public function test_clear_static() {
global $DB;
$this->resetAfterTest();
$statictarget = new test_static_target_shortname();
$indicators['test_indicator_max'] = \core_analytics\manager::get_indicator('test_indicator_max');
$model = \core_analytics\model::create($statictarget, $indicators, '\core\analytics\time_splitting\quarters');
$modelobj = $model->get_model_obj();
// Static models are always considered trained.
$this->assertEquals(1, $DB->get_field('analytics_models', 'trained', array('id' => $modelobj->id)));
$model->clear();
// Check that the model is still marked as trained even after clearing.
$this->assertEquals(1, $DB->get_field('analytics_models', 'trained', array('id' => $modelobj->id)));
}
public function test_model_manager() {
$this->resetAfterTest(true);
+6
View File
@@ -2917,5 +2917,11 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2019031500.01);
}
if ($oldversion < 2019032200.02) {
// The no_teaching model might have been marked as not-trained by mistake (static models are always trained).
$DB->set_field('analytics_models', 'trained', 1, ['target' => '\core\analytics\target\no_teaching']);
upgrade_main_savepoint(true, 2019032200.02);
}
return true;
}
+1 -1
View File
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2019032200.01; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2019032200.02; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.