Skip to content

Commit

Permalink
[206] view submissions (#253)
Browse files Browse the repository at this point in the history
View Submissions 'index' page with statuses
---------

Co-authored-by: Stephen Chudleigh <stephen@smartlogic.io>
Co-authored-by: Stephen Chudleigh <stepchud@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 6, 2024
1 parent 256b649 commit b48aef2
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 4 deletions.
6 changes: 6 additions & 0 deletions app/controllers/manage_submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ class ManageSubmissionsController < ApplicationController
def index
@challenges = current_user.challenge_manager_challenges
end

def show
@challenge = current_user.challenge_manager_challenges.find(params[:challenge_id])
@phase = @challenge.phases.find(params[:id])
@submissions = @phase.submissions
end
end
7 changes: 7 additions & 0 deletions app/helpers/manage_submissions_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# frozen_string_literal: true

module ManageSubmissionsHelper
def eligible_for_evaluation?(submission)
submission.judging_status.in?(%w[selected winner])
end

def selected_to_advance?(submission)
submission.judging_status.in?(%w[winner])
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@
Manage Evaluators
</button>
<% unless phase.submissions.empty? %>
<button class="usa-button font-body-2xs text-no-wrap">
View Submissions
</button>
<%= link_to(challenge_manage_submission_path(challenge, phase)) do %>
<button class="usa-button font-body-2xs text-no-wrap">
View Submissions
</button>
<% end %>
<% end %>
</div>
</td>
Expand Down
83 changes: 83 additions & 0 deletions app/views/manage_submissions/_submissions_table.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<table class="usa-table usa-table--stacked-header usa-table--borderless width-full">
<thead>
<tr>
<th scope="col">Submission ID</th>
<th scope="col">Eligible for Evaluation</th>
<th scope="col">Selected to Advance</th>
<th scope="col">Assigned Evaluators</th>
<th scope="col">Average Score</th>
</tr>
</thead>
<tbody>
<% @submissions.each do |submission| %>
<tr>
<th data-label="Submission ID" scope="row">
<span class="mobile-lg:display-none">Submission ID </span><%= submission.id %>
</th>
<td data-label="Eligible for Evaluation">
<div class="display-flex flex-align-center">
<% if eligible_for_evaluation?(submission) %>
<input type="checkbox" disabled checked class="display-none mobile-lg:display-block">
<div class="mobile-lg:display-none">
<%= image_tag(
"images/usa-icons/verified.svg",
class: "usa-icon--size-3 margin-right-1",
alt: ""
)%>
<span class="text-top">Eligible for Evaluation</span>
</div>
<% else %>
<input type="checkbox" disabled class="display-none mobile-lg:display-block">
<div class="mobile-lg:display-none">
<%= image_tag(
"images/usa-icons/highlight_off.svg",
class: "usa-icon--size-3 margin-right-1",
alt: ""
)%>
<span class="text-top">Not Eligible for Evaluation</span>
</div>
<% end %>
</div>
</td>
<td data-label="Selected to Advance">
<div class="display-flex flex-align-center">
<% if selected_to_advance?(submission) %>
<input type="checkbox" disabled checked class="display-none mobile-lg:display-block">
<div class="mobile-lg:display-none">
<%= image_tag(
"images/usa-icons/star.svg",
class: "usa-icon--size-3 margin-right-1",
alt: ""
)%>
<span class="text-top">Selected to Advance</span>
</div>
<% else %>
<input type="checkbox" disabled class="display-none mobile-lg:display-block">
<div class="mobile-lg:display-none">
<%= image_tag(
"images/usa-icons/star_outline.svg",
class: "usa-icon--size-3 margin-right-1",
alt: ""
)%>
<span class="text-top">Not Selected to Advance</span>
</div>
<% end %>
</div>
</td>
<td data-label="Assigned Evaluators">
No evaluators assigned to this submission
</td>
<td>
N/A
</td>
<td>
<div class="display-flex flex-no-wrap grid-row grid-gap-1">
<button class="usa-button font-body-2xs text-no-wrap">
View Submission
</button>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
2 changes: 1 addition & 1 deletion app/views/manage_submissions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
<p>You currently do not have any challenges.</p>
</div>
<% else %>
<%= render partial: "table", locals: { challenges: @challenges } %>
<%= render partial: "phases_table", locals: { challenges: @challenges } %>
<% end %>
10 changes: 10 additions & 0 deletions app/views/manage_submissions/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h1><%= challenge_phase_title(@phase.challenge, @phase) %></h1>
<p class="text-normal">View challenge submissions and manage evaluation progress.</p>

<% if @submissions.empty? %>
<div class="text-normal">
<p>This challenge phase does not currently have any submissions.</p>
</div>
<% else %>
<%= render partial: "submissions_table", locals: { submissions: @submissions } %>
<% end %>
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
resources :evaluation_forms
post '/evaluation_forms/clone', to: 'evaluation_forms#create_from_existing'
resources :manage_submissions, only: [:index]
resources :challenges, only: [] do
resources :manage_submissions, only: [:show]
end

# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
# Can be used by load balancers and uptime monitors to verify that the app is live.
Expand Down
28 changes: 28 additions & 0 deletions spec/requests/manage_submissions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,34 @@
expect(response.body).to include("Turning monster energy into pepto bismol")
expect(response.body).to include("Frodo")
end

it "renders an empty list of submissions for a user's challenge" do
challenge = create_challenge(user: challenge_user, title: "Boston Tea Party Cleanup")
phase = create_phase(challenge_id: challenge.id)

get challenge_manage_submission_path(challenge, phase)
expect(response.body).to include("Boston Tea Party Cleanup")

expect(response.body).to include("This challenge phase does not currently have any submissions.")
end

it "renders a list of submissions for a user's challenge" do
challenge = create_challenge(user: challenge_user, title: "Boston Tea Party Cleanup")
phase = create_phase(challenge_id: challenge.id)
submission = create(:submission, challenge: challenge)

get challenge_manage_submission_path(challenge, phase)
expect(response.body).to include("Boston Tea Party Cleanup")
expect(response.body).to include(submission.id.to_s)
end

it "does not render submissions for a challenge the user is not assigned to" do
challenge = create_challenge(title: "Star Spangled Banister")
phase = create_phase(challenge_id: challenge.id)

get challenge_manage_submission_path(challenge, phase)
expect(response).to have_http_status(:not_found)
end
end

context "when logged in as an evaluator" do
Expand Down
39 changes: 39 additions & 0 deletions spec/system/manage_submissions_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

require 'rails_helper'

describe "A11y", :js do
let(:user) { nil }

before do
system_login_user(user) if user
end

describe "Logged-in as a Challenge Manager" do
let(:user) { create_user(role: "challenge_manager") }

it "manage submissions index page is accessible with no challenges" do
visit manage_submissions_path
expect(user.role).to eq("challenge_manager")
expect(page).to(be_axe_clean)
end

it "manage submissions index page is accessible with one challenge" do
challenge = create_challenge(user: user, title: "Boston Tea Party Cleanup")
create_phase(challenge_id: challenge.id)
visit manage_submissions_path
expect(user.role).to eq("challenge_manager")
expect(page).to have_content("Boston Tea Party Cleanup")
expect(page).to(be_axe_clean)
end

it "manage submissions by challenge phase page is accessible with one challenge" do
challenge = create_challenge(user: user, title: "Boston Tea Party Cleanup")
phase = create_phase(challenge_id: challenge.id)
visit challenge_manage_submission_path(challenge, phase)
expect(user.role).to eq("challenge_manager")
expect(page).to have_content("Boston Tea Party Cleanup")
expect(page).to(be_axe_clean)
end
end
end

0 comments on commit b48aef2

Please sign in to comment.