@classmethod<EOL><INDENT>def is_user_enrolled(cls, user, course_id, course_mode):<DEDENT>
enrollment_client = EnrollmentApiClient()<EOL>try:<EOL><INDENT>enrollments = enrollment_client.get_course_enrollment(user.username, course_id)<EOL>if enrollments and course_mode == enrollments.get('<STR_LIT>'):<EOL><INDENT>return True<EOL><DEDENT><DEDENT>except HttpClientError as exc:<EOL><INDENT>logging.error(<EOL>'<STR_LIT>',<EOL>dict(user=user.username, message=str(exc))<EOL>)<EOL><DEDENT>except KeyError as exc:<EOL><INDENT>logging.warning(<EOL>'<STR_LIT>',<EOL>dict(user=user.username, message=str(exc))<EOL>)<EOL><DEDENT>return False<EOL>
Query the enrollment API and determine if a learner is enrolled in a given course run track.

Args:
    user: The user whose enrollment needs to be checked
    course_mode: The mode with which the enrollment should be checked
    course_id: course id of the course where enrollment should be checked.

Returns:
    Boolean: Whether or not enrollment exists