visibility_editor.html 6.08 KB
Newer Older
1
<%page expression_filter="h"/>
2
<%
3
from django.conf import settings
4
from django.utils.translation import ugettext as _
5
from contentstore.utils import ancestor_has_staff_lock, get_visibility_partition_info
6
from openedx.core.djangolib.markup import HTML, Text
7

8
partition_info = get_visibility_partition_info(xblock)
9 10 11
selectable_partitions = partition_info["selectable_partitions"]
selected_partition_index = partition_info["selected_partition_index"]
selected_groups_label = partition_info["selected_groups_label"]
12 13 14 15 16

is_staff_locked = ancestor_has_staff_lock(xblock)
%>

<div class="modal-section visibility-summary">
17
    % if len(selectable_partitions) == 0:
18
        <div class="is-not-configured has-actions">
19
            <h3 class="title">${_('No visibility settings')}</h3>
20
            <div class="copy">
21 22 23 24 25 26
                <p>${_('No visibility settings are defined for this component, but visibility might be affected by inherited settings.')}</p>
                % if settings.FEATURES.get('ENABLE_ENROLLMENT_TRACK_USER_PARTITION'):
                <p>${_('You can make this component visible only to specific groups of learners based either on their enrollment track, or by content groups that you create.')}</p>
                % else:
                <p>${_('You can make this component visible only to specific groups of learners based on content groups that you create.')}</p>
                % endif
27 28 29
            </div>

            <div class="actions">
30
                <a href="${manage_groups_url}" class="action action-primary action-settings">${_('Manage content groups')}</a>
31 32 33 34
            </div>
        </div>
    % elif is_staff_locked:
        <div class="summary-message summary-message-warning visibility-summary-message">
35
            <span class="icon fa fa-exclamation-triangle" aria-hidden="true"></span>
36 37
            <p class="copy">
                ## Translators: Any text between {screen_reader_start} and {screen_reader_end} is only read by screen readers and never shown in the browser.
38 39 40 41 42
                ${Text(_(
                    "{screen_reader_start}Warning:{screen_reader_end} The unit that contains this component is hidden from learners. The unit setting overrides the component visibility settings defined here."
                    )).format(
                        screen_reader_start=HTML('<span class="sr">'),
                        screen_reader_end=HTML('</span>'),
43 44 45
                    )
                }
            </p>
46 47 48 49
        </div>
    % endif
</div>

50
% if len(selectable_partitions) > 0:
51
    <form class="visibility-controls-form" method="post" action="">
52
        <div role="group" aria-labelledby="visibility-title">
53
        <div class="modal-section visibility-controls">
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
            <h3 class="modal-section-title visibility-header" id="visibility-title">
                <span class="current-visibility-title">
                    <span class="icon fa fa-eye" aria-hidden="true"></span>
                    <span>${_('Currently visible to:')}</span>
                </span>
                % if selected_partition_index == -1:
                <span>${_('All Learners and Staff')}</span>
                % else:
                <span>${selected_groups_label}</span>
                % endif
            </h3>
            <div class="modal-section-content partition-visibility">
                <label class="group-select-title">${_('Change visibility to:')}
                    <select>
                        <option value="-1" selected ="selected">
                            % if selected_partition_index == -1:
                                ${_('Choose one')}
                            % else:
                                ${_('All Learners and Staff')}
                            % endif
                        </option>
                        % for index, partition in enumerate(selectable_partitions):
                            <option value="${partition["id"]}" id="visibility-partition-${partition["id"]}" ${'selected="selected"' if selected_partition_index == index else ''}}>
                                ${partition["name"]}
                            </option>
                        % endfor
                    </select>
                </label>
82

83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
                % for index, partition in enumerate(selectable_partitions):
                <div role="group" aria-labelledby="partition-group-directions-${partition["id"]}" aria-describedby="visibility-partition-${partition["id"]}"
                    class="partition-group-control partition-group-control-${partition["id"]} ${'is-hidden' if selected_partition_index != index else ''}">
                    <div class="partition-group-directions" id="partition-group-directions-${partition["id"]}">${_('Select one or more groups:')}
                        % for group in partition["groups"]:
                        <div class="field partition-group-visibility partition-group-visibility-${partition["id"]} ${'was-removed' if group["deleted"] else ''}">
                            <input type="checkbox"
                                id="visibility-group-${partition["id"]}-${group["id"]}"
                                name="visibility-group"
                                value="${group["id"]}"
                                class="input input-checkbox"
                                ${'checked="checked"' if group["selected"] else ''}
                            />
                            % if group["deleted"]:
                            <label for="visibility-group-${partition["id"]}-${group["id"]}" class="label">
                                ${_("Deleted Group")}
                                <span class="note">${_('This group no longer exists. Choose another group or make this component visible to All Learners and Staff.')}</span>
                            </label>
                            % else:
                            <label for="visibility-group-${partition["id"]}-${group["id"]}" class="label">${group["name"]}</label>
103
                            % endif
104 105 106
                         </div>
                        % endfor
                    </div>
107
                </div>
108
                % endfor
109 110 111
            </div>
        </div>
    </form>
112
% endif