-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add Studio/Insights links to Staff Instructor Toolbar #24020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,10 @@ $proctoring-banner-text-size: 14px; | |
| @extend %inner-wrapper; | ||
|
|
||
| width: auto; | ||
|
|
||
| a.btn { | ||
| margin: 5px 0 5px 5px; | ||
|
||
| } | ||
| } | ||
|
|
||
| .preview-actions { | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,10 +26,32 @@ | |
| 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 = settings.ANALYTICS_DASHBOARD_URL | ||
| 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, | ||
| ) | ||
| %> | ||
| <nav class="wrapper-preview-menu" aria-label="${_('Course View')}"> | ||
| <div class="preview-menu" style="display: flex; align-items: center;"> | ||
|
||
| <ol class="preview-actions"> | ||
| <ol class="preview-actions" style="flex-grow: 1;"> | ||
| <li class="action-preview"> | ||
| <form action="#" class="action-preview-form" method="post"> | ||
| <label for="action-preview-select" class="action-preview-label">${_("View this course as:")}</label> | ||
|
|
@@ -66,13 +88,59 @@ | |
| </p> | ||
| </div> | ||
| % endif | ||
| <div style="flex-shrink: 1; text-align: center;"> | ||
| % if microfrontend_link: | ||
| <div style="flex-grow: 1; text-align: right;"> | ||
| <a class="btn btn-primary" style="border: solid 1px white;" href="${microfrontend_link}"> | ||
| ${_("View this unit in the new experience")} | ||
| ${_("View in the new experience")} | ||
| </a> | ||
| </div> | ||
| % endif | ||
| % if studio_url: | ||
| <a | ||
| class="btn btn-primary view-in-studio" | ||
| style="border: solid 1px white;" | ||
| href="${studio_url}" | ||
| data-studio-base-url="${studio_base_url}" | ||
| > | ||
| ${_("View in Studio")} | ||
| </a> | ||
| <script type="text/javascript"> | ||
| $(function () { | ||
| $('.wrapper-preview-menu a.view-in-studio').click(function (event) { | ||
| /* | ||
| When we start rendering this template, we | ||
| don't yet have a vertical in the context | ||
| (that happens in a separate `render` call, | ||
| if this is even on a unit-level page), | ||
| so we dynamically lookup the vertical element in | ||
| the DOM and use its data-* attributes to | ||
| construct a Studio link directly to this unit. | ||
| If no vertical is present, the link behaves as | ||
| normal. | ||
| */ | ||
| var verticals = $('.xblock-student_view-vertical'); | ||
| if (verticals.length > 0) { | ||
| var blockId = verticals[0].dataset.usageId; | ||
| var url = [ | ||
| this.dataset.studioBaseUrl, | ||
| 'container', | ||
| blockId, | ||
| ].join('/'); | ||
| window.location.href = url; | ||
| return false; | ||
| } | ||
| // There's no vertical, so let the event | ||
| // bubble up, ie, work like a normal link. | ||
| return true; | ||
| }); | ||
| }); | ||
| </script> | ||
| % endif | ||
| % if insights_url: | ||
| <a class="btn btn-primary" style="border: solid 1px white;" href="${insights_url}"> | ||
| ${_("View in Insights")} | ||
| </a> | ||
| % endif | ||
| </div> | ||
| </div> | ||
| </nav> | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -323,23 +323,7 @@ def add_staff_markup(user, disable_staff_debug_info, block, view, frag, context) | |
| return frag | ||
| # TODO: make this more general, eg use an XModule attribute instead | ||
| if isinstance(block, VerticalBlock) and (not context or not context.get('child_of_vertical', False)): | ||
| # check that the course is a mongo backed Studio course before doing work | ||
| is_studio_course = block.course_edit_method == "Studio" | ||
|
||
|
|
||
| if is_studio_course: | ||
| # build edit link to unit in CMS. Can't use reverse here as lms doesn't load cms's urls.py | ||
| edit_link = "//" + settings.CMS_BASE + '/container/' + text_type(block.location) | ||
|
||
|
|
||
| # return edit link in rendered HTML for display | ||
| return wrap_fragment( | ||
| frag, | ||
| render_to_string( | ||
| "edit_unit_link.html", | ||
| {'frag_content': frag.content, 'edit_link': edit_link} | ||
| ) | ||
| ) | ||
| else: | ||
| return frag | ||
| return frag | ||
|
|
||
| if isinstance(block, SequenceModule) or getattr(block, 'HIDDEN', False): | ||
| return frag | ||
|
|
||




There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests seem fairly module-level specific, so probably not worth porting over as-is.
How much, if any, do we care to add testing here for the legacy view/component?
Spoiler: I've not added any at this point :)