Пример #1
0
 def fetch_group_usage(cls, modulestore, structure):
     groups_usage_dict = {}
     groups_usage_info = GroupConfiguration.get_content_groups_usage_info(
         modulestore, structure).items()
     groups_usage_info.extend(
         GroupConfiguration.get_content_groups_items_usage_info(
             modulestore, structure).items())
     if groups_usage_info:
         for name, group in groups_usage_info:
             for module in group:
                 view, args, kwargs = resolve(module['url'])  # pylint: disable=unused-variable
                 usage_key_string = unicode(kwargs['usage_key_string'])
                 if groups_usage_dict.get(usage_key_string, None):
                     groups_usage_dict[usage_key_string].append(name)
                 else:
                     groups_usage_dict[usage_key_string] = [name]
     return groups_usage_dict
Пример #2
0
    def test_can_handle_multiple_partitions(self):
        # Create the user partitions
        self.course.user_partitions = [
            UserPartition(
                id=0,
                name='Cohort user partition',
                scheme=UserPartition.get_scheme('cohort'),
                description='Cohorted user partition',
                groups=[
                    Group(id=0, name="Group A"),
                    Group(id=1, name="Group B"),
                ],
            ),
            UserPartition(
                id=1,
                name='Random user partition',
                scheme=UserPartition.get_scheme('random'),
                description='Random user partition',
                groups=[
                    Group(id=0, name="Group A"),
                    Group(id=1, name="Group B"),
                ],
            ),
        ]
        self.store.update_item(self.course, ModuleStoreEnum.UserID.test)

        # Assign group access rules for multiple partitions, one of which is a cohorted partition
        __, problem = self._create_problem_with_content_group(0, 1)
        problem.group_access = {
            0: [0],
            1: [1],
        }
        self.store.update_item(problem, ModuleStoreEnum.UserID.test)

        # This used to cause an exception since the code assumed that
        # only one partition would be available.
        actual = GroupConfiguration.get_content_groups_usage_info(
            self.store, self.course)
        self.assertEqual(actual.keys(), [0])

        actual = GroupConfiguration.get_content_groups_items_usage_info(
            self.store, self.course)
        self.assertEqual(actual.keys(), [0])
Пример #3
0
 def fetch_group_usage(cls, modulestore, structure):
     groups_usage_dict = {}
     groups_usage_info = GroupConfiguration.get_content_groups_usage_info(modulestore, structure).items()
     groups_usage_info.extend(
         GroupConfiguration.get_content_groups_items_usage_info(
             modulestore,
             structure
         ).items()
     )
     if groups_usage_info:
         for name, group in groups_usage_info:
             for module in group:
                 view, args, kwargs = resolve(module['url'])  # pylint: disable=unused-variable
                 usage_key_string = unicode(kwargs['usage_key_string'])
                 if groups_usage_dict.get(usage_key_string, None):
                     groups_usage_dict[usage_key_string].append(name)
                 else:
                     groups_usage_dict[usage_key_string] = [name]
     return groups_usage_dict
    def test_can_handle_multiple_partitions(self):
        # Create the user partitions
        self.course.user_partitions = [
            UserPartition(
                id=0,
                name='Cohort user partition',
                scheme=UserPartition.get_scheme('cohort'),
                description='Cohorted user partition',
                groups=[
                    Group(id=0, name="Group A"),
                    Group(id=1, name="Group B"),
                ],
            ),
            UserPartition(
                id=1,
                name='Random user partition',
                scheme=UserPartition.get_scheme('random'),
                description='Random user partition',
                groups=[
                    Group(id=0, name="Group A"),
                    Group(id=1, name="Group B"),
                ],
            ),
        ]
        self.store.update_item(self.course, ModuleStoreEnum.UserID.test)

        # Assign group access rules for multiple partitions, one of which is a cohorted partition
        __, problem = self._create_problem_with_content_group(0, 1)
        problem.group_access = {
            0: [0],
            1: [1],
        }
        self.store.update_item(problem, ModuleStoreEnum.UserID.test)

        # This used to cause an exception since the code assumed that
        # only one partition would be available.
        actual = GroupConfiguration.get_content_groups_usage_info(self.store, self.course)
        self.assertEqual(actual.keys(), [0])

        actual = GroupConfiguration.get_content_groups_items_usage_info(self.store, self.course)
        self.assertEqual(actual.keys(), [0])