Skip to content

Commit

Permalink
Rubycop fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipansha authored and Dipansha committed Oct 21, 2017
1 parent ed0dc13 commit 1e4e5b3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 32 deletions.
60 changes: 30 additions & 30 deletions app/controllers/response_controller.rb
Expand Up @@ -5,7 +5,7 @@ class ResponseController < ApplicationController
def action_allowed?
response = user_id = nil
action = params[:action]
if(['edit','delete','update','view'].include?(action))
if (%w(edit delete update view).include?(action))
response = Response.find(params[:id])
user_id = response.map.reviewer.user_id if(response.map.reviewer)
end
Expand All @@ -17,13 +17,13 @@ def action_allowed?
when 'delete', 'update'
return current_user_id?(user_id)
when 'view'
return is_edit_allowed?(response.map,user_id)
return edit_allowed?(response.map,user_id)
else
current_user
end
end

def is_edit_allowed?(map,user_id)
def edit_allowed?(map, user_id)
assignment = map.reviewer.assignment
# if it is a review response map, all the members of reviewee team should be able to view the reponse (can be done from heat map)
if map.is_a? ReviewResponseMap
Expand Down Expand Up @@ -141,10 +141,10 @@ def create
end
is_submitted = (params[:isSubmit] == 'Yes')
@response = Response.create(
map_id: @map.id,
additional_comment: params[:review][:comments],
round: @round,
is_submitted: is_submitted
map_id: @map.id,
additional_comment: params[:review][:comments],
round: @round,
is_submitted: is_submitted
)
# ,:version_num=>@version)
# Change the order for displaying questions for editing response views.
Expand Down Expand Up @@ -207,25 +207,25 @@ def pending_surveys

# Get all the course survey deployments for this user
@surveys = []
[CourseParticipant,AssignmentParticipant].each do |item|
[CourseParticipant, AssignmentParticipant].each do |item|
# Get all the participant(course or assignment) entries for this user
participant_type = item.where(user_id: session[:user].id)
next unless participant_type
participant_type.each do |p|
survey_deployment_type = (participant_type == CourseParticipant)? AssignmentSurveyDeployment : CourseSurveyDeployment
survey_deployment_type = (participant_type == CourseParticipant) ? AssignmentSurveyDeployment : CourseSurveyDeployment
survey_deployments = survey_deployment_type.where(parent_id: p.parent_id)
next unless survey_deployments
survey_deployments.each do |survey_deployment|
next unless survey_deployment && Time.now > survey_deployment.start_date && Time.now < survey_deployment.end_date
@surveys <<
[
'survey' => Questionnaire.find(survey_deployment.questionnaire_id),
'survey_deployment_id' => survey_deployment.id,
'start_date' => survey_deployment.start_date,
'end_date' => survey_deployment.end_date,
'parent_id' => p.parent_id,
'participant_id' => p.id,
'global_survey_id' => survey_deployment.global_survey_id
'survey' => Questionnaire.find(survey_deployment.questionnaire_id),
'survey_deployment_id' => survey_deployment.id,
'start_date' => survey_deployment.start_date,
'end_date' => survey_deployment.end_date,
'parent_id' => p.parent_id,
'participant_id' => p.id,
'global_survey_id' => survey_deployment.global_survey_id
]
end
end
Expand Down Expand Up @@ -257,27 +257,27 @@ def set_content(new_response = false)

def set_questionnaire_for_new_response
case @map.type
when "ReviewResponseMap", "SelfReviewResponseMap"
reviewees_topic = SignedUpTeam.topic_id_by_team_id(@contributor.id)
@current_round = @assignment.number_of_current_round(reviewees_topic)
@questionnaire = @map.questionnaire(@current_round)
when
when "ReviewResponseMap", "SelfReviewResponseMap"
reviewees_topic = SignedUpTeam.topic_id_by_team_id(@contributor.id)
@current_round = @assignment.number_of_current_round(reviewees_topic)
@questionnaire = @map.questionnaire(@current_round)
when
"MetareviewResponseMap",
"TeammateReviewResponseMap",
"FeedbackResponseMap",
"CourseSurveyResponseMap",
"AssignmentSurveyResponseMap",
"GlobalSurveyResponseMap"
@questionnaire = @map.questionnaire
"TeammateReviewResponseMap",
"FeedbackResponseMap",
"CourseSurveyResponseMap",
"AssignmentSurveyResponseMap",
"GlobalSurveyResponseMap"
@questionnaire = @map.questionnaire
end
end

def scores
@review_scores = []
@questions.each do |question|
@review_scores << Answer.where(
response_id: @response.id,
question_id: question.id
response_id: @response.id,
question_id: question.id
).first
end
end
Expand All @@ -292,7 +292,7 @@ def set_questionnaire
def set_dropdown_or_scale
use_dropdown = AssignmentQuestionnaire.where(assignment_id: @assignment.try(:id),
questionnaire_id: @questionnaire.try(:id))
.first.try(:dropdown)
.first.try(:dropdown)
@dropdown_or_scale = (use_dropdown == true ? 'dropdown' : 'scale')
end

Expand Down
3 changes: 1 addition & 2 deletions spec/controllers/response_controller_spec.rb
Expand Up @@ -231,7 +231,7 @@
end

context 'when params[:return] is other content' do
it 'redirects to student_review#list page' do
it 'redirects to student_review#list page' do
params = {return: "other"}
get :redirection, params
expect(response).to redirect_to('/student_review/list?id=' + review_response.reviewer.id.to_s)
Expand All @@ -254,7 +254,6 @@
expect(response).to have_http_status(200)
expect(response).to render_template("pending_surveys")
end

end
end
end

0 comments on commit 1e4e5b3

Please sign in to comment.