Fix anonymous peer review links for non-students

This change fixes an issue where students with anonymous peer reviews
assigned were being given non-anonymized links on the Dashboard ToDo
list if they had a non-student enrollment in another course.

Test Plan:
 - Add 2 student enrollments to a published course
 - Enroll one of those students as a teacher in another course
 - Create an assignment in the first course with:
 -- A due date that is nearby
 -- Anonymous peer reviews enabled
 -- Submissions from both students
 -- Peer reviews assigned for both students
 - As the student with a teacher enrollment visit the Dashboard
 - Ensure that the peer review link is one with 'anonymous_submissions'

fixes KNO-293
flag=none

Change-Id: I54f8e325d740ef36a82d13a52a619212c950c388
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/228143
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Ahmad Amireh <ahmad@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
This commit is contained in:
Ben Nelson 2020-02-26 19:35:59 -07:00
parent 77c117a75b
commit c689c64c5d
2 changed files with 25 additions and 1 deletions

View File

@ -222,6 +222,9 @@ class ToDoListPresenter
delegate :context, :context_name, :short_context_name, to: :assignment_presenter
attr_reader :assignment
include ApplicationHelper
include Rails.application.routes.url_helpers
def initialize(view, assessment_request, user)
@view = view
@assessment_request = assessment_request
@ -238,7 +241,11 @@ class ToDoListPresenter
end
def submission_path
@view.course_assignment_submission_path(@assignment.context_id, @assignment.id, @assessment_request.user_id)
if @assignment.anonymous_peer_reviews?
context_url(context, :context_assignment_anonymous_submission_url, @assignment.id, @assessment_request.submission.anonymous_id)
else
@view.course_assignment_submission_path(@assignment.context_id, @assignment.id, @assessment_request.user_id)
end
end
def ignore_url

View File

@ -138,5 +138,22 @@ describe 'ToDoListPresenter' do
# basically checking that ToDoListPresenter.initialize didn't raise and error
expect(presenter).not_to be_nil
end
it "returns the correct submission_path for peer reviews" do
view_stub = double('view')
allow(view_stub).to receive(:course_assignment_submission_path).and_return('path/to/submission')
course1.assignments.last.update({anonymous_peer_reviews: false})
presenter = ToDoListPresenter.new(view_stub, reviewer, [course1])
expect(presenter.needs_reviewing.last.submission_path).to eq 'path/to/submission'
end
it "returns the correct submission_path for anonymous peer reviews" do
course1.assignments.last.update({anonymous_peer_reviews: true})
presenter = ToDoListPresenter.new(nil, reviewer, [course1])
expect(presenter.needs_reviewing.last.submission_path).to include('anonymous_submissions')
end
end
end