Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.257.0 #1217

Merged
merged 2 commits into from
Aug 17, 2023
Merged

0.257.0 #1217

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions app/controllers/admin/cscrm_data_collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
module Admin
class CscrmDataCollectionsController < AdminController
before_action :set_cscrm_data_collection, only: %i[
show
edit update
show
edit update
submit publish reset
destroy
]
Expand All @@ -13,9 +13,10 @@ def index
respond_to do |format|
format.html {
if cscrm_manager_permissions?
@cscrm_data_collections = CscrmDataCollection.all
@cscrm_data_collections = CscrmDataCollection.all.includes(:organization)
else
@cscrm_data_collections = current_user.organization.cscrm_data_collections.all
# Redirect non-admin users to CSCRM2
redirect_to admin_cscrm_data_collections2_index_path
end
}
format.csv {
Expand Down Expand Up @@ -80,7 +81,7 @@ def publish
Event.log_event(Event.names[:cscrm_data_collection_collection_published], 'CSRCM Data Collection', @cscrm_data_collection.id, "CSRCM Data Collection #{@cscrm_data_collection.id} published at #{DateTime.now}", current_user.id)
redirect_to admin_cscrm_data_collection_path(@cscrm_data_collection), notice: 'CSRCM Data Collection has been published successfully.'
end

def reset
if cscrm_manager_permissions?
@cscrm_data_collection.reset!
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def question_type_javascript_params(question)
"form.querySelector(\"input[name=#{question.answer_field}]:checked\") && form.querySelector(\"input[name=#{question.answer_field}]:checked\").value"
elsif question.question_type == 'thumbs_up_down_buttons'
"form.querySelector(\"input[name=#{question.answer_field}]:checked\") && form.querySelector(\"input[name=#{question.answer_field}]:checked\").value"
elsif question.question_type == 'big_thumbs_up_down_buttons'
"form.querySelector(\"input[name=#{question.answer_field}]:checked\") && form.querySelector(\"input[name=#{question.answer_field}]:checked\").value"
elsif question.question_type == 'yes_no_buttons'
"form.querySelector(\"input[name=#{question.answer_field}]\") && form.querySelector(\"input[name=#{question.answer_field}]\").value"
elsif question.question_type == 'checkbox'
Expand Down
60 changes: 60 additions & 0 deletions app/models/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,66 @@ def to_csv(start_date: nil, end_date: nil)
end
end

def to_a11_v2_csv(start_date: nil, end_date: nil)
non_flagged_submissions = submissions
.non_flagged
.where('created_at >= ?', start_date)
.where('created_at <= ?', end_date)
.order('created_at')
return nil if non_flagged_submissions.blank?

header_attributes = hashed_fields_for_export.values
header_attributes = [
:id,
:q1,
:positive_effectiveness,
:positive_ease,
:positive_efficiency,
:positive_transparency,
:positive_humanity,
:positive_employee,
:positive_other,
:negative_effectiveness,
:negative_ease,
:negative_efficiency,
:negative_transparency,
:negative_humanity,
:negative_employee,
:negative_other,
:q4
]

attributes = fields_for_export

CSV.generate(headers: true) do |csv|
csv << header_attributes

non_flagged_submissions.each do |submission|
csv << [
submission.id,
submission.answer_01,
submission.answer_02 && submission.answer_02.split(",").include?("effectiveness") ? 1 : 0,
submission.answer_02 && submission.answer_02.split(",").include?("ease") ? 1 : 0,
submission.answer_02 && submission.answer_02.split(",").include?("efficiency") ? 1 : 0,
submission.answer_02 && submission.answer_02.split(",").include?("transparency") ? 1 : 0,
submission.answer_02 && submission.answer_02.split(",").include?("humanity") ? 1 : 0,
submission.answer_02 && submission.answer_02.split(",").include?("employee") ? 1 : 0,
submission.answer_02 && submission.answer_02.split(",").include?("other") ? 1 : 0,

submission.answer_03 && submission.answer_03.split(",").include?("effectiveness") ? 1 : 0,
submission.answer_03 && submission.answer_03.split(",").include?("ease") ? 1 : 0,
submission.answer_03 && submission.answer_03.split(",").include?("efficiency") ? 1 : 0,
submission.answer_03 && submission.answer_03.split(",").include?("transparency") ? 1 : 0,
submission.answer_03 && submission.answer_03.split(",").include?("humanity") ? 1 : 0,
submission.answer_03 && submission.answer_03.split(",").include?("employee") ? 1 : 0,
submission.answer_03 && submission.answer_03.split(",").include?("other") ? 1 : 0,

submission.answer_04
]
end
end
end

def user_role?(user:)
role = user_roles.find_by_user_id(user.id)
role.present? ? role.role : nil
Expand Down
1 change: 1 addition & 0 deletions app/models/question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Question < ApplicationRecord
'states_dropdown',
'star_radio_buttons',
'thumbs_up_down_buttons',
'big_thumbs_up_down_buttons',
'yes_no_buttons',
'hidden_field',
'date_select',
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/cscrm_data_collections2/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<% end %>

<p>
<%= link_to admin_cscrm_data_collection_path(@cscrm_data_collection) do %>
<%= link_to admin_cscrm_data_collections2_index_path(@cscrm_data_collection) do %>
<i class="fa fa-arrow-circle-left"></i>
Back to CSCRM Data Collection
<% end %>
Expand All @@ -14,7 +14,7 @@
<%= render "form", cscrm_data_collection: @cscrm_data_collection %>

<% if @cscrm_data_collection.persisted? %>
<%= button_to "Destroy", admin_cscrm_data_collection_path(@cscrm_data_collection),
<%= button_to "Destroy", admin_cscrm_data_collections2_path(@cscrm_data_collection),
class: "usa-button usa-button--secondary float-right",
method: :delete %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/questions/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<br>
<% end %>
<% else %>
<%= f.select :question_type, Question::QUESTION_TYPES - ["thumbs_up_down_buttons", "custom_text_display", "yes_no_buttons"], { selected: question.question_type, include_blank: true }, { class: "usa-select" } %>
<%= f.select :question_type, Question::QUESTION_TYPES - ["big_thumbs_up_down_buttons", "thumbs_up_down_buttons", "custom_text_display", "yes_no_buttons"], { selected: question.question_type, include_blank: true }, { class: "usa-select" } %>
<% end %>
</div>

Expand Down
2 changes: 2 additions & 0 deletions app/views/admin/questions/_question.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<% @form_component_path = 'components/forms/edit/question_types/radio_buttons' %>
<% elsif question.question_type == "thumbs_up_down_buttons" %>
<% @form_component_path = 'components/forms/question_types/thumbs_up_down_buttons' %>
<% elsif question.question_type == "big_thumbs_up_down_buttons" %>
<% @form_component_path = 'components/forms/question_types/big_thumbs_up_down_buttons' %>
<% elsif question.question_type == "dropdown" %>
<% @form_component_path = 'components/forms/edit/question_types/dropdown' %>
<% elsif question.question_type == "states_dropdown" %>
Expand Down
2 changes: 2 additions & 0 deletions app/views/components/forms/_custom.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
<%= render 'components/forms/question_types/star_radio_buttons', form: form, question: question, question_number: multi_section_question_number %>
<% elsif question.question_type == "thumbs_up_down_buttons" %>
<%= render 'components/forms/question_types/thumbs_up_down_buttons', form: form, question: question, question_number: multi_section_question_number %>
<% elsif question.question_type == "big_thumbs_up_down_buttons" %>
<%= render 'components/forms/question_types/big_thumbs_up_down_buttons', form: form, question: question, question_number: multi_section_question_number %>
<% elsif question.question_type == "yes_no_buttons" %>
<%= render 'components/forms/question_types/yes_no_buttons', form: form, question: question, question_number: multi_section_question_number %>
<% elsif question.question_type == "radio_buttons" %>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<style>
.component.thumbs-up-down .prompt {
font-weight: bold;
}

.component.thumbs-up-down .thank-you-message {
display: none;
}

.component.thumbs-up-down .bar {
color: white;
border: 1px solid #005ea2;
background-color: #005ea2;
padding: 5px;
width: calc(100% - 40px);
margin: 0 auto; border-bottom: none;
}

.component.thumbs-up-down a {
color: white;
}

.component.thumbs-up-down .expandable-bar {
border: 1px solid #005ea2;
width: 100%;
}
</style>

<div class="component">
<%= render 'components/question_title', question: question %>

<br>
<div id="<%= question.answer_field.to_sym %>" class="font-sans-2xl text-center">
<button
class="fa fa-thumbs-up text-no-underline"
style="border: none; background-color: white;">
<span class="usa-sr-only">Yes</span>
</button>
&nbsp;
&nbsp;
<button
class="fa fa-thumbs-down text-no-underline"
style="border: none; background-color: white;">
<span class="usa-sr-only">No</span>
</button>
</div>
</div>

<fieldset class="usa-fieldset radios" role="group">
<legend class="usa-sr-only"><%= question.text %></legend>
<%= render 'components/question_title', question: question %>
<div class="question-options" id="<%= question.answer_field.to_sym %>">
<div class="radio-button usa-radio"
id="<%#= dom_id(option) %>"
data-id="<#= option.id %>"
<% if question.help_text.present? %>
aria-describedby="<%#= "question-id-#{question.id}-help-text" %>"
<% end %>
>
<%= radio_button_tag("yes", "yes", nil, { id: "yes", name: question.answer_field, class: "usa-radio__input usa-radio__input--tile", required: question.is_required }) %>
<%= label_tag("yes", nil, class: "usa-radio__label") do %><%#= option.text %><% end %>

<label class="btn btn-outline-success col mr-2">
<input type="radio" name="like" value="1"> <i class="fa fa-fw fa-thumbs-up"></i>好き!
</label>
</div>

</div>
</fieldset>
31 changes: 31 additions & 0 deletions docs/models/collections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
### Collections

A Collection represents a quarterly CX Data Collection.
OMB collects CX Data on a quarterly basis from each of the High-impact Service Providers (HISPs).

Data is published for download at https://www.performance.gov/cx/data/.

|Field Name | Sample Input | Format | Description |
|-- | -- | -- | -- |
| id | 59 | Number | Unique number for a collection record. A collection record is generated for each HISP each reporting quarter. A record indicates whether HISP has reported survey(s) for the quarter, as well as how many surveys were reported. |
| name | CX Quarterly Reporting | Text | Name of collection; same for all HISPs |
| start_date | 10/1/2023 | Date | Start date of the reporting quarter |
| end_date | 12/31/2023 | Date | End date of the reporting quarter |
| service_provider_id | 36 | Number | Unique number for each HISP |
| service_provider_name | Farm Service Agency | Text | Name of HISP |
| service_provider_organization_id | 2098 | Number | Unique number for each department. A department may contain several HISPs. |
| service_provider_organization_name | Department of Agriculture | Text | Name of department |
| service_provider_organization_abbreviation | USDA | Text | Abbreviation of each department name |
| organization_id | 2098 | Number | Unique number for each department. A department may contain several HISPs. |
| organization_name | Department of Agriculture | Text | Name of department |
| organization_abbreviation | USDA | Text | Abbreviation of each department name |
| user_email |   | Text | Email of POC for each HISP |
| year | 2021 | Year | Year of reported data |
| quarter | 1 | Quarter | Quarter of reported data |
| reflection | This FY21 first quarter report completes the data collection for the first annual FPAC Producer Satisfaction Survey… | Text | Each HISP provide a reflection text on the insights gleaned from all surveys for the quarter. |
| created_at | 2021-07-06 20:25:51 UTC | Date | Timestamp for creation of collection record |
| updated_at | 2021-08-04 16:29:20 UTC | Date | Timestamp for update to the collection record. May reflection HISP POC updating records and/or OMB reviewing data submission and approval to publish. |
| rating | PARTIAL | Text | OMB provides a rating of the data submission after review. |
| aasm_state | draft | Text | Indicates whether HISP records are in draft, submitted, or published. Draft is when OMB creates the collection record. Submitted indicates that HISP has affirmatively provided data submission. Published indicates that OMB has reviewed and cleared data submission for publishing. OMB uses the published tag as filter for HISPs that met the data reporting requirements. |
| integrity_hash |   | Text | This is an auto-generated tag for unique record. |
| omb_cx_reporting_collections_count | 1 | Number | Number of surveys submitted by the HISPs for the quarter. |
Loading