don't include test students in peer reviews

test plan:
* create an assignment with manual peer reviews
* within student view, submit to the assignment
* visit the peer reviews page
* should not include the test student in the page
* should not automatically assign peer reviews
 to or for the test student

refs #CNVS-20040

Change-Id: I42ddd0fcf306b686469046ab10e153b9b608225e
Reviewed-on: https://gerrit.instructure.com/52988
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins
QA-Review: Clare Strong <clare@instructure.com>
This commit is contained in:
James Williams 2015-04-28 08:57:51 -06:00
parent b5177169d9
commit f15110f61f
4 changed files with 15 additions and 2 deletions

View File

@ -273,7 +273,7 @@ class AssignmentsController < ApplicationController
@context.students_visible_to(@current_user)
end
@students = student_scope.uniq.order_by_sortable_name
@students = student_scope.not_fake_student.uniq.order_by_sortable_name
@submissions = @assignment.submissions.include_assessment_requests
end
end

View File

@ -1507,7 +1507,7 @@ class Assignment < ActiveRecord::Base
return [] unless self.peer_review_count && self.peer_review_count > 0
submissions = self.submissions.having_submission.include_assessment_requests
student_ids = students_with_visibility(context.students).pluck(:id)
student_ids = students_with_visibility(context.students.not_fake_student).pluck(:id)
submissions = submissions.select{|s| student_ids.include?(s.user_id) }
submission_ids = Set.new(submissions) { |s| s.id }

View File

@ -197,6 +197,8 @@ class User < ActiveRecord::Base
scope :has_current_student_enrollments, -> { where("EXISTS (SELECT * FROM enrollments JOIN courses ON courses.id=enrollments.course_id AND courses.workflow_state='available' WHERE enrollments.user_id=users.id AND enrollments.workflow_state IN ('active','invited') AND enrollments.type='StudentEnrollment')") }
scope :not_fake_student, -> { where("enrollments.type <> 'StudentViewEnrollment'")}
# NOTE: only use for courses with differentiated assignments on
scope :able_to_see_assignment_in_course_with_da, lambda {|assignment_id, course_id|
joins(:assignment_student_visibilities).

View File

@ -823,6 +823,17 @@ describe Assignment do
end
end
it "should not assign peer reviews to fake students" do
fake_student = @course.student_view_student
fake_sub = @a.submit_homework(fake_student, :submission_type => "online_url", :url => "http://www.google.com")
@a.peer_review_count = 1
res = @a.assign_peer_reviews
expect(res.length).to eql(@submissions.length)
expect(res.map{|a| a.asset}).to_not be_include(fake_sub)
expect(res.map{|a| a.assessor_asset}).to_not be_include(fake_sub)
end
it "should assign when already graded" do
@users.each do |u|
@a.grade_student(u, :grader => @teacher, :grade => '100')