feat: add circles
This commit is contained in:
parent
a48ac35e62
commit
50738b2bf3
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import List
|
from typing import List, Set, Tuple
|
||||||
|
|
||||||
from vbv_lernwelt.assignment.models import (
|
from vbv_lernwelt.assignment.models import (
|
||||||
Assignment,
|
Assignment,
|
||||||
|
|
@ -74,11 +74,12 @@ def get_assignment_completions(
|
||||||
|
|
||||||
def get_praxis_assignments(
|
def get_praxis_assignments(
|
||||||
course_session: CourseSession, participants: List[User]
|
course_session: CourseSession, participants: List[User]
|
||||||
) -> List[PraxisAssignmentStatus]:
|
) -> Tuple[List[PraxisAssignmentStatus], Set[int]]:
|
||||||
records = []
|
records = []
|
||||||
|
circle_ids = set()
|
||||||
|
|
||||||
if not participants:
|
if not participants:
|
||||||
return records
|
return records, circle_ids
|
||||||
|
|
||||||
for course_session_assignment in CourseSessionAssignment.objects.filter(
|
for course_session_assignment in CourseSessionAssignment.objects.filter(
|
||||||
course_session=course_session,
|
course_session=course_session,
|
||||||
|
|
@ -102,14 +103,18 @@ def get_praxis_assignments(
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
circle_id = learning_content.get_circle().id
|
||||||
|
|
||||||
records.append(
|
records.append(
|
||||||
PraxisAssignmentStatus(
|
PraxisAssignmentStatus(
|
||||||
id=course_session_assignment.id,
|
id=course_session_assignment.id,
|
||||||
title=learning_content.content_assignment.title,
|
title=learning_content.content_assignment.title,
|
||||||
circle_id=learning_content.get_circle().id,
|
circle_id=circle_id,
|
||||||
pending_evaluations=submitted_count,
|
pending_evaluations=submitted_count,
|
||||||
completions=completions,
|
completions=completions,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return records
|
circle_ids.add(circle_id)
|
||||||
|
|
||||||
|
return records, circle_ids
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,13 @@ class LearningMentorAPITest(APITestCase):
|
||||||
self.course, self.course_page = create_course("Test Course")
|
self.course, self.course_page = create_course("Test Course")
|
||||||
self.course_session = create_course_session(course=self.course, title="Test VV")
|
self.course_session = create_course_session(course=self.course, title="Test VV")
|
||||||
|
|
||||||
circle, _ = create_circle(title="Circle", course_page=self.course_page)
|
self.circle, _ = create_circle(title="Circle", course_page=self.course_page)
|
||||||
|
|
||||||
self.assignment = create_assignment(
|
self.assignment = create_assignment(
|
||||||
course=self.course, assignment_type=AssignmentType.PRAXIS_ASSIGNMENT
|
course=self.course, assignment_type=AssignmentType.PRAXIS_ASSIGNMENT
|
||||||
)
|
)
|
||||||
|
|
||||||
lca = create_assignment_learning_content(circle, self.assignment)
|
lca = create_assignment_learning_content(self.circle, self.assignment)
|
||||||
create_course_session_assignment(
|
create_course_session_assignment(
|
||||||
course_session=self.course_session, learning_content_assignment=lca
|
course_session=self.course_session, learning_content_assignment=lca
|
||||||
)
|
)
|
||||||
|
|
@ -141,6 +141,11 @@ class LearningMentorAPITest(APITestCase):
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(len(response.data["praxis_assignments"]), 1)
|
self.assertEqual(len(response.data["praxis_assignments"]), 1)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
response.data["circles"],
|
||||||
|
[{"id": self.circle.id, "title": self.circle.title}],
|
||||||
|
)
|
||||||
|
|
||||||
assignment = response.data["praxis_assignments"][0]
|
assignment = response.data["praxis_assignments"][0]
|
||||||
self.assertEqual(assignment["pending_evaluations"], 1)
|
self.assertEqual(assignment["pending_evaluations"], 1)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,10 +87,13 @@ class AttendanceServicesTestCase(TestCase):
|
||||||
participants = [self.user1, self.user2, self.user3, self.user4]
|
participants = [self.user1, self.user2, self.user3, self.user4]
|
||||||
|
|
||||||
# WHEN
|
# WHEN
|
||||||
result = get_praxis_assignments(self.course_session, participants)
|
assignments, circle_ids = get_praxis_assignments(
|
||||||
|
self.course_session, participants
|
||||||
|
)
|
||||||
|
|
||||||
# THEN
|
# THEN
|
||||||
assignment = result[0]
|
assignment = assignments[0]
|
||||||
self.assertEqual(assignment.pending_evaluations, 1)
|
self.assertEqual(assignment.pending_evaluations, 1)
|
||||||
self.assertEqual(assignment.title, "Dummy Assignment (PRAXIS_ASSIGNMENT)")
|
self.assertEqual(assignment.title, "Dummy Assignment (PRAXIS_ASSIGNMENT)")
|
||||||
self.assertEqual(assignment.circle_id, self.circle.id)
|
self.assertEqual(assignment.circle_id, self.circle.id)
|
||||||
|
self.assertEqual(list(circle_ids)[0], self.circle.id)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ from vbv_lernwelt.learning_mentor.content.praxis_assignment import (
|
||||||
)
|
)
|
||||||
from vbv_lernwelt.learning_mentor.models import LearningMentor
|
from vbv_lernwelt.learning_mentor.models import LearningMentor
|
||||||
from vbv_lernwelt.learning_mentor.serializers import PraxisAssignmentStatusSerializer
|
from vbv_lernwelt.learning_mentor.serializers import PraxisAssignmentStatusSerializer
|
||||||
|
from vbv_lernwelt.learnpath.models import Circle
|
||||||
|
|
||||||
|
|
||||||
@api_view(["GET"])
|
@api_view(["GET"])
|
||||||
|
|
@ -26,11 +27,14 @@ def mentor_summary(request, course_session_id: int):
|
||||||
participants = mentor.participants.filter(course_session=course_session)
|
participants = mentor.participants.filter(course_session=course_session)
|
||||||
users = [p.user for p in participants]
|
users = [p.user for p in participants]
|
||||||
|
|
||||||
praxis_assignments = get_praxis_assignments(course_session, users)
|
praxis_assignments, circle_ids = get_praxis_assignments(course_session, users)
|
||||||
|
|
||||||
|
circles = Circle.objects.filter(id__in=circle_ids).values("id", "title")
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
{
|
{
|
||||||
"participants": [UserSerializer(user).data for user in users],
|
"participants": [UserSerializer(user).data for user in users],
|
||||||
|
"circles": list(circles),
|
||||||
"praxis_assignments": PraxisAssignmentStatusSerializer(
|
"praxis_assignments": PraxisAssignmentStatusSerializer(
|
||||||
praxis_assignments, many=True
|
praxis_assignments, many=True
|
||||||
).data,
|
).data,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue