Commit c9321553 by swdanielli

Merge pull request #25 from pmitros/danielli/accessibility

change deendorse to remove
parents 1af564d7 ba7a8ebe
...@@ -106,13 +106,13 @@ class RecommenderXBlock(XBlock): ...@@ -106,13 +106,13 @@ class RecommenderXBlock(XBlock):
# Usage: the same as default_recommendations # Usage: the same as default_recommendations
deendorsed_recommendations = Dict( deendorsed_recommendations = Dict(
help="Dict of deendorsed resources", default={}, scope=Scope.user_state_summary help="Dict of removed resources", default={}, scope=Scope.user_state_summary
) )
# A list of recommendations deendorsed by course staff, it is a JSON object # A list of recommendations removed by course staff, it is a JSON object
# aggregated across many users of a single block. # aggregated across many users of a single block.
# Usage: the same as default_recommendations plus # Usage: the same as default_recommendations plus
# deendorsed_recommendations[index]['reason'] = (String) the reason why # deendorsed_recommendations[index]['reason'] = (String) the reason why
# course staff deendorse this resource # course staff remove this resource
endorsed_recommendation_ids = List( endorsed_recommendation_ids = List(
help="List of endorsed resources' ID", default=[], scope=Scope.user_state_summary help="List of endorsed resources' ID", default=[], scope=Scope.user_state_summary
...@@ -489,7 +489,7 @@ class RecommenderXBlock(XBlock): ...@@ -489,7 +489,7 @@ class RecommenderXBlock(XBlock):
# check url for de-endorsed resources # check url for de-endorsed resources
if resource_id in self.deendorsed_recommendations: if resource_id in self.deendorsed_recommendations:
result['error'] = ('The resource you are attempting to ' + result['error'] = ('The resource you are attempting to ' +
'provide has been de-endorsed by staff, ' + 'provide has been removed by staff, ' +
'because: ' + self.deendorsed_recommendations[resource_id]['reason']) 'because: ' + self.deendorsed_recommendations[resource_id]['reason'])
for field in self.resource_content_fields: for field in self.resource_content_fields:
result['dup_' + field] = self.deendorsed_recommendations[resource_id][field] result['dup_' + field] = self.deendorsed_recommendations[resource_id][field]
...@@ -556,7 +556,7 @@ class RecommenderXBlock(XBlock): ...@@ -556,7 +556,7 @@ class RecommenderXBlock(XBlock):
# check url for de-endorsed resources # check url for de-endorsed resources
if edited_resource_id in self.deendorsed_recommendations: if edited_resource_id in self.deendorsed_recommendations:
result['error'] = ('The resource you are attempting to ' + result['error'] = ('The resource you are attempting to ' +
'provide has been de-endorsed by ' + 'provide has been removed by ' +
'staff, because: ' + 'staff, because: ' +
self.deendorsed_recommendations[edited_resource_id]['reason']) self.deendorsed_recommendations[edited_resource_id]['reason'])
for field in self.resource_content_fields: for field in self.resource_content_fields:
...@@ -678,21 +678,21 @@ class RecommenderXBlock(XBlock): ...@@ -678,21 +678,21 @@ class RecommenderXBlock(XBlock):
@XBlock.json_handler @XBlock.json_handler
def deendorse_resource(self, data, _suffix=''): def deendorse_resource(self, data, _suffix=''):
""" """
Deendorse an entry of resource. Remove an entry of resource.
Args: Args:
data: dict in JSON format data: dict in JSON format
data['id']: the ID of the resouce to be deendorsed data['id']: the ID of the resouce to be removed
data['reason']: the reason why the resouce was deendorsed data['reason']: the reason why the resouce was removed
Returns: Returns:
result: dict in JSON format result: dict in JSON format
result['Success']: the boolean indicator for whether the deendorsement is complete result['Success']: the boolean indicator for whether the removal is complete
result['error']: the error message generated when the deendorsement fails result['error']: the error message generated when the removal fails
result['recommendation']: (Dict) the deendorsed resource result['recommendation']: (Dict) the removed resource
result['recommendation']['reason']: the reason why the resouce was deendorsed result['recommendation']['reason']: the reason why the resouce was removed
""" """
if not self.get_user_is_staff(): if not self.get_user_is_staff():
msg = 'Deendorse resource without permission' msg = 'Remove resource without permission'
return self.error_handler(msg, 'deendorse_resource') return self.error_handler(msg, 'deendorse_resource')
resource_id = stem_url(data['id']) resource_id = stem_url(data['id'])
......
...@@ -248,7 +248,7 @@ input[type="button"]:not([DISABLED]){ ...@@ -248,7 +248,7 @@ input[type="button"]:not([DISABLED]){
color: white; color: white;
} }
.resourceRankingForDeendorsementButton:not(deendorsementMode):before { content: 'Ordinary '; } .resourceRankingForDeendorsementButton:not(deendorsementMode):before { content: 'Ordinary '; }
.resourceRankingForDeendorsementButton.deendorsementMode:before { content: 'De-endorsement '; } .resourceRankingForDeendorsementButton.deendorsementMode:before { content: 'Removal '; }
.endorse:not(.endorsed) { color: #DFD3D3; display: none; } .endorse:not(.endorsed) { color: #DFD3D3; display: none; }
.endorse.endorsed { color: rgb(69, 194, 10); } .endorse.endorsed { color: rgb(69, 194, 10); }
...@@ -259,7 +259,6 @@ input[type="button"]:not([DISABLED]){ ...@@ -259,7 +259,6 @@ input[type="button"]:not([DISABLED]){
.plusIcon:before { content: '+'; } .plusIcon:before { content: '+'; }
.nextPageIcon:before { content: '►'; } .nextPageIcon:before { content: '►'; }
.previousPageIcon:before { content: '◄'; } .previousPageIcon:before { content: '◄'; }
/*.morePageIcon:before { content: '...'; }*/
.highlightActivePageNumber { background-color: #948f8f; } .highlightActivePageNumber { background-color: #948f8f; }
.my-custom-theme { .my-custom-theme {
......
...@@ -159,7 +159,7 @@ ...@@ -159,7 +159,7 @@
name="deendorseRationale" name="deendorseRationale"
placeholder="Reason for why this resource should be removed"/> placeholder="Reason for why this resource should be removed"/>
</label> </label>
<input type="button" value="Deendorse resource" class="deendorseResource"/> <input type="button" value="Remove resource" class="deendorseResource"/>
</div> </div>
<div class="endorsePage" style='display: none;' aria-hidden="true"> <div class="endorsePage" style='display: none;' aria-hidden="true">
<div class="modifyPageTitle"></div> <div class="modifyPageTitle"></div>
......
...@@ -41,7 +41,7 @@ var tooltipsCatsText = { ...@@ -41,7 +41,7 @@ var tooltipsCatsText = {
'.recommenderVoteArrowDown': '<span>Downvote if the resource is not helpful</span>', '.recommenderVoteArrowDown': '<span>Downvote if the resource is not helpful</span>',
'.recommenderVoteScore': '<span>Votes</span>', // '.recommenderVoteScore': '<span>Votes</span>', //
'a': '<span>Resource title</span>', // TODO: I would suggest making the description be the tooltip. 'a': '<span>Resource title</span>', // TODO: I would suggest making the description be the tooltip.
'.deendorse': '<span>Deendorse this resource and give the reason why you do that</span>', '.deendorse': '<span>Remove this resource and give the reason why you do that</span>',
'.previewingImg': '<span>Preview image (typically, a screenshot)</span>', '.previewingImg': '<span>Preview image (typically, a screenshot)</span>',
'.inTitle': '<span>Give a short (1-3 sentence) summary of the resource; ideally, this should be concise, but give enough detail to let students know whether this resources is useful to them</span>', '.inTitle': '<span>Give a short (1-3 sentence) summary of the resource; ideally, this should be concise, but give enough detail to let students know whether this resources is useful to them</span>',
'.inUrl': '<span>Cut-and-paste the URL of the resource.</span>', '.inUrl': '<span>Cut-and-paste the URL of the resource.</span>',
...@@ -59,7 +59,7 @@ var tooltipsCatsText = { ...@@ -59,7 +59,7 @@ var tooltipsCatsText = {
'.hideShow.resourceListExpanded': '<span>Hide the recommendations list</span>', '.hideShow.resourceListExpanded': '<span>Hide the recommendations list</span>',
'.checkIcon': '<span>Check the icon to endorse this resource</span>', '.checkIcon': '<span>Check the icon to endorse this resource</span>',
'.checkIcon.endorsed': '<span>This resource is endorsed by staff</span>', '.checkIcon.endorsed': '<span>This resource is endorsed by staff</span>',
'.resourceRankingForDeendorsementButton': '<span>Click to view resources for de-endorsement</span>', '.resourceRankingForDeendorsementButton': '<span>Click to view resources for removal</span>',
'.resourceRankingForDeendorsementButton.deendorsementMode': '<span>Click to view resources in ordinary decreasing-vote order</span>' '.resourceRankingForDeendorsementButton.deendorsementMode': '<span>Click to view resources in ordinary decreasing-vote order</span>'
}; };
...@@ -106,7 +106,7 @@ var headerText = { ...@@ -106,7 +106,7 @@ var headerText = {
'.editResourcePage': 'Edit existing resource', '.editResourcePage': 'Edit existing resource',
'.flagResourcePage': 'Flag Resource', '.flagResourcePage': 'Flag Resource',
'.endorsePage': 'Endorse Resource', '.endorsePage': 'Endorse Resource',
'.deendorsePage': 'Deendorse Resource' '.deendorsePage': 'Remove Resource'
}; };
var modifyPageTitle = { var modifyPageTitle = {
...@@ -115,7 +115,7 @@ var modifyPageTitle = { ...@@ -115,7 +115,7 @@ var modifyPageTitle = {
'.editResourcePage': 'Edit the resource and make it more helpful for other students with this problem. Please do not give the answer directly.', '.editResourcePage': 'Edit the resource and make it more helpful for other students with this problem. Please do not give the answer directly.',
'.flagResourcePage': 'Why would you like to flag this resource? The staff will review all flagged resources, and remove inappropriate ones (spam, incorrect, abusive, etc.). Giving a clear reason will help us do this efficiently.', '.flagResourcePage': 'Why would you like to flag this resource? The staff will review all flagged resources, and remove inappropriate ones (spam, incorrect, abusive, etc.). Giving a clear reason will help us do this efficiently.',
'.endorsePage': 'Endorse this resource and give the reason why you do that.', '.endorsePage': 'Endorse this resource and give the reason why you do that.',
'.deendorsePage': 'Deendorse this resource and give the reason why you do that.' '.deendorsePage': 'Remove this resource and give the reason why you do that.'
}; };
var writeDatabaseEnum = { var writeDatabaseEnum = {
...@@ -164,7 +164,7 @@ var ariaLabelText = { ...@@ -164,7 +164,7 @@ var ariaLabelText = {
'endorsedResource': 'endorsed resource', 'endorsedResource': 'endorsed resource',
'endorseResource': 'endorse resource', 'endorseResource': 'endorse resource',
'undoEndorseResource': 'undo endorse resource', 'undoEndorseResource': 'undo endorse resource',
'deendorseResource': 'deendorse resource' 'deendorseResource': 'remove resource'
} }
var toggleVoteFlag = 'toggle'; var toggleVoteFlag = 'toggle';
...@@ -208,7 +208,7 @@ var loggerStatus = { ...@@ -208,7 +208,7 @@ var loggerStatus = {
'endorse': 'Endorse resource', 'endorse': 'Endorse resource',
'unendorse': 'Unendorse resource' 'unendorse': 'Unendorse resource'
}, },
'deendorseResource': {'deendorseResource': 'Deendorse resource'}, 'deendorseResource': {'deendorseResource': 'Remove resource'},
'hover': {'hover': 'Hovering resource'}, 'hover': {'hover': 'Hovering resource'},
'clickResource': {'clickResource': 'A resource was clicked'}, 'clickResource': {'clickResource': 'A resource was clicked'},
'backToView': {'backToView': 'Back to resource list mode'} 'backToView': {'backToView': 'Back to resource list mode'}
......
...@@ -188,7 +188,7 @@ function RecommenderXBlock(runtime, element, init_data) { ...@@ -188,7 +188,7 @@ function RecommenderXBlock(runtime, element, init_data) {
/** /**
* Hide resource list and show pages for modifying * Hide resource list and show pages for modifying
* (i.e., add/edit/endorse/deendorse/import/flag) recommender * (i.e., add/edit/endorse/remove/import/flag) recommender
* @param {string} page The string indicating the page we are going to show. * @param {string} page The string indicating the page we are going to show.
*/ */
function showModifyingPage(page) { function showModifyingPage(page) {
...@@ -298,7 +298,7 @@ function RecommenderXBlock(runtime, element, init_data) { ...@@ -298,7 +298,7 @@ function RecommenderXBlock(runtime, element, init_data) {
} }
/** /**
* Interrupt a submission (resource add, edit, flag, endorse, deendorse, * Interrupt a submission (resource add, edit, flag, endorse, remove,
* import, etc.). First, log the typed information for an incomplete * import, etc.). First, log the typed information for an incomplete
* submission. Second, go back from pages for resource addition, edit, * submission. Second, go back from pages for resource addition, edit,
* flag, etc. to pages for viewing resources. * flag, etc. to pages for viewing resources.
...@@ -893,9 +893,9 @@ function RecommenderXBlock(runtime, element, init_data) { ...@@ -893,9 +893,9 @@ function RecommenderXBlock(runtime, element, init_data) {
} }
/** /**
* This is a function restricted to course staff, where we can toggle between viewing mode for deendorsement and * This is a function restricted to course staff, where we can toggle between viewing mode for removal and
* ordinary browsing * ordinary browsing
* Deendorsement mode: * Removal mode:
* Re-rank resources by first showing flagged resource, then non-flagged one in the order of increasing votes * Re-rank resources by first showing flagged resource, then non-flagged one in the order of increasing votes
* Show the reason and accumulated flagged result * Show the reason and accumulated flagged result
* Ordinary mode: * Ordinary mode:
...@@ -1036,13 +1036,13 @@ function RecommenderXBlock(runtime, element, init_data) { ...@@ -1036,13 +1036,13 @@ function RecommenderXBlock(runtime, element, init_data) {
/** /**
* Bind the event for deendorsing a resource and submitting the * Bind the event for deendorsing a resource and submitting the
* reason why the staff think the resource should be deendorsed. * reason why the staff think the resource should be removed.
* @param {element} ele The recommenderResource element the event will be bound to. * @param {element} ele The recommenderResource element the event will be bound to.
*/ */
function bindResourceDeendorseEvent(ele) { function bindResourceDeendorseEvent(ele) {
if ($('.deendorse', ele).length == 0) { $('.recommenderEdit', ele).append(deendorseIcon); } if ($('.deendorse', ele).length == 0) { $('.recommenderEdit', ele).append(deendorseIcon); }
/* Enter deendorse mode */ /* Enter removal mode */
$('.deendorse', ele).click(function() { $('.deendorse', ele).click(function() {
showModifyingPage('.deendorsePage') showModifyingPage('.deendorsePage')
$('.deendorsePage', element).find('input[type="text"]').val(''); $('.deendorsePage', element).find('input[type="text"]').val('');
...@@ -1050,7 +1050,7 @@ function RecommenderXBlock(runtime, element, init_data) { ...@@ -1050,7 +1050,7 @@ function RecommenderXBlock(runtime, element, init_data) {
data['id'] = $(this).parent().parent().find('.recommenderEntryId').text(); data['id'] = $(this).parent().parent().find('.recommenderEntryId').text();
$('.deendorseResource', element).unbind(); $('.deendorseResource', element).unbind();
/* Deendorse a selected resource */ /* Remove a selected resource */
$('.deendorseResource', element).click(function() { $('.deendorseResource', element).click(function() {
data['reason'] = $('.deendorseReason', element).val(); data['reason'] = $('.deendorseReason', element).val();
Logger.log('mit.recommender.deendorseResource', generateLog(loggerStatus['deendorseResource']['deendorseResource'], data)); Logger.log('mit.recommender.deendorseResource', generateLog(loggerStatus['deendorseResource']['deendorseResource'], data));
...@@ -1062,7 +1062,7 @@ function RecommenderXBlock(runtime, element, init_data) { ...@@ -1062,7 +1062,7 @@ function RecommenderXBlock(runtime, element, init_data) {
if (result['Success']) { if (result['Success']) {
var deletedResourceIdx = findResourceDiv(result['id']); var deletedResourceIdx = findResourceDiv(result['id']);
$('.recommenderResource:eq(' + deletedResourceIdx.toString() + ')', element).remove(); $('.recommenderResource:eq(' + deletedResourceIdx.toString() + ')', element).remove();
/* Deendorse (remove) last resource */ /* Remove last resource */
if ($('.recommenderResource', element).length == deletedResourceIdx) { deletedResourceIdx--; } if ($('.recommenderResource', element).length == deletedResourceIdx) { deletedResourceIdx--; }
CURRENT_PAGE = Math.ceil((deletedResourceIdx + 1)/ENTRIES_PER_PAGE); CURRENT_PAGE = Math.ceil((deletedResourceIdx + 1)/ENTRIES_PER_PAGE);
paginationItem(); paginationItem();
...@@ -1116,7 +1116,7 @@ function RecommenderXBlock(runtime, element, init_data) { ...@@ -1116,7 +1116,7 @@ function RecommenderXBlock(runtime, element, init_data) {
} }
/** /**
* Set the text of endorse/deendorse buttons for accessibility, these * Set the text of endorse/remove buttons for accessibility, these
* buttons are limited to staff. * buttons are limited to staff.
* @param {element} ele The recommenderResource element the buttons attached to. * @param {element} ele The recommenderResource element the buttons attached to.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment