Skip to content

Commit

Permalink
MDL-65284 analytics: Final deprecation get_analysables()
Browse files Browse the repository at this point in the history
  • Loading branch information
Amaia Anabitarte committed Dec 16, 2020
1 parent c307f3b commit 46927df
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 195 deletions.
25 changes: 3 additions & 22 deletions analytics/classes/local/analyser/base.php
Expand Up @@ -106,21 +106,10 @@ public function __construct($modelid, \core_analytics\local\target\base $target,
}

/**
* 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.');
}

/**
Expand All @@ -134,15 +123,7 @@ public function get_analysables() {
* @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.
Expand Down
3 changes: 3 additions & 0 deletions analytics/upgrade.txt
Expand Up @@ -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 ===

Expand Down
15 changes: 0 additions & 15 deletions lib/tests/analysers_test.php
Expand Up @@ -27,7 +27,6 @@

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');

/**
Expand Down Expand Up @@ -197,20 +196,6 @@ public function test_student_enrolments_analyser() {
$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
*
Expand Down
158 changes: 0 additions & 158 deletions lib/tests/fixtures/deprecated_analyser.php

This file was deleted.

0 comments on commit 46927df

Please sign in to comment.