Files
edx-platform/lms/djangoapps/program_enrollments/api/api.py
2019-09-09 08:52:01 -06:00

54 lines
1.7 KiB
Python

# -*- coding: utf-8 -*-
"""
ProgramEnrollment internal api.
"""
from __future__ import absolute_import, unicode_literals
from lms.djangoapps.program_enrollments.rest_api.v1.utils import (
get_due_dates as get_due_dates_util,
get_course_run_url as get_course_run_url_util,
get_emails_enabled as get_emails_enabled_util,
)
def get_due_dates(request, course_key, user):
"""
Get due date information for a user for blocks in a course.
Arguments:
request: the request object
course_key (CourseKey): the CourseKey for the course
user: the user object for which we want due date information
Returns:
due_dates (list): a list of dictionaries containing due date information
keys:
name: the display name of the block
url: the deep link to the block
date: the due date for the block
"""
return get_due_dates_util(request, course_key, user)
def get_course_run_url(request, course_id):
"""
Get the URL to a course run.
Arguments:
request: the request object
course_id (string): the course id of the course
Returns:
(string): the URL to the course run associated with course_id
"""
return get_course_run_url_util(request, course_id)
def get_emails_enabled(user, course_id):
"""
Get whether or not emails are enabled in the context of a course.
Arguments:
user: the user object for which we want to check whether emails are enabled
course_id (string): the course id of the course
Returns:
(bool): True if emails are enabled for the course associated with course_id for the user;
False otherwise
"""
return get_emails_enabled_util(user, course_id)