本文整理汇总了Python中oasis.lib.Courses.set_prac_vis方法的典型用法代码示例。如果您正苦于以下问题:Python Courses.set_prac_vis方法的具体用法?Python Courses.set_prac_vis怎么用?Python Courses.set_prac_vis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oasis.lib.Courses
的用法示例。
在下文中一共展示了Courses.set_prac_vis方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_assess_create
# 需要导入模块: from oasis.lib import Courses [as 别名]
# 或者: from oasis.lib.Courses import set_prac_vis [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: test_practice_topic_list
# 需要导入模块: from oasis.lib import Courses [as 别名]
# 或者: from oasis.lib.Courses import set_prac_vis [as 别名]
def test_practice_topic_list(self):
with self.app.test_client() as c:
self.login(ADMIN_UNAME, self.adminpass, client=c)
s = c.get('/practice/top', follow_redirects=True)
self.assertEqual(s.status, "200 OK")
self.assertIn("Choose A Course", s.data)
self.assertNotIn("TESTCOURSE10", s.data)
course_id = Courses.create("TESTCOURSE10", "unit tests", 1, 1)
Courses.create_config(course_id, "casual", 1)
Courses.set_active(course_id, True)
Courses.set_prac_vis(course_id, "all")
s = c.get('/practice/top', follow_redirects=True)
self.assertEqual(s.status, "200 OK")
self.assertIn("Choose A Course", s.data)
self.assertIn("TESTCOURSE10", s.data)
s = c.get('/practice/coursequestions/%s' % course_id)
self.assertIn("<h2>TESTCOURSE10 (unit tests)</h2>", s.data)
self.assertIn("Select a Topic", s.data)
示例3: cadmin_config_submit
# 需要导入模块: from oasis.lib import Courses [as 别名]
# 或者: from oasis.lib.Courses import set_prac_vis [as 别名]
def cadmin_config_submit(course_id):
""" Allow some course configuration """
course = Courses2.get_course(course_id)
if not course:
abort(404)
form = request.form
if "cancel" in form:
flash("Cancelled edit")
return redirect(url_for("cadmin_top", course_id=course_id))
saved = False
new_name = form.get('name', course['name'])
existing = Courses.get_course_by_name(new_name)
if not new_name == course['name']:
if not (3 <= len(new_name) <= 20):
flash("Course Name must be between 3 and 20 characters.")
elif existing:
flash("There is already a course called %(name)s" % existing)
else:
Courses.set_name(course['id'], new_name)
saved = True
new_title = form.get('title', course['title'])
if not new_title == course['title']:
if not (3 <= len(new_title) <= 100):
flash("Course Title must be between 3 and 100 characters.")
else:
Courses.set_title(course['id'], new_title)
saved = True
practice_visibility = form.get('practice_visibility',
course['practice_visibility'])
if not (practice_visibility == course['practice_visibility']):
saved = True
Courses.set_prac_vis(course_id, practice_visibility)
if saved:
flash("Changes Saved")
else:
flash("No changes made.")
return redirect(url_for("cadmin_config", course_id=course_id))
示例4: test_practice_course_list
# 需要导入模块: from oasis.lib import Courses [as 别名]
# 或者: from oasis.lib.Courses import set_prac_vis [as 别名]
def test_practice_course_list(self):
""" Check the list of courses is reasonably ok
:return:
"""
with self.app.test_client() as c:
self.login(ADMIN_UNAME, self.adminpass, client=c)
s = c.get('/practice/top', follow_redirects=True)
self.assertEqual(s.status, "200 OK")
self.assertIn("Choose A Course", s.data)
self.assertNotIn("TESTCOURSE1", s.data)
# create a course, set it visible, is it there?
course_id = Courses.create("TESTCOURSE1", "unit tests", 1, 1)
Courses.create_config(course_id, "casual", 1)
Courses.set_active(course_id, True)
Courses.set_prac_vis(course_id, "all")
s = c.get('/practice/top', follow_redirects=True)
self.assertEqual(s.status, "200 OK")
self.assertIn("Choose A Course", s.data)
self.assertIn("TESTCOURSE1", s.data)
self.assertNotIn("TESTCOURSE2", s.data)
# create a second course, set it visible, is it there?
course_id = Courses.create("TESTCOURSE2", "unit tests", 1, 1)
Courses.create_config(course_id, "casual", 1)
Courses.set_active(course_id, True)
Courses.set_prac_vis(course_id, "all")
s = c.get('/practice/top', follow_redirects=True)
self.assertEqual(s.status, "200 OK")
self.assertIn("Choose A Course", s.data)
self.assertIn("TESTCOURSE1", s.data)
self.assertIn("TESTCOURSE2", s.data)
# create a third course, set it not visible
course_id = Courses.create("TESTCOURSE3", "unit tests", 1, 1)
Courses.create_config(course_id, "casual", 1)
Courses.set_active(course_id, True)
Courses.set_prac_vis(course_id, "none")
s = c.get('/practice/top', follow_redirects=True)
self.assertEqual(s.status, "200 OK")
self.assertIn("Choose A Course", s.data)
self.assertIn("TESTCOURSE1", s.data)
self.assertIn("TESTCOURSE2", s.data)
# admin can still see it
self.assertIn("TESTCOURSE3", s.data)