本文整理汇总了Python中oasis.lib.DB.get_qt_editor方法的典型用法代码示例。如果您正苦于以下问题:Python DB.get_qt_editor方法的具体用法?Python DB.get_qt_editor怎么用?Python DB.get_qt_editor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oasis.lib.DB
的用法示例。
在下文中一共展示了DB.get_qt_editor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cadmin_edit_topic
# 需要导入模块: from oasis.lib import DB [as 别名]
# 或者: from oasis.lib.DB import get_qt_editor [as 别名]
def cadmin_edit_topic(course_id, topic_id):
""" Present a page to view and edit a topic, including adding/editing
questions and setting some parameters.
"""
user_id = session['user_id']
if not course_id:
abort(404)
course = Courses2.get_course(course_id)
topic = {
'id': topic_id,
'position': Topics.get_pos(topic_id),
'name': Topics.get_name(topic_id)
}
questions = [question
for question in Topics.get_qts(topic_id).values()]
for question in questions:
question['embed_id'] = DB.get_qt_embedid(question['id'])
if question['embed_id']:
question['embed_url'] = "%s/embed/question/%s/question.html" % \
(OaConfig.parentURL, question['embed_id'])
else:
question['embed_url'] = None
question['editor'] = DB.get_qt_editor(question['id'])
all_courses = Courses2.get_course_list()
all_courses = [crse
for crse in all_courses
if satisfy_perms(user_id, int(crse['id']),
("questionedit", "courseadmin",
"sysadmin"))]
all_courses.sort(lambda f, s: cmp(f['name'], s['name']))
all_course_topics = []
for crse in all_courses:
topics = Courses.get_topics_all(crse['id'], numq=False)
if topics:
all_course_topics.append({'course': crse['name'], 'topics': topics})
questions.sort(key=lambda k: k['position'])
return render_template(
"courseadmin_edittopic.html",
course=course,
topic=topic,
questions=questions,
all_course_topics=all_course_topics
)
示例2: cadmin_view_topic
# 需要导入模块: from oasis.lib import DB [as 别名]
# 或者: from oasis.lib.DB import get_qt_editor [as 别名]
def cadmin_view_topic(course_id, topic_id):
""" Present a page to view a topic, including basic stats """
user_id = session["user_id"]
if not course_id:
abort(404)
course = Courses2.get_course(course_id)
topic = {"id": topic_id, "position": Topics.get_pos(topic_id), "name": Topics.get_name(topic_id)}
questions = [question for question in Topics.get_qts(topic_id).values()]
for question in questions:
question["embed_id"] = DB.get_qt_embedid(question["id"])
if question["embed_id"]:
question["embed_url"] = "%s/embed/question/%s/question.html" % (OaConfig.parentURL, question["embed_id"])
else:
question["embed_url"] = None
question["editor"] = DB.get_qt_editor(question["id"])
all_courses = Courses2.get_course_list()
all_courses = [
crse
for crse in all_courses
if satisfy_perms(user_id, int(crse["id"]), ("questionedit", "courseadmin", "sysadmin"))
]
all_courses.sort(lambda f, s: cmp(f["name"], s["name"]))
all_course_topics = []
for crse in all_courses:
topics = Courses.get_topics_all(crse["id"], numq=False)
if topics:
all_course_topics.append({"course": crse["name"], "topics": topics})
questions.sort(key=lambda k: k["position"])
return render_template(
"courseadmin_viewtopic.html",
course=course,
topic=topic,
questions=questions,
all_course_topics=all_course_topics,
)