Class: Course::Assessment::ReminderService

Inherits:
Object
  • Object
show all
Includes:
ReminderServiceConcern
Defined in:
app/services/course/assessment/reminder_service.rb

Instance Method Summary collapse

Methods included from ReminderServiceConcern

#name_list

Instance Method Details

#closing_reminder(assessment, token) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/services/course/assessment/reminder_service.rb', line 9

def closing_reminder(assessment, token)
  return unless assessment.closing_reminder_token == token && assessment.published?
  return unless email_enabled?(assessment, :assessment_closing)

  # Send reminder emails to each student who hasn't submitted.
  recipients = uncompleted_students(assessment)
  recipients.each do |recipient|
    # Need to get the User model from the Course User because we need the email address.
    Course::Mailer.assessment_closing_reminder_email(assessment, recipient.user).deliver_later
  end

  # Send an email to each instructor with a list of students who haven't submitted.
  course_instructors = assessment.course.instructors.includes(:user).map(&:user)
  student_list = name_list(recipients)
  course_instructors.each do |instructor|
    Course::Mailer.assessment_closing_summary_email(
      instructor, assessment, student_list
    ).deliver_later
  end
end