MDL-58363 mod_choice: Remove calendar is_visible
authorAndrew Nicols <andrew@nicols.co.uk>
Wed, 22 Mar 2017 01:34:01 +0000 (09:34 +0800)
committerDamyon Wiese <damyon@moodle.com>
Mon, 3 Apr 2017 03:37:08 +0000 (11:37 +0800)
Part of MDL-55611 epic.

mod/choice/lib.php
mod/choice/tests/lib_test.php

index a9fc470..b1bed45 100644 (file)
@@ -1182,19 +1182,6 @@ function choice_check_updates_since(cm_info $cm, $from, $filter = array()) {
     return $updates;
 }
 
-/**
- * Is the event visible?
- *
- * @param \core_calendar\event $event
- * @return bool Returns true if the event is visible to the current user, false otherwise.
- */
-function mod_choice_core_calendar_is_event_visible(\core_calendar\event $event) {
-    $cm = get_fast_modinfo($event->courseid)->instances['choice'][$event->instance];
-    $context = context_module::instance($cm->id);
-
-    return has_capability('mod/choice:view', $context);
-}
-
 /**
  * Handles creating actions for events.
  *
index b69fd86..a3105cc 100644 (file)
@@ -264,48 +264,6 @@ class mod_choice_lib_testcase extends externallib_advanced_testcase {
         $this->assertEquals('expired', array_keys($warnings)[0]);
     }
 
-    public function test_choice_core_calendar_is_event_visible() {
-        $this->resetAfterTest();
-
-        $this->setAdminUser();
-
-        // Create a course.
-        $course = $this->getDataGenerator()->create_course();
-
-        // Create a choice.
-        $choice = $this->getDataGenerator()->create_module('choice', array('course' => $course->id));
-
-        // Create a calendar event.
-        $event = $this->create_action_event($course->id, $choice->id, CHOICE_EVENT_TYPE_OPEN);
-
-        // Check that we can see the event.
-        $this->assertTrue(mod_choice_core_calendar_is_event_visible($event));
-    }
-
-    public function test_choice_core_calendar_is_event_visible_as_non_user() {
-        global $CFG;
-
-        $this->resetAfterTest();
-
-        $this->setAdminUser();
-
-        // Create a course.
-        $course = $this->getDataGenerator()->create_course();
-
-        // Create a choice.
-        $choice = $this->getDataGenerator()->create_module('choice', array('course' => $course->id));
-
-        // Create a calendar event.
-        $event = $this->create_action_event($course->id, $choice->id, CHOICE_EVENT_TYPE_OPEN);
-
-        // Log out the user and set force login to true.
-        \core\session\manager::init_empty_session();
-        $CFG->forcelogin = true;
-
-        // Check that we can't see the event.
-        $this->assertFalse(mod_choice_core_calendar_is_event_visible($event));
-    }
-
     public function test_choice_core_calendar_provide_event_action_open() {
         $this->resetAfterTest();