本文整理汇总了Python中oasis.lib.DB.get_student_q_practice_num方法的典型用法代码示例。如果您正苦于以下问题:Python DB.get_student_q_practice_num方法的具体用法?Python DB.get_student_q_practice_num怎么用?Python DB.get_student_q_practice_num使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oasis.lib.DB
的用法示例。
在下文中一共展示了DB.get_student_q_practice_num方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_q_list
# 需要导入模块: from oasis.lib import DB [as 别名]
# 或者: from oasis.lib.DB import get_student_q_practice_num [as 别名]
def get_q_list(tid, uid=None, numdone=True):
""" Return a list of dicts with question template information for the topic.
[{ qtid: int QTemplate ID
name: string Name of Question
position: int Position of Question in topic
done: Number of times the given user has submitted a question
for practice
},]
"""
qlist = []
qtemplates = Topics.get_qts(int(tid))
for qtid in qtemplates:
if uid and numdone:
num = DB.get_student_q_practice_num(uid, qtid)
else:
num = 0
qlist.append({'qtid': qtid,
'name': qtemplates[qtid]['name'],
'position': qtemplates[qtid]['position'],
'done': num})
# Sort them by position
qlist.sort(lambda f, s: cmp(f["position"], s["position"]))
return qlist