本文整理汇总了Python中oasis.lib.Exams.create方法的典型用法代码示例。如果您正苦于以下问题:Python Exams.create方法的具体用法?Python Exams.create怎么用?Python Exams.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oasis.lib.Exams
的用法示例。
在下文中一共展示了Exams.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_assess_create
# 需要导入模块: from oasis.lib import Exams [as 别名]
# 或者: from oasis.lib.Exams import create [as 别名]
def test_assess_create(self):
""" Create an empty assessment"""
course_id = Courses.create("TESTCOURSE5", "unit tests for assessment", 1, 1)
Courses.create_config(course_id, "casual", 1)
Courses.set_active(course_id, True)
Courses.set_prac_vis(course_id, "none")
Courses.set_assess_vis(course_id, "none")
title = "Test Assessment 1"
atype = 2 # assignment
duration = 60
code = "123456"
instant = 1
instructions = "These are the instructions"
astart = datetime.datetime.utcnow()
aend = astart + datetime.timedelta(hours=2)
exam_id = Exams.create(course_id, 1, title, atype, duration, astart,
aend, instructions, code=code, instant=instant)
self.assertGreater(exam_id, 0)
topic1_id = Topics.create(course_id, "TESTASSESS1", 1, 1)
self.assertGreater(topic1_id, 0)
data = open(self.test_question_fname).read()
numread = External.import_qts_from_zip(data, topic1_id)
self.assertEqual(numread, 3)
示例2: exam_edit_submit
# 需要导入模块: from oasis.lib import Exams [as 别名]
# 或者: from oasis.lib.Exams import create [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