original_string: public function can_edit(field_controller $field, int $instanceid = 0) : bool {
          if ($instanceid) {
              $context = $this->get_instance_context($instanceid);
              return (!$field->get_configdata_property('locked') ||
                      has_capability('moodle/course:changelockedcustomfields', $context));
          } else {
              $context = $this->get_parent_context();
              return (!$field->get_configdata_property('locked') ||
                  guess_if_creator_will_have_course_capability('moodle/course:changelockedcustomfields', $context));
          }
      }
code: public function can_edit(field_controller $field, int $instanceid = 0) : bool {
          if ($instanceid) {
              $context = $this->get_instance_context($instanceid);
              return (!$field->get_configdata_property('locked') ||
                      has_capability('moodle/course:changelockedcustomfields', $context));
          } else {
              $context = $this->get_parent_context();
              return (!$field->get_configdata_property('locked') ||
                  guess_if_creator_will_have_course_capability('moodle/course:changelockedcustomfields', $context));
          }
      }
code_tokens: public function can_edit ( field_controller $ field , int $ instanceid = 0 ) : bool { if ( $ instanceid ) { $ context = $ this -> get_instance_context ( $ instanceid ) ; return ( ! $ field -> get_configdata_property ( 'locked' ) || has_capability ( 'moodle/course:changelockedcustomfields' , $ context ) ) ; } else { $ context = $ this -> get_parent_context ( ) ; return ( ! $ field -> get_configdata_property ( 'locked' ) || guess_if_creator_will_have_course_capability ( 'moodle/course:changelockedcustomfields' , $ context ) ) ; } }
docstring: The current user can edit 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
docstring_tokens: The current user can edit custom fields on the given course .