예제 #1
0
def get_course_assignment_date_blocks(course,
                                      user,
                                      request,
                                      num_return=None,
                                      include_past_dates=False,
                                      include_access=False):
    """
    Returns a list of assignment (at the subsection/sequential level) due date
    blocks for the given course. Will return num_return results or all results
    if num_return is None in date increasing order.
    """
    date_blocks = []
    for assignment in get_course_assignments(course.id,
                                             user,
                                             include_access=include_access):
        date_block = CourseAssignmentDate(course, user)
        date_block.date = assignment.date
        date_block.contains_gated_content = assignment.contains_gated_content
        date_block.first_component_block_id = assignment.first_component_block_id
        date_block.complete = assignment.complete
        date_block.assignment_type = assignment.assignment_type
        date_block.past_due = assignment.past_due
        date_block.link = request.build_absolute_uri(
            assignment.url) if assignment.url else ''
        date_block.set_title(assignment.title, link=assignment.url)
        date_block._extra_info = assignment.extra_info  # pylint: disable=protected-access
        date_blocks.append(date_block)
    date_blocks = sorted(
        (b for b in date_blocks if b.is_enabled or include_past_dates),
        key=date_block_key_fn)
    if num_return:
        return date_blocks[:num_return]
    return date_blocks
예제 #2
0
def get_course_assignment_date_blocks(course,
                                      user,
                                      request,
                                      num_return=None,
                                      include_past_dates=False,
                                      include_access=False):
    """
    Returns a list of assignment (at the subsection/sequential level) due date
    blocks for the given course. Will return num_return results or all results
    if num_return is None in date increasing order.
    """
    date_blocks = []
    for assignment in get_course_assignments(course.id,
                                             user,
                                             request,
                                             include_access=include_access):
        date_block = CourseAssignmentDate(course, user)
        date_block.date = assignment.date
        date_block.contains_gated_content = assignment.contains_gated_content
        date_block.complete = assignment.complete
        date_block.past_due = assignment.past_due
        date_block.link = assignment.url
        date_block.set_title(assignment.title, link=assignment.url)
        date_blocks.append(date_block)
    date_blocks = sorted(
        (b for b in date_blocks if b.is_enabled or include_past_dates),
        key=date_block_key_fn)
    if num_return:
        return date_blocks[:num_return]
    return date_blocks