visibility_editor.html 5.86 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<%
from django.utils.translation import ugettext as _

from openedx.core.djangoapps.course_groups.partition_scheme import get_cohorted_user_partition
from contentstore.utils import ancestor_has_staff_lock

cohorted_user_partition = get_cohorted_user_partition(xblock.location.course_key)
unsorted_groups = cohorted_user_partition.groups if cohorted_user_partition else []
groups = sorted(unsorted_groups, key=lambda group: group.name)
selected_group_ids = xblock.group_access.get(cohorted_user_partition.id, []) if cohorted_user_partition else []
has_selected_groups = len(selected_group_ids) > 0
is_staff_locked = ancestor_has_staff_lock(xblock)
%>

<div class="modal-section visibility-summary">
    % if len(groups) == 0:
        <div class="is-not-configured has-actions">
18
            <h4 class="title">${_('No content groups exist')}</h4>
19 20

            <div class="copy">
21
                <p>${_('Use content groups to give groups of students access to a specific set of course content. Create one or more content groups, and make specific components visible to them.')}</p>
22 23 24
            </div>

            <div class="actions">
25
                <a href="${manage_groups_url}" class="action action-primary action-settings">${_('Manage content groups')}</a>
26 27 28 29
            </div>
        </div>
    % elif is_staff_locked:
        <div class="summary-message summary-message-warning visibility-summary-message">
30 31 32 33 34 35 36 37 38 39 40
            <i class="icon fa fa-exclamation-triangle" aria-hidden="true"></i>
            <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.
                ${_(
                    "{screen_reader_start}Warning:{screen_reader_end} The Unit this component is contained in is hidden from students. Visibility settings here will be trumped by this."
                    ).format(
                        screen_reader_start='<span class="sr">',
                        screen_reader_end='</span>',
                    )
                }
            </p>
41 42 43 44 45 46 47 48
        </div>
    % endif
</div>

% if len(groups) > 0:
    <form class="visibility-controls-form" method="post" action="">

        <div class="modal-section visibility-controls">
49
            <h3 class="modal-section-title">${_('Make visible to:')}</h3>
50 51 52 53 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103

            <div class="modal-section-content">

                <section class="visibility-controls-primary">
                    <ul class="list-fields list-radio">
                        <li class="field field-radio field-visibility-level">
                            <input type="radio" id="visibility-level-all" name="visibility-level" value="" class="input input-radio visibility-level-all" ${'checked="checked"' if not has_selected_groups else ''} />
                            <label for="visibility-level-all" class="label">${_('All Students and Staff')}</label>
                        </li>

                        <li class="field field-radio field-visibility-level">
                            <input type="radio" id="visibility-level-specific" name="visibility-level" value="" class="input input-radio visibility-level-specific"  ${'checked="checked"' if has_selected_groups else ''} />
                            <label for="visibility-level-specific" class="label">${_('Specific Content Groups')}</label>
                        </li>
                    </ul>
                </section>

                <div class="wrapper-visibility-specific" data-user-partition-id="${cohorted_user_partition.id}">
                    <section class="visibility-controls-secondary">
                        <div class="visibility-controls-group">
                            <h4 class="visibility-controls-title modal-subsection-title sr">${_('Content Groups')}</h4>
                            <ul class="list-fields list-checkbox">
                                <%
                                missing_group_ids = set(selected_group_ids)
                                %>
                                % for group in groups:
                                    <%
                                    is_group_selected = group.id in selected_group_ids
                                    if is_group_selected:
                                        missing_group_ids.remove(group.id)
                                    %>
                                    <li class="field field-checkbox field-visibility-content-group">
                                        <input type="checkbox" id="visibility-content-group-${group.id}" name="visibility-content-group" value="${group.id}" class="input input-checkbox"  ${'checked="checked"' if group.id in selected_group_ids else ''}/>
                                        <label for="visibility-content-group-${group.id}" class="label">${group.name | h}</label>
                                    </li>
                                % endfor

                                % for group_id in missing_group_ids:
                                    <li class="field field-checkbox field-visibility-content-group was-removed">
                                        <input type="checkbox" id="visibility-content-group-${group_id}" name="visibility-content-group" value="${group_id}" class="input input-checkbox" checked="checked" />
                                        <label for="visibility-content-group-${group_id}" class="label">
                                            ${_('Deleted Content Group')}
                                            <span class="note">${_('Content group no longer exists. Please choose another or allow access to All Students and staff')}</span>
                                        </label>
                                    </li>
                                % endfor
                            </ul>
                        </div>
                    </section>
                </div>
            </div>
        </div>
    </form>
% endif