Beispiel #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,
                                             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
Beispiel #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,
                                             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
Beispiel #3
0
def get_course_assignment_due_dates(course, user, request, num_return=None, include_past_dates=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.
    """
    store = modulestore()
    all_course_dates = get_dates_for_course(course.id, user)
    date_blocks = []
    for (block_key, date_type), date in all_course_dates.items():
        if date_type == 'due' and block_key.block_type == 'sequential':
            item = store.get_item(block_key)
            if item.graded:
                date_block = CourseAssignmentDate(course, user)
                date_block.date = date

                block_url = None
                now = datetime.now().replace(tzinfo=pytz.UTC)
                assignment_released = item.start < now if item.start else None
                if assignment_released:
                    block_url = reverse('jump_to', args=[course.id, block_key])
                    block_url = request.build_absolute_uri(block_url) if request else None
                assignment_title = item.display_name if item.display_name else _('Assignment')
                date_block.set_title(assignment_title, link=block_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