Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/mailers/report_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ class ReportMailer < ApplicationMailer

def report_content
@reported_content = params.fetch(:reported_content)
study_group = @reported_content.submission.study_group
exercise = @reported_content.exercise

# NOTE: This implementation assumes the course URL is static and does not vary per user.
# This is currently valid for a majority of use cases. However, in dynamic scenarios (such as
# content trees in openHPI used in conjunction with A/B/n testing) this assumption may no longer hold true.
@course_url = LtiParameter.find_by(study_group:, exercise:)&.lti_parameters&.[]('launch_presentation_return_url')

mail(subject: I18n.t('report_mailer.report_content.subject', content_name: @reported_content.model_name.human))
end
Expand Down
2 changes: 2 additions & 0 deletions app/views/report_mailer/report_content.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ h3 = t('.prolog')
blockquote style="white-space: pre-wrap;" = @reported_content.question
p = t('.take_action')
p = link_to(request_for_comment_url(@reported_content), request_for_comment_url(@reported_content))
- if @course_url.present?
p = link_to(t('.authentication'), @course_url)
5 changes: 5 additions & 0 deletions app/views/report_mailer/report_content.text.slim
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@
== t('.take_action')
== "\n\n"
== request_for_comment_url(@reported_content)
== "\n\n"
- if @course_url.present?
== t('.authentication')
== "\n\n"
== @course_url
1 change: 1 addition & 0 deletions config/locales/de/report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
de:
report_mailer:
report_content:
authentication: Kurs-URL für die LTI-Authentifizierung.
prolog: 'Die folgenden Inhalte wurden als unangemessen gemeldet:'
subject: 'Spam Report: Ein %{content_name} in CodeOcean wurde als unangemessen markiert.'
take_action: Bitte ergreifen Sie gegebenenfalls Maßnahmen.
1 change: 1 addition & 0 deletions config/locales/en/report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
en:
report_mailer:
report_content:
authentication: Course URL for LTI authentication.
prolog: 'The following content has been reported as inappropriate:'
subject: 'Spam Report: A %{content_name} on CodeOcean has been marked as inappropriate.'
take_action: Please take action if required.
9 changes: 9 additions & 0 deletions spec/mailers/report_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
expect(mail.text_part.body).to include(question)
expect(mail.html_part.body).to include(question)
end

it 'includes the LTI retrun URL for course authentication' do
create(:lti_parameter,
exercise: reported_content.exercise,
study_group: reported_content.submission.study_group)

expect(mail.text_part.body).to match(%r{https.+/courses/})
expect(mail.html_part.body).to match(%r{https.+/courses/})
end
end
end
end