本文整理汇总了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)
示例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
示例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)
示例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)
示例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)