protected function any_feedback($action, \cm_info $cm, $contextid, $user) {

        if (!in_array($action, ['submitted', 'replied', 'viewed'])) {
            throw new \coding_exception('Provided action "' . $action . '" is not valid.');
        }

        if (empty($this->activitylogs[$contextid])) {
            return false;
        }

        if (empty($this->grades[$contextid]) && $this->feedback_check_grades()) {
            // If there are no grades there is no feedback.
            return false;
        }

        $it = $this->activitylogs[$contextid];
        if ($user) {
            if (empty($this->activitylogs[$contextid][$user->id])) {
                return false;
            }
            $it = array($user->id => $this->activitylogs[$contextid][$user->id]);
        }

        foreach ($this->activitylogs[$contextid] as $userid => $events) {
            $methodname = 'feedback_' . $action;
            if ($this->{$methodname}($cm, $contextid, $userid)) {
                return true;
            }
            // If it wasn't viewed try with the next user.
        }
        return false;
    }