From b8bb8fe8de3d690b47aecc06e3d43d7d0d68e495 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Fri, 13 Oct 2017 12:52:26 +0200 Subject: [PATCH] MDL-60434 analytics: Remove legacy is_valid method This method was used when the API was tied to students at risk model, this method does not make sense any more as it is up to each target to define what is a valid course. --- analytics/classes/course.php | 14 -------------- analytics/tests/course_test.php | 10 ++++------ 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/analytics/classes/course.php b/analytics/classes/course.php index 07c5e9d5ef7..f934e072ad1 100644 --- a/analytics/classes/course.php +++ b/analytics/classes/course.php @@ -365,20 +365,6 @@ class course implements \core_analytics\analysable { return $this->course; } - /** - * Is the course valid to extract indicators from it? - * - * @return bool - */ - public function is_valid() { - - if (!$this->was_started() || !$this->is_finished()) { - return false; - } - - return true; - } - /** * Has the course started? * diff --git a/analytics/tests/course_test.php b/analytics/tests/course_test.php index f96bcb7fa6f..0383c0836a8 100644 --- a/analytics/tests/course_test.php +++ b/analytics/tests/course_test.php @@ -86,7 +86,6 @@ class core_analytics_course_testcase extends advanced_testcase { $courseman = new \core_analytics\course($this->course->id); $this->assertFalse($courseman->was_started()); $this->assertFalse($courseman->is_finished()); - $this->assertFalse($courseman->is_valid()); // Nothing should change when assigning as teacher. for ($i = 0; $i < 10; $i++) { @@ -94,7 +93,8 @@ class core_analytics_course_testcase extends advanced_testcase { $this->getDataGenerator()->enrol_user($user->id, $this->course->id, $this->teacherroleid); } $courseman = new \core_analytics\course($this->course->id); - $this->assertFalse($courseman->is_valid()); + $this->assertFalse($courseman->was_started()); + $this->assertFalse($courseman->is_finished()); // More students now. for ($i = 0; $i < 10; $i++) { @@ -102,7 +102,8 @@ class core_analytics_course_testcase extends advanced_testcase { $this->getDataGenerator()->enrol_user($user->id, $this->course->id, $this->studentroleid); } $courseman = new \core_analytics\course($this->course->id); - $this->assertFalse($courseman->is_valid()); + $this->assertFalse($courseman->was_started()); + $this->assertFalse($courseman->is_finished()); // Valid start date unknown end date. $this->course->startdate = gmmktime('0', '0', '0', 10, 24, 2015); @@ -110,7 +111,6 @@ class core_analytics_course_testcase extends advanced_testcase { $courseman = new \core_analytics\course($this->course->id); $this->assertTrue($courseman->was_started()); $this->assertFalse($courseman->is_finished()); - $this->assertFalse($courseman->is_valid()); // Valid start and end date. $this->course->enddate = gmmktime('0', '0', '0', 8, 27, 2016); @@ -118,7 +118,6 @@ class core_analytics_course_testcase extends advanced_testcase { $courseman = new \core_analytics\course($this->course->id); $this->assertTrue($courseman->was_started()); $this->assertTrue($courseman->is_finished()); - $this->assertTrue($courseman->is_valid()); // Valid start and ongoing course. $this->course->enddate = gmmktime('0', '0', '0', 8, 27, 2286); @@ -126,7 +125,6 @@ class core_analytics_course_testcase extends advanced_testcase { $courseman = new \core_analytics\course($this->course->id); $this->assertTrue($courseman->was_started()); $this->assertFalse($courseman->is_finished()); - $this->assertFalse($courseman->is_valid()); } /**