Use cohort settings from CourseCohortSettings.

TNL-1258
This commit is contained in:
Usman Khalid
2015-02-21 20:06:59 +05:00
parent b56e123350
commit d59be9949e
16 changed files with 227 additions and 131 deletions

View File

@@ -71,12 +71,9 @@ def _cohort_membership_changed(sender, **kwargs):
tracker.emit(event_name, event)
# A 'default cohort' is an auto-cohort that is automatically created for a course if no auto_cohort_groups have been
# specified. It is intended to be used in a cohorted-course for users who have yet to be assigned to a cohort.
# Note 1: If an administrator chooses to configure a cohort with the same name, the said cohort will be used as
# the "default cohort".
# Note 2: If auto_cohort_groups are configured after the 'default cohort' has been created and populated, the
# stagnant 'default cohort' will still remain (now as a manual cohort) with its previously assigned students.
# A 'default cohort' is an auto-cohort that is automatically created for a course if no cohort with automatic
# assignment have been specified. It is intended to be used in a cohorted-course for users who have yet to be assigned
# to a cohort.
# Translation Note: We are NOT translating this string since it is the constant identifier for the "default group"
# and needed across product boundaries.
DEFAULT_COHORT_NAME = "Default Group"
@@ -110,7 +107,7 @@ def is_course_cohorted(course_key):
Raises:
Http404 if the course doesn't exist.
"""
return courses.get_course_by_id(course_key).is_cohorted
return get_course_cohort_settings(course_key).is_cohorted
def get_cohort_id(user, course_key):
@@ -135,18 +132,19 @@ def is_commentable_cohorted(course_key, commentable_id):
Http404 if the course doesn't exist.
"""
course = courses.get_course_by_id(course_key)
course_cohort_settings = get_course_cohort_settings(course_key)
if not course.is_cohorted:
if not course_cohort_settings.is_cohorted:
# this is the easy case :)
ans = False
elif (
commentable_id in course.top_level_discussion_topic_ids or
course.always_cohort_inline_discussions is False
course_cohort_settings.always_cohort_inline_discussions is False
):
# top level discussions have to be manually configured as cohorted
# (default is not).
# Same thing for inline discussions if the default is explicitly set to False in settings
ans = commentable_id in course.cohorted_discussions
ans = commentable_id in course_cohort_settings.cohorted_discussions
else:
# inline discussions are cohorted by default
ans = True
@@ -162,13 +160,13 @@ def get_cohorted_commentables(course_key):
Given a course_key return a set of strings representing cohorted commentables.
"""
course = courses.get_course_by_id(course_key)
course_cohort_settings = get_course_cohort_settings(course_key)
if not course.is_cohorted:
if not course_cohort_settings.is_cohorted:
# this is the easy case :)
ans = set()
else:
ans = course.cohorted_discussions
ans = set(course_cohort_settings.cohorted_discussions)
return ans
@@ -193,12 +191,10 @@ def get_cohort(user, course_key, assign=True):
"""
# First check whether the course is cohorted (users shouldn't be in a cohort
# in non-cohorted courses, but settings can change after course starts)
try:
course = courses.get_course_by_id(course_key)
except Http404:
raise ValueError("Invalid course_key")
course = courses.get_course(course_key)
course_cohort_settings = get_course_cohort_settings(course.id)
if not course.is_cohorted:
if not course_cohort_settings.is_cohorted:
return None
try:
@@ -232,9 +228,8 @@ def migrate_cohort_settings(course):
Migrate all the cohort settings associated with this course from modulestore to mysql.
After that we will never touch modulestore for any cohort related settings.
"""
course_id = course.location.course_key
cohort_settings, created = CourseCohortsSettings.objects.get_or_create(
course_id=course_id,
course_id=course.id,
defaults={
'is_cohorted': course.is_cohorted,
'cohorted_discussions': list(course.cohorted_discussions),
@@ -246,14 +241,14 @@ def migrate_cohort_settings(course):
if created:
# Update the manual cohorts already present in CourseUserGroup
manual_cohorts = CourseUserGroup.objects.filter(
course_id=course_id,
course_id=course.id,
group_type=CourseUserGroup.COHORT
).exclude(name__in=course.auto_cohort_groups)
for cohort in manual_cohorts:
CourseCohort.create(course_user_group=cohort)
for group_name in course.auto_cohort_groups:
CourseCohort.create(cohort_name=group_name, course_id=course_id, assignment_type=CourseCohort.RANDOM)
CourseCohort.create(cohort_name=group_name, course_id=course.id, assignment_type=CourseCohort.RANDOM)
return cohort_settings
@@ -454,7 +449,7 @@ def set_course_cohort_settings(course_key, **kwargs):
A CourseCohortSettings object.
Raises:
ValueError if course_key is invalid.
Http404 if course_key is invalid.
"""
fields = {'is_cohorted': bool, 'always_cohort_inline_discussions': bool, 'cohorted_discussions': list}
course_cohort_settings = get_course_cohort_settings(course_key)
@@ -478,11 +473,11 @@ def get_course_cohort_settings(course_key):
A CourseCohortSettings object.
Raises:
ValueError if course_key is invalid.
Http404 if course_key is invalid.
"""
try:
course_cohort_settings = CourseCohortsSettings.objects.get(course_id=course_key)
except CourseCohortsSettings.DoesNotExist:
course = courses.get_course(course_key)
course = courses.get_course_by_id(course_key)
course_cohort_settings = migrate_cohort_settings(course)
return course_cohort_settings

View File

@@ -4,13 +4,15 @@ Helper methods for testing cohorts.
import factory
from factory import post_generation, Sequence
from factory.django import DjangoModelFactory
import json
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from xmodule.modulestore.django import modulestore
from xmodule.modulestore import ModuleStoreEnum
from ..models import CourseUserGroup, CourseCohort, CourseCohortsSettings
import json
from ..cohorts import get_course_cohort_settings, set_course_cohort_settings
from ..models import CourseUserGroup, CourseCohort, CourseCohortsSettings
class CohortFactory(DjangoModelFactory):
@@ -67,7 +69,7 @@ def topic_name_to_id(course, name):
)
def config_course_cohorts(
def config_course_cohorts_legacy(
course,
discussions,
cohorted,
@@ -77,7 +79,11 @@ def config_course_cohorts(
):
"""
Given a course with no discussion set up, add the discussions and set
the cohort config appropriately.
the cohort config on the course descriptor.
Since cohort settings are now stored in models.CourseCohortSettings,
this is only used for testing data migration from the CourseDescriptor
to the table.
Arguments:
course: CourseDescriptor
@@ -105,7 +111,6 @@ def config_course_cohorts(
if cohorted_discussions is not None:
config["cohorted_discussions"] = [to_id(name)
for name in cohorted_discussions]
if auto_cohort_groups is not None:
config["auto_cohort_groups"] = auto_cohort_groups
@@ -119,3 +124,57 @@ def config_course_cohorts(
modulestore().update_item(course, ModuleStoreEnum.UserID.test)
except NotImplementedError:
pass
def config_course_cohorts(
course,
is_cohorted,
auto_cohorts=[],
manual_cohorts=[],
discussion_topics=[],
cohorted_discussions=[],
always_cohort_inline_discussions=True # pylint: disable=invalid-name
):
"""
Set discussions and configure cohorts for a course.
Arguments:
course: CourseDescriptor
is_cohorted (bool): Is the course cohorted?
auto_cohorts (list): Names of auto cohorts to create.
manual_cohorts (list): Names of manual cohorts to create.
discussion_topics (list): Discussion topic names. Picks ids and
sort_keys automatically.
cohorted_discussions: Discussion topics to cohort. Converts the
list to use the same ids as discussion topic names.
always_cohort_inline_discussions (bool): Whether inline discussions
should be cohorted by default.
Returns:
Nothing -- modifies course in place.
"""
def to_id(name):
return topic_name_to_id(course, name)
set_course_cohort_settings(
course.id,
is_cohorted = is_cohorted,
cohorted_discussions = [to_id(name) for name in cohorted_discussions],
always_cohort_inline_discussions = always_cohort_inline_discussions
)
for cohort_name in auto_cohorts:
cohort = CohortFactory(course_id=course.id, name=cohort_name)
CourseCohortFactory(course_user_group=cohort, assignment_type=CourseCohort.RANDOM)
for cohort_name in manual_cohorts:
cohort = CohortFactory(course_id=course.id, name=cohort_name)
CourseCohortFactory(course_user_group=cohort, assignment_type=CourseCohort.MANUAL)
course.discussion_topics = dict((name, {"sort_key": "A", "id": to_id(name)})
for name in discussion_topics)
try:
# Not implemented for XMLModulestore, which is used by test_cohorts.
modulestore().update_item(course, ModuleStoreEnum.UserID.test)
except NotImplementedError:
pass

View File

@@ -19,7 +19,8 @@ from xmodule.modulestore.tests.django_utils import TEST_DATA_MIXED_TOY_MODULESTO
from ..models import CourseUserGroup, CourseCohort, CourseUserGroupPartitionGroup
from .. import cohorts
from ..tests.helpers import (
topic_name_to_id, config_course_cohorts, CohortFactory, CourseCohortFactory, CourseCohortSettingsFactory
topic_name_to_id, config_course_cohorts, config_course_cohorts_legacy,
CohortFactory, CourseCohortFactory, CourseCohortSettingsFactory
)
@patch("openedx.core.djangoapps.course_groups.cohorts.tracker")
@@ -146,12 +147,10 @@ class TestCohorts(ModuleStoreTestCase):
Make sure cohorts.is_course_cohorted() correctly reports if a course is cohorted or not.
"""
course = modulestore().get_course(self.toy_course_key)
self.assertFalse(course.is_cohorted)
self.assertFalse(cohorts.is_course_cohorted(course.id))
config_course_cohorts(course, [], cohorted=True)
config_course_cohorts(course, is_cohorted=True)
self.assertTrue(course.is_cohorted)
self.assertTrue(cohorts.is_course_cohorted(course.id))
# Make sure we get a Http404 if there's no course
@@ -164,12 +163,12 @@ class TestCohorts(ModuleStoreTestCase):
invalid course key.
"""
course = modulestore().get_course(self.toy_course_key)
self.assertFalse(course.is_cohorted)
self.assertFalse(cohorts.is_course_cohorted(course.id))
user = UserFactory(username="test", email="a@b.com")
self.assertIsNone(cohorts.get_cohort_id(user, course.id))
config_course_cohorts(course, discussions=[], cohorted=True)
config_course_cohorts(course, is_cohorted=True)
cohort = CohortFactory(course_id=course.id, name="TestCohort")
cohort.users.add(user)
self.assertEqual(cohorts.get_cohort_id(user, course.id), cohort.id)
@@ -221,7 +220,7 @@ class TestCohorts(ModuleStoreTestCase):
"""
course = modulestore().get_course(self.toy_course_key)
self.assertEqual(course.id, self.toy_course_key)
self.assertFalse(course.is_cohorted)
self.assertFalse(cohorts.is_course_cohorted(course.id))
user = UserFactory(username="test", email="a@b.com")
other_user = UserFactory(username="test2", email="a2@b.com")
@@ -237,7 +236,7 @@ class TestCohorts(ModuleStoreTestCase):
)
# Make the course cohorted...
config_course_cohorts(course, discussions=[], cohorted=True)
config_course_cohorts(course, is_cohorted=True)
self.assertEquals(
cohorts.get_cohort(user, course.id).id,
@@ -256,16 +255,15 @@ class TestCohorts(ModuleStoreTestCase):
assigned to a user instead of assigning/creating a group automatically
"""
course = modulestore().get_course(self.toy_course_key)
self.assertFalse(course.is_cohorted)
self.assertFalse(cohorts.is_course_cohorted(course.id))
user = UserFactory(username="test", email="a@b.com")
# Add an auto_cohort_group to the course...
config_course_cohorts(
course,
discussions=[],
cohorted=True,
auto_cohort_groups=["AutoGroup"]
is_cohorted=True,
auto_cohorts=["AutoGroup"]
)
# get_cohort should return None as no group is assigned to user
@@ -274,13 +272,13 @@ class TestCohorts(ModuleStoreTestCase):
# get_cohort should return a group for user
self.assertEquals(cohorts.get_cohort(user, course.id).name, "AutoGroup")
def test_cohorting_with_auto_cohort_groups(self):
def test_cohorting_with_auto_cohorts(self):
"""
Make sure cohorts.get_cohort() does the right thing with auto_cohort_groups.
Make sure cohorts.get_cohort() does the right thing.
If there are auto cohort groups then a user should be assigned one.
"""
course = modulestore().get_course(self.toy_course_key)
self.assertFalse(course.is_cohorted)
self.assertFalse(cohorts.is_course_cohorted(course.id))
user1 = UserFactory(username="test", email="a@b.com")
user2 = UserFactory(username="test2", email="a2@b.com")
@@ -293,9 +291,8 @@ class TestCohorts(ModuleStoreTestCase):
# Add an auto_cohort_group to the course...
config_course_cohorts(
course,
discussions=[],
cohorted=True,
auto_cohort_groups=["AutoGroup"]
is_cohorted=True,
auto_cohorts=["AutoGroup"]
)
self.assertEquals(cohorts.get_cohort(user1, course.id).id, cohort.id, "user1 should stay put")
@@ -315,16 +312,15 @@ class TestCohorts(ModuleStoreTestCase):
# Add an auto_cohort_group to the course...
config_course_cohorts(
course,
discussions=[],
cohorted=True,
auto_cohort_groups=["AutoGroup"]
is_cohorted=True,
auto_cohorts=["AutoGroup"]
)
self.assertEquals(cohorts.get_cohort(user1, course.id).name, "AutoGroup", "user1 should be auto-cohorted")
# Now set the auto_cohort_group to something different
# This will have no effect on lms side as we are already done with migrations
config_course_cohorts(
config_course_cohorts_legacy(
course,
discussions=[],
cohorted=True,
@@ -339,15 +335,15 @@ class TestCohorts(ModuleStoreTestCase):
cohorts.get_cohort(user1, course.id).name, "AutoGroup", "user1 should still be in originally placed cohort"
)
def test_cohorting_with_no_auto_cohort_groups(self):
def test_cohorting_with_no_auto_cohorts(self):
"""
Make sure cohorts.get_cohort() does the right thing with auto_cohort_groups.
If there are not auto cohort groups then a user should be assigned to Default Cohort Group.
Make sure cohorts.get_cohort() does the right thing.
If there are not auto cohorts then a user should be assigned to Default Cohort Group.
Also verifies that cohort config changes on studio/moduletore side will
not be reflected on lms after the migrations are done.
"""
course = modulestore().get_course(self.toy_course_key)
self.assertFalse(course.is_cohorted)
self.assertFalse(cohorts.is_course_cohorted(course.id))
user1 = UserFactory(username="test", email="a@b.com")
user2 = UserFactory(username="test2", email="a2@b.com")
@@ -355,9 +351,8 @@ class TestCohorts(ModuleStoreTestCase):
# Make the auto_cohort_group list empty
config_course_cohorts(
course,
discussions=[],
cohorted=True,
auto_cohort_groups=[]
is_cohorted=True,
auto_cohorts=[]
)
self.assertEquals(
@@ -368,7 +363,7 @@ class TestCohorts(ModuleStoreTestCase):
# Add an auto_cohort_group to the course
# This will have no effect on lms side as we are already done with migrations
config_course_cohorts(
config_course_cohorts_legacy(
course,
discussions=[],
cohorted=True,
@@ -393,11 +388,11 @@ class TestCohorts(ModuleStoreTestCase):
Make sure cohorts.get_cohort() randomizes properly.
"""
course = modulestore().get_course(self.toy_course_key)
self.assertFalse(course.is_cohorted)
self.assertFalse(cohorts.is_course_cohorted(course.id))
groups = ["group_{0}".format(n) for n in range(5)]
config_course_cohorts(
course, discussions=[], cohorted=True, auto_cohort_groups=groups
course, is_cohorted=True, auto_cohorts=groups
)
# Assign 100 users to cohorts
@@ -423,7 +418,7 @@ class TestCohorts(ModuleStoreTestCase):
Tests get_course_cohorts returns an empty list when no cohorts exist.
"""
course = modulestore().get_course(self.toy_course_key)
config_course_cohorts(course, [], cohorted=True)
config_course_cohorts(course, is_cohorted=True)
self.assertEqual([], cohorts.get_course_cohorts(course))
def test_get_course_cohorts(self):
@@ -432,8 +427,9 @@ class TestCohorts(ModuleStoreTestCase):
"""
course = modulestore().get_course(self.toy_course_key)
config_course_cohorts(
course, [], cohorted=True,
auto_cohort_groups=["AutoGroup1", "AutoGroup2"]
course,
is_cohorted=True,
auto_cohorts=["AutoGroup1", "AutoGroup2"]
)
# add manual cohorts to course 1
@@ -445,7 +441,7 @@ class TestCohorts(ModuleStoreTestCase):
def test_is_commentable_cohorted(self):
course = modulestore().get_course(self.toy_course_key)
self.assertFalse(course.is_cohorted)
self.assertFalse(cohorts.is_course_cohorted(course.id))
def to_id(name):
return topic_name_to_id(course, name)
@@ -457,7 +453,7 @@ class TestCohorts(ModuleStoreTestCase):
)
# not cohorted
config_course_cohorts(course, ["General", "Feedback"], cohorted=False)
config_course_cohorts(course, is_cohorted=False, discussion_topics=["General", "Feedback"])
self.assertFalse(
cohorts.is_commentable_cohorted(course.id, to_id("General")),
@@ -465,9 +461,9 @@ class TestCohorts(ModuleStoreTestCase):
)
# cohorted, but top level topics aren't
config_course_cohorts(course, ["General", "Feedback"], cohorted=True)
config_course_cohorts(course, is_cohorted=True, discussion_topics=["General", "Feedback"])
self.assertTrue(course.is_cohorted)
self.assertTrue(cohorts.is_course_cohorted(course.id))
self.assertFalse(
cohorts.is_commentable_cohorted(course.id, to_id("General")),
"Course is cohorted, but 'General' isn't."
@@ -475,12 +471,13 @@ class TestCohorts(ModuleStoreTestCase):
# cohorted, including "Feedback" top-level topics aren't
config_course_cohorts(
course, ["General", "Feedback"],
cohorted=True,
course,
is_cohorted=True,
discussion_topics= ["General", "Feedback"],
cohorted_discussions=["Feedback"]
)
self.assertTrue(course.is_cohorted)
self.assertTrue(cohorts.is_course_cohorted(course.id))
self.assertFalse(
cohorts.is_commentable_cohorted(course.id, to_id("General")),
"Course is cohorted, but 'General' isn't."
@@ -492,14 +489,15 @@ class TestCohorts(ModuleStoreTestCase):
def test_is_commentable_cohorted_inline_discussion(self):
course = modulestore().get_course(self.toy_course_key)
self.assertFalse(course.is_cohorted)
self.assertFalse(cohorts.is_course_cohorted(course.id))
def to_id(name): # pylint: disable=missing-docstring
return topic_name_to_id(course, name)
config_course_cohorts(
course, ["General", "Feedback"],
cohorted=True,
course,
is_cohorted=True,
discussion_topics =["General", "Feedback"],
cohorted_discussions=["Feedback", "random_inline"]
)
self.assertTrue(
@@ -510,8 +508,9 @@ class TestCohorts(ModuleStoreTestCase):
# if always_cohort_inline_discussions is set to False, non-top-level discussion are always
# non cohorted unless they are explicitly set in cohorted_discussions
config_course_cohorts(
course, ["General", "Feedback"],
cohorted=True,
course,
is_cohorted=True,
discussion_topics=["General", "Feedback"],
cohorted_discussions=["Feedback", "random_inline"],
always_cohort_inline_discussions=False
)
@@ -538,12 +537,13 @@ class TestCohorts(ModuleStoreTestCase):
self.assertEqual(cohorts.get_cohorted_commentables(course.id), set())
config_course_cohorts(course, [], cohorted=True)
config_course_cohorts(course, is_cohorted=True)
self.assertEqual(cohorts.get_cohorted_commentables(course.id), set())
config_course_cohorts(
course, ["General", "Feedback"],
cohorted=True,
course,
is_cohorted=True,
discussion_topics=["General", "Feedback"],
cohorted_discussions=["Feedback"]
)
self.assertItemsEqual(
@@ -552,8 +552,9 @@ class TestCohorts(ModuleStoreTestCase):
)
config_course_cohorts(
course, ["General", "Feedback"],
cohorted=True,
course,
is_cohorted=True,
discussion_topics=["General", "Feedback"],
cohorted_discussions=["General", "Feedback"]
)
self.assertItemsEqual(

View File

@@ -41,7 +41,7 @@ class TestCohortPartitionScheme(ModuleStoreTestCase):
self.course_key = SlashSeparatedCourseKey("edX", "toy", "2012_Fall")
self.course = modulestore().get_course(self.course_key)
config_course_cohorts(self.course, [], cohorted=True)
config_course_cohorts(self.course, is_cohorted=True)
self.groups = [Group(10, 'Group 10'), Group(20, 'Group 20')]
self.user_partition = UserPartition(

View File

@@ -25,7 +25,9 @@ from ..cohorts import (
get_cohort, get_cohort_by_name, get_cohort_by_id,
DEFAULT_COHORT_NAME, get_group_info_for_cohort
)
from .helpers import config_course_cohorts, CohortFactory, CourseCohortFactory, topic_name_to_id
from .helpers import (
config_course_cohorts, config_course_cohorts_legacy, CohortFactory, CourseCohortFactory, topic_name_to_id
)
class CohortViewsTestCase(ModuleStoreTestCase):
@@ -136,7 +138,7 @@ class CourseCohortSettingsHandlerTestCase(CohortViewsTestCase):
Verify that course_cohort_settings_handler is working for HTTP GET.
"""
cohorted_discussions = ['Topic A', 'Topic B']
config_course_cohorts(self.course, [], cohorted=True, cohorted_discussions=cohorted_discussions)
config_course_cohorts(self.course, is_cohorted=True, cohorted_discussions=cohorted_discussions)
response = self.get_handler(self.course, handler=course_cohort_settings_handler)
response['cohorted_discussions'].sort()
@@ -155,7 +157,7 @@ class CourseCohortSettingsHandlerTestCase(CohortViewsTestCase):
"""
Verify that course_cohort_settings_handler is working for HTTP POST.
"""
config_course_cohorts(self.course, [], cohorted=True)
config_course_cohorts(self.course, is_cohorted=True)
response = self.get_handler(self.course, handler=course_cohort_settings_handler)
@@ -176,7 +178,7 @@ class CourseCohortSettingsHandlerTestCase(CohortViewsTestCase):
"""
Verify that course_cohort_settings_handler return HTTP 400 if required data field is missing from post data.
"""
config_course_cohorts(self.course, [], cohorted=True)
config_course_cohorts(self.course, is_cohorted=True)
response = self.put_handler(self.course, expected_response_code=400, handler=course_cohort_settings_handler)
self.assertEqual("Bad Request", response.get("error"))
@@ -185,7 +187,7 @@ class CourseCohortSettingsHandlerTestCase(CohortViewsTestCase):
"""
Verify that course_cohort_settings_handler return HTTP 400 if field data type is incorrect.
"""
config_course_cohorts(self.course, [], cohorted=True)
config_course_cohorts(self.course, is_cohorted=True)
response = self.put_handler(
self.course,
@@ -268,23 +270,21 @@ class CohortHandlerTestCase(CohortViewsTestCase):
"""
Verify that auto cohorts are included in the response.
"""
config_course_cohorts(self.course, [], cohorted=True,
auto_cohort_groups=["AutoGroup1", "AutoGroup2"])
config_course_cohorts(self.course, is_cohorted=True, auto_cohorts=["AutoGroup1", "AutoGroup2"])
# Will create cohort1, cohort2, and cohort3. Auto cohorts remain uncreated.
# Will create manual cohorts cohort1, cohort2, and cohort3.
self._create_cohorts()
# Get the cohorts from the course, which will cause auto cohorts to be created.
actual_cohorts = self.get_handler(self.course)
# Get references to the created auto cohorts.
auto_cohort_1 = get_cohort_by_name(self.course.id, "AutoGroup1")
auto_cohort_2 = get_cohort_by_name(self.course.id, "AutoGroup2")
expected_cohorts = [
CohortHandlerTestCase.create_expected_cohort(auto_cohort_1, 0, CourseCohort.RANDOM),
CohortHandlerTestCase.create_expected_cohort(auto_cohort_2, 0, CourseCohort.RANDOM),
CohortHandlerTestCase.create_expected_cohort(self.cohort1, 3, CourseCohort.MANUAL),
CohortHandlerTestCase.create_expected_cohort(self.cohort2, 2, CourseCohort.MANUAL),
CohortHandlerTestCase.create_expected_cohort(self.cohort3, 2, CourseCohort.MANUAL),
CohortHandlerTestCase.create_expected_cohort(self.cohort4, 2, CourseCohort.RANDOM),
CohortHandlerTestCase.create_expected_cohort(auto_cohort_1, 0, CourseCohort.RANDOM),
CohortHandlerTestCase.create_expected_cohort(auto_cohort_2, 0, CourseCohort.RANDOM),
]
self.verify_lists_expected_cohorts(expected_cohorts, actual_cohorts)
@@ -295,8 +295,8 @@ class CohortHandlerTestCase(CohortViewsTestCase):
# verify the default cohort is not created when the course is not cohorted
self.verify_lists_expected_cohorts([])
# create a cohorted course without any auto_cohort_groups
config_course_cohorts(self.course, [], cohorted=True)
# create a cohorted course without any auto_cohorts
config_course_cohorts(self.course, is_cohorted=True)
# verify the default cohort is not yet created until a user is assigned
self.verify_lists_expected_cohorts([])
@@ -320,7 +320,7 @@ class CohortHandlerTestCase(CohortViewsTestCase):
# set auto_cohort_groups
# these cohort config will have not effect on lms side as we are already done with migrations
config_course_cohorts(self.course, [], cohorted=True, auto_cohort_groups=["AutoGroup"])
config_course_cohorts_legacy(self.course, [], cohorted=True, auto_cohort_groups=["AutoGroup"])
# We should expect the DoesNotExist exception because above cohort config have
# no effect on lms side so as a result there will be no AutoGroup cohort present