## mako <%page args="active_page=None" expression_filter="h" /> <%namespace name='static' file='/static_content.html'/> <%! from django.utils.translation import ugettext as _ from django.conf import settings from openedx.core.djangolib.js_utils import dump_js_escaped_json from openedx.core.djangolib.markup import HTML, Text from xmodule.partitions.partitions_service import get_all_partitions_for_course %> <% show_preview_menu = course and can_masquerade and supports_preview_menu %> % if show_preview_menu: <% def selected(is_selected): return "selected" if is_selected else "" course_partitions = get_all_partitions_for_course(course) masquerade_user_name = masquerade.user_name if masquerade else None masquerade_group_id = masquerade.group_id if masquerade else None masquerade_user_partition_id = masquerade.user_partition_id if masquerade else None staff_selected = selected(not masquerade or masquerade.role != "student") specific_student_selected = selected(not staff_selected and masquerade.user_name) student_selected = selected(not staff_selected and not specific_student_selected and not masquerade_group_id) if settings.HTTPS == 'on': protocol = 'https' else: protocol = 'http' insights_base_url = '' if settings.ANALYTICS_DASHBOARD_URL: insights_base_url = settings.ANALYTICS_DASHBOARD_URL + '/courses' studio_base_url = '' if settings.CMS_BASE: studio_base_url = protocol + '://' + settings.CMS_BASE insights_url = insights_base_url studio_url = studio_base_url if course and course.id: if insights_base_url: insights_url = "{base_url}/{course_id}".format( base_url=insights_base_url, course_id=course.id, ) if studio_base_url: studio_url = "{base_url}/course/{course_id}".format( base_url=studio_base_url, course_id=course.id, ) %> <% preview_options = { "courseId": course.id, "disableStudentAccess": disable_student_access if disable_student_access is not UNDEFINED else False, "specificStudentSelected": specific_student_selected, "masqueradeUsername" : masquerade_user_name if masquerade_user_name is not UNDEFINED else None, } %> <%static:require_module_async module_name="lms/js/preview/preview_factory" class_name="PreviewFactory"> PreviewFactory(${preview_options | n, dump_js_escaped_json}); % endif