Пример #1
0
    def _get_resume_course_info(self, request, course_id):
        """
        Returns information relevant to resume course functionality.

        Returns a tuple: (has_visited_course, resume_course_url)
            has_visited_course: True if the user has ever completed a block, False otherwise.
            resume_course_url: The URL of the 'resume course' block if the user has completed a block,
                otherwise the URL of the first block to start the course.

        """
        course_outline_root_block = get_course_outline_block_tree(
            request, course_id, request.user)
        resume_block = get_resume_block(
            course_outline_root_block) if course_outline_root_block else None
        has_visited_course = bool(resume_block)
        if resume_block:
            resume_course_url = resume_block['lms_web_url']
        else:
            start_block = get_start_block(
                course_outline_root_block
            ) if course_outline_root_block else None
            resume_course_url = start_block[
                'lms_web_url'] if start_block else None

        return has_visited_course, resume_course_url
Пример #2
0
def is_course_accessed(user, course_id):
    """
    Check if the learner accessed the course.

    Arguments:
        user (User): Django User object.
        course_id (String): The course identifier

    Returns:
        (bool): True if course has been accessed by the enterprise learner.
    """
    request = _create_placeholder_request(user)
    course_outline_root_block = get_course_outline_block_tree(request, course_id, user)
    resume_block = get_resume_block(course_outline_root_block) if course_outline_root_block else None
    return bool(resume_block)