allow cross shard enrollments to view peer reviews
fixes VICE-769 flag=none test plan: - grab a snack, you might be here awhile - create two accounts that are trusted - you'll need mra configured on your installation - once you have the two accounts created, create a trust: > Account.create_web_of_trust([account1, account2]) - add to the account your course will live in a new auth provider - visit /accounts/:id/authentication_providers - select 'trusted canvas instance' in the identity provider dropdown - select the other account as the provider - if this fails, ensure both accounts have populated domains > account.account_domains.create(host: 'foo.bar') # if not - make sure to eat your snack, we're only halfway done - in one of the accounts, create a course with a graded discussion topic - enroll two users from the second account - as both users, leave a reply to the discussion - enable the peer review option for grading - assign the two users as peer reviewers for each other - this can be done at /courses/:id/assignments/:id/peer_reviews - as both of the users, visit the discussion once again - you should see that each user is assigned as a peer reviewer - if you really want to get fancy, test the same setup, but with users on the same shard as the course - or re-read the tests and see we should be good \o/ qa risk: low Change-Id: Iebf08ffdaed9c268b22728f53042a377df9608ab Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/247519 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Matthew Lemon <mlemon@instructure.com> QA-Review: Matthew Lemon <mlemon@instructure.com> Product-Review: Matthew Lemon <mlemon@instructure.com>
This commit is contained in:
parent
31957106b8
commit
a3ccb49d59
|
@ -66,7 +66,7 @@ class DiscussionTopicPresenter
|
|||
end
|
||||
|
||||
def peer_reviews_for(user)
|
||||
reviews = user.assigned_submission_assessments.for_assignment(assignment.id).to_a
|
||||
reviews = user.assigned_submission_assessments.shard(assignment.shard).for_assignment(assignment.id).to_a
|
||||
if reviews.any?
|
||||
valid_student_ids = assignment.context.participating_students.where(:id => reviews.map(&:user_id)).pluck(:id).to_set
|
||||
reviews = reviews.select{|r| valid_student_ids.include?(r.user_id)}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../sharding_spec_helper.rb')
|
||||
|
||||
describe DiscussionTopicPresenter do
|
||||
let (:topic) { DiscussionTopic.new(:title => 'Test Topic', :assignment => assignment) }
|
||||
|
@ -191,4 +192,39 @@ describe DiscussionTopicPresenter do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#peer_reviews_for" do
|
||||
let(:user2) { user_model }
|
||||
let(:user3) { user_model }
|
||||
|
||||
before do
|
||||
topic.context = course
|
||||
assignment.context = course
|
||||
assignment.peer_reviews = true
|
||||
assignment.save!
|
||||
[user, user2, user3].map do |u|
|
||||
course.enroll_student(u, {enrollment_state: 'active'})
|
||||
end
|
||||
assignment.assign_peer_review(user, user2)
|
||||
end
|
||||
|
||||
it "returns the assigned peer reviews" do
|
||||
expect(
|
||||
presenter.peer_reviews_for(user).map(&:user_id)
|
||||
).to match_array [user2.id]
|
||||
end
|
||||
|
||||
context "for cross-shard enrollments" do
|
||||
specs_require_sharding
|
||||
|
||||
let(:user) { @shard2.activate { user_model } }
|
||||
let(:user2) { @shard2.activate { user_model } }
|
||||
|
||||
it "returns the assigned peer reviews" do
|
||||
expect(
|
||||
presenter.peer_reviews_for(user).map(&:user_id)
|
||||
).to match_array [user2.id]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue