protected function user_can_access_course($user, $course, $capability) {
        if (!isset($this->courseaccesscache[$course->id][$user->id][$capability])) {
            $this->courseaccesscache[$course->id][$user->id][$capability] = can_access_course($course, $user, $capability, true);
        }
        return $this->courseaccesscache[$course->id][$user->id][$capability];
    }