-
Notifications
You must be signed in to change notification settings - Fork 479
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
Facilitator application csv #26723
Facilitator application csv #26723
Changes from 16 commits
39d1ddf
044896b
17e6ddc
9f2cdc8
bb1f6c1
44629d6
50a25ba
89d9e14
73ac948
7175ecc
21b8509
8445025
b509a79
3523af2
f22bb33
a946b45
549e7f1
7aa06b5
1e646a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,138 +148,51 @@ def self.filtered_labels(course) | |
FILTERED_LABELS[course] | ||
end | ||
|
||
# @override | ||
def self.csv_header(course, user) | ||
# strip all markdown formatting out of the labels | ||
markdown = Redcarpet::Markdown.new(Redcarpet::Render::StripDown) | ||
CSV.generate do |csv| | ||
columns = filtered_labels(course).values.map {|l| markdown.render(l)}.map(&:strip) | ||
columns.push( | ||
'Status', | ||
'Locked', | ||
'General Notes', | ||
'Notes 2', | ||
'Notes 3', | ||
'Notes 4', | ||
'Notes 5', | ||
'Question 1 Support Teachers', | ||
'Question 2 Student Access', | ||
'Question 3 Receive Feedback', | ||
'Question 4 Give Feedback', | ||
'Question 5 Redirect Conversation', | ||
'Question 6 Time Commitment', | ||
'Question 7 Regional Needs', | ||
'Regional Partner' | ||
) | ||
csv << columns | ||
# Filter out extraneous answers based on selected program (course) | ||
def self.columns_to_remove(course) | ||
if course == 'csf' | ||
CSV_LABELS.keys.select {|k| k.to_s.start_with?('csd', 'csp')} | ||
elsif course == 'csd' | ||
CSV_LABELS.keys.select {|k| k.to_s.start_with?('csf', 'csp')} | ||
else | ||
CSV_LABELS.keys.select {|k| k.to_s.start_with?('csf', 'csd_training')} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Many questions are common to csd and csp, and they are all prefixed with 'csd_csp'. So for a csp csv, we want to include all of those. The only csd-specific question is the one prefixed 'csd_training', so we want to exclude that one here. The course names, as stored in the |
||
end | ||
end | ||
|
||
def self.cohort_csv_header(optional_columns) | ||
columns = [ | ||
'Date Accepted', | ||
'Name', | ||
'School District', | ||
'School Name', | ||
'Email', | ||
'Status', | ||
'Assigned Workshop' | ||
] | ||
if optional_columns[:registered_workshop] | ||
columns.push 'Registered Workshop' | ||
end | ||
if optional_columns[:accepted_teachercon] | ||
columns.push 'Accepted Teachercon' | ||
end | ||
|
||
columns.push( | ||
'General Notes', | ||
'Notes 2', | ||
'Notes 3', | ||
'Notes 4', | ||
'Notes 5', | ||
'Question 1 Support Teachers', | ||
'Question 2 Student Access', | ||
'Question 3 Receive Feedback', | ||
'Question 4 Give Feedback', | ||
'Question 5 Redirect Conversation', | ||
'Question 6 Time Commitment', | ||
'Question 7 Regional Needs' | ||
) | ||
def self.csv_filtered_labels(course) | ||
labels = {} | ||
labels_to_remove = Pd::Application::Facilitator1920Application.columns_to_remove(course) | ||
|
||
CSV.generate do |csv| | ||
csv << columns | ||
CSV_LABELS.keys.each do |k| | ||
unless labels_to_remove.include? k.to_sym | ||
labels[k] = CSV_LABELS[k] | ||
end | ||
end | ||
labels | ||
end | ||
|
||
# @override | ||
def to_csv_row(user) | ||
answers = full_answers | ||
def self.csv_header(course) | ||
# strip all markdown formatting out of the labels | ||
markdown = Redcarpet::Markdown.new(Redcarpet::Render::StripDown) | ||
CSV.generate do |csv| | ||
row = self.class.filtered_labels(course).keys.map {|k| answers[k]} | ||
row.push( | ||
status, | ||
locked?, | ||
notes, | ||
notes_2, | ||
notes_3, | ||
notes_4, | ||
notes_5, | ||
question_1, | ||
question_2, | ||
question_3, | ||
question_4, | ||
question_5, | ||
question_6, | ||
question_7, | ||
regional_partner_name | ||
) | ||
csv << row | ||
columns = csv_filtered_labels(course).values.map {|l| markdown.render(l)}.map(&:strip) | ||
csv << columns | ||
end | ||
end | ||
|
||
def to_cohort_csv_row(optional_columns) | ||
columns = [ | ||
date_accepted, | ||
applicant_name, | ||
district_name, | ||
school_name, | ||
user.email, | ||
status, | ||
fit_workshop_date_and_location | ||
] | ||
if optional_columns[:registered_workshop] | ||
if workshop.try(:local_summer?) | ||
columns.push(registered_workshop? ? 'Yes' : 'No') | ||
else | ||
columns.push nil | ||
end | ||
end | ||
if optional_columns[:accepted_teachercon] | ||
if workshop.try(:teachercon?) | ||
columns.push(pd_teachercon1819_registration ? 'Yes' : 'No') | ||
else | ||
columns.push nil | ||
end | ||
end | ||
|
||
columns.push( | ||
notes, | ||
notes_2, | ||
notes_3, | ||
notes_4, | ||
notes_5, | ||
question_1, | ||
question_2, | ||
question_3, | ||
question_4, | ||
question_5, | ||
question_6, | ||
question_7 | ||
) | ||
|
||
# @override | ||
def to_csv_row(course) | ||
columns_to_exclude = Pd::Application::Facilitator1920Application.columns_to_remove(course) | ||
CSV.generate do |csv| | ||
csv << columns | ||
row = [] | ||
CSV_LABELS.keys.each do |k| | ||
if columns_to_exclude&.include? k.to_sym | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense for the |
||
next | ||
end | ||
row.push(full_answers[k] || try(k) || all_scores[k]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style nits (with the caveat that I'm not the most fluent rubyist): I feel like I've been pushed toward inlining one-line conditionals like this one: next if columns_to_exclude&.include? k.to_sym Then again, I wonder if it's simpler change unless columns_to_exclude&.include? k.to_sym
row.push(full_answers[k] || try(k) || all_scores[k])
end Or (and I'm not sure this is cleaner) can we just filter the set we're iterating over? CSV_LABELS.keys.
reject {|k| columns_to_exclude&.include? k.to_sym}.
each {|k| row.push(full_answers[k] || try(k) || all_scores[k]} I don't want to be prescriptive here - totally open to conversation about what we find most readable. |
||
end | ||
csv << row | ||
end | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function creates a list of columns to filter, correct? If so, can you update this column to a bit clearer?