Skip to content

Commit 5cfd765

Browse files
committed
feat: Report email with LIT authorization path
To act on spam reports the teacher needs to sign in through the course to authenticate in the study group. The LTI return URL is used to link back to the course.
1 parent dc156e4 commit 5cfd765

File tree

6 files changed

+21
-0
lines changed

6 files changed

+21
-0
lines changed

app/mailers/report_mailer.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ class ReportMailer < ApplicationMailer
55

66
def report_content
77
@reported_content = params.fetch(:reported_content)
8+
study_group = @reported_content.submission.study_group
9+
exercise = @reported_content.exercise
10+
@course_url = LtiParameter.find_by(study_group:, exercise:)&.lti_parameters&.[]('launch_presentation_return_url')
811

912
mail(subject: I18n.t('report_mailer.report_content.subject', content_name: @reported_content.model_name.human))
1013
end

app/views/report_mailer/report_content.html.slim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ h3 = t('.prolog')
22
blockquote style="white-space: pre-wrap;" = @reported_content.question
33
p = t('.take_action')
44
p = link_to(request_for_comment_url(@reported_content), request_for_comment_url(@reported_content))
5+
- if @course_url.present?
6+
p = link_to(t('.authentication'), @course_url)

app/views/report_mailer/report_content.text.slim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@
55
== t('.take_action')
66
== "\n\n"
77
== request_for_comment_url(@reported_content)
8+
== "\n\n"
9+
- if @course_url.present?
10+
== t('.authentication')
11+
== "\n\n"
12+
== @course_url

config/locales/de/report.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
de:
33
report_mailer:
44
report_content:
5+
authentication: Übungs-URL für die LTI-Authentifizierung.
56
prolog: 'Die folgenden Inhalte wurden als unangemessen gemeldet:'
67
subject: 'Spam Report: Ein %{content_name} in CodeOcean wurde als unangemessen markiert.'
78
take_action: Bitte ergreifen Sie gegebenenfalls Maßnahmen.

config/locales/en/report.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
en:
33
report_mailer:
44
report_content:
5+
authentication: Exercise URL for LTI authentication.
56
prolog: 'The following content has been reported as inappropriate:'
67
subject: 'Spam Report: A %{content_name} on CodeOcean has been marked as inappropriate.'
78
take_action: Please take action if required.

spec/mailers/report_mailer_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@
2222
expect(mail.text_part.body).to include(question)
2323
expect(mail.html_part.body).to include(question)
2424
end
25+
26+
it 'includes the LTI retrun URL for course authentication' do
27+
create(:lti_parameter,
28+
exercise: reported_content.exercise,
29+
study_group: reported_content.submission.study_group)
30+
31+
expect(mail.text_part.body).to match(%r{https.+/courses/})
32+
expect(mail.html_part.body).to match(%r{https.+/courses/})
33+
end
2534
end
2635
end
2736
end

0 commit comments

Comments
 (0)