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


Python DB.get_qt_name方法代码示例

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


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

示例1: gen_q_from_var

# 需要导入模块: from oasis.lib import DB [as 别名]
# 或者: from oasis.lib.DB import get_qt_name [as 别名]
def gen_q_from_var(qt_id, student, exam, position, version, variation):
    """ Generate a question given a specific variation. """
    qvars = None
    q_id = DB.create_q(qt_id,
                       DB.get_qt_name(qt_id),
                       student,
                       1,
                       variation,
                       version,
                       exam)
    try:
        q_id = int(q_id)
        assert (q_id > 0)
    except (ValueError, TypeError, AssertionError):
        L.error("OaDB.createQuestion(%s,...) FAILED" % qt_id)
    imageexists = DB.get_q_att_mimetype(qt_id, "image.gif", variation, version)
    if not imageexists:
        if not qvars:
            qvars = DB.get_qt_variation(qt_id, variation, version)
        qvars['Oasis_qid'] = q_id
        image = DB.get_qt_att(qt_id, "image.gif", version)
        if image:
            newimage = gen_q_image(qvars, image)
            DB.create_q_att(qt_id,
                            variation,
                            "image.gif",
                            "image/gif",
                            newimage,
                            version)
    htmlexists = DB.get_q_att_mimetype(qt_id,
                                       "qtemplate.html",
                                       variation,
                                       version)
    if not htmlexists:
        if not qvars:
            qvars = DB.get_qt_variation(qt_id, variation, version)
        html = DB.get_qt_att(qt_id, "qtemplate.html", version)
        if html:
            qvars['Oasis_qid'] = q_id
            newhtml = gen_q_html(qvars, html)
            L.info("generating new qattach qtemplate.html for %s" % q_id)
            DB.create_q_att(qt_id,
                            variation,
                            "qtemplate.html",
                            "application/oasis-html",
                            newhtml,
                            version)
    try:
        q_id = int(q_id)
        assert (q_id > 0)
    except (ValueError, TypeError, AssertionError):
        L.error("generateQuestionFromVar(%s,%s), can't find qid %s? " %
                   (qt_id, student, q_id))
    if exam >= 1:
        DB.add_exam_q(student, exam, q_id, position)
    return q_id
开发者ID:tkanesh,项目名称:oasisqe,代码行数:58,代码来源:General.py

示例2: practice_mark_question

# 需要导入模块: from oasis.lib import DB [as 别名]
# 或者: from oasis.lib.DB import get_qt_name [as 别名]
def practice_mark_question(topic_id, question_id):
    """ Mark the submitted question answersjust wa """
    user_id = session['user_id']

    course_id = Topics.get_course_id(topic_id)
    if not course_id:
        abort(404)

    course = Courses2.get_course(course_id)
    if not course:
        abort(404)

    topictitle = "UNKNOWN"
    try:
        topictitle = Topics.get_name(topic_id)
    except KeyError:
        abort(404)

    qt_id = DB.get_q_parent(question_id)

    q_title = DB.get_qt_name(qt_id)
    questions = Practice.get_sorted_questions(course_id, topic_id, user_id)
    q_pos = DB.get_qtemplate_topic_pos(qt_id, topic_id)

    blocked = Practice.is_q_blocked(user_id, course_id, topic_id, qt_id)
    if blocked:
        return render_template(
            "practicequestionblocked.html",
            mesg=blocked,
            topictitle=topictitle,
            topic_id=topic_id,
            qt_id=qt_id,
            course=course,
            q_title=q_title,
            questions=questions,
            q_pos=q_pos,
        )

    marking = Practice.mark_q(user_id, topic_id, question_id, request)
    prev_id, next_id = Practice.get_next_prev(qt_id, topic_id)

    return render_template(
        "practicemarkquestion.html",
        topictitle=topictitle,
        topic_id=topic_id,
        qt_id=qt_id,
        course=course,
        q_title=q_title,
        questions=questions,
        q_pos=q_pos,
        q_id=question_id,
        marking=marking,
        next_id=next_id,
        prev_id=prev_id
    )
开发者ID:jamesdoherty,项目名称:oasisqe,代码行数:57,代码来源:views_practice.py

示例3: qtlog_as_html

