本文整理汇总了Python中oasis.lib.Courses.get_groups方法的典型用法代码示例。如果您正苦于以下问题:Python Courses.get_groups方法的具体用法?Python Courses.get_groups怎么用?Python Courses.get_groups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oasis.lib.Courses
的用法示例。
在下文中一共展示了Courses.get_groups方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_course_config
# 需要导入模块: from oasis.lib import Courses [as 别名]
# 或者: from oasis.lib.Courses import get_groups [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(), [])
示例2: cadmin_top
# 需要导入模块: from oasis.lib import Courses [as 别名]
# 或者: from oasis.lib.Courses import get_groups [as 别名]
def cadmin_top(course_id):
""" Present top level course admin page """
course = Courses2.get_course(course_id)
if not course:
abort(404)
user_id = session['user_id']
is_sysadmin = check_perm(user_id, -1, 'sysadmin')
topics = Courses2.get_topics_list(course_id)
exams = [Exams.get_exam_struct(exam_id, course_id)
for exam_id in Courses.get_exams(course_id, prev_years=False)]
exams.sort(key=lambda y: y['start_epoch'], reverse=True)
groups = Courses.get_groups(course_id)
choosegroups = [group
for group in Groups.all_groups()
if group.id not in groups]
return render_template(
"courseadmin_top.html",
course=course,
topics=topics,
exams=exams,
choosegroups=choosegroups,
groups=groups,
is_sysadmin=is_sysadmin
)
示例3: admin_course_save
# 需要导入模块: from oasis.lib import Courses [as 别名]
# 或者: from oasis.lib.Courses import get_groups [as 别名]
def admin_course_save(course_id):
""" accept saved settings """
form = request.form
cancel_edit = form.get("cancel_edit", False)
if cancel_edit:
flash("Course edits cancelled")
return redirect(url_for("admin_courses"))
changed = False
course = Courses2.get_course(course_id)
groups = Courses.get_groups(course_id)
for g_id, group in groups.iteritems():
if form.get('delgroup_%s' % g_id):
changed = True
flash("Removing group %s" % group.name, "info")
Courses.del_group(int(g_id), course_id)
if 'course_name' in form:
name = form['course_name']
if not name == course['name']:
changed = True
Courses.set_name(course_id, name)
if 'course_title' in form:
title = form['course_title']
if not title == course['title']:
changed = True
Courses.set_title(course_id, title)
if 'course_active' in form:
active = form['course_active']
if active == '1' or active == 1:
active = True
else:
active = False
if not (active == course['active']):
changed = True
Courses.set_active(course_id, active)
addbtn = form.get('group_addbtn')
if addbtn:
newgroup = form.get('addgroup', None)
if newgroup:
Courses.add_group(newgroup, course_id)
changed = True
group = Groups.Group(newgroup)
flash("Group %s added." % group.name)
if changed:
Courses2.reload_if_needed()
flash("Course changes saved!")
return redirect(url_for("admin_course", course_id=course_id))
course = Courses2.get_course(course_id)
course['size'] = len(Courses.get_users(course_id))
return redirect(url_for("admin_courses"))
示例4: admin_course
# 需要导入模块: from oasis.lib import Courses [as 别名]
# 或者: from oasis.lib.Courses import get_groups [as 别名]
def admin_course(course_id):
""" Present page to administer settings for a given course"""
course = Courses2.get_course(course_id)
course['size'] = len(Courses.get_users(course_id))
groups = Courses.get_groups(course_id)
choosegroups = [group
for g_id, group in Groups.enrolment_groups().iteritems()
if not g_id in groups]
return render_template(
"cadmin_course.html",
course=course,
groups=groups,
choosegroups=choosegroups
)
示例5: cadmin_config
# 需要导入模块: from oasis.lib import Courses [as 别名]
# 或者: from oasis.lib.Courses import get_groups [as 别名]
def cadmin_config(course_id):
""" Allow some course configuration """
course = Courses2.get_course(course_id)
if not course:
abort(404)
user_id = session["user_id"]
is_sysadmin = check_perm(user_id, -1, "sysadmin")
coords = [
Users2.get_user(perm[0]) for perm in Permissions.get_course_perms(course_id) if perm[1] == 3
] # course_coord
groups = Courses.get_groups(course_id)
choosegroups = [group for group in Groups.all_groups() if not group.id in groups]
return render_template(
"courseadmin_config.html",
course=course,
coords=coords,
choosegroups=choosegroups,
groups=groups,
is_sysadmin=is_sysadmin,
)