diff --git a/app/controllers/admin/result_controller.rb b/app/controllers/admin/result_controller.rb index 697a352..0c18024 100644 --- a/app/controllers/admin/result_controller.rb +++ b/app/controllers/admin/result_controller.rb @@ -11,9 +11,11 @@ module Admin # TODO: Limit results to the quizzes current_user has access to def index + sort_case = "(case when review_status = 0 then '' else name end)" + sort_with_case = sort_column == 'name' ? sort_case : sort_column @candidates = Candidate.where(completed: true) .includes(:recruiter) - .order("#{sort_column} #{sort_direction}") + .order("#{sort_with_case} #{sort_direction}") .page(params[:page]) end @@ -28,7 +30,7 @@ module Admin private def sort_column - Candidate.column_names.include?(params[:sort]) ? params[:sort] : 'completed_at' + @sort_col ||= Candidate.column_names.include?(params[:sort]) ? params[:sort] : 'completed_at' end end end diff --git a/app/views/admin/result/index.html.erb b/app/views/admin/result/index.html.erb index 82703c9..59ff4d2 100644 --- a/app/views/admin/result/index.html.erb +++ b/app/views/admin/result/index.html.erb @@ -6,7 +6,7 @@
<%= sortable "test_hash", "Test ID" %> | -<%= sortable "experience" %> | +<%= sortable "name" %> | <%= sortable "project", "Client/Project" %> | Recruiter | <%= sortable "completed_at", "Submitted on" %> | @@ -16,7 +16,7 @@ <% @candidates.each do |candidate| %>
---|---|---|---|---|---|
<%= link_to candidate.test_hash, admin_result_path(candidate.test_hash) %> | -<%= candidate.experience %> years | +<%= candidate.name if !candidate.pending? %> | <%= candidate.project %> | <%= mail_to(candidate.recruiter.email) %> | <%= candidate.completed_at.strftime('%D') unless candidate.completed_at.nil? %> | diff --git a/app/views/admin/result/view.html.erb b/app/views/admin/result/view.html.erb index a8e7a73..45fdc79 100644 --- a/app/views/admin/result/view.html.erb +++ b/app/views/admin/result/view.html.erb @@ -8,6 +8,9 @@