Skip to content

Commit

Permalink
add unmute assignment warning dialog to speedgrader
Browse files Browse the repository at this point in the history
This adds an unmute dialog to SpeedGrader mimicking what already exists
in Gradebook.

fixes CNVS-34824

test plan:
 - Have a class with a muted assignment and a student.
 - Go into SpeedGrader for the assignment.
 - Click the mute/unmute icon.
 - Note the Unmute Assignment dialog appears.
 - Click the Unmute Assignment button.
 - Note the icon is now in the "unmuted" state.
 - Go to gradebook and confirm assignment is unmuted.

Change-Id: Id398c6e17ee85c60f15aa2c7450df5be8f408bcc
Reviewed-on: https://gerrit.instructure.com/101772
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <[email protected]>
Reviewed-by: Shahbaz Javeed <[email protected]>
QA-Review: KC Naegle <[email protected]>
Product-Review: Christi Wruck
  • Loading branch information
ktgeek committed Feb 17, 2017
1 parent 93e5dba commit 8ad874e
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/views/gradebooks/speed_grader.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@
</div>
</form>
<%= render :partial => "shared/mute_dialog" %>
<%= render :partial => "shared/unmute_dialog" %>
<ul id="section-menu" class="ui-selectmenu-menu ui-widget ui-widget-content ui-selectmenu-menu-dropdown ui-selectmenu-open" style="display:none;" role="listbox" aria-activedescendant="section-menu-link">
<li role="presentation" class="ui-selectmenu-item">
<a href="#" tabindex="-1" role="option" aria-selected="true" id="section-menu-link">
Expand Down
8 changes: 8 additions & 0 deletions app/views/shared/_unmute_dialog.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div id="unmute_dialog" style="display: none; width: 400px;" data-title="<%= t("Unmute Assignment") %>">
<%=
mt(:unmute_dialog, <<-STR)
This assignment is currently muted. That means students can't see their grades and feedback. Would you like to unmute now?
STR
%>
</div>

31 changes: 29 additions & 2 deletions public/javascripts/speed_grader.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ define([
link: $('#mute_link'),
modal: $('#mute_dialog')
},
unmute: {
modal: $('#unmute_dialog')
},
nav: $gradebook_header.find('#prev-student-button, #next-student-button'),
settings: {
form: $('#settings_form'),
Expand Down Expand Up @@ -399,7 +402,7 @@ define([
}, this)
},{
text: I18n.t('mute_assignment', 'Mute Assignment'),
'class': 'btn-primary',
class: 'btn-primary btn-mute',
click: $.proxy(function(){
this.toggleMute();
this.elements.mute.modal.dialog('close');
Expand All @@ -410,6 +413,26 @@ define([
title: this.elements.mute.modal.data('title'),
width: 400
});
this.elements.unmute.modal.dialog({
autoOpen: false,
buttons: [{
text: I18n.t('Cancel'),
click: $.proxy(function () {
this.elements.unmute.modal.dialog('close');
}, this)
}, {
text: I18n.t('Unmute Assignment'),
class: 'btn-primary btn-unmute',
click: $.proxy(function () {
this.toggleMute();
this.elements.unmute.modal.dialog('close');
}, this)
}],
modal: true,
resizable: false,
title: this.elements.unmute.modal.data('title'),
width: 400
});
},

toAssignment: function(e){
Expand Down Expand Up @@ -451,7 +474,11 @@ define([

onMuteClick: function(e){
e.preventDefault();
this.muted ? this.toggleMute() : this.elements.mute.modal.dialog('open');
if (this.muted) {
this.elements.unmute.modal.dialog('open');
} else {
this.elements.mute.modal.dialog('open');
}
},

muteUrl: function(){
Expand Down
38 changes: 38 additions & 0 deletions spec/selenium/grades/speedgrader/speedgrader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,44 @@ def submit_with_attachment
end
end

context "mute/unmute dialogs" do
before(:once) do
init_course_with_students

@assignment = @course.assignments.create!(
grading_type: 'points',
points_possible: 10
)
end

before(:each) do
user_session(@teacher)
end

it "shows dialog when attempting to mute and mutes" do
@assignment.update_attributes(muted: false)

get "/courses/#{@course.id}/gradebook/speed_grader?assignment_id=#{@assignment.id}#"
f('#mute_link').click
expect(f('#mute_dialog').attribute('style')).not_to include('display: none')
f('button.btn-mute').click
@assignment.reload
expect(@assignment.muted?).to be true
end

it "shows dialog when attempting to unmute and unmutes" do
@assignment.update_attributes(muted: true)

get "/courses/#{@course.id}/gradebook/speed_grader?assignment_id=#{@assignment.id}#"
f('#mute_link').click
expect(f('#unmute_dialog').attribute('style')).not_to include('display: none')
f('button.btn-unmute').click
@assignment.reload
expect(@assignment.muted?).to be false
end

end

private

def grader_speedgrader_assignment(grade1, grade2, clear_grade=true)
Expand Down

0 comments on commit 8ad874e

Please sign in to comment.