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


Python CourseTabList.get_tab_by_id方法代码示例

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


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

示例1: get_tab_by_locator

# 需要导入模块: from xmodule.tabs import CourseTabList [as 别名]
# 或者: from xmodule.tabs.CourseTabList import get_tab_by_id [as 别名]
def get_tab_by_locator(tab_list, usage_key_string):
    """
    Look for a tab with the specified locator.  Returns the first matching tab.
    """
    tab_location = UsageKey.from_string(usage_key_string)
    item = modulestore().get_item(tab_location)
    static_tab = StaticTab(name=item.display_name, url_slug=item.location.name)
    return CourseTabList.get_tab_by_id(tab_list, static_tab.tab_id)
开发者ID:mrstephencollins,项目名称:edx-platform,代码行数:10,代码来源:tabs.py

示例2: get_tab_by_tab_id_locator

# 需要导入模块: from xmodule.tabs import CourseTabList [as 别名]
# 或者: from xmodule.tabs.CourseTabList import get_tab_by_id [as 别名]
def get_tab_by_tab_id_locator(tab_list, tab_id_locator):
    """
    Look for a tab with the specified tab_id or locator.  Returns the first matching tab.
    """
    if 'tab_id' in tab_id_locator:
        tab = CourseTabList.get_tab_by_id(tab_list, tab_id_locator['tab_id'])
    elif 'tab_locator' in tab_id_locator:
        tab = get_tab_by_locator(tab_list, tab_id_locator['tab_locator'])
    return tab
开发者ID:AdityaKashyap,项目名称:edx-platform,代码行数:11,代码来源:tabs.py

示例3: get_tab_by_locator

# 需要导入模块: from xmodule.tabs import CourseTabList [as 别名]
# 或者: from xmodule.tabs.CourseTabList import get_tab_by_id [as 别名]
def get_tab_by_locator(tab_list, tab_locator):
    """
    Look for a tab with the specified locator.  Returns the first matching tab.
    """
    tab_location = loc_mapper().translate_locator_to_location(BlockUsageLocator(tab_locator))
    item = modulestore('direct').get_item(tab_location)
    static_tab = StaticTab(
        name=item.display_name,
        url_slug=item.location.name,
    )
    return CourseTabList.get_tab_by_id(tab_list, static_tab.tab_id)
开发者ID:DazzaGreenwood,项目名称:edx-platform,代码行数:13,代码来源:tabs.py

示例4: calendar_edit

# 需要导入模块: from xmodule.tabs import CourseTabList [as 别名]
# 或者: from xmodule.tabs.CourseTabList import get_tab_by_id [as 别名]
def calendar_edit(request, course_id):
    url = request.POST.get('url', '')
    message = request.POST.get('message', '')

    course_key = CourseKey.from_string(course_id)
    course = get_course_with_access(request.user, "load", course_key)

    # Find the given tab in the course
    tab = CourseTabList.get_tab_by_id(course.tabs, "calendar_tab")

    if tab is None or not bool(has_access(request.user, 'staff', course)):
        raise Http404("Tab with id_locator calendar_tab does not exist.")

    data = {'url': url, 'message': message}
    tab.data = json.dumps(data)
    modulestore().update_item(course, request.user.id)
    return redirect('calendar_dashboard', course_id=course.id)
开发者ID:raccoongang,项目名称:open_edx_calendar_tab,代码行数:19,代码来源:views.py

示例5: calendar_dashboard

# 需要导入模块: from xmodule.tabs import CourseTabList [as 别名]
# 或者: from xmodule.tabs.CourseTabList import get_tab_by_id [as 别名]
def calendar_dashboard(request, course_id):
    course_key = CourseKey.from_string(course_id)
    course = get_course_with_access(request.user, "load", course_key)
    add_lookup('main', os.path.join(os.path.dirname(os.path.dirname(__file__)), 'calendar_tab/templates'))
    csrf_token = csrf(request)['csrf_token']
    tab = CourseTabList.get_tab_by_id(course.tabs, "calendar_tab")
    is_staff = bool(has_access(request.user, 'staff', course))

    try:
        data = json.loads(tab.data)
    except (TypeError, ValueError):
        data = {}

    context = {
        "course": course,
        "csrf_token": csrf_token,
        'url': data.get('url', '#'),
        'message': data.get('message', _('Open calendar')),
        'is_staff': is_staff
    }
    return render_to_response("calendar_tab/calendar_tab.html", context)
开发者ID:raccoongang,项目名称:open_edx_calendar_tab,代码行数:23,代码来源:views.py


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