def test_content_multiple_groups_id_provided(self): """ Tests that we get content groups IDs when course is assigned to cohort which is assigned to multiple content groups. """ self.add_seq_with_content_groups() self.add_user_to_cohort_group() # Second cohort link link_cohort_to_partition_group( self.second_cohort, self.user_partition.id, self.groups[0].id, ) self.courses[0].save() modulestore().update_item(self.courses[0], self.user.id) field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters( user=self.user, course_id=unicode(self.courses[0].id)) self.assertTrue('start_date' in filter_dictionary) self.assertEqual(unicode(self.courses[0].id), field_dictionary['course']) # returns only first group, relevant to current user self.assertEqual([unicode(self.content_groups[0])], filter_dictionary['content_groups'])
def test_content_multiple_groups_id_provided(self): """ Tests that we get content groups IDs when course is assigned to cohort which is assigned to multiple content groups. """ self.add_seq_with_content_groups() self.add_user_to_cohort_group() # Second cohort link link_cohort_to_partition_group( self.second_cohort, self.user_partition.id, self.groups[0].id, ) self.courses[0].save() modulestore().update_item(self.courses[0], self.user.id) field_dictionary, filter_dictionary, _ = LmsSearchFilterGenerator.generate_field_filters( user=self.user, course_id=unicode(self.courses[0].id) ) self.assertTrue('start_date' in filter_dictionary) self.assertEqual(unicode(self.courses[0].id), field_dictionary['course']) # returns only first group, relevant to current user self.assertEqual([unicode(self.content_groups[0])], filter_dictionary['content_groups'])
def add_user_to_cohort_group(self): """ adds user to cohort and links cohort to content group """ add_user_to_cohort(self.first_cohort, self.user.username) link_cohort_to_partition_group(self.first_cohort, self.user_partition.id, self.groups[0].id) self.courses[0].save() modulestore().update_item(self.courses[0], self.user.id)
def add_user_to_cohort_group(self): """ adds user to cohort and links cohort to content group """ add_user_to_cohort(self.first_cohort, self.user.username) link_cohort_to_partition_group( self.first_cohort, self.user_partition.id, self.groups[0].id, ) self.courses[0].save() modulestore().update_item(self.courses[0], self.user.id)
def setup_chorts(self, course): """ Sets up a cohort for each previously created user partition. """ for user_partition in self.user_partitions: config_course_cohorts(course, is_cohorted=True) self.cohorts = [] for group in self.groups: cohort = CohortFactory(course_id=course.id) self.cohorts.append(cohort) link_cohort_to_partition_group( cohort, user_partition.id, group.id, )
def setup_cohorts(self, course): """ Sets up a cohort for each previously created user partition. """ config_course_cohorts(course, is_cohorted=True) self.partition_cohorts = [] for user_partition in self.user_partitions: partition_cohorts = [] for group in self.groups: cohort = CohortFactory(course_id=course.id) partition_cohorts.append(cohort) link_cohort_to_partition_group( cohort, user_partition.id, group.id, ) self.partition_cohorts.append(partition_cohorts)