Skip to content

Commit df9fab1

Browse files
committed
add muting to gradebook2
Change-Id: Ib11a665f12319bf96fa2de4bda84d38c64132b6d Reviewed-on: https://gerrit.instructure.com/5970 Reviewed-by: Ryan Shaw <ryan@instructure.com> Tested-by: Hudson <hudson@instructure.com>
1 parent 54b0dcd commit df9fab1

13 files changed

Lines changed: 276 additions & 6 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
I18n.scoped 'AssignmentMuter', (I18n) ->
2+
class @AssignmentMuter
3+
constructor: (@$link, @assignment, @url) ->
4+
@$link = $(@$link)
5+
@updateLink()
6+
@$link.click (event) =>
7+
event.preventDefault()
8+
if @assignment.muted then @confirmUnmute() else @showDialog()
9+
10+
updateLink: =>
11+
@$link.text(if @assignment.muted then I18n.t('unmute_assignment', 'Unmute Assignment') else I18n.t('mute_assignment', 'Mute Assignment'))
12+
13+
showDialog: =>
14+
@$dialog = $(Template('mute_dialog')).dialog
15+
buttons: [{
16+
text: I18n.t('mute_assignment', 'Mute Assignment')
17+
'data-text-while-loading': I18n.t('muting_assignment', 'Muting Assignment...')
18+
click: =>
19+
@$dialog.disableWhileLoading $.ajaxJSON(@url, 'put', { status : true }, @afterUpdate)
20+
}]
21+
close: => @$dialog.remove()
22+
resizable: false
23+
width: 400
24+
25+
afterUpdate: (serverResponse) =>
26+
@assignment.muted = serverResponse.assignment.muted
27+
@updateLink()
28+
@$dialog.dialog('close')
29+
$.publish('assignment_muting_toggled', [@assignment])
30+
31+
confirmUnmute: =>
32+
@$dialog = $('<div />')
33+
.text(I18n.t('unmute_dialog', "This assignment is currently muted. That means students can't see their grades and feedback. Would you like to unmute now?"))
34+
.dialog
35+
buttons: [{
36+
text: I18n.t('unmute_button', 'Unmute Assignment')
37+
'data-text-while-loading': I18n.t('unmuting_assignment', 'Unmuting Assignment...')
38+
click: =>
39+
@$dialog.disableWhileLoading $.ajaxJSON(@url, 'put', { status : false }, @afterUpdate)
40+
}]
41+
close: => @$dialog.remove()
42+
resizable: false
43+
title: I18n.t("unmute_assignment", "Unmute Assignment")
44+
width: 400

app/coffeescripts/gradebook2/Gradebook.coffee

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ I18n.scoped 'gradebook2', (I18n) ->
1313
@show_attendance = $.store.userGet("show_attendance_#{@options.context_code}") == 'true'
1414
@include_ungraded_assignments = $.store.userGet("include_ungraded_assignments_#{@options.context_code}") == 'true'
1515
$.subscribe 'assignment_group_weights_changed', @buildRows
16+
$.subscribe 'assignment_muting_toggled', @buildRows
1617
$.subscribe 'submissions_updated', @updateSubmissionsFromExternal
1718
promise = $.when(
1819
$.ajaxJSON( @options.assignment_groups_url, "GET", {}, @gotAssignmentGroups),
@@ -210,8 +211,8 @@ I18n.scoped 'gradebook2', (I18n) ->
210211
$headers.find('.gradebook-header-drop').click (event) =>
211212
$link = $(event.target)
212213
unless $link.data('gradebookHeaderMenu')
213-
new GradebookHeaderMenu(@assignments[$link.data('assignmentId')], $link, this)
214-
return false
214+
$link.data('gradebookHeaderMenu', new GradebookHeaderMenu(@assignments[$link.data('assignmentId')], $link, this))
215+
return false
215216
)()
216217
originalStopFn = $headers.sortable 'option', 'stop'
217218
(fixupStopCallback = ->

app/coffeescripts/gradebook2/GradebookHeaderMenu.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ I18n.scoped 'gradebook2', (I18n) ->
2727
}
2828
)
2929
.popup('open')
30+
new AssignmentMuter(@$menu.find("[data-action=toggleMuting]"), @assignment, "#{@gradebook.options.context_url}/assignments/#{@assignment.id}/mute")
3031