# 需要导入模块: from oasis.lib import DB [as 别名]
# 或者: from oasis.lib.DB import get_qt_name [as 别名]
def qtlog_as_html(topic, qtid):
    """Show the most recent log errors for the given qtid.
    """
    versionre = re.compile(r'version=(\d+),')
    variationre = re.compile(r'variation=(\d+),')
    priorityre = re.compile(r'priority=([^,]+),')
    facilityre = re.compile(r'facility=([^,]+),')
    messagere = re.compile(r'message=(.+)$', re.MULTILINE)

    out = ""
    name = DB.get_qt_name(qtid)
    out += "<h2>Log Entries for %s, topic %s</h2>" % (name, topic)
    out += "<p><i>These can be created from within __marker.py or __results.py by calling "
    out += "log(priority, mesg), for example:</i> "
    out += "<pre>log('error','User entered a value we can't parse.')</pre></p>"
    out += "<p><i>Typical priorities might be 'error', 'info', 'noise'</i></p>"
    out += "<table style='border: solid 1px black;' border='1'><tr><th>Time</th><th>Ver</th>"
    out += "<th>Variation</th><th>Pri</th><th>Fac</th><th>Message</th></tr>"
    entries = Audit.get_records_by_object(qtid, limit=100, offset=0)
    for entry in entries:
        try:
            version = versionre.findall(entry['message'])[0]
        except (IndexError, TypeError):
            version = '.'
        try:
            variation = variationre.findall(entry['message'])[0]
        except (IndexError, TypeError):
            variation = '.'
        try:
            priority = priorityre.findall(entry['message'])[0]
        except (IndexError, TypeError):
            priority = '.'
        try:
            facility = facilityre.findall(entry['message'])[0]
        except (IndexError, TypeError):
            facility = '.'
        try:
            message = messagere.findall(entry['message'])[0]
        except (IndexError, TypeError):
            message = '.'
        out += "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>" % (entry['time'].strftime("%Y/%b/%d %H:%M:%S"), version, variation, priority, facility, message)
    out += "</table>"
    return out
开发者ID:colincoghill,项目名称:oasisqe,代码行数:45,代码来源:QEditor2.py

示例4: do_topic_page_commands

# 需要导入模块: from oasis.lib import DB [as 别名]
# 或者: from oasis.lib.DB import get_qt_name [as 别名]
def do_topic_page_commands(request, topic_id, user_id):
    """We've been asked to perform some operations on the Topic page.

        Expecting form fields:

            selected_QTID
            position_QTID
            name_QTID

        where QTID is a question template id. May receive many.

            new_position
            new_name
            new_type

            select_cmd = 'copy' | 'move'
            select_target = TOPICID of target topic

    """

    form = request.form
    mesg = []

    # Make a list of all the commands to run
    cmdlist = []
    for command in request.form.keys():
        (cmd, data) = command.split('_', 2)
        value = form[command]
        if not value == "none":
            cmdlist += [{'cmd': cmd, 'data': data, 'value': value}]

    # Now run them:
    # Titles first
    for command in [cmd for cmd in cmdlist if cmd['cmd'] == 'name']:
        qid = int(command['data'])
        title = command['value']
        DB.update_qt_title(qid, title)

    # Then positions
    for command in [cmd for cmd in cmdlist if cmd['cmd'] == 'position']:
        qtid = int(command['data'])
        try:
            position = int(command['value'])
        except ValueError:
            position = 0
        DB.update_qt_pos(qtid, topic_id, position)

    # Then commands on selected questions
    target_cmd = form.get('target_cmd', None)
    if target_cmd:
        qtids = [int(cmd['data']) for cmd in cmdlist if cmd['cmd'] == 'select']
        try:
            target_topic = int(form.get('target_topic', 0))
        except ValueError:
            target_topic = None

        if target_cmd == 'move':
            if target_topic:
                for qtid in qtids:
                    qt_title = DB.get_qt_name(qtid)
                    topic_title = Topics.get_name(target_topic)
                    flash("Moving %s to %s" % (qt_title, topic_title))
                    DB.move_qt_to_topic(qtid, target_topic)
                    Topics.flush_num_qs(topic_id)
                    Topics.flush_num_qs(target_topic)
        if target_cmd == 'copy':
            if target_topic:
                for qtid in qtids:
                    qt_title = DB.get_qt_name(qtid)
                    topic_title = Topics.get_name(target_topic)
                    flash("Copying %s to %s" % (qt_title, topic_title))
                    newid = DB.copy_qt_all(qtid)
                    DB.add_qt_to_topic(newid, target_topic)
                    Topics.flush_num_qs(target_topic)

        if target_cmd == 'hide':
            for qtid in qtids:
                position = DB.get_qtemplate_topic_pos(qtid, topic_id)
                if position > 0:  # If visible, make it hidden
                    DB.update_qt_pos(qtid, topic_id, -position)
                    title = DB.get_qt_name(qtid)
                    flash("Made '%s' Hidden" % title)
                    Topics.flush_num_qs(topic_id)

        if target_cmd == 'show':
            for qtid in qtids:
                position = DB.get_qtemplate_topic_pos(qtid, topic_id)
                if position == 0:  # If hidden, make it visible
                    newpos = DB.get_qt_max_pos_in_topic(topic_id)
                    DB.update_qt_pos(qtid, topic_id, newpos + 1)
                    Topics.flush_num_qs(topic_id)
                    title = DB.get_qt_name(qtid)
                    flash("Made '%s' Visible" % title)
                if position < 0:  # If hidden, make it visible
                    DB.update_qt_pos(qtid, topic_id, -position)
                    Topics.flush_num_qs(topic_id)
                    title = DB.get_qt_name(qtid)
                    flash("Made '%s' Visible" % title)
        if target_cmd == "export":
            if len(qtids) < 1:
