Skip to content

Commit

Permalink
Merge commit from fork
Browse files Browse the repository at this point in the history
  • Loading branch information
20wildmanj authored Nov 27, 2024
1 parent 1aa4c76 commit fe44b53
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,6 @@ gem 'uri', '0.10.3'

# To generate slugged urls
gem 'friendly_id', '~> 5.5.0'

# to sanitize CSV files
gem 'csv-safe'
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ GEM
crack (0.4.5)
rexml
crass (1.0.6)
csv (3.3.0)
csv-safe (3.3.1)
csv (~> 3.0)
daemons (1.4.1)
database_cleaner (2.0.2)
database_cleaner-active_record (>= 2, < 3)
Expand Down Expand Up @@ -482,6 +485,7 @@ DEPENDENCIES
capybara
codeclimate-test-reporter
coffee-rails (>= 4.0.0)
csv-safe
database_cleaner
devise (>= 4.5.0)
diffy
Expand Down
17 changes: 9 additions & 8 deletions app/controllers/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -570,15 +570,16 @@ def download_roster
@cuds = @course.course_user_data.where(instructor: false,
course_assistant: false,
dropped: false)
output = ""
@cuds.each do |cud|
user = cud.user
# to_csv avoids issues with commas
output += [@course.semester, cud.user.email, user.last_name, user.first_name,
cud.school, cud.major, cud.year, cud.grade_policy,
cud.course_number, cud.lecture, cud.section].to_csv
csv_content = CSVSafe.generate do |csv|
@cuds.each do |cud|
user = cud.user
# to_csv avoids issues with commas
csv << [@course.semester, cud.user.email, user.last_name, user.first_name,
cud.school, cud.major, cud.year, cud.grade_policy,
cud.course_number, cud.lecture, cud.section]
end
end
send_data output, filename: "roster.csv", type: "text/csv", disposition: "inline"
send_data csv_content, filename: "roster.csv", type: "text/csv", disposition: "inline"
end

# email - The email action allows instructors to email the entire course, or
Expand Down

0 comments on commit fe44b53

Please sign in to comment.