3132
showAssignmentDetails: =>
3233
new AssignmentDetailsDialog(@assignment, @gradebook)

app/coffeescripts/gradebook2/SubmissionCell.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class @SubmissionCell
7272
classes.push('late') if assignment.due_at && submission.submitted_at && (submission.submitted_at.timestamp > assignment.due_at.timestamp)
7373
classes.push('dropped') if submission.drop
7474
classes.push('ungraded') if ''+assignment.submission_types is "not_graded"
75+
classes.push('muted') if assignment.muted
7576
classes
7677

7778
class SubmissionCell.out_of extends SubmissionCell

app/views/gradebook2/show.html.erb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
content_for :page_title, "Gradebook - #{@context.name}"
33
@body_classes << "gradebook2"
44
@show_left_side = false
5-
jammit_js :jquery_ui_menu, :slickgrid, :gradebook2
5+
jammit_js :jquery_ui_menu, :slickgrid, :assignmentMuter, :gradebook2
66
jammit_css :slickgrid, :gradebook2
77
options = {
88
:chunk_size => Setting.get_cached('gradebook2.submissions_chunk_size', '35').to_i,
@@ -54,8 +54,9 @@
5454
GRADEBOOK_TRANSLATIONS = <%= {
5555
:submission_tooltip_dropped => t('dropped_for_grading', 'Dropped for grading purposes'),
5656
:submission_tooltip_late => t('submitted_late', 'Submitted late'),
57+
:submission_tooltip_muted => t('muted_students_wont_see', 'This assignment is muted, students will not see changes'),
5758
:submission_tooltip_resubmitted => t('resubmitted', 'Resubmitted since last graded'),
58-
:submission_tooltip_ungraded => t('ungraded', 'Not factored into grading')
59+
:submission_tooltip_ungraded => t('ungraded', 'Not factored into grading'),
5960
}.to_json.html_safe %>;
6061
new Gradebook(<%= options.to_json.html_safe %>);
6162
</script>

app/views/jst/gradebook2/GradebookHeaderMenu.handlebars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
<li><a data-action="curveGrades" href="#">{{#t "curve_grades"}}Curve Grades{{/t}}</a></li>
77
<li><a data-action="downloadSubmissions" href="#">{{#t "download_submissions"}}Download Submissions{{/t}}</a></li>
88
<li><a data-action="reuploadSubmissions" href="#">{{#t "re-upload_submissions"}}Re-Upload Submissions{{/t}}</a></li>
9+
<li><a data-action="toggleMuting" href="#"></a></li>
910
</ul>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<div title="{{#t "mute_assignment"}}Mute Assignment{{/t}}">
2+
<p>
3+
{{#t "sure_you_want_to_mute"}}
4+
Are you sure you want to mute this assignment? While this assignment
5+
is muted, students will not receive new notifications about or be
6+
able to see:
7+
{{/t}}
8+
</p>
9+
<ul>
10+
<li>{{#t "grade_change_notifications"}}Grade change notifications{{/t}}</li>
11+
<li>{{#t "submission_comments"}}Submission comments{{/t}}</li>
12+
<li>{{#t "curving_assignments"}}Curving assignments{{/t}}</li>
13+
<li>{{#t "score_change_notifications"}}Score change notifications{{/t}}</li>
14+
</ul>
15+
<p>
16+
{{#t "students_will_see"}}Students will be able to see that this assignment is muted.{{/t}}
17+
</p>
18+
<p>
19+
{{#t "how_to_unmute"}}
20+
Once you have muted this assignment, you can begin sending
21+
notifications again by clicking the "Unmute Assignment" link.
22+
{{/t}}
23+
</p>
24+
</div>

config/assets.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ javascripts:
8686
- public/javascripts/compiled/license_help.js
8787
- public/javascripts/wiki_sidebar.js
8888
- public/javascripts/translations/_core_en.js
89+
assignmentMuter:
90+
- public/javascripts/compiled/AssignmentMuter.js
91+
- public/javascripts/jst/mute_dialog.js
8992
speed_grader:
9093
- public/javascripts/vendor/jquery.elastic.js
9194
- public/javascripts/vendor/ui.selectmenu.js

public/javascripts/compiled/AssignmentMuter.js

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/javascripts/compiled/gradebook2/Gradebook.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)