本文整理汇总了Python中oasis.lib.Courses.create_config方法的典型用法代码示例。如果您正苦于以下问题:Python Courses.create_config方法的具体用法?Python Courses.create_config怎么用?Python Courses.create_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oasis.lib.Courses
的用法示例。
在下文中一共展示了Courses.create_config方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_assess_create
# 需要导入模块: from oasis.lib import Courses [as 别名]
# 或者: from oasis.lib.Courses import create_config [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 create_config [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_add_course_save
# 需要导入模块: from oasis.lib import Courses [as 别名]
# 或者: from oasis.lib.Courses import create_config [as 别名]
def cadmin_add_course_save():
""" accept saved settings for a new course"""
user_id = session["user_id"]
form = request.form
if "cancel_edit" in form:
flash("Course creation cancelled")
return redirect(url_for("setup_courses"))
if not "save_changes" in form:
abort(400)
if not "name" in form:
flash("You must give the course a name!")
return redirect(url_for("cadmin_add_course"))
if not "title" in form:
flash("You must give the course a title!")
return redirect(url_for("cadmin_add_course"))
name = form.get("name", "")
title = form.get("title", "")
coursetemplate = form.get("coursetemplate", "casual")
courserepeat = form.get("courserepeat", "eternal")
course = {"name": name, "title": title, "coursetemplate": coursetemplate, "courserepeat": courserepeat}
if len(name) < 1:
flash("You must give the course a name!")
return render_template("cadmin_add_course.html", course=course)
existing = Courses.get_course_by_name(name)
if existing:
flash("There is already a course called %(name)s" % existing)
return render_template("cadmin_add_course.html", course=course)
if len(title) < 1:
flash("You must give the course a title!")
return render_template("cadmin_add_course.html", course=course)
course_id = Courses.create(name, title, user_id, 1)
if not course_id:
flash("Error Adding Course!")
return render_template("cadmin_add_course.html", course=course)
Courses.create_config(course_id, coursetemplate, int(courserepeat))
flash("Course %s added!" % name)
return redirect(url_for("cadmin_top", course_id=course_id))
示例4: test_course_config
# 需要导入模块: from oasis.lib import Courses [as 别名]
# 或者: from oasis.lib.Courses import create_config [as 别名]
def test_course_config(self):
""" Test course configuration templates
"""
course1_id = Courses.create("TEMPL01", "Test course templates", 1, 1)
period = Periods.Period(name="TEMPL01",
title="Template 01",
start=datetime.datetime.now(),
finish=datetime.datetime.now(),
code="TMPL1"
)
period.save()
period2 = Periods.Period(code="TMPL1")
Courses.create_config(course1_id, "large", period2.id)
groups = Courses.get_groups(course1_id)
self.assertEqual(len(groups), 1)
course2_id = Courses.create("TEMPL02", "Test course standard", 1, 1)
Courses.create_config(course2_id, "standard", period2.id)
groups = Courses.get_groups(course2_id)
self.assertEqual(len(groups), 2)
course3_id = Courses.create("TEMPL03", "Test course demo", 1, 1)
Courses.create_config(course3_id, "demo", period2.id)
groups = Courses.get_groups(course3_id)
self.assertEqual(len(groups), 3)
self.assertListEqual(groups.keys(), [4, 5, 6])
self.assertEqual(groups[4].members(), [])
self.assertEqual(groups[5].members(), [])
self.assertEqual(groups[6].members(), [])
groups[4].add_member(1)
self.assertEqual(groups[4].members(), [1])
self.assertEqual(groups[5].members(), [])
self.assertEqual(groups[6].members(), [])
groups[4].add_member(1)
groups[5].add_member(1)
self.assertEqual(groups[4].members(), [1])
self.assertEqual(groups[5].members(), [1])
groups[4].remove_member(1)
self.assertEqual(groups[4].members(), [])
self.assertEqual(groups[5].members(), [1])
self.assertListEqual(groups[4].member_unames(), [])
self.assertListEqual(groups[5].member_unames(), ["admin"])
self.assertEqual(groups[4].size(), 0)
self.assertEqual(groups[5].size(), 1)
groups[5].flush_members()
self.assertEqual(groups[5].members(), [])
示例5: test_practice_course_list
# 需要导入模块: from oasis.lib import Courses [as 别名]
# 或者: from oasis.lib.Courses import create_config [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)
示例6: cadmin_add_course_save
# 需要导入模块: from oasis.lib import Courses [as 别名]
# 或者: from oasis.lib.Courses import create_config [as 别名]
def cadmin_add_course_save():
""" accept saved settings for a new course"""
user_id = session['user_id']
form = request.form
if 'cancel_edit' in form:
flash("Course creation cancelled")
return redirect(url_for("setup_courses"))
if 'save_changes' not in form:
abort(400)
if 'name' not in form:
flash("You must give the course a name!")
return redirect(url_for("cadmin_add_course"))
if 'title' not in form:
flash("You must give the course a title!")
return redirect(url_for("cadmin_add_course"))
name = form.get('name', '')
title = form.get('title', '')
coursetemplate = form.get('coursetemplate', 'casual')
courserepeat = form.get('courserepeat', 1)
course = {
'name': name,
'title': title,
'coursetemplate': coursetemplate,
'courserepeat': courserepeat
}
if len(name) < 1:
flash("You must give the course a name!")
return render_template(
"cadmin_add_course.html",
course=course
)
existing = Courses.get_course_by_name(name)
if existing:
flash("There is already a course called %(name)s" % existing)
return render_template(
"cadmin_add_course.html",
course=course
)
if len(title) < 1:
flash("You must give the course a title!")
return render_template(
"cadmin_add_course.html",
course=course
)
course_id = Courses.create(name, title, user_id, 1)
if not course_id:
flash("Error Adding Course!")
return render_template(
"cadmin_add_course.html",
course=course
)
Courses.create_config(course_id, coursetemplate, int(courserepeat))
flash("Course %s added!" % name)
return redirect(url_for("cadmin_top", course_id=course_id))