MDL-59057 analytics: Standarize indicators and targets ids
[moodle.git] / admin / tool / models / db / install.php
blob5d3ca8f0efe9308b552baebe30c4ec0e53a03543
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Tool models install function.
20 * @package tool_models
21 * @copyright 2017 David Monllao {@link http://www.davidmonllao.com}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
27 /**
28 * Tool models install function.
30 * @return void
32 function xmldb_tool_models_install() {
34 // Students at risk of dropping out of courses.
35 $target = \core_analytics\manager::get_target('\tool_models\analytics\target\course_dropout');
36 // We need the model to be created in order to know all its potential indicators and set them.
37 $model = \core_analytics\model::create($target, array());
38 // TODO All of them for the moment, we will define a limited set of them once in core.
39 $model->update(0, $model->get_potential_indicators());
41 // Course without teachers.
42 $target = \core_analytics\manager::get_target('\tool_models\analytics\target\no_teaching_activity');
43 $weekbeforestart = '\core_analytics\local\time_splitting\week_before_course_start';
44 $noteacher = \core_analytics\manager::get_indicator('\core_course\analytics\indicator\no_teacher');
45 \core_analytics\model::create($target, array($noteacher->get_id() => $noteacher), $weekbeforestart);