Merged in fix/feedback-on-trainer (pull request #219)

fix: filter out feedback from experts

Approved-by: Christian Cueni
This commit is contained in:
Livio Bieri 2023-10-16 07:41:25 +00:00
commit 7ec912d570
2 changed files with 12 additions and 3 deletions

View File

@ -54,7 +54,7 @@ class FeedbackNotificationTestCase(FeedbackBaseTestCase):
self.assertEqual(notification.course_session, self.course_session)
def test_only_submitted_feedback_triggers_notification(self):
feedback = FeedbackResponse.objects.create(
FeedbackResponse.objects.create(
circle=self.circle_basis,
course_session=self.course_session,
feedback_user=self.student,
@ -79,10 +79,14 @@ class FeedbackRestApiTestCase(FeedbackBaseTestCase):
"course_negative_feedback": ["Maus", "Hase", "Fuchs"],
}
self.students = [
self.feedback_users = [
# MEMBERS of the course session
self.student,
User.objects.get(username="test-student2@example.com"),
User.objects.get(username="test-student3@example.com"),
# EXPERT has submitted feedback for "testing purposes"
# -> should be filtered out!
User.objects.get(username="test-trainer1@example.com"),
]
for i in range(3):
@ -111,7 +115,7 @@ class FeedbackRestApiTestCase(FeedbackBaseTestCase):
"course_negative_feedback"
][i],
},
feedback_user=self.students[i],
feedback_user=self.feedback_users[i],
submitted=True,
)

View File

@ -5,6 +5,7 @@ from rest_framework.decorators import api_view
from rest_framework.exceptions import PermissionDenied
from rest_framework.response import Response
from vbv_lernwelt.course.models import CourseSessionUser
from vbv_lernwelt.course.permissions import is_course_session_expert
from vbv_lernwelt.feedback.models import FeedbackResponse
@ -57,6 +58,10 @@ def get_feedback_for_circle(request, course_session_id, circle_id):
course_session__id=course_session_id,
submitted=True,
circle_id=circle_id,
# filter out experts that might have submitted just for testing
feedback_user__in=CourseSessionUser.objects.filter(
course_session_id=course_session_id, role=CourseSessionUser.Role.MEMBER
).values_list("user", flat=True),
).order_by("created_at")
# I guess this is ok for the üK case