This retrieves user preferences for edxnotes visibility by: 1. Adding a `bind_course_for_student` method to course overview model. 2. Using a bound XBlock in the `toggle_notes.html` template. The previously used unbound course instance was returning a default value.
36 lines
1.5 KiB
HTML
36 lines
1.5 KiB
HTML
<%page args="course, block" expression_filter="h"/>
|
|
<%!
|
|
from django.utils.translation import gettext as _
|
|
from django.urls import reverse
|
|
from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string
|
|
%>
|
|
<%namespace name='static' file='/static_content.html'/>
|
|
|
|
<%
|
|
edxnotes_visibility = getattr(block, 'edxnotes_visibility', course.edxnotes_visibility)
|
|
edxnotes_visibility_url = reverse("edxnotes_visibility", kwargs={"course_id": course.id})
|
|
if is_learning_mfe is UNDEFINED:
|
|
hide_ui = False
|
|
else:
|
|
hide_ui = is_learning_mfe
|
|
%>
|
|
<div class="wrapper-utility edx-notes-visibility ${'hidden' if hide_ui else ''}">
|
|
<span class="action-toggle-message" aria-live="polite"></span>
|
|
<button class="utility-control utility-control-button action-toggle-notes is-disabled ${"is-active" if edxnotes_visibility else ""}">
|
|
<span class="icon fa fa-pencil" aria-hidden="true"></span>
|
|
% if edxnotes_visibility:
|
|
<span class="utility-control-label sr">${_("Hide notes")}</span>
|
|
% else:
|
|
<span class="utility-control-label sr">${_("Show notes")}</span>
|
|
% endif
|
|
</button>
|
|
</div>
|
|
|
|
<%static:require_module_async module_name="js/edxnotes/views/notes_visibility_factory" class_name="NotesVisibilityFactory">
|
|
NotesVisibilityFactory.ToggleVisibilityView(
|
|
${edxnotes_visibility | n, dump_js_escaped_json},
|
|
'${edxnotes_visibility_url | n, js_escaped_string}',
|
|
${hide_ui | n, dump_js_escaped_json}
|
|
);
|
|
</%static:require_module_async>
|