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


Python General.render_mark_results方法代码示例

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


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

示例1: mark_q

# 需要导入模块: from oasis.lib import General [as 别名]
# 或者: from oasis.lib.General import render_mark_results [as 别名]
def mark_q(user_id, topic_id, q_id, request):
    """Mark the question and return the results"""
    answers = {}
    for i in request.form.keys():
        part = re.search(r"^Q_(\d+)_ANS_(\d+)$", i)
        if part:
            newqid = int(part.groups()[0])
            part = int(part.groups()[1])
            if newqid == q_id:
                value = request.form[i]
                answers["G%d" % part] = value
                DB.save_guess(newqid, part, value)
            else:
                L.warn("received guess for wrong question? (%d,%d,%d,%s)" %
                       (user_id, topic_id, q_id, request.form))
    try:
        marks = General.mark_q(q_id, answers)
        DB.set_q_status(q_id, 3)    # 3 = marked
        DB.set_q_marktime(q_id)
    except OaMarkerError:
        L.warn("Marker Error - (%d, %d, %d, %s)" %
               (user_id, topic_id, q_id, request.form))
        marks = {}
    q_body = General.render_mark_results(q_id, marks)
    parts = [int(var[1:])
             for var in marks.keys()
             if re.search(r"^A([0-9]+)$", var) > 0]
    parts.sort()
    total = 0.0
    for part in parts:
        if 'M%d' % (part,) in marks:
            total += float(marks['M%d' % (part,)])
    DB.update_q_score(q_id, total)    # 3 = marked
    DB.set_q_status(q_id, 2)
    return q_body
开发者ID:colincoghill,项目名称:oasisqe,代码行数:37,代码来源:Practice.py

示例2: mark_q

# 需要导入模块: from oasis.lib import General [as 别名]
# 或者: from oasis.lib.General import render_mark_results [as 别名]
def mark_q(user_id, qtid, request):
    """Mark the question and show a page containing marking results."""

    if "OaQID" in request.form:
        qid = int(request.form["OaQID"])
    else:
        qid = None

    out = u""
    answers = {}
    for i in request.form.keys():
        part = re.search(r"^Q_(\d+)_ANS_(\d+)$", i)
        if part:
            newqid = int(part.groups()[0])
            part = int(part.groups()[1])

            value = request.form[i]
            answers["G%d" % part] = value
            DB.save_guess(newqid, part, value)

    if qid:
        try:
            marks = General.mark_q(qid, answers)
            DB.set_q_status(qid, 3)    # 3 = marked
            DB.set_q_marktime(qid)
        except OaMarkerError:
            log(INFO,
                "getMarkQuestionPage(%d, %d, %s) Marker ERROR" %
                (user_id, qtid, request.form))
            marks = {}

        out += General.render_mark_results(qid, marks)
        parts = [int(var[1:])
                 for var in marks.keys()
                 if re.search("^A([0-9]+)$", var) > 0]
        parts.sort()
        total = 0.0
        for part in parts:
            if marks.has_key('M%d' % (part,)):
                total += float(marks['M%d' % (part,)])

    return out
开发者ID:jamesdoherty,项目名称:oasisqe,代码行数:44,代码来源:Embed.py


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