示例#1
0
def get_answers_distribution_reports_from_course(course_key):
    """Return a list of reports files ordered by date corresponding to a course."""
    course_path = shared.get_path(ANSWERS_DISTRIBUTION_REPORTS_DIRECTORY,
                                  course_key.org, course_key.course)

    if os.path.exists(course_path):
        files = [f for f in os.listdir(course_path)
                 if os.path.isfile(os.path.join(course_path, f))]
        files.sort(key=lambda s: os.path.getmtime(os.path.join(course_path, s)),
                   reverse=True)
        return files
    return None
示例#2
0
文件: views.py 项目: cuissai/fun-apps
def download(request, course_id, answers_distribution_report):
    course_key = get_course_key(course_id)

    file_path = shared.get_path(ANSWERS_DISTRIBUTION_REPORTS_DIRECTORY,
                                course_key.org, course_key.course,
                                answers_distribution_report)

    if not file_path or not os.path.exists(file_path):
        raise Http404

    response = HttpResponse(open(file_path).read(), content_type='text/csv')
    response['Content-Disposition'] = 'attachment; filename="{}"'.format(remove_accents(answers_distribution_report))
    return response
示例#3
0
def download(request, course_id, answers_distribution_report):
    course_key = get_course_key(course_id)

    file_path = shared.get_path(ANSWERS_DISTRIBUTION_REPORTS_DIRECTORY,
                                course_key.org, course_key.course,
                                answers_distribution_report)

    if not file_path or not os.path.exists(file_path):
        raise Http404

    response = HttpResponse(open(file_path).read(), content_type='text/csv')
    response['Content-Disposition'] = 'attachment; filename="{}"'.format(
        remove_accents(answers_distribution_report))
    return response
示例#4
0
def get_reports_from_course(course_key):
    """
    Return a list of reports files ordered by date corresponding to a course
    """
    course_path = shared.get_path(ANSWERS_DISTRIBUTION_REPORTS_DIRECTORY,
                                  course_key.org, course_key.course)

    if os.path.exists(course_path):
        files = [
            f for f in os.listdir(course_path)
            if os.path.isfile(os.path.join(course_path, f))
        ]

        files.sort(
            key=lambda s: os.path.getmtime(os.path.join(course_path, s)),
            reverse=True)
        return files
    return None