Skip to content

Commit

Permalink
Merge branch 'dev' into 200_manage_evaluators_list
Browse files Browse the repository at this point in the history
  • Loading branch information
emmabjj authored Nov 19, 2024
2 parents a30de58 + 4d4ab10 commit 15405e0
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 9 deletions.
15 changes: 15 additions & 0 deletions app/helpers/manage_submissions_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 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

def phase_has_recused_evaluator?(phase)
phase.evaluator_submission_assignments.recused.exists?
end
end
4 changes: 4 additions & 0 deletions app/helpers/phases_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ module PhasesHelper
def phase_number(challenge, phase)
challenge.phase_ids.index(phase.id) + 1
end

def phase_has_recused_evaluator?(phase)
phase.evaluator_submission_assignments.recused.exists?
end
end
1 change: 1 addition & 0 deletions app/models/phase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Phase < ApplicationRecord
belongs_to :challenge
# More relations from phoenix app
has_many :submissions, dependent: :destroy
has_many :evaluator_submission_assignments, through: :submissions
has_one :evaluation_form, dependent: :destroy
# has_one :winner, class_name: 'PhaseWinner'
has_many :evaluator_invitations, dependent: :destroy
Expand Down
2 changes: 1 addition & 1 deletion app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Submission < ApplicationRecord

# Associations
belongs_to :challenge
belongs_to :phase
belongs_to :phase, counter_cache: true
belongs_to :submitter, class_name: 'User'
belongs_to :manager, class_name: 'User'
has_many :evaluator_submission_assignments, dependent: :destroy
Expand Down
13 changes: 6 additions & 7 deletions app/views/phases/_phases_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
<% @challenges.each do |challenge| %>
<% challenge.phases.each do |phase| %>
<tr>
<th data-label="Form Title" scope="row" class="text-top">
<strong><%= challenge_phase_title(challenge, phase) %></strong>
<span class="<%= challenge.status == 'published' ? 'text-green' : 'text-accent-warm-dark' %> padding-top-05 display-block text-bold padding-bottom-2"><%= challenge.status.capitalize %></span>
</th>
<td data-label="Number of Submissions" class="text-top">
<%= phase.submissions.length %>
<th data-label="Form Title" scope="row">
<%= challenge_phase_title(challenge, phase) %>
</th>
<td data-label="Number of Submissions">
<%= phase.submissions_count %>
</td>
<td data-label="Evaluation Form" class="text-top">
<% if phase.evaluation_form %>
Expand All @@ -40,7 +39,7 @@
<%= link_to phase_evaluators_path(phase), class: "usa-button font-body-2xs text-no-wrap width-full margin-bottom-105" do %>
Manage Evaluators
<% end %>
<% unless phase.submissions.empty? %>
<% if phase.submissions_count > 0 %>
<%= link_to(submissions_phase_path(phase)) do %>
<button class="usa-button font-body-2xs text-no-wrap width-full">
View Submissions
Expand Down
8 changes: 8 additions & 0 deletions app/views/phases/_submissions_table.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<% if @phase.evaluation_form.nil? %>
<%= render 'shared/alert_error', alert_heading: t('alerts.no_evaluation_form.heading'), alert_text: t('alerts.no_evaluation_form.text') %>
<% end %>
<% if phase_has_recused_evaluator?(@phase) %>
<%= render 'shared/alert_error', alert_heading: t('alerts.recused_evaluator.heading'), alert_text: t('alerts.recused_evaluator.text') %>
<% end %>

<table class="usa-table usa-table--stacked-header usa-table--borderless width-full">
<thead>
<tr>
Expand Down
12 changes: 12 additions & 0 deletions app/views/shared/_alert_error.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div class="grid-row margin-top-105">
<div class="grid-col-12 tablet:grid-col-6">
<div class="usa-alert usa-alert--error padding-top-105" role="alert">
<div class="usa-alert__body">
<h4 class="usa-alert__heading"><%= alert_heading %></h4>
<p class="usa-alert__text">
<%= alert_text %>
</p>
</div>
</div>
</div>
</div>
7 changes: 7 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,10 @@ en:
evaluation_criterion_unique_title_in_form_error: "Evaluation criteria title must be unique within the same form."
evaluation_form_criteria_weight_total_error: "The total weight of all evaluation criteria must add up to 100 when weighted scoring is enabled."
evaluation_criteria_form_title_placeholder: "Add criteria title here"
alerts:
recused_evaluator:
heading: "Recused Evaluator"
text: "One of the challenge submissions has a recused evaluator. Please review the list of submissions and unassign a recused evaluator."
no_evaluation_form:
heading: "No Evaluation Form"
text: "This challenge does not have an assigned evaluation form. Please create an evaluation form and assign it to the challenge."
5 changes: 5 additions & 0 deletions db/migrate/20241115193605_add_submissions_count_to_phases.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddSubmissionsCountToPhases < ActiveRecord::Migration[7.2]
def change
add_column :phases, :submissions_count, :integer, default: 0, null: false
end
end
7 changes: 7 additions & 0 deletions db/migrate/20241115193801_reset_phase_submissions_count.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ResetPhaseSubmissionsCount < ActiveRecord::Migration[7.2]
def change
Phase.find_each do |phase|
Phase.reset_counters(phase.id, :submissions)
end
end
end
5 changes: 4 additions & 1 deletion db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,8 @@ CREATE TABLE public.phases (
how_to_enter text,
how_to_enter_delta text,
inserted_at timestamp(0) without time zone NOT NULL,
updated_at timestamp(0) without time zone NOT NULL
updated_at timestamp(0) without time zone NOT NULL,
submissions_count integer DEFAULT 0 NOT NULL
);


Expand Down Expand Up @@ -2256,6 +2257,8 @@ ALTER TABLE ONLY public.winners
SET search_path TO "$user", public;

INSERT INTO "schema_migrations" (version) VALUES
(20241115193801),
(20241115193605),
(20241107161811),
(20241023195356),
(20241018150049),
Expand Down

0 comments on commit 15405e0

Please sign in to comment.