当前位置: 首页>>代码示例>>Python>>正文


Python Exams.get_marks方法代码示例

本文整理汇总了Python中oasis.lib.Exams.get_marks方法的典型用法代码示例。如果您正苦于以下问题:Python Exams.get_marks方法的具体用法?Python Exams.get_marks怎么用?Python Exams.get_marks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oasis.lib.Exams的用法示例。


在下文中一共展示了Exams.get_marks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cadmin_exam_results

# 需要导入模块: from oasis.lib import Exams [as 别名]
# 或者: from oasis.lib.Exams import get_marks [as 别名]
def cadmin_exam_results(course_id, exam_id):
    """ View the results of an assessment """
    course = Courses2.get_course(course_id)
    if not course:
        abort(404)

    exam = Exams.get_exam_struct(exam_id, course_id)
    if not exam:
        abort(404)

    if not int(exam['cid']) == int(course_id):
        flash("Assessment %s does not belong to this course." % int(exam_id))
        return redirect(url_for('cadmin_top', course_id=course_id))

    exam['start_date'] = int(date_from_py2js(exam['start']))
    exam['end_date'] = int(date_from_py2js(exam['end']))
    exam['start_hour'] = int(exam['start'].hour)
    exam['end_hour'] = int(exam['end'].hour)
    exam['start_minute'] = int(exam['start'].minute)
    exam['end_minute'] = int(exam['end'].minute)

    groups = [Groups.Group(g_id=g_id)
              for g_id
              in Groups.active_by_course(course_id)]
    results = {}
    uids = set([])
    totals = {}
    for group in groups:
        results[group.id] = Exams.get_marks(group, exam_id)
        for user_id in results[group.id]:
            uids.add(user_id)
            if user_id not in totals:
                totals[user_id] = 0.0
            for qt, val in results[group.id][user_id].iteritems():
                totals[user_id] += val['score']

    questions = Exams.get_qts_list(exam_id)
    users = {}
    for uid in uids:
        users[uid] = Users2.get_user(uid)
    return render_template(
        "cadmin_examresults.html",
        course=course,
        exam=exam,
        results=results,
        groups=groups,
        users=users,
        questions=questions,
        when=datetime.now().strftime("%H:%m, %a %d %b %Y"),
        totals=totals
    )
开发者ID:tkanesh,项目名称:oasisqe,代码行数:53,代码来源:views_cadmin.py

示例2: exam_results_as_spreadsheet

# 需要导入模块: from oasis.lib import Exams [as 别名]
# 或者: from oasis.lib.Exams import get_marks [as 别名]
def exam_results_as_spreadsheet(course_id, group, exam_id):
    """ Export the assessment results as a XLSX spreadsheet """

    course = Courses2.get_course(course_id)
    exam = Exams.get_exam_struct(exam_id, course_id)

    uids = set([])
    totals = {}

    results = Exams.get_marks(group, exam_id)
    for user_id in results:
        uids.add(user_id)
        if user_id not in totals:
            totals[user_id] = 0.0
        for qt, val in results[user_id].iteritems():
            totals[user_id] += val['score']

    questions = Exams.get_qts_list(exam_id)
    users = {}
    for uid in uids:
        users[uid] = Users2.get_user(uid)

    wb = Workbook()

    ws = wb.get_active_sheet()

    ws.title = "Results"

    ws.cell(row=1, column=0).value = course['name']
    ws.cell(row=1, column=1).value = course['title']
    ws.cell(row=2, column=0).value = "Assessment:"
    ws.cell(row=2, column=1).value = exam['title']
    ws.cell(row=3, column=0).value = "Group:"
    ws.cell(row=3, column=1).value = group.name

    col = 5
    qcount = 1
    for _ in questions:
        ws.cell(row=4, column=col).value = "Q%s" % qcount
        qcount += 1
        col += 1

    ws.cell(row=4, column=col).value = "Total"

    row = 5
    sortusers = users.keys()
    sortusers.sort(key=lambda us: users[us]['familyname'])

    for user_id in sortusers:
        result = results[user_id]
        ws.cell(row=row, column=0).value = users[user_id]['uname']
        ws.cell(row=row, column=1).value = users[user_id]['student_id']
        ws.cell(row=row, column=2).value = users[user_id]['familyname']
        ws.cell(row=row, column=3).value = users[user_id]['givenname']
        ws.cell(row=row, column=4).value = users[user_id]['email']
        col = 5

        for pos in questions:
            for qt in pos:
                if qt['id'] in result:
                    ws.cell(row=row, column=col).value = result[qt['id']]['score']
                    col += 1

        ws.cell(row=row, column=col).value = totals[user_id]
        row += 1

    return save_virtual_workbook(wb)
开发者ID:tkanesh,项目名称:oasisqe,代码行数:69,代码来源:Spreadsheets.py


注:本文中的oasis.lib.Exams.get_marks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。