本文整理汇总了Python中oasis.lib.Topics.get_topic方法的典型用法代码示例。如果您正苦于以下问题:Python Topics.get_topic方法的具体用法?Python Topics.get_topic怎么用?Python Topics.get_topic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oasis.lib.Topics
的用法示例。
在下文中一共展示了Topics.get_topic方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_topic
# 需要导入模块: from oasis.lib import Topics [as 别名]
# 或者: from oasis.lib.Topics import get_topic [as 别名]
def test_create_topic(self):
""" Fetch a topic back and check it
"""
course_id = Courses.create("TEST101", "Test topic position logic", 1, 1)
self.assertDictContainsSubset(
{course_id:
{'active': 1,
'assess_visibility': 'enrol',
'id': course_id,
'name': 'TEST101',
'owner': 1,
'practice_visibility': 'all',
'title': 'Test topic position logic',
'type': 1
}
},
Courses.get_courses_dict(),
)
topic1_id = Topics.create(course_id, "TESTTOPIC1", 1, 2)
topic2_id = Topics.create(course_id, "TESTTOPIC2", 3, 3)
self.assertGreater(topic1_id, 0)
self.assertIsInstance(topic1_id, int)
self.assertGreater(topic2_id, 0)
self.assertIsInstance(topic2_id, int)
self.assertNotEqual(topic1_id, topic2_id)
topic1 = Topics.get_topic(topic1_id)
topic2 = Topics.get_topic(topic2_id)
self.assertEqual(topic1['id'], topic1_id)
self.assertEqual(topic2['id'], topic2_id)
self.assertEqual(topic1['title'], "TESTTOPIC1")
self.assertEqual(topic2['title'], "TESTTOPIC2")
self.assertEqual(topic1['visibility'], 1)
self.assertEqual(topic2['visibility'], 3)
self.assertEqual(Topics.get_name(topic1_id), topic1['title'])
Topics.set_name(topic1_id, "NEWNAME1")
self.assertEqual(Topics.get_name(topic1_id), "NEWNAME1")
self.assertEqual(Topics.get_num_qs(topic1_id), 0)
self.assertEqual(Topics.get_pos(topic1_id), 2)
Topics.set_pos(topic1_id, 8)
self.assertEqual(Topics.get_pos(topic1_id), 8)
示例2: topic_to_zip
# 需要导入模块: from oasis.lib import Topics [as 别名]
# 或者: from oasis.lib.Topics import get_topic [as 别名]
def topic_to_zip(topic_id):
"""
:param topic_id: ID of the topic to export
:return: binary string containing ZIPped data
"""
topic = Topics.get_topic(topic_id)
qts = Topics.get_qts(topic_id)
return qts_to_zip(qts, extra_info={'topic': topic})
示例3: topic_to_zip
# 需要导入模块: from oasis.lib import Topics [as 别名]
# 或者: from oasis.lib.Topics import get_topic [as 别名]
def topic_to_zip(topic_id, fname='oa_export', suffix='oaq'):
"""
:param topic_id: ID of the topic to export
:param fname: filename to create
:param suffix: suffix
:return: binary string containing ZIPped data
"""
topic = Topics.get_topic(topic_id)
qts = Topics.get_qts(topic_id)
return qts_to_zip(qts, fname=fname, extra_info={'topic': topic})
示例4: practice_choose_question
# 需要导入模块: from oasis.lib import Topics [as 别名]
# 或者: from oasis.lib.Topics import get_topic [as 别名]
def practice_choose_question(topic_id):
""" Present a list of questions for them to choose from the given topic """
user_id = session['user_id']
try:
course_id = Topics.get_course_id(topic_id)
except KeyError:
course_id = None
abort(404)
topics = []
try:
topics = Courses2.get_topics_list(course_id)
except KeyError:
abort(404)
try:
course = Courses2.get_course(course_id)
except KeyError:
course = None
abort(404)
topictitle = Topics.get_name(topic_id)
questions = Practice.get_sorted_questions(course_id, topic_id, user_id)
thistopic = Topics.get_topic(topic_id)
members = []
if thistopic['visibility'] == 2: # course only
if not members:
members = Courses.get_users(course_id)
if not user_id in members:
abort(404)
for topic in topics:
if topic['visibility'] == 2: # course only
if not members:
members = Courses.get_users(course_id)
if not user_id in members:
topics.remove(topic)
return render_template(
"practicetopic.html",
canpreview=check_perm(user_id, course_id, "questionpreview"),
topics=topics,
topic_id=topic_id,
course=course,
topictitle=topictitle,
questions=questions
)