diff --git a/app/controllers/review_mapping_controller.rb b/app/controllers/review_mapping_controller.rb index 9934bff282e..12aafd4a8ea 100755 --- a/app/controllers/review_mapping_controller.rb +++ b/app/controllers/review_mapping_controller.rb @@ -1,3 +1,8 @@ +=begin + Implements: assigning reviewers to projects and reviewers to teams + Used: for automatic review mapping, peer review, self review and dynamic reviewer assignment. +=end + class ReviewMappingController < ApplicationController include AuthorizationHelper @@ -24,7 +29,15 @@ def action_allowed? end end - def add_calibration +=begin + Used: when instructor wants to do an expert peer-review and adds calibration + Implements: checking by user_id, if the the instructor is a participant in the assignment. + If not, he is made a new participant. When the record in the ReviewReponseMap + doesn't exist, it creates a new record. The record's id is then passed to the + response controller to create a new response. +=end + + def add_calibration_for_instructor participant = begin AssignmentParticipant.where(parent_id: params[:id], user_id: session[:user].id).first rescue StandardError diff --git a/app/views/assignments/edit/_calibration.html.erb b/app/views/assignments/edit/_calibration.html.erb index def870265ca..f33441c7cfb 100755 --- a/app/views/assignments/edit/_calibration.html.erb +++ b/app/views/assignments/edit/_calibration.html.erb @@ -42,7 +42,7 @@ <% end %> <% else %> <% if session[:user].id == assignment.instructor.id %> - <%= link_to "Begin", {:controller => 'review_mapping', :action => 'add_calibration', :id => assignment.id, :team_id => team.id} %> + <%= link_to "Begin", {:controller => 'review_mapping', :action => 'add_calibration_for_instructor', :id => assignment.id, :team_id => team.id} %> <% end %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index cb5c410ded6..18e1fd79f93 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -365,7 +365,7 @@ resources :review_mapping, only: [] do collection do - get :add_calibration + get :add_calibration_for_instructor get :list_mappings get :unsubmit_review post :add_reviewer diff --git a/spec/controllers/review_mapping_controller_spec.rb b/spec/controllers/review_mapping_controller_spec.rb index e5166b811f4..0723b7526f8 100755 --- a/spec/controllers/review_mapping_controller_spec.rb +++ b/spec/controllers/review_mapping_controller_spec.rb @@ -27,7 +27,7 @@ allow(reviewer).to receive(:get_reviewer).and_return(reviewer) end - describe '#add_calibration' do + describe '#add_calibration_for_instructor' do context 'when both participant and review_response_map have already existed' do it 'does not need to create new objects and redirects to responses#new maps' do allow(AssignmentParticipant).to receive_message_chain(:where, :first) @@ -36,7 +36,8 @@ .with(reviewed_object_id: '1', reviewer_id: 1, reviewee_id: '1', calibrate_to: true).with(no_args).and_return(review_response_map) request_params = { id: 1, team_id: 1 } user_session = { user: build(:instructor, id: 1) } - get :add_calibration, params: request_params, session: user_session + get :add_calibration_for_instructor, params: request_params, session: user_session + puts response expect(response).to redirect_to '/response/new?assignment_id=1&id=1&return=assignment_edit' end end @@ -53,7 +54,7 @@ .with(reviewed_object_id: '1', reviewer_id: 1, reviewee_id: '1', calibrate_to: true).and_return(review_response_map) request_params = { id: 1, team_id: 1 } user_session = { user: build(:instructor, id: 1) } - get :add_calibration, params: request_params, session: user_session + get :add_calibration_for_instructor, params: request_params, session: user_session expect(response).to redirect_to '/response/new?assignment_id=1&id=1&return=assignment_edit' end end