Merge pull request #15289 from edx/jlajoie/EDUCATOR-434

EDUCATOR-434: Unit Group Access
This commit is contained in:
Jeff LaJoie
2017-07-19 15:32:02 -04:00
committed by GitHub
50 changed files with 1334 additions and 246 deletions

View File

@@ -72,6 +72,8 @@ from openedx.core.djangolib.markup import HTML, Text
data-field="display_name" data-field-display-name="${_("Display Name")}">
<h1 class="page-header-title xblock-field-value incontext-editor-value"><span class="title-value">${xblock.display_name_with_default}</span></h1>
</div>
<div class="container-access">
</div>
</div>
<nav class="nav-actions" aria-label="${_('Page Actions')}">

View File

@@ -26,7 +26,7 @@ from openedx.core.djangolib.markup import HTML, Text
<%block name="header_extras">
<link rel="stylesheet" type="text/css" href="${static.url('js/vendor/timepicker/jquery.timepicker.css')}" />
% for template_name in ['course-outline', 'xblock-string-field-editor', 'basic-modal', 'modal-button', 'course-outline-modal', 'due-date-editor', 'release-date-editor', 'grading-editor', 'publish-editor', 'staff-lock-editor', 'content-visibility-editor', 'verification-access-editor', 'timed-examination-preference-editor', 'access-editor', 'settings-modal-tabs', 'show-correctness-editor']:
% for template_name in ['course-outline', 'xblock-string-field-editor', 'basic-modal', 'modal-button', 'course-outline-modal', 'due-date-editor', 'release-date-editor', 'grading-editor', 'publish-editor', 'staff-lock-editor', 'unit-access-editor', 'content-visibility-editor', 'verification-access-editor', 'timed-examination-preference-editor', 'access-editor', 'settings-modal-tabs', 'show-correctness-editor']:
<script type="text/template" id="${template_name}-tpl">
<%static:include path="js/${template_name}.underscore" />
</script>

View File

@@ -0,0 +1,31 @@
<%
var selectedGroupsLabel = userPartitionInfo['selected_groups_label'];
var selectedPartitionIndex = userPartitionInfo['selected_partition_index'];
var category = this.model.attributes.category;
var blockType = "";
if (category == "vertical") {
blockType = gettext("unit")
} else {
blockType = gettext("component")
}
%>
<% if (selectedGroupsLabel) { %>
<span class="access-message"><%-
edx.StringUtils.interpolate(
// Translators: blockType refers to the type of the xblock that access is restricted to.
gettext('Access to this {blockType} is restricted to: {selectedGroupsLabel}'),
{
selectedGroupsLabel: selectedGroupsLabel,
blockType: blockType
}
) %></span>
<% } else if (hasPartitionGroupComponents) { %>
<span class="access-message"><%-
edx.StringUtils.interpolate(
// Translators: blockType refers to the type of the xblock that access is restricted to.
gettext('Access to some content in this {blockType} is restricted to specific groups of learners.'),
{
blockType: blockType
}
) %></span>
<% } %>

View File

