Merge branch 'MDL-65284-master' of git://github.com/aanabit/moodle
This commit is contained in:
@@ -106,21 +106,10 @@ abstract class base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of analysable elements available on the site.
|
||||
*
|
||||
* \core_analytics\local\analyser\by_course and \core_analytics\local\analyser\sitewide are implementing
|
||||
* this method returning site courses (by_course) and the whole system (sitewide) as analysables.
|
||||
*
|
||||
* @todo MDL-65284 This will be removed in Moodle 3.11
|
||||
* @deprecated
|
||||
* @see get_analysables_iterator
|
||||
* @throws \coding_exception
|
||||
* @return \core_analytics\analysable[] Array of analysable elements using the analysable id as array key.
|
||||
* @deprecated since Moodle 3.7
|
||||
*/
|
||||
public function get_analysables() {
|
||||
// This function should only be called from get_analysables_iterator and we keep it here until Moodle 3.11
|
||||
// for backwards compatibility.
|
||||
throw new \coding_exception('This method is deprecated in favour of get_analysables_iterator.');
|
||||
throw new \coding_exception('get_analysables() method has been removed and cannot be used any more.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,15 +123,7 @@ abstract class base {
|
||||
* @param \context[] $contexts Only analysables that depend on the provided contexts. All analysables in the system if empty.
|
||||
* @return \Iterator
|
||||
*/
|
||||
public function get_analysables_iterator(?string $action = null, array $contexts = []) {
|
||||
|
||||
debugging('Please overwrite get_analysables_iterator with your own implementation, we only keep this default
|
||||
implementation for backwards compatibility purposes with get_analysables(). note that $action param will
|
||||
be ignored so the analysable elements will be processed using get_analysables order, regardless of the
|
||||
last time they were processed.');
|
||||
|
||||
return new \ArrayIterator($this->get_analysables());
|
||||
}
|
||||
abstract public function get_analysables_iterator(?string $action = null, array $contexts = []);
|
||||
|
||||
/**
|
||||
* This function returns this analysable list of samples.
|
||||
|
||||
@@ -2,12 +2,15 @@ This files describes API changes in analytics sub system,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 3.11 ===
|
||||
|
||||
* Final deprecation get_enabled_time_splitting_methods. Method has been removed. Use
|
||||
get_time_splitting_methods_for_evaluation instead.
|
||||
* Final deprecation add_builtin_models. Method has been removed. The functionality
|
||||
has been replaced with automatic update of models provided by the core moodle component.
|
||||
There is no need to call this method explicitly any more. Instead, adding new models can be achieved
|
||||
by updating the lib/db/analytics.php file and bumping the core version.
|
||||
* Final deprecation - get_analysables(). Please see get_analysables_interator() instead.
|
||||
get_analysables_iterator() needs to be overridden by the child class.
|
||||
|
||||
=== 3.8 ===
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once(__DIR__ . '/../../analytics/tests/fixtures/test_target_course_level_shortname.php');
|
||||
require_once(__DIR__ . '/../../analytics/tests/fixtures/test_target_shortname.php');
|
||||
require_once(__DIR__ . '/fixtures/deprecated_analyser.php');
|
||||
require_once(__DIR__ . '/../../lib/enrollib.php');
|
||||
|
||||
/**
|
||||
@@ -197,20 +196,6 @@ class core_analytics_analysers_testcase extends advanced_testcase {
|
||||
$this->assertCount(2, $analyser->get_analysables_iterator(false, [$category1context, $category2context]));
|
||||
}
|
||||
|
||||
/**
|
||||
* test_deprecated_analyser
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_deprecated_analyser() {
|
||||
|
||||
$target = new test_target_shortname();
|
||||
$analyser = new deprecated_analyser(1, $target, [], [], []);
|
||||
|
||||
$analysables = $analyser->get_analysables_iterator();
|
||||
$this->assertDebuggingCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* test_get_analysables_iterator description
|
||||
*
|
||||
|
||||
-158
@@ -1,158 +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/>.
|
||||
|
||||
/**
|
||||
* Deprecated analyser for testing purposes.
|
||||
*
|
||||
* @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();
|
||||
|
||||
/**
|
||||
* Deprecated analyser for testing purposes.
|
||||
*
|
||||
* @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 deprecated_analyser extends \core_analytics\local\analyser\base {
|
||||
|
||||
/**
|
||||
* Implementation of a deprecated method.
|
||||
*
|
||||
* It should be called by get_analysables_iterator, which triggers a debugging message.
|
||||
* @return \core_analytics\analysable[]
|
||||
*/
|
||||
public function get_analysables() {
|
||||
$analysable = new \core_analytics\site();
|
||||
return [SYSCONTEXTID => $analysable];
|
||||
}
|
||||
|
||||
/**
|
||||
* Samples origin is course table.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_samples_origin() {
|
||||
return 'user';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sample analysable
|
||||
*
|
||||
* @param int $sampleid
|
||||
* @return \core_analytics\analysable
|
||||
*/
|
||||
public function get_sample_analysable($sampleid) {
|
||||
return new \core_analytics\site();
|
||||
}
|
||||
|
||||
/**
|
||||
* Data this analyer samples provide.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function provided_sample_data() {
|
||||
return array('user');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sample context.
|
||||
*
|
||||
* @param int $sampleid
|
||||
* @return \context
|
||||
*/
|
||||
public function sample_access_context($sampleid) {
|
||||
return \context_system::instance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all site courses.
|
||||
*
|
||||
* @param \core_analytics\analysable $site
|
||||
* @return array
|
||||
*/
|
||||
public function get_all_samples(\core_analytics\analysable $site) {
|
||||
global $DB;
|
||||
|
||||
$users = $DB->get_records('user');
|
||||
$userids = array_keys($users);
|
||||
$sampleids = array_combine($userids, $userids);
|
||||
|
||||
$users = array_map(function($user) {
|
||||
return array('user' => $user);
|
||||
}, $users);
|
||||
|
||||
return array($sampleids, $users);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all complete samples data from sample ids.
|
||||
*
|
||||
* @param int[] $sampleids
|
||||
* @return array
|
||||
*/
|
||||
public function get_samples($sampleids) {
|
||||
global $DB;
|
||||
|
||||
list($userssql, $params) = $DB->get_in_or_equal($sampleids, SQL_PARAMS_NAMED);
|
||||
$users = $DB->get_records_select('user', "id {$userssql}", $params);
|
||||
$userids = array_keys($users);
|
||||
$sampleids = array_combine($userids, $userids);
|
||||
|
||||
$users = array_map(function($user) {
|
||||
return array('user' => $user);
|
||||
}, $users);
|
||||
|
||||
return array($sampleids, $users);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of a sample.
|
||||
*
|
||||
* @param int $sampleid
|
||||
* @param int $contextid
|
||||
* @param array $sampledata
|
||||
* @return array array(string, \renderable)
|
||||
*/
|
||||
public function sample_description($sampleid, $contextid, $sampledata) {
|
||||
$description = fullname($sampledata['user']);
|
||||
$userimage = new \pix_icon('i/user', get_string('user'));
|
||||
return array($description, $userimage);
|
||||
}
|
||||
|
||||
/**
|
||||
* We need to delete associated data if a user requests his data to be deleted.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function processes_user_data() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Join the samples origin table with the user id table.
|
||||
*
|
||||
* @param string $sampletablealias
|
||||
* @return string
|
||||
*/
|
||||
public function join_sample_user($sampletablealias) {
|
||||
return "JOIN {user} u ON u.id = {$sampletablealias}.sampleid";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user