Use different verbs for different types of assignments
This commit is contained in:
parent
978136fba0
commit
ccbeb9725f
|
|
@ -40,6 +40,17 @@ class NotificationService:
|
||||||
def send_assignment_submitted_notification(
|
def send_assignment_submitted_notification(
|
||||||
cls, recipient: User, sender: User, assignment_completion: AssignmentCompletion
|
cls, recipient: User, sender: User, assignment_completion: AssignmentCompletion
|
||||||
):
|
):
|
||||||
|
if (
|
||||||
|
assignment_completion.assignment.assignment_type
|
||||||
|
== AssignmentType.PRAXIS_ASSIGNMENT.value
|
||||||
|
):
|
||||||
|
texts = {
|
||||||
|
"de": "%(sender)s hat den Praxisauftrag «%(assignment_title)s» abgegeben.",
|
||||||
|
"fr": "%(sender)s a soumis la mission pratique «%(assignment_title)s».",
|
||||||
|
"it": "%(sender)s ha consegnato l'incarico pratico «%(assignment_title)s».",
|
||||||
|
}
|
||||||
|
# this was the default case before the praxis assignment was introduced
|
||||||
|
else:
|
||||||
texts = {
|
texts = {
|
||||||
"de": "%(sender)s hat die geleitete Fallarbeit «%(assignment_title)s» abgegeben.",
|
"de": "%(sender)s hat die geleitete Fallarbeit «%(assignment_title)s» abgegeben.",
|
||||||
"fr": "%(sender)s a soumis l'étude de cas dirigée «%(assignment_title)s».",
|
"fr": "%(sender)s a soumis l'étude de cas dirigée «%(assignment_title)s».",
|
||||||
|
|
@ -70,6 +81,17 @@ class NotificationService:
|
||||||
assignment_completion: AssignmentCompletion,
|
assignment_completion: AssignmentCompletion,
|
||||||
target_url: str,
|
target_url: str,
|
||||||
):
|
):
|
||||||
|
if (
|
||||||
|
assignment_completion.assignment.assignment_type
|
||||||
|
== AssignmentType.PRAXIS_ASSIGNMENT.value
|
||||||
|
):
|
||||||
|
texts = {
|
||||||
|
"de": "%(sender)s hat den Praxisauftrag «%(assignment_title)s» bewertet.",
|
||||||
|
"fr": "%(sender)s a évalué la mission pratique «%(assignment_title)s».",
|
||||||
|
"it": "%(sender)s ha valutato l'incarico pratico «%(assignment_title)s».",
|
||||||
|
}
|
||||||
|
# this was the default case before the praxis assignment was introduced
|
||||||
|
else:
|
||||||
texts = {
|
texts = {
|
||||||
"de": "%(sender)s hat die geleitete Fallarbeit «%(assignment_title)s» bewertet.",
|
"de": "%(sender)s hat die geleitete Fallarbeit «%(assignment_title)s» bewertet.",
|
||||||
"fr": "%(sender)s a évalué l'étude de cas dirigée «%(assignment_title)s».",
|
"fr": "%(sender)s a évalué l'étude de cas dirigée «%(assignment_title)s».",
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,13 @@ from django.test import TestCase
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
|
|
||||||
from vbv_lernwelt.assignment.models import AssignmentType
|
from vbv_lernwelt.assignment.models import (
|
||||||
|
Assignment,
|
||||||
|
AssignmentCompletion,
|
||||||
|
AssignmentCompletionStatus,
|
||||||
|
AssignmentType,
|
||||||
|
)
|
||||||
|
from vbv_lernwelt.core.admin import User
|
||||||
from vbv_lernwelt.core.constants import TEST_COURSE_SESSION_BERN_ID
|
from vbv_lernwelt.core.constants import TEST_COURSE_SESSION_BERN_ID
|
||||||
from vbv_lernwelt.core.create_default_users import create_default_users
|
from vbv_lernwelt.core.create_default_users import create_default_users
|
||||||
from vbv_lernwelt.course.creators.test_course import create_test_course
|
from vbv_lernwelt.course.creators.test_course import create_test_course
|
||||||
|
|
@ -24,6 +30,7 @@ from vbv_lernwelt.notify.email.reminders.assigment import (
|
||||||
send_assignment_reminder_notifications,
|
send_assignment_reminder_notifications,
|
||||||
)
|
)
|
||||||
from vbv_lernwelt.notify.models import Notification
|
from vbv_lernwelt.notify.models import Notification
|
||||||
|
from vbv_lernwelt.notify.services import NotificationService
|
||||||
|
|
||||||
EXPECTED_MEMBER_VERB = "Erinnerung: Bald ist ein Abgabetermin"
|
EXPECTED_MEMBER_VERB = "Erinnerung: Bald ist ein Abgabetermin"
|
||||||
EXPECTED_EXPERT_VERB = "Erinnerung: Bald ist ein Bewertungstermin"
|
EXPECTED_EXPERT_VERB = "Erinnerung: Bald ist ein Bewertungstermin"
|
||||||
|
|
@ -40,6 +47,7 @@ ASSIGNMENT_TYPE_LEARNING_CONTENT_LOOKUP: Dict[AssignmentType, str] = {
|
||||||
AssignmentType.PREP_ASSIGNMENT: "test-lehrgang-lp-circle-fahrzeug-lc-fahrzeug-mein-erstes-auto",
|
AssignmentType.PREP_ASSIGNMENT: "test-lehrgang-lp-circle-fahrzeug-lc-fahrzeug-mein-erstes-auto",
|
||||||
AssignmentType.REFLECTION: "test-lehrgang-lp-circle-fahrzeug-lc-reflexion",
|
AssignmentType.REFLECTION: "test-lehrgang-lp-circle-fahrzeug-lc-reflexion",
|
||||||
AssignmentType.CASEWORK: "test-lehrgang-lp-circle-fahrzeug-lc-überprüfen-einer-motorfahrzeug-versicherungspolice",
|
AssignmentType.CASEWORK: "test-lehrgang-lp-circle-fahrzeug-lc-überprüfen-einer-motorfahrzeug-versicherungspolice",
|
||||||
|
AssignmentType.PRAXIS_ASSIGNMENT: "test-lehrgang-lp-circle-reisen-lc-mein-kundenstamm",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -284,3 +292,164 @@ class TestAssignmentCourseRemindersTest(TestCase):
|
||||||
|
|
||||||
with self.assertRaises(Notification.DoesNotExist):
|
with self.assertRaises(Notification.DoesNotExist):
|
||||||
Notification.objects.get(recipient__username=RECIPIENT_TRAINER)
|
Notification.objects.get(recipient__username=RECIPIENT_TRAINER)
|
||||||
|
|
||||||
|
|
||||||
|
class TestAssignmentCourseUpdateTest(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
create_default_users()
|
||||||
|
create_test_course(with_sessions=True)
|
||||||
|
|
||||||
|
CourseSessionAssignment.objects.all().delete()
|
||||||
|
Notification.objects.all().delete()
|
||||||
|
|
||||||
|
self.student = User.objects.get(email=RECIPIENT_STUDENTS[0])
|
||||||
|
self.trainer = User.objects.get(email=RECIPIENT_TRAINER)
|
||||||
|
|
||||||
|
@freeze_time("2023-01-01")
|
||||||
|
def test_notification_title_casework_for_experts(self):
|
||||||
|
# GIVEN
|
||||||
|
casework = create_assignment(
|
||||||
|
assignment_type=AssignmentType.CASEWORK,
|
||||||
|
submission_deadline=timezone.make_aware(datetime(2022, 12, 12)),
|
||||||
|
evaluation_deadline=timezone.make_aware(datetime(2023, 1, 2)),
|
||||||
|
)
|
||||||
|
assignment = Assignment.objects.get(
|
||||||
|
slug="test-lehrgang-assignment-überprüfen-einer-motorfahrzeugs-versicherungspolice"
|
||||||
|
)
|
||||||
|
|
||||||
|
ac = AssignmentCompletion.objects.create(
|
||||||
|
completion_status=AssignmentCompletionStatus.SUBMITTED.value,
|
||||||
|
assignment_user=self.student,
|
||||||
|
assignment=assignment,
|
||||||
|
evaluation_passed=True,
|
||||||
|
course_session=casework.course_session,
|
||||||
|
completion_data={},
|
||||||
|
evaluation_max_points=10,
|
||||||
|
evaluation_points=10,
|
||||||
|
evaluation_user=self.trainer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# WHEN
|
||||||
|
NotificationService.send_assignment_submitted_notification(
|
||||||
|
recipient=self.trainer,
|
||||||
|
sender=ac.assignment_user,
|
||||||
|
assignment_completion=ac,
|
||||||
|
)
|
||||||
|
|
||||||
|
# THEN
|
||||||
|
self.assertEqual(1, len(Notification.objects.all()))
|
||||||
|
|
||||||
|
notification = Notification.objects.get(recipient__username=RECIPIENT_TRAINER)
|
||||||
|
self.assertEqual("USER_INTERACTION", notification.notification_category)
|
||||||
|
self.assertIn("hat die geleitete Fallarbeit", notification.verb)
|
||||||
|
|
||||||
|
def test_notification_title_praxis_assignment_for_experts(self):
|
||||||
|
# GIVEN.
|
||||||
|
casework = create_assignment(
|
||||||
|
assignment_type=AssignmentType.PRAXIS_ASSIGNMENT,
|
||||||
|
)
|
||||||
|
assignment = Assignment.objects.get(
|
||||||
|
slug="test-lehrgang-assignment-mein-kundenstamm"
|
||||||
|
)
|
||||||
|
|
||||||
|
ac = AssignmentCompletion.objects.create(
|
||||||
|
completion_status=AssignmentCompletionStatus.SUBMITTED.value,
|
||||||
|
assignment_user=self.student,
|
||||||
|
assignment=assignment,
|
||||||
|
evaluation_passed=True,
|
||||||
|
course_session=casework.course_session,
|
||||||
|
completion_data={},
|
||||||
|
evaluation_max_points=10,
|
||||||
|
evaluation_points=10,
|
||||||
|
evaluation_user=self.trainer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# WHEN
|
||||||
|
NotificationService.send_assignment_submitted_notification(
|
||||||
|
recipient=self.trainer,
|
||||||
|
sender=ac.assignment_user,
|
||||||
|
assignment_completion=ac,
|
||||||
|
)
|
||||||
|
|
||||||
|
# THEN
|
||||||
|
self.assertEqual(1, len(Notification.objects.all()))
|
||||||
|
|
||||||
|
notification = Notification.objects.get(recipient__username=RECIPIENT_TRAINER)
|
||||||
|
self.assertEqual("USER_INTERACTION", notification.notification_category)
|
||||||
|
self.assertIn("hat den Praxisauftrag", notification.verb)
|
||||||
|
|
||||||
|
@freeze_time("2023-01-01")
|
||||||
|
def test_notification_title_casework_for_student(self):
|
||||||
|
# GIVEN
|
||||||
|
casework = create_assignment(
|
||||||
|
assignment_type=AssignmentType.CASEWORK,
|
||||||
|
submission_deadline=timezone.make_aware(datetime(2022, 12, 12)),
|
||||||
|
evaluation_deadline=timezone.make_aware(datetime(2023, 1, 2)),
|
||||||
|
)
|
||||||
|
assignment = Assignment.objects.get(
|
||||||
|
slug="test-lehrgang-assignment-überprüfen-einer-motorfahrzeugs-versicherungspolice"
|
||||||
|
)
|
||||||
|
|
||||||
|
ac = AssignmentCompletion.objects.create(
|
||||||
|
completion_status=AssignmentCompletionStatus.EVALUATION_SUBMITTED.value,
|
||||||
|
assignment_user=self.student,
|
||||||
|
assignment=assignment,
|
||||||
|
evaluation_passed=True,
|
||||||
|
course_session=casework.course_session,
|
||||||
|
completion_data={},
|
||||||
|
evaluation_max_points=10,
|
||||||
|
evaluation_points=10,
|
||||||
|
evaluation_user=self.trainer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# WHEN
|
||||||
|
NotificationService.send_assignment_evaluated_notification(
|
||||||
|
recipient=ac.assignment_user,
|
||||||
|
sender=self.trainer,
|
||||||
|
assignment_completion=ac,
|
||||||
|
target_url="/some/url",
|
||||||
|
)
|
||||||
|
|
||||||
|
# THEN
|
||||||
|
self.assertEqual(1, len(Notification.objects.all()))
|
||||||
|
|
||||||
|
notification = Notification.objects.get(recipient__username=self.student.email)
|
||||||
|
self.assertEqual("USER_INTERACTION", notification.notification_category)
|
||||||
|
self.assertIn("hat die geleitete Fallarbeit", notification.verb)
|
||||||
|
|
||||||
|
@freeze_time("2023-01-01")
|
||||||
|
def test_notification_title_praxis_assignment_for_student(self):
|
||||||
|
# GIVEN
|
||||||
|
casework = create_assignment(
|
||||||
|
assignment_type=AssignmentType.PRAXIS_ASSIGNMENT,
|
||||||
|
)
|
||||||
|
assignment = Assignment.objects.get(
|
||||||
|
slug="test-lehrgang-assignment-mein-kundenstamm"
|
||||||
|
)
|
||||||
|
|
||||||
|
ac = AssignmentCompletion.objects.create(
|
||||||
|
completion_status=AssignmentCompletionStatus.EVALUATION_SUBMITTED.value,
|
||||||
|
assignment_user=self.student,
|
||||||
|
assignment=assignment,
|
||||||
|
evaluation_passed=True,
|
||||||
|
course_session=casework.course_session,
|
||||||
|
completion_data={},
|
||||||
|
evaluation_max_points=10,
|
||||||
|
evaluation_points=10,
|
||||||
|
evaluation_user=self.trainer,
|
||||||
|
)
|
||||||
|
|
||||||
|
# WHEN
|
||||||
|
NotificationService.send_assignment_evaluated_notification(
|
||||||
|
recipient=ac.assignment_user,
|
||||||
|
sender=self.trainer,
|
||||||
|
assignment_completion=ac,
|
||||||
|
target_url="/some/url",
|
||||||
|
)
|
||||||
|
|
||||||
|
# THEN
|
||||||
|
self.assertEqual(1, len(Notification.objects.all()))
|
||||||
|
|
||||||
|
notification = Notification.objects.get(recipient__username=self.student.email)
|
||||||
|
self.assertEqual("USER_INTERACTION", notification.notification_category)
|
||||||
|
self.assertIn("hat den Praxisauftrag", notification.verb)
|
||||||
Loading…
Reference in New Issue