本文整理汇总了Python中oasis.lib.DB.create_q方法的典型用法代码示例。如果您正苦于以下问题:Python DB.create_q方法的具体用法?Python DB.create_q怎么用?Python DB.create_q使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oasis.lib.DB
的用法示例。
在下文中一共展示了DB.create_q方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gen_q_from_var
# 需要导入模块: from oasis.lib import DB [as 别名]
# 或者: from oasis.lib.DB import create_q [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