mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-59010 analytics: Logstores initialised during tests
Part of MDL-57791 epic.
This commit is contained in:
parent
f67f35f324
commit
cad362520f
3 changed files with 5 additions and 45 deletions
|
@ -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');
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue