diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index efa70bb4f01..5fb20ad3372 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -131,7 +131,7 @@ class SubmissionsController < ApplicationController @visible_rubric_assessments = @submission.rubric_assessments.select{|a| a.grants_right?(@current_user, session, :read)}.sort_by{|a| [a.assessment_type == 'grading' ? CanvasSort::First : CanvasSort::Last, Canvas::ICU.collation_key(a.assessor_name)] } end - @assessment_request = @submission.assessment_requests.where(assessor_id: @current_user).first rescue nil + @assessment_request = @submission.assessment_requests.where(assessor_id: @current_user).first if authorized_action(@submission, @current_user, :read) respond_to do |format| json_handled = false diff --git a/app/views/submissions/show.html.erb b/app/views/submissions/show.html.erb index 819704e0899..5abff3f03aa 100644 --- a/app/views/submissions/show.html.erb +++ b/app/views/submissions/show.html.erb @@ -1,10 +1,11 @@ <% + currently_peer_reviewing = @assessment_request.try(:assigned?) js_bundle :rubric_assessment, :submissions js_env({ :RUBRIC_ASSESSMENT => { :assessment_user_id => @submission.user_id, :assessor_id => @current_user ? @current_user.id : "null", - :assessment_type => can_do(@submission, @current_user, :grade) ? "grading" : "peer_review" + :assessment_type => (!currently_peer_reviewing && can_do(@submission, @current_user, :grade)) ? "grading" : "peer_review" }, :SUBMISSION => { @@ -133,7 +134,7 @@ <% end %>
- <% if can_do(@context, @current_user, :manage_grades) %> + <% if !currently_peer_reviewing && can_do(@context, @current_user, :manage_grades) %> <% else %> diff --git a/spec/factories/rubric_association_factory.rb b/spec/factories/rubric_association_factory.rb index ef61f54e07b..b169ab0ee88 100644 --- a/spec/factories/rubric_association_factory.rb +++ b/spec/factories/rubric_association_factory.rb @@ -19,8 +19,10 @@ def rubric_association_model(opts={}) course_model(:reusable => true) unless @course || opts[:context] @rubric = opts[:rubric] || rubric_model(:context => opts[:context] || @course) - @rubric_association_object = @course.assignments.first || @course.assignments.create!(assignment_valid_attributes) - @rubric_association = @rubric.rubric_associations.create!(valid_rubric_assessment_attributes.merge(:association_object => opts[:association_object] || @rubric_association_object, :context => opts[:context] || @course, :purpose => opts[:purpose] || "none")) + @rubric_association_object = opts[:association_object] || + @course.assignments.first || + @course.assignments.create!(assignment_valid_attributes) + @rubric_association = @rubric.rubric_associations.create!(valid_rubric_assessment_attributes.merge(:association_object => @rubric_association_object, :context => opts[:context] || @course, :purpose => opts[:purpose] || "none")) end def valid_rubric_assessment_attributes diff --git a/spec/selenium/assignments_peer_reviews_spec.rb b/spec/selenium/assignments_peer_reviews_spec.rb index 66f0bb1ed41..b59c969a082 100644 --- a/spec/selenium/assignments_peer_reviews_spec.rb +++ b/spec/selenium/assignments_peer_reviews_spec.rb @@ -28,5 +28,31 @@ describe "assignments" do expect(fj('.student_reviews:first .peer_reviews').text()).to match /None Assigned/ expect(@assignment.submissions.map(&:assessment_requests).flatten.length).to eq 1 end + + it "allows an account admin who is also a student to submit a peer review" do + course(active_course: true) + admin_logged_in(account: @course.root_account) + student_in_course(user: @admin) + @student = student_in_course.user + + @assignment = assignment_model({ + course: @course, + peer_reviews: true, + automatic_peer_reviews: false, + }) + rubric_association_model(purpose: 'grading', association_object: @assignment) + @assignment.assign_peer_review(@admin, @student) + + get "/courses/#{@course.id}/assignments/#{@assignment.id}/submissions/#{@student.id}" + + f('.assess_submission_link').click + wait_for_animations + f('.rubric_table .criterion .rating').click + f('.save_rubric_button').click + wait_for_ajaximations + + assessment = @assignment.submissions.where(user_id: @student).first.rubric_assessments.first + expect(assessment.assessment_type).to eq 'peer_review' + end end end