Skip to content

Commit 4e2f452

Browse files
committed
hide assignment statistics to students when < 5 submissions
if there's less than 5 submissions a student may be able to look at the box and whisker plot + the high/mean/low stats and determine other students grades. fixes #11458 test plan: - create an assignment, and grade < 5 students. - as one of the students, go to the grades summary page, click "all details" - you should not see a box and whisker plot or a tooltip with high/mean/low data - now grade more students, so that > 5 have grades - as a student, go back, and now the graph + tooltip should show Change-Id: Ib76164dc9ca9cf7c8563de427b27f52e5081447a Reviewed-on: https://gerrit.instructure.com/14757 Reviewed-by: Stanley Stuart <stanley@instructure.com> Tested-by: Jenkins <jenkins@instructure.com>
1 parent 4a236e3 commit 4e2f452

3 files changed

Lines changed: 29 additions & 5 deletions

File tree

app/views/gradebooks/grade_summary.html.erb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
<%
121121
submission = @submissions.find {|s| s.assignment_id == assignment.id }
122122
submission_unread = (submission.present? ? @unread_submission_ids.include?(submission.id) : false)
123+
assignment_submissions = @all_submissions.select { |s| s.assignment_id == assignment.id }
123124
visible_rubric_assessments = []
124125
visible_rubric_assessments = submission.rubric_assessments.select{|a| a.grants_rights?(@current_user, :read)[:read]}.sort_by{|a| [a.assessment_type == 'grading' ? '0' : '1', a.assessor_name] } if submission && !assignment.muted?
125126
%>
@@ -251,8 +252,9 @@
251252
<tr id="grade_info_<%= assignment.id %>" aria-expanded="false" role="region" class="comments <%= 'assignment_graded' if submission && submission.grade && !assignment.muted? %>" style="display: none;">
252253
<% if !assignment.special_class && (has_comments || has_scoring_details) %>
253254
<td colspan="5" style="padding-bottom: 20px;">
254-
<% if assignment && assignment.points_possible && assignment.points_possible > 0 && !assignment.muted? %>
255-
<% high, low, mean = assignment.grade_distribution(@all_submissions.select { |s| s.assignment_id == assignment.id }) %>
255+
<% can_view_distribution = can_do(@context, @current_user, :read_as_admin) || assignment_submissions.length >= 5 %>
256+
<% if assignment && assignment.points_possible && assignment.points_possible > 0 && !assignment.muted? && can_view_distribution %>
257+
<% high, low, mean = assignment.grade_distribution(assignment_submissions) %>
256258
<% title = "" %>
257259
<% title += " " + before_label(:mean_score, "Mean") + " " + (mean.round(1) rescue 0).to_s %>
258260
<% title += " " + before_label(:high_score, "High") + " " + high.to_s unless assignment && assignment.hide_max_scores_for_assignments %>

spec/selenium/grades_spec.rb

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@
114114
context "as a student" do
115115
before(:each) do
116116
user_session(@student_1)
117-
get "/courses/#{@course.id}/grades"
118-
@grade_tbody = f('#grades_summary > tbody')
119117
end
120118

121119
it "should allow student to test modifying grades" do
120+
get "/courses/#{@course.id}/grades"
121+
122122
# just one ajax request
123123
Assignment.expects(:find_or_create_submission).once.returns(@submission)
124124

@@ -142,6 +142,8 @@
142142
end
143143

144144
it "should display rubric on assignment" do
145+
get "/courses/#{@course.id}/grades"
146+
145147
#click rubric
146148
f("#submission_#{@first_assignment.id} .toggle_rubric_assessments_link").click
147149
wait_for_animations
@@ -153,6 +155,8 @@
153155
end
154156

155157
it "should not display rubric on muted assignment" do
158+
get "/courses/#{@course.id}/grades"
159+
156160
@first_assignment.muted = true
157161
@first_assignment.save!
158162
get "/courses/#{@course.id}/grades"
@@ -161,6 +165,8 @@
161165
end
162166

163167
it "should not display letter grade score on muted assignment" do
168+
get "/courses/#{@course.id}/grades"
169+
164170
@another_assignment = assignment_model({
165171
:course => @course,
166172
:title => 'another assignment',
@@ -178,6 +184,14 @@
178184
end
179185

180186
it "should display teacher comment and assignment statistics" do
187+
# get up to a point where statistics can be shown
188+
5.times do
189+
s = student_in_course(:active_all => true).user
190+
@first_assignment.grade_student(s, :grade => 4)
191+
end
192+
193+
get "/courses/#{@course.id}/grades"
194+
181195
#check comment
182196
f('.toggle_comments_link img').click
183197
comment_row = f('#grades_summary tr.comments')
@@ -186,11 +200,16 @@
186200
#check tooltip text statistics
187201
driver.execute_script('$("#grades_summary tr.comments span.tooltip_text").css("visibility", "visible");')
188202
statistics_text = comment_row.find_element(:css, 'span.tooltip_text').text
189-
statistics_text.include?("#{before_label(:mean_score, "Mean")} 3.5").should be_true
203+
statistics_text.include?("Mean:").should be_true
190204
statistics_text.include?('High: 4').should be_true
191205
statistics_text.include?('Low: 3').should be_true
192206
end
193207

208+
it "should not show assignment statistics on assignments with less than 5 submissions" do
209+
get "/courses/#{@course.id}/grades"
210+
f("#grade_info_#{@first_assignment.id} .tooltip").should be_nil
211+
end
212+
194213
it "should show rubric even if there are no comments" do
195214
@third_association = @rubric.associate_with(@third_assignment, @course, :purpose => 'grading')
196215
@third_submission = @third_assignment.submissions.create!(:user => @student_1) # unsubmitted submission :/

spec/views/gradebooks/grade_summary.html.erb_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
assigns[:assignments] = [a]
2929
assigns[:submissions] = []
3030
assigns[:courses_with_grades] = []
31+
assigns[:all_submissions] = []
3132
render "gradebooks/grade_summary"
3233
response.should_not be_nil
3334
end
@@ -41,6 +42,7 @@
4142
assigns[:assignments] = [a]
4243
assigns[:submissions] = []
4344
assigns[:courses_with_grades] = []
45+
assigns[:all_submissions] = []
4446
render "gradebooks/grade_summary"
4547
response.should_not be_nil
4648
page = Nokogiri('<document>' + response.body + '</document>')
@@ -58,6 +60,7 @@
5860
assigns[:assignments] = [a]
5961
assigns[:submissions] = []
6062
assigns[:courses_with_grades] = []
63+
assigns[:all_submissions] = []
6164
render "gradebooks/grade_summary"
6265
response.should_not be_nil
6366
response.body.should_not match /Click any score/

0 commit comments

Comments
 (0)