Module: Course::ReminderServiceConcern

Extended by:
ActiveSupport::Concern
Included in:
Assessment::ReminderService, Survey::ReminderService
Defined in:
app/controllers/concerns/course/reminder_service_concern.rb

Instance Method Summary collapse

Instance Method Details

#name_list(course_users) ⇒ String

Converts a set of course users to a string, with each name on a new line. Sorts the names alphabetically and prepends an index number to each name.

Parameters:

  • course_users (Array<CourseUser>)

    The array of course users to turn into a list.

Returns:

  • (String)

    The numbered list of course users.


10
11
12
13
14
15
# File 'app/controllers/concerns/course/reminder_service_concern.rb', line 10

def name_list(course_users)
  course_users_names = course_users.to_a.map(&:name).sort!
  course_users_names.each_with_index do |course_user, index|
    course_users_names[index] = "#{index + 1}. #{course_user}"
  end.join("\n")
end