Class: Course::Mailer

Inherits:
ApplicationMailer show all
Defined in:
app/mailers/course/mailer.rb

Overview

The mailer for course emails.

Instance Method Summary collapse

Instance Method Details

#assessment_closing_reminder_email(assessment, user) ⇒ Object

Send a reminder of the assessment closing to a single user

Parameters:

  • assessment (Course::Assessment)

    The assessment that is closing.

  • user (User)

    The user who hasn't done the assessment yet.


63
64
65
66
67
68
69
70
71
72
# File 'app/mailers/course/mailer.rb', line 63

def assessment_closing_reminder_email(assessment, user)
  @recipient = user
  @assessment = assessment
  ActsAsTenant.without_tenant do
    @course = assessment.course
  end

  mail(to: @recipient.email,
       subject: t('.subject', course: @course.title, assessment: @assessment.title))
end

#assessment_closing_summary_email(recipient, assessment, users) ⇒ Object

Send an email to all instructors with the names of users who haven't done the assessment.

Parameters:

  • recipient (User)

    The course instructor who will receive this email.

  • assessment (Course::Assessment)

    The assessment that is closing.

  • users (String)

    The users who haven't done the assessment yet.


80
81
82
83
84
85
86
87
88
89
90
# File 'app/mailers/course/mailer.rb', line 80

def assessment_closing_summary_email(recipient, assessment, users)
  ActsAsTenant.without_tenant do
    @course = assessment.course
  end
  @recipient = recipient
  @assessment = assessment
  @students = users

  mail(to: @recipient.email,
       subject: t('.subject', course: @course.title, assessment: @assessment.title))
end

#course_duplicated_email(original_course, new_course, user) ⇒ Object

Send a notification email to a user informing the completion of his course duplication.

Parameters:

  • original_course (Course)

    The original course that was duplicated.

  • new_course (Course)

    The resulting course of the duplication.

  • user (User)

    The user who performed the duplication.


49
50
51
52
53
54
55
56
57
# File 'app/mailers/course/mailer.rb', line 49

def course_duplicated_email(original_course, new_course, user)
  # Based on DuplicationService, user might default to User.system which has no email.
  return unless user.email

  @original_course = original_course
  @new_course = new_course
  @recipient = user
  mail(to: @recipient.email, subject: t('.subject', new_course: @new_course.title))
end

#submission_graded_email(submission) ⇒ Object

Send an email to the submission's creator when it has been graded.

Parameters:


95
96
97
98
99
100
101
102
103
104
105
# File 'app/mailers/course/mailer.rb', line 95

def submission_graded_email(submission)
  ActsAsTenant.without_tenant do
    @course = submission.assessment.course
  end
  @recipient = submission.creator
  @assessment = submission.assessment
  @submission = submission

  mail(to: @recipient.email,
       subject: t('.subject', course: @course.title, assessment: @assessment.title))
end

#survey_closing_reminder_email(recipient, survey) ⇒ Object

Send a reminder of the survey closing to a single user.

Parameters:

  • recipient (User)

    The student who has not completed the survey.

  • survey (Course::Survey)

    The survey that has opened.


111
112
113
114
115
116
117
118
119
120
# File 'app/mailers/course/mailer.rb', line 111

def survey_closing_reminder_email(recipient, survey)
  ActsAsTenant.without_tenant do
    @course = survey.course
  end
  @recipient = recipient
  @survey = survey

  mail(to: @recipient.email,
       subject: t('.subject', course: @course.title, survey: @survey.title))
end

#survey_closing_summary_email(recipient, survey, student_list) ⇒ Object

Send an email to a course instructor with the names of users who have not completed the survey.

Parameters:

  • recipient (User)

    The course instructor who will receive this email.

  • survey (Course::Survey)

    The survey that is closing.

  • student_list (String)

    The list of students who have not completed the survey.


128
129
130
131
132
133
134
135
136
137
138
# File 'app/mailers/course/mailer.rb', line 128

def survey_closing_summary_email(recipient, survey, student_list)
  ActsAsTenant.without_tenant do
    @course = survey.course
  end
  @recipient = recipient
  @survey = survey
  @student_list = student_list

  mail(to: @recipient.email,
       subject: t('.subject', course: @course.title, survey: @survey.title))
end

#user_added_email(course, user) ⇒ Object

Sends a notification email to a user informing his registration in a course.

Parameters:

  • course (Course)

    The course that was involved.

  • user (CourseUser)

    The user who was added.


20
21
22
23
24
25
# File 'app/mailers/course/mailer.rb', line 20

def user_added_email(course, user)
  @course = course
  @recipient = user.user

  mail(to: @recipient.email, subject: t('.subject', course: @course.title))
end

#user_enrol_requested_email(enrol_request) ⇒ Object

Sends a notification email to the course managers to approve a given EnrolRequest.

Parameters:

  • enrol_request (Course)

    The user enrol request.


30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/mailers/course/mailer.rb', line 30

def user_enrol_requested_email(enrol_request)
  ActsAsTenant.without_tenant do
    @course = enrol_request.course
  end

  return unless Course::Settings::UsersComponent.email_enabled?(@course, :new_enrol_request)

  @enrol_request = enrol_request
  @recipient = OpenStruct.new(name: t('course.mailer.user_enrol_requested_email.recipients'))

  mail(to: @course.managers.map(&:user).map(&:email),
       subject: t('.subject', course: @course.title))
end

#user_invitation_email(course, invitation) ⇒ Object

Sends an invitation email for the given invitation.

Parameters:


8
9
10
11
12
13
14
# File 'app/mailers/course/mailer.rb', line 8

def user_invitation_email(course, invitation)
  @course = course
  @invitation = invitation
  @recipient = invitation

  mail(to: invitation.email, subject: t('.subject', course: @course.title))
end