#.........这里部分代码省略.........
开发者ID:tkanesh,项目名称:oasisqe,代码行数:103,代码来源:Setup.py

示例5: do_topic_page_commands

# 需要导入模块: from oasis.lib import DB [as 别名]
# 或者: from oasis.lib.DB import get_qt_name [as 别名]
def do_topic_page_commands(request, topic_id, user_id):
    """We've been asked to perform some operations on the Topic page.

        Expecting form fields:

            selected_QTID
            position_QTID
            name_QTID

        where QTID is a question template id. May receive many.

            new_position
            new_name
            new_type

            select_cmd = 'copy' | 'move'
            select_target = TOPICID of target topic

    """

    form = request.form
    files = request.files

    mesg = []

    # Make a list of all the commands to run
    cmdlist = []
    for command in request.form.keys():
        if '_' in command:
            (cmd, data) = command.split('_', 2)
            value = form[command]
            if not value == "none":
                cmdlist += [{'cmd': cmd, 'data': data, 'value': value}]

    # Now run them:
    # Titles first
    for command in [cmd for cmd in cmdlist if cmd['cmd'] == 'name']:
        qid = int(command['data'])
        title = command['value']
        DB.update_qt_title(qid, title)

    # Then positions
    for command in [cmd for cmd in cmdlist if cmd['cmd'] == 'position']:
        qtid = int(command['data'])
        try:
            position = int(command['value'])
        except ValueError:
            position = 0
        DB.update_qt_practice_pos(qtid, position)

    # Then commands on selected questions
    target_cmd = form.get('target_cmd', None)
    if target_cmd:
        qtids = [int(cmd['data']) for cmd in cmdlist if cmd['cmd'] == 'select']
        try:
            target_topic = int(form.get('target_topic', 0))
        except ValueError:
            target_topic = None

        if target_cmd == 'move':
            if target_topic:
                for qtid in qtids:
                    qt_title = DB.get_qt_name(qtid)
                    topic_title = Topics.get_name(target_topic)
                    flash("Moving %s to %s" % (qt_title, topic_title))
                    DB.move_qt_to_topic(qtid, target_topic)
                    Topics.flush_num_qs(target_topic)
        if target_cmd == 'copy':
            if target_topic:
                for qtid in qtids:
                    qt_title = DB.get_qt_name(qtid)
                    topic_title = Topics.get_name(target_topic)
                    flash("Copying %s to %s" % (qt_title, topic_title))
                    position = DB.get_qtemplate_practice_pos(qtid)
                    newid = DB.copy_qt_all(qtid)
                    DB.move_qt_to_topic(newid, target_topic, position)
                    Topics.flush_num_qs(target_topic)

        if target_cmd == 'hide':
            for qtid in qtids:
                position = DB.get_qtemplate_practice_pos(qtid)
                if position > 0:  # If visible, make it hidden
                    DB.update_qt_practice_pos(qtid, -position)
                    title = DB.get_qt_name(qtid)
                    flash("Made '%s' Hidden" % title)

        if target_cmd == 'show':
            for qtid in qtids:
                position = DB.get_qtemplate_practice_pos(qtid)
                if position == 0:  # If hidden, make it visible
                    newpos = DB.get_qt_max_pos_in_topic(topic_id)
                    DB.update_qt_practice_pos(qtid, newpos + 1)
                    title = DB.get_qt_name(qtid)
                    flash("Made '%s' Visible" % title)
                if position < 0:  # If hidden, make it visible
                    DB.update_qt_practice_pos(qtid, -position)
                    title = DB.get_qt_name(qtid)
                    flash("Made '%s' Visible" % title)
        if target_cmd == "export":
            if len(qtids) < 1:
#.........这里部分代码省略.........
开发者ID:colincoghill,项目名称:oasisqe,代码行数:103,代码来源:Setup.py


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