public function can_view(field_controller $field, int $instanceid) : bool {
        $visibility = $field->get_configdata_property('visibility');
        if ($visibility == self::NOTVISIBLE) {
            return false;
        } else if ($visibility == self::VISIBLETOTEACHERS) {
            return has_capability('moodle/course:update', $this->get_instance_context($instanceid));
        } else {
            return true;
        }
    }
public function can_view(field_controller $field, int $instanceid) : bool {
        $visibility = $field->get_configdata_property('visibility');
        if ($visibility == self::NOTVISIBLE) {
            return false;
        } else if ($visibility == self::VISIBLETOTEACHERS) {
            return has_capability('moodle/course:update', $this->get_instance_context($instanceid));
        } else {
            return true;
        }
    }
public function can_view ( field_controller $ field , int $ instanceid ) : bool { $ visibility = $ field -> get_configdata_property ( 'visibility' ) ; if ( $ visibility == self :: NOTVISIBLE ) { return false ; } else if ( $ visibility == self :: VISIBLETOTEACHERS ) { return has_capability ( 'moodle/course:update' , $ this -> get_instance_context ( $ instanceid ) ) ; } else { return true ; } }
The current user can view custom fields on the given course.

@param field_controller $field
@param int $instanceid id of the course to test edit permission
@return bool true if the current can edit custom fields, false otherwise
The current user can view custom fields on the given course .