@@ -4,6 +4,9 @@ var visibilityState = xblockInfo.get('visibility_state');
var published = xblockInfo.get('published');
var prereq = xblockInfo.get('prereq');
var hasPartitionGroups = xblockInfo.get('has_partition_group_components');
var userPartitionInfo = xblockInfo.get('user_partition_info');
var selectedGroupsLabel = userPartitionInfo['selected_groups_label'];
var selectedPartitionIndex = userPartitionInfo['selected_partition_index'];
var statusMessages = [];
var messageType;
@@ -57,7 +60,16 @@ if (staffOnlyMessage) {
addStatusMessage(messageType, messageText);
}
if (hasPartitionGroups) {
if (selectedPartitionIndex !== -1 && !isNaN(selectedPartitionIndex) && xblockInfo.isVertical()) {
messageType = 'partition-groups';
messageText = edx.StringUtils.interpolate(
gettext('Access to this unit is restricted to: {selectedGroupsLabel}'),
{
selectedGroupsLabel: selectedGroupsLabel
}
)
addStatusMessage(messageType, messageText);
} else if (hasPartitionGroups && xblockInfo.isVertical()) {
addStatusMessage(
'partition-groups',
gettext('Access to some content in this unit is restricted to specific groups of learners')

View File

@@ -47,7 +47,7 @@
<button class="edit-button action-button"></button>
</li>
<li class="action-item action-visibility">
<button class="visibility-button action-button"></button>
<button class="access-button action-button"></button>
</li>
<li class="action-item action-duplicate">
<button class="duplicate-button action-button"></button>
@@ -78,7 +78,7 @@
<button class="edit-button action-button"></button>
</li>
<li class="action-item action-visibility">
<button class="visibility-button action-button"></button>
<button class="access-button action-button"></button>
</li>
<li class="action-item action-duplicate">
<button class="duplicate-button action-button"></button>
@@ -109,7 +109,7 @@
<button class="edit-button action-button"></button>
</li>
<li class="action-item action-visibility">
<button class="visibility-button action-button"></button>
<button class="access-button action-button"></button>
</li>
<li class="action-item action-duplicate">
<button class="duplicate-button action-button"></button>
@@ -170,7 +170,7 @@
<button class="edit-button action-button"></button>
</li>
<li class="action-item action-visibility">
<button class="visibility-button action-button"></button>
<button class="access-button action-button"></button>
</li>
<li class="action-item action-duplicate">
<button class="duplicate-button action-button"></button>
@@ -201,7 +201,7 @@
<button class="edit-button action-button"></button>
</li>
<li class="action-item action-visibility">
<button class="visibility-button action-button"></button>
<button class="access-button action-button"></button>
</li>
<li class="action-item action-duplicate">
<button class="duplicate-button action-button"></button>
@@ -232,7 +232,7 @@
<button class="edit-button action-button"></button>
</li>
<li class="action-item action-visibility">
<button class="visibility-button action-button"></button>
<button class="access-button action-button"></button>
</li>
<li class="action-item action-duplicate">
<button class="duplicate-button action-button"></button>

View File

@@ -97,12 +97,6 @@ var visibleToStaffOnly = visibilityState === 'staff_only';
<% } else { %>
<p class="visbility-copy copy"><%- gettext("Staff and Learners") %></p>
<% } %>
<% if (hasPartitionGroupComponents) { %>
<p class="note-visibility">
<span class="icon fa fa-eye" aria-hidden="true"></span>
<span class="note-copy"><%- gettext("Access to some content in this unit is restricted to specific groups of learners.") %></span>
</p>
<% } %>
<ul class="actions-inline">
<li class="action-inline">
<a href="" class="action-staff-lock" role="button" aria-pressed="<%- hasExplicitStaffLock %>">

View File

@@ -7,26 +7,19 @@
<% } %>
</h3>
<div class="modal-section-content staff-lock">
<ul class="list-fields list-input">
<li class="field field-checkbox checkbox-cosmetic">
<input type="checkbox" id="staff_lock" name="staff_lock" class="input input-checkbox" />
<label for="staff_lock" class="label">
<span class="icon fa fa-check-square-o input-checkbox-checked" aria-hidden="true"></span>
<span class="icon fa fa-square-o input-checkbox-unchecked" aria-hidden="true"></span>
<%- gettext('Hide from learners') %>
</label>
<% if (hasExplicitStaffLock && !ancestorLocked) { %>
<p class="tip tip-warning">
<% if (xblockInfo.isVertical()) { %>
<%- gettext('If the unit was previously published and released to learners, any changes you made to the unit when it was hidden will now be visible to learners.') %>
<% } else { %>
<% var message = gettext('If you make this %(xblockType)s visible to learners, learners will be able to see its content after the release date has passed and you have published the unit. Only units that are explicitly hidden from learners will remain hidden after you clear this option for the %(xblockType)s.') %>
<%- interpolate(message, { xblockType: xblockType }, true) %>
<% } %>
</p>
<% } %>
</li>
</ul>
<label class="label">
<input type="checkbox" id="staff_lock" name="staff_lock" class="input input-checkbox" />
<%- gettext('Hide from learners') %>
</label>
<% if (hasExplicitStaffLock && !ancestorLocked) { %>
<p class="tip tip-warning">
<% if (xblockInfo.isVertical()) { %>
<%- gettext('If the unit was previously published and released to learners, any changes you made to the unit when it was hidden will now be visible to learners.') %>
<% } else { %>
<% var message = gettext('If you make this %(xblockType)s visible to learners, learners will be able to see its content after the release date has passed and you have published the unit. Only units that are explicitly hidden from learners will remain hidden after you clear this option for the %(xblockType)s.') %>
<%- interpolate(message, { xblockType: xblockType }, true) %>
<% } %>
</p>
<% } %>
</div>
</form>

View File

@@ -0,0 +1,46 @@
<%
var userPartitionInfo = xblockInfo.get('user_partition_info');
var selectablePartitions = userPartitionInfo['selectable_partitions'];
%>
<form>
<% if (selectablePartitions.length > 0) { %>
<h3 class="modal-section-title access-change">
<%- gettext('Unit Access') %>
</h3>
<div class="modal-section-content access-change">
<label class="group-select-title"><%- gettext('Restrict access to:') %>
<select class="user-partition-select" id="partition-select">
<option value="-1" selected ="selected"><%- gettext('Select a group type') %></option>
<% for (var i=0; i < selectablePartitions.length; i++) { %>
<option id="<%- selectablePartitions[i].id %>-option" value="<%- selectablePartitions[i].id %>"><%- selectablePartitions[i].name %></option>
<% } %>
</select>
</label>
<br>
<div class="user-partition-group-checkboxes">
<% for (var i=0; i < selectablePartitions.length; i++) { %>
<div role="group" aria-labelledby="partition-group-directions-<%- selectablePartitions[i].id %>" id="<%- selectablePartitions[i].id %>-checkboxes">
<div class="partition-group-directions" id="partition-group-directions-<%- selectablePartitions[i].id %>">
<%- gettext('Select one or more groups:') %>
<% for (var j = 0; j < selectablePartitions[i].groups.length; j++) { %>
<div class="field partition-group-control">
<input type="checkbox" id="content-group-<%- selectablePartitions[i].groups[j].id %>" value="<%- selectablePartitions[i].groups[j].id %>" class="input input-checkbox"
<% if (selectablePartitions[i].groups[j].selected) { %> checked="checked" <% } %> />
<% if (selectablePartitions[i].groups[j].deleted) { %>
<label for="content-group-<%- selectablePartitions[i].groups[j].id %>" class="label deleted">
<%- gettext('Deleted Group') %>
<span class="deleted-group-message"><%- gettext('This group no longer exists. Choose another group or do not restrict access to this unit.') %></span>
<% } else { %>
<label for="content-group-<%-selectablePartitions[i].groups[j].id %>" class="label">
<%- selectablePartitions[i].groups[j].name %>
</label>
<% } %>
</div>
<% } %>
</div>
</div>
<% } %>
</div>
</div>
<% } %>
</form>

View File

@@ -0,0 +1,5 @@
<div class="access-editor-action-wrapper">
<button class="unit-container access-button">
<span class="icon fa fa-gear" aria-hidden="true"></span><span class="sr"> <%- gettext('Set Access') %></span>
</button>
</div>

View File

@@ -1,14 +1,14 @@
<div class="incontext-editor-action-wrapper">
<a href="" class="action-edit action-inline xblock-field-value-edit incontext-editor-open-action" title="<%- gettext('Edit the name') %>">
<span class="icon fa fa-pencil" aria-hidden="true"></span><span class="sr"> <%- gettext("Edit") %></span>
</a>
<button class="action-edit action-inline xblock-field-value-edit incontext-editor-open-action">
<span class="icon fa fa-pencil" aria-hidden="true"></span><span class="sr"> <%- gettext('Edit') %></span>
</button>
</div>
<div class="xblock-string-field-editor incontext-editor-form">
<form>
<% var formLabel = gettext("Edit %(display_name)s (required)"); %>
<label><span class="sr"><%= interpolate(formLabel, {display_name: fieldDisplayName}, true) %></span>
<input type="text" value="<%= value %>" class="xblock-field-input incontext-editor-input" data-metadata-name="<%= fieldName %>" title="<%= gettext('Edit the name') %>">
<input type="text" value="<%= value %>" class="xblock-field-input incontext-editor-input" data-metadata-name="<%= fieldName %>">
</label>
<button class="sr action action-primary" name="submit" type="submit"><%= gettext("Save") %></button>
<button class="sr action action-secondary" name="cancel" type="button"><%= gettext("Cancel") %></button>

View File

@@ -82,7 +82,7 @@ messages = xblock.validate().to_json()
</li>
% if can_edit_visibility:
<li class="action-item action-visibility">
<button data-tooltip="${_("Access Settings")}" class="btn-default visibility-button action-button">
<button data-tooltip="${_("Access Settings")}" class="btn-default access-button action-button">
<span class="icon fa fa-gear" aria-hidden="true"></span>
<span class="sr">${_("Set Access")}</span>
</button>