MDL-59010 analytics: Logstores initialised during tests

Part of MDL-57791 epic.
This commit is contained in:
David Monllao 2017-06-13 09:36:30 +02:00
parent f67f35f324
commit cad362520f
3 changed files with 5 additions and 45 deletions

View file

@ -251,7 +251,7 @@ class manager {
/**
* get_analytics_logstore
*
* @return \core\log\reader
* @return \core\log\sql_reader
*/
public static function get_analytics_logstore() {
$readers = get_log_manager()->get_readers('core\log\sql_reader');

View file

@ -153,48 +153,4 @@ class core_analytics_course_testcase extends advanced_testcase {
protected function time_less_than($time) {
return $time + (WEEKSECS * 2);
}
/**
* Generate a log.
*
* @param int $time
* @param int $userid
* @param int $courseid
* @return void
*/
protected function generate_log($time, $userid = false, $courseid = false) {
global $DB;
if (empty($userid)) {
$userid = $this->stu1->id;
}
if (empty($courseid)) {
$courseid = $this->course->id;
}
$context = context_course::instance($courseid);
$obj = (object)[
'eventname' => '\\core\\event\\course_viewed',
'component' => 'core',
'action' => 'viewed',
'target' => 'course',
'objecttable' => 'course',
'objectid' => $courseid,
'crud' => 'r',
'edulevel' => \core\event\base::LEVEL_PARTICIPATING,
'contextid' => $context->id,
'contextlevel' => $context->contextlevel,
'contextinstanceid' => $context->instanceid,
'userid' => $userid,
'courseid' => $courseid,
'relateduserid' => null,
'anonymous' => 0,
'other' => null,
'timecreated' => $time,
'origin' => 'web',
];
$DB->insert_record('logstore_standard_log', $obj);
}
}

View file

@ -48,6 +48,8 @@ class core_analytics_prediction_testcase extends advanced_testcase {
public function test_ml_training_and_prediction($timesplittingid, $npredictedranges, $predictionsprocessorclass) {
global $DB;
set_config('enabled_stores', 'logstore_standard', 'tool_log');
$ncourses = 10;
$this->resetAfterTest(true);
@ -155,6 +157,8 @@ class core_analytics_prediction_testcase extends advanced_testcase {
public function test_ml_evaluation($modelquality, $ncourses, $expected, $predictionsprocessorclass) {
$this->resetAfterTest(true);
set_config('enabled_stores', 'logstore_standard', 'tool_log');
$sometimesplittings = '\core_analytics\local\time_splitting\weekly,' .
'\core_analytics\local\time_splitting\single_range,' .
'\core_analytics\local\time_splitting\quarters';