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


Python XBlock.load_tagged_classes方法代码示例

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


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

示例1: get_orphans

# 需要导入模块: from xblock.core import XBlock [as 别名]
# 或者: from xblock.core.XBlock import load_tagged_classes [as 别名]
 def get_orphans(self, course_location, _branch):
     """
     Return an array all of the locations for orphans in the course.
     """
     detached_categories = [name for name, __ in XBlock.load_tagged_classes("detached")]
     all_items = self.collection.find({
         '_id.org': course_location.org,
         '_id.course': course_location.course,
         '_id.category': {'$nin': detached_categories}
     })
     all_reachable = set()
     item_locs = set()
     for item in all_items:
         if item['_id']['category'] != 'course':
             item_locs.add(Location(item['_id']).replace(revision=None).url())
         all_reachable = all_reachable.union(item.get('definition', {}).get('children', []))
     item_locs -= all_reachable
     return list(item_locs)
开发者ID:WEForum,项目名称:edx-platform,代码行数:20,代码来源:base.py

示例2: get_orphans

# 需要导入模块: from xblock.core import XBlock [as 别名]
# 或者: from xblock.core.XBlock import load_tagged_classes [as 别名]
 def get_orphans(self, course_key):
     """
     Return an array all of the locations (deprecated string format) for orphans in the course.
     """
     detached_categories = [name for name, __ in XBlock.load_tagged_classes("detached")]
     query = self._course_key_to_son(course_key)
     query['_id.category'] = {'$nin': detached_categories}
     all_items = self.collection.find(query)
     all_reachable = set()
     item_locs = set()
     for item in all_items:
         if item['_id']['category'] != 'course':
             # It would be nice to change this method to return UsageKeys instead of the deprecated string.
             item_locs.add(
                 Location._from_deprecated_son(item['_id'], course_key.run).replace(revision=None).to_deprecated_string()
             )
         all_reachable = all_reachable.union(item.get('definition', {}).get('children', []))
     item_locs -= all_reachable
     return list(item_locs)
开发者ID:jmangas,项目名称:edx-platform,代码行数:21,代码来源:base.py

示例3: test_loading_tagged_classes

# 需要导入模块: from xblock.core import XBlock [as 别名]
# 或者: from xblock.core.XBlock import load_tagged_classes [as 别名]
def test_loading_tagged_classes():

    @XBlock.tag("thetag")
    class HasTag1(XBlock):
        """Toy XBlock"""
        pass

    class HasTag2(HasTag1):
        """Toy XBlock"""
        pass

    class HasntTag(XBlock):
        """Toy XBlock"""
        pass

    the_classes = [('hastag1', HasTag1), ('hastag2', HasTag2), ('hasnttag', HasntTag)]
    tagged_classes = [('hastag1', HasTag1), ('hastag2', HasTag2)]
    with patch('xblock.core.XBlock.load_classes', return_value=the_classes):
        assert_equals(set(XBlock.load_tagged_classes('thetag')), set(tagged_classes))
开发者ID:Keeward,项目名称:XBlock,代码行数:21,代码来源:test_core.py

示例4: dict

# 需要导入模块: from xblock.core import XBlock [as 别名]
# 或者: from xblock.core.XBlock import load_tagged_classes [as 别名]
import ddt
from mock import patch
from xblock.core import XBlock, XBlockAside
from xblock.fields import Scope, String
from xblock.runtime import DictKeyValueStore, KvsFieldData
from xblock.test.tools import TestRuntime

from xmodule.course_module import CourseSummary
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.draft_and_published import DIRECT_ONLY_CATEGORIES
from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.modulestore.tests.factories import CourseFactory
from xmodule.modulestore.tests.utils import SPLIT_MODULESTORE_SETUP, MongoModulestoreBuilder, PureModulestoreTestCase

DETACHED_BLOCK_TYPES = dict(XBlock.load_tagged_classes('detached'))

# These tests won't work with courses, since they're creating blocks inside courses
TESTABLE_BLOCK_TYPES = set(DIRECT_ONLY_CATEGORIES)
TESTABLE_BLOCK_TYPES.discard('course')

TestField = namedtuple('TestField', ['field_name', 'initial', 'updated'])


class AsideTest(XBlockAside):
    """
    Test xblock aside class
    """
    content = String(default="content", scope=Scope.content)

开发者ID:digitalsatori,项目名称:edx-platform,代码行数:30,代码来源:test_semantics.py

示例5: set

# 需要导入模块: from xblock.core import XBlock [as 别名]
# 或者: from xblock.core.XBlock import load_tagged_classes [as 别名]
import re
import logging
from collections import namedtuple

import uuid
from xblock.core import XBlock

DETACHED_XBLOCK_TYPES = set(name for name, __ in XBlock.load_tagged_classes("detached"))


def _prefix_only_url_replace_regex(pattern):
    """
    Match urls in quotes pulling out the fields from pattern
    """
    return re.compile(ur"""
        (?x)                      # flags=re.VERBOSE
        (?P<quote>\\?['"])        # the opening quotes
        {}
        (?P=quote)                # the first matching closing quote
        """.format(pattern))


def rewrite_nonportable_content_links(source_course_id, dest_course_id, text):
    """
    rewrite any non-portable links to (->) relative links:
         /c4x/<org>/<course>/asset/<name> -> /static/<name>
         /jump_to/i4x://<org>/<course>/<category>/<name> -> /jump_to_id/<id>
    """

    def portable_asset_link_subtitution(match):
        quote = match.group('quote')
开发者ID:10clouds,项目名称:edx-platform,代码行数:33,代码来源:store_utilities.py


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