diff --git a/app/controllers/admin/result_controller.rb b/app/controllers/admin/result_controller.rb new file mode 100644 index 0000000..9d14ded --- /dev/null +++ b/app/controllers/admin/result_controller.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true +module Admin + class ResultController < AdminController + # + # TODO: change context from Candidate to Quiz + # bypass pundit lockdowns until completed + after_action :skip_policy_scope + after_action :skip_authorization + # + + def index + @candidates = Candidate.where(completed: true).includes(:recruiter) + end + + def view + @candidate = Candidate.find_by(test_hash: params[:test_hash]) + @quiz = @candidate.my_quiz + @status = QuizStatus.new(@candidate) + end + end +end diff --git a/app/controllers/review_controller.rb b/app/controllers/review_controller.rb deleted file mode 100644 index d810bad..0000000 --- a/app/controllers/review_controller.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true -class ReviewController < ApplicationController - before_action :authorize_reviewer, except: [:login, :auth] - - def index - @candidates = Candidate.where(completed: true).includes(:recruiter) - end - - def view - @candidate = Candidate.find_by(test_hash: params[:test_hash]) - @quiz = @candidate.my_quiz - @status = QuizStatus.new(@candidate) - end - - def login - redirect_to review_path unless current_reviewer.nil? - end - - def auth - reviewer = User.find_by(email: auth_params[:email], role: %w(admin reviewer)) - - if reviewer && reviewer.authenticate(auth_params[:password]) - session[:user] = reviewer.to_i - redirect_to review_path - else - redirect_to review_login_path, flash: { error: "Sorry, incorrect email or password. Please try again." } - end - end - - def logout - reset_session - redirect_to review_login_path - end -end diff --git a/app/views/review/index.html.erb b/app/views/admin/result/index.html.erb similarity index 81% rename from app/views/review/index.html.erb rename to app/views/admin/result/index.html.erb index 3601598..158605e 100644 --- a/app/views/review/index.html.erb +++ b/app/views/admin/result/index.html.erb @@ -10,7 +10,7 @@ <% @candidates.each do |candidate| %>
Candidate <%= @candidate.test_hash %> has completed the Skills Assessment Test.
-You can view the results here: <%= link_to nil, review_test_url(@candidate.test_hash) %>.
+You can view the results here: <%= link_to nil, admin_result_url(@candidate.test_hash) %>.