public final function can_be_edited_by_user() {
        global $USER;

        // We need to be able to explore the repository.
        try {
            $this->check_capability();
        } catch (repository_exception $e) {
            return false;
        }

        $repocontext = context::instance_by_id($this->instance->contextid);
        if ($repocontext->contextlevel == CONTEXT_USER && $repocontext->instanceid != $USER->id) {
            // If the context of this instance is a user context, we need to be this user.
            return false;
        } else if ($repocontext->contextlevel == CONTEXT_MODULE && !has_capability('moodle/course:update', $repocontext)) {
            // We need to have permissions on the course to edit the instance.
            return false;
        } else if ($repocontext->contextlevel == CONTEXT_SYSTEM && !has_capability('moodle/site:config', $repocontext)) {
            // Do not meet the requirements for the context system.
            return false;
        }

        return true;
    }