当前位置: 首页>>代码示例>>Python>>正文


Python GroupConfiguration.get_content_groups_usage_info方法代码示例

本文整理汇总了Python中contentstore.course_group_config.GroupConfiguration.get_content_groups_usage_info方法的典型用法代码示例。如果您正苦于以下问题:Python GroupConfiguration.get_content_groups_usage_info方法的具体用法?Python GroupConfiguration.get_content_groups_usage_info怎么用?Python GroupConfiguration.get_content_groups_usage_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在contentstore.course_group_config.GroupConfiguration的用法示例。


在下文中一共展示了GroupConfiguration.get_content_groups_usage_info方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fetch_group_usage

# 需要导入模块: from contentstore.course_group_config import GroupConfiguration [as 别名]
# 或者: from contentstore.course_group_config.GroupConfiguration import get_content_groups_usage_info [as 别名]
 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
开发者ID:marcore,项目名称:edx-platform,代码行数:21,代码来源:courseware_index.py

示例2: test_can_handle_multiple_partitions

# 需要导入模块: from contentstore.course_group_config import GroupConfiguration [as 别名]
# 或者: from contentstore.course_group_config.GroupConfiguration import get_content_groups_usage_info [as 别名]
    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])
开发者ID:Certific-NET,项目名称:edx-platform,代码行数:43,代码来源:test_group_configurations.py


注:本文中的contentstore.course_group_config.GroupConfiguration.get_content_groups_usage_info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。