def METHOD_NAME(survey):
    """Check whether the current user has submitted a survey."""
    from indico.modules.events.surveys.models.surveys import Survey
    query = (Survey.query.with_parent(survey.event)
             .filter(Survey.submissions.any(db.and_(SurveySubmission.is_submitted,
                                                    SurveySubmission.user == session.user))))
    user_submitted_surveys = set(query)
    if session.user and survey in user_submitted_surveys:
        return True
    # anonymous survey: check anonymous submission table
    if survey.anonymous and session.user:
        return session.user.anonymous_survey_submissions.filter_by(survey=survey).has_rows()
    submission_id = session.get('submitted_surveys', {}).get(survey.id)
    if submission_id is None:
        return False
    return SurveySubmission.query.filter_by(id=submission_id, is_submitted=True).has_rows()