Skip to content

Commit

Permalink
Changed add_calibration function name to add_calibration_for_instruct…
Browse files Browse the repository at this point in the history
…or and necessary comments
  • Loading branch information
root committed Oct 22, 2022
1 parent 338ea39 commit 4017953
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
15 changes: 14 additions & 1 deletion 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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/assignments/edit/_calibration.html.erb
Expand Up @@ -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 %>
</td>
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions spec/controllers/review_mapping_controller_spec.rb
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4017953

Please sign in to comment.