mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
MDL-65588 analytics: New models for student accesses
This commit is contained in:
parent
7d8ed90757
commit
2d9280e0df
21 changed files with 1079 additions and 89 deletions
|
@ -31,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
|
|||
* @copyright 2019 David Monllaó {@link http://www.davidmonllao.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class test_timesplitting_seconds extends \core_analytics\local\time_splitting\periodic {
|
||||
class test_timesplitting_seconds extends \core_analytics\local\time_splitting\past_periodic {
|
||||
|
||||
/**
|
||||
* Every second.
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Time splitting method that generates weekly predictions.
|
||||
*
|
||||
* @package core_analytics
|
||||
* @copyright 2019 David Monllao {@link http://www.davidmonllao.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Time splitting method that generates weekly predictions.
|
||||
*
|
||||
* @package core_analytics
|
||||
* @copyright 2019 David Monllao {@link http://www.davidmonllao.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class test_timesplitting_weekly extends \core_analytics\local\time_splitting\periodic {
|
||||
|
||||
/**
|
||||
* The time splitting method name.
|
||||
* @return \lang_string
|
||||
*/
|
||||
public static function get_name() : \lang_string {
|
||||
return new \lang_string('error');
|
||||
}
|
||||
|
||||
/**
|
||||
* Once per week.
|
||||
* @return \DateInterval
|
||||
*/
|
||||
public function periodicity() {
|
||||
return new \DateInterval('P1W');
|
||||
}
|
||||
}
|
|
@ -365,10 +365,14 @@ class analytics_manager_testcase extends advanced_testcase {
|
|||
$noteaching = \core_analytics\manager::get_target('\core_course\analytics\target\no_teaching');
|
||||
$dropout = \core_analytics\manager::get_target('\core_course\analytics\target\course_dropout');
|
||||
$upcomingactivities = \core_analytics\manager::get_target('\core_user\analytics\target\upcoming_activities_due');
|
||||
$norecentaccesses = \core_analytics\manager::get_target('\core_course\analytics\target\no_recent_accesses');
|
||||
$noaccesssincestart = \core_analytics\manager::get_target('\core_course\analytics\target\no_access_since_course_start');
|
||||
|
||||
$this->assertTrue(\core_analytics\model::exists($noteaching));
|
||||
$this->assertTrue(\core_analytics\model::exists($dropout));
|
||||
$this->assertTrue(\core_analytics\model::exists($upcomingactivities));
|
||||
$this->assertTrue(\core_analytics\model::exists($norecentaccesses));
|
||||
$this->assertTrue(\core_analytics\model::exists($noaccesssincestart));
|
||||
|
||||
foreach (\core_analytics\manager::get_all_models() as $model) {
|
||||
$model->delete();
|
||||
|
@ -377,16 +381,22 @@ class analytics_manager_testcase extends advanced_testcase {
|
|||
$this->assertFalse(\core_analytics\model::exists($noteaching));
|
||||
$this->assertFalse(\core_analytics\model::exists($dropout));
|
||||
$this->assertFalse(\core_analytics\model::exists($upcomingactivities));
|
||||
$this->assertFalse(\core_analytics\model::exists($norecentaccesses));
|
||||
$this->assertFalse(\core_analytics\model::exists($noaccesssincestart));
|
||||
|
||||
$updated = \core_analytics\manager::update_default_models_for_component('moodle');
|
||||
|
||||
$this->assertEquals(3, count($updated));
|
||||
$this->assertEquals(5, count($updated));
|
||||
$this->assertTrue(array_pop($updated) instanceof \core_analytics\model);
|
||||
$this->assertTrue(array_pop($updated) instanceof \core_analytics\model);
|
||||
$this->assertTrue(array_pop($updated) instanceof \core_analytics\model);
|
||||
$this->assertTrue(array_pop($updated) instanceof \core_analytics\model);
|
||||
$this->assertTrue(array_pop($updated) instanceof \core_analytics\model);
|
||||
$this->assertTrue(\core_analytics\model::exists($noteaching));
|
||||
$this->assertTrue(\core_analytics\model::exists($dropout));
|
||||
$this->assertTrue(\core_analytics\model::exists($upcomingactivities));
|
||||
$this->assertTrue(\core_analytics\model::exists($norecentaccesses));
|
||||
$this->assertTrue(\core_analytics\model::exists($noaccesssincestart));
|
||||
|
||||
$repeated = \core_analytics\manager::update_default_models_for_component('moodle');
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class analytics_stats_testcase extends advanced_testcase {
|
|||
|
||||
// By default, sites have {@link \core_course\analytics\target\no_teaching} and
|
||||
// {@link \core_user\analytics\target\upcoming_activities_due} enabled.
|
||||
$this->assertEquals(2, \core_analytics\stats::enabled_models());
|
||||
$this->assertEquals(4, \core_analytics\stats::enabled_models());
|
||||
|
||||
$model = \core_analytics\model::create(
|
||||
\core_analytics\manager::get_target('\core_course\analytics\target\course_dropout'),
|
||||
|
@ -63,11 +63,11 @@ class analytics_stats_testcase extends advanced_testcase {
|
|||
);
|
||||
|
||||
// Purely adding a new model does not make it included in the stats.
|
||||
$this->assertEquals(2, \core_analytics\stats::enabled_models());
|
||||
$this->assertEquals(4, \core_analytics\stats::enabled_models());
|
||||
|
||||
// New models must be enabled to have them counted.
|
||||
$model->enable('\core\analytics\time_splitting\quarters');
|
||||
$this->assertEquals(3, \core_analytics\stats::enabled_models());
|
||||
$this->assertEquals(5, \core_analytics\stats::enabled_models());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue