本文整理汇总了Python中oasis.lib.General.gen_q方法的典型用法代码示例。如果您正苦于以下问题:Python General.gen_q方法的具体用法?Python General.gen_q怎么用?Python General.gen_q使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oasis.lib.General
的用法示例。
在下文中一共展示了General.gen_q方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_do_question
# 需要导入模块: from oasis.lib import General [as 别名]
# 或者: from oasis.lib.General import gen_q [as 别名]
def test_do_question(self):
""" Do a question"""
course_id = Courses.create("TEST102", "Test question logic", 1, 1)
self.assertGreater(course_id, 0)
topic1_id = Topics.create(course_id, "TESTQUESTIONS1", 1, 2)
self.assertGreater(topic1_id, 0)
qt1_id = DB.create_qt(1, "TESTQ9", "Test question 9", 0, 5.0, 1, topic_id=topic1_id)
self.assertIsNotNone(qt1_id)
ver = DB.get_qt_version(qt1_id)
self.assertGreater(ver, 0)
data = "2\n|1\n|2\n"
qvars = [{'A1': "2"}, {'A1': "3"}]
for row in range(0, len(qvars)):
DB.add_qt_variation(qt1_id, row + 1, qvars[row], ver)
DB.create_qt_att(qt1_id, "datfile.dat", "text/plain", data , ver)
DB.create_qt_att(qt1_id, "qtemplate.html", "text/html", "What is <VAL A1>? <ANSWER 1>", ver)
q_id = DB.get_q_by_qt_student(qt1_id, 1)
self.assertFalse(q_id) # Not generated yet
q_id = General.gen_q(qt1_id, 1)
self.assertGreater(q_id, 0)
q_id = DB.get_q_by_qt_student(qt1_id, 1)
self.assertTrue(qt1_id) # Better be there now
DB.update_qt_maxscore(qt1_id, 7.0)
score = DB.get_qt_maxscore(qt1_id)
self.assertEqual(score, 7.0)
DB.set_q_viewtime(q_id)
self.assertIsNotNone(DB.get_q_viewtime(q_id))
示例2: get_practice_q
# 需要导入模块: from oasis.lib import General [as 别名]
# 或者: from oasis.lib.General import gen_q [as 别名]
def get_practice_q(qt_id, user_id):
""" Find an existing, or create a new, practice question
for the given user."""
try:
qt_id = int(qt_id)
assert qt_id > 0
except (ValueError, TypeError, AssertionError):
L.warn("Called with bad qtid %s?" % qt_id)
qid = DB.get_q_by_qt_student(qt_id, user_id)
if qid is not False:
return int(qid)
qid = General.gen_q(qt_id, user_id)
try:
qid = int(qid)
except (ValueError, TypeError):
L.warn("generateQuestion(%s,%s) Fail: returned %s" % (qt_id, user_id, qid))
else:
DB.set_q_viewtime(qid)
return qid