本文整理汇总了Python中oasis.lib.DB.update_exam_qt_in_pos方法的典型用法代码示例。如果您正苦于以下问题:Python DB.update_exam_qt_in_pos方法的具体用法?Python DB.update_exam_qt_in_pos怎么用?Python DB.update_exam_qt_in_pos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oasis.lib.DB
的用法示例。
在下文中一共展示了DB.update_exam_qt_in_pos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exam_edit_submit
# 需要导入模块: from oasis.lib import DB [as 别名]
# 或者: from oasis.lib.DB import update_exam_qt_in_pos [as 别名]
def exam_edit_submit(request, user_id, cid, exam_id):
""" Accept the submitted exam edit/create form.
If exam_id is not provided, create a new one.
"""
# TODO: More validation. Currently we trust the client validation,
# although the user is authenticated staff so probably not too high a
# risk of shenanigans.
title = str(request.form['assess_title'])
atype = int(request.form['assess_type'])
startdate = request.form['startdate']
starthour = int(request.form['examstart_hour'])
startmin = int(request.form['examstart_minute'])
enddate = request.form['enddate']
endhour = int(request.form['examend_hour'])
endmin = int(request.form['examend_minute'])
duration = int(request.form['duration'])
code = request.form['assess_code']
instant = int(request.form['assess_instant'])
if "instructions" in request.form:
instructions = request.form['instructions']
else:
instructions = ""
astart = datetime.datetime.strptime(startdate, "%a %d %b %Y")
astart = astart.replace(hour=starthour, minute=startmin)
aend = datetime.datetime.strptime(enddate, "%a %d %b %Y")
aend = aend.replace(hour=endhour, minute=endmin)
qns = {}
for k in request.form.keys():
v = request.form.getlist(k)
if k.startswith("question_"):
_, q, p = k.split("_")
if not q in qns:
qns[q] = []
if not v[0] == '---':
qns[q].append(int(v[0]))
if not exam_id:
exam_id = Exams.create(cid, user_id, title, atype, duration, astart,
aend, instructions, code=code, instant=instant)
else: # update
Exams.set_title(exam_id, title)
Exams.set_duration(exam_id, duration)
Exams.set_type(exam_id, atype)
Exams.set_description(exam_id, instructions)
Exams.set_start_time(exam_id, astart)
Exams.set_end_time(exam_id, aend)
Exams.set_code(exam_id, code)
Exams.set_instant(exam_id, instant)
for pos, qts in qns.iteritems():
if pos:
DB.update_exam_qt_in_pos(exam_id, int(pos), qts)
return exam_id