diff --git a/app/controllers/evaluations_controller.rb b/app/controllers/evaluations_controller.rb
index 2142a0ad..e49ddd8f 100644
--- a/app/controllers/evaluations_controller.rb
+++ b/app/controllers/evaluations_controller.rb
@@ -10,9 +10,12 @@ class EvaluationsController < ApplicationController
before_action :set_phase, only: [:submissions]
def index
- @challenges = Challenge.joins(phases: :challenge_phases_evaluators).
- where(challenge_phases_evaluators: { user_id: current_user.id }).
- includes(phases: [:evaluation_form]).
+ @phases = Phase.joins(:evaluator_submission_assignments).
+ where(evaluator_submission_assignments: {
+ user_id: current_user.id,
+ status: [:assigned, :recused]
+ }).
+ includes(:challenge, :evaluation_form).
distinct
end
@@ -171,4 +174,4 @@ def evaluation_params
end
end
# TODO: Remove this after above refactor
-# rubocop:enable all
\ No newline at end of file
+# rubocop:enable all
diff --git a/app/views/evaluations/_phases_table.html.erb b/app/views/evaluations/_phases_table.html.erb
index 71163935..c3f899f1 100644
--- a/app/views/evaluations/_phases_table.html.erb
+++ b/app/views/evaluations/_phases_table.html.erb
@@ -9,36 +9,32 @@
- <% @challenges.each do |challenge| %>
- <% challenge.phases.each do |phase| %>
-
-
- <%= challenge_phase_title(challenge, phase) %>
- |
-
- <%= assigned_submissions_count(current_user, challenge, phase) %>
- |
-
- <%= remaining_evaluations_count(current_user, challenge, phase) %>
- |
-
- <% if phase.evaluation_form %>
- <%= phase.evaluation_form.closing_date %>
- <% else %>
- N/A
+ <% @phases.each do |phase| %>
+ |
+
+ <%= challenge_phase_title(phase.challenge, phase) %>
+ |
+
+ <%= assigned_submissions_count(current_user, phase.challenge, phase) %>
+ |
+
+ <%= remaining_evaluations_count(current_user, phase.challenge, phase) %>
+ |
+
+ <% if phase.evaluation_form %>
+ <%= phase.evaluation_form.closing_date %>
+ <% else %>
+ N/A
+ <% end %>
+ |
+
+
+ <%= link_to submissions_evaluation_path(phase), class: "usa-button font-body-2xs text-no-wrap width-full" do %>
+ View Submissions
<% end %>
- |
-
-
- <%= link_to submissions_evaluation_path(phase), class: "usa-button font-body-2xs text-no-wrap width-full" do %>
- View Submissions
- <% end %>
-
-
- |
-
-
- <% end %>
- <% end %>
+
+
+
+ <% end %>
diff --git a/app/views/evaluations/index.html.erb b/app/views/evaluations/index.html.erb
index db563021..a19d9710 100644
--- a/app/views/evaluations/index.html.erb
+++ b/app/views/evaluations/index.html.erb
@@ -1,7 +1,7 @@
View challenges with submissions assigned to me to evaluate.
-<% if @challenges.empty? %>
+<% if @phases.empty? %>
You currently do not have any challenges.
diff --git a/spec/requests/evaluations_spec.rb b/spec/requests/evaluations_spec.rb
index 6ad2b742..e2a351b9 100644
--- a/spec/requests/evaluations_spec.rb
+++ b/spec/requests/evaluations_spec.rb
@@ -62,6 +62,102 @@
expect(response).to redirect_to(ENV.fetch("PHOENIX_URI", nil))
end
end
+
+ context "when logged in as an evaluator" do
+ let(:evaluator) { create_and_log_in_user(role: 'evaluator') }
+
+ let(:challenge_with_submissions) { create(:challenge, title: "Challenge with Submissions", is_multi_phase: false) }
+ let(:phase_with_submissions) { challenge_with_submissions.phases.first }
+
+ let(:multi_phase_challenge) { create(:challenge, title: "Multi-Phase Challenge", is_multi_phase: true) }
+ let(:phase1) { create(:phase, challenge: multi_phase_challenge) }
+ let(:phase2) { create(:phase, challenge: multi_phase_challenge) }
+
+ let(:challenge_without_submissions) { create(:challenge, title: "Challenge without Submissions", is_multi_phase: false) }
+ let(:phase_without_submissions) { challenge_without_submissions.phases.first }
+
+ before do
+ ChallengePhasesEvaluator.create!(challenge: challenge_with_submissions, phase: phase_with_submissions, user: evaluator)
+ ChallengePhasesEvaluator.create!(challenge: multi_phase_challenge, phase: phase1, user: evaluator)
+ ChallengePhasesEvaluator.create!(challenge: challenge_without_submissions, phase: phase_without_submissions, user: evaluator)
+ end
+
+ it "only shows phases with assigned or recused submissions" do
+ # Submissions for single phase challenge
+ assigned_submission = create(:submission, phase: phase_with_submissions, challenge: challenge_with_submissions)
+ create(:evaluator_submission_assignment,
+ submission: assigned_submission,
+ evaluator: evaluator,
+ status: :assigned
+ )
+
+ recused_submission = create(:submission, phase: phase_with_submissions, challenge: challenge_with_submissions)
+ create(:evaluator_submission_assignment,
+ submission: recused_submission,
+ evaluator: evaluator,
+ status: :recused
+ )
+
+ unassigned_submission = create(:submission, phase: phase_with_submissions, challenge: challenge_with_submissions)
+ create(:evaluator_submission_assignment,
+ submission: unassigned_submission,
+ evaluator: evaluator,
+ status: :unassigned
+ )
+
+ recused_unassigned_submission = create(:submission, phase: phase_with_submissions, challenge: challenge_with_submissions)
+ create(:evaluator_submission_assignment,
+ submission: recused_unassigned_submission,
+ evaluator: evaluator,
+ status: :recused_unassigned
+ )
+
+ # Submissions for multi-phase challenge
+ multi_phase_submission = create(:submission, phase: phase1, challenge: multi_phase_challenge)
+ create(:evaluator_submission_assignment,
+ submission: multi_phase_submission,
+ evaluator: evaluator,
+ status: :assigned
+ )
+
+ multi_phase_recused_submission = create(:submission, phase: phase1, challenge: multi_phase_challenge)
+ create(:evaluator_submission_assignment,
+ submission: multi_phase_recused_submission,
+ evaluator: evaluator,
+ status: :recused
+ )
+
+ multi_phase_unassigned_submission = create(:submission, phase: phase1, challenge: multi_phase_challenge)
+ create(:evaluator_submission_assignment,
+ submission: multi_phase_unassigned_submission,
+ evaluator: evaluator,
+ status: :unassigned
+ )
+
+ multi_phase_recused_unassigned_submission = create(:submission, phase: phase1, challenge: multi_phase_challenge)
+ create(:evaluator_submission_assignment,
+ submission: multi_phase_recused_unassigned_submission,
+ evaluator: evaluator,
+ status: :recused_unassigned
+ )
+
+ get evaluations_path
+
+ expect(response.body).to include(challenge_with_submissions.title)
+ expect(response.body).not_to include(challenge_without_submissions.title)
+
+ expect(response.body.scan(/data-label="Challenge Title"/).count).to eq(2)
+ expect(response.body.scan(/#{multi_phase_challenge.title}/).count).to eq(1)
+
+ within("#phase_#{phase_with_submissions.id}") do
+ expect(page).to have_css('td[data-label="Assigned to me"]', text: '2')
+ end
+
+ within("#phase_#{phase1.id}") do
+ expect(page).to have_css('td[data-label="Assigned to me"]', text: '2')
+ end
+ end
+ end
end
describe "GET /evaluations/:id/submissions" do