feat: praxis assignments
This commit is contained in:
parent
669dfdd7c1
commit
80cc83cde0
|
|
@ -1,5 +1,5 @@
|
|||
from vbv_lernwelt.core.models import User
|
||||
from vbv_lernwelt.course.models import CourseSession, CourseSessionUser
|
||||
from vbv_lernwelt.course.models import Course, CourseSession, CourseSessionUser
|
||||
from vbv_lernwelt.course_session_group.models import CourseSessionGroup
|
||||
from vbv_lernwelt.learnpath.models import LearningSequence
|
||||
|
||||
|
|
@ -123,3 +123,11 @@ def can_view_course_session(user: User, course_session: CourseSession) -> bool:
|
|||
course_session=course_session,
|
||||
user=user,
|
||||
).exists()
|
||||
|
||||
|
||||
def has_role_in_course(user: User, course: Course) -> bool:
|
||||
"""
|
||||
Test for regio leiter, member, trainer...
|
||||
"""
|
||||
...
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -7,14 +7,17 @@ from vbv_lernwelt.assignment.models import (
|
|||
)
|
||||
from vbv_lernwelt.course.creators.test_utils import (
|
||||
create_assignment,
|
||||
create_assignment_learning_content,
|
||||
create_circle,
|
||||
create_course,
|
||||
create_course_session,
|
||||
create_course_session_assignment,
|
||||
create_user,
|
||||
)
|
||||
from vbv_lernwelt.learning_mentor.views import (
|
||||
CompletionStatus,
|
||||
get_assignment_completions,
|
||||
get_praxis_assignments,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -52,7 +55,7 @@ class AttendanceServicesTestCase(TestCase):
|
|||
completion_status=AssignmentCompletionStatus.IN_PROGRESS.value,
|
||||
)
|
||||
|
||||
def test_assignments(self):
|
||||
def test_assignment_completions(self):
|
||||
# GIVEN
|
||||
participants = [self.user1, self.user2, self.user3, self.user4]
|
||||
|
||||
|
|
@ -66,11 +69,28 @@ class AttendanceServicesTestCase(TestCase):
|
|||
expected_statuses = {
|
||||
"Alpha": CompletionStatus.EVALUATED, # user1
|
||||
"Beta": CompletionStatus.SUBMITTED, # user2
|
||||
"Gamma": CompletionStatus.PENDING, # user4 (no AssignmentCompletion)
|
||||
"Kappa": CompletionStatus.PENDING, # user3 (IN_PROGRESS should be PENDING)
|
||||
"Gamma": CompletionStatus.UNKNOWN, # user4 (no AssignmentCompletion)
|
||||
"Kappa": CompletionStatus.UNKNOWN, # user3 (IN_PROGRESS should be PENDING)
|
||||
}
|
||||
|
||||
self.assertEqual(len(results), len(participants))
|
||||
for i, result in enumerate(results):
|
||||
self.assertEqual(result.last_name, expected_order[i])
|
||||
self.assertEqual(result.status, expected_statuses[result.last_name])
|
||||
|
||||
def test_praxis_assignment_status(self):
|
||||
# GIVEN
|
||||
lca = create_assignment_learning_content(self.circle, self.assignment)
|
||||
create_course_session_assignment(
|
||||
course_session=self.course_session, learning_content_assignment=lca
|
||||
)
|
||||
participants = [self.user1, self.user2, self.user3, self.user4]
|
||||
|
||||
# WHEN
|
||||
result = get_praxis_assignments(self.course_session, participants)
|
||||
|
||||
# THEN
|
||||
assignment = result[0]
|
||||
self.assertEqual(assignment.pending_evaluations, 1)
|
||||
self.assertEqual(assignment.title, "Dummy Assignment (CASEWORK)")
|
||||
self.assertEqual(assignment.circle_id, self.circle.id)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ from vbv_lernwelt.learning_mentor.models import LearningMentor
|
|||
|
||||
|
||||
class CompletionStatus(str, Enum):
|
||||
PENDING = "PENDING"
|
||||
UNKNOWN = "UNKNOWN"
|
||||
SUBMITTED = "SUBMITTED"
|
||||
EVALUATED = "EVALUATED"
|
||||
|
||||
|
|
@ -36,6 +36,7 @@ class PraxisAssignmentStatus:
|
|||
id: str
|
||||
title: str
|
||||
circle_id: str
|
||||
pending_evaluations: int
|
||||
completions: List[PraxisAssignmentCompletion]
|
||||
|
||||
|
||||
|
|
@ -60,7 +61,7 @@ def get_assignment_completions(
|
|||
]:
|
||||
status = CompletionStatus.SUBMITTED
|
||||
else:
|
||||
status = CompletionStatus.PENDING
|
||||
status = CompletionStatus.UNKNOWN
|
||||
|
||||
user_status_map[result["assignment_user"]] = (
|
||||
status,
|
||||
|
|
@ -70,14 +71,14 @@ def get_assignment_completions(
|
|||
status_priority = {
|
||||
CompletionStatus.SUBMITTED: 1,
|
||||
CompletionStatus.EVALUATED: 2,
|
||||
CompletionStatus.PENDING: 3,
|
||||
CompletionStatus.UNKNOWN: 3,
|
||||
}
|
||||
|
||||
sorted_participants = sorted(
|
||||
participants,
|
||||
key=lambda u: (
|
||||
status_priority.get(
|
||||
user_status_map.get(u.id, (CompletionStatus.PENDING, ""))[0]
|
||||
user_status_map.get(u.id, (CompletionStatus.UNKNOWN, ""))[0]
|
||||
),
|
||||
user_status_map.get(u.id, ("", u.last_name))[1],
|
||||
),
|
||||
|
|
@ -86,7 +87,7 @@ def get_assignment_completions(
|
|||
return [
|
||||
PraxisAssignmentCompletion(
|
||||
status=user_status_map.get(
|
||||
user.id, (CompletionStatus.PENDING, user.last_name)
|
||||
user.id, (CompletionStatus.UNKNOWN, user.last_name)
|
||||
)[0],
|
||||
user_id=user.id,
|
||||
last_name=user.last_name,
|
||||
|
|
@ -108,16 +109,28 @@ def get_praxis_assignments(
|
|||
],
|
||||
):
|
||||
learning_content = course_session_assignment.learning_content
|
||||
|
||||
completions = get_assignment_completions(
|
||||
course_session=course_session,
|
||||
assignment=learning_content.content_assignment,
|
||||
participants=participants,
|
||||
)
|
||||
|
||||
submitted_count = len(
|
||||
[
|
||||
completion
|
||||
for completion in completions
|
||||
if completion.status == CompletionStatus.SUBMITTED
|
||||
]
|
||||
)
|
||||
|
||||
records.append(
|
||||
PraxisAssignmentStatus(
|
||||
id=course_session_assignment.id,
|
||||
title=learning_content.content_assignment.title,
|
||||
circle_id=learning_content.get_circle().id,
|
||||
completions=get_assignment_completions(
|
||||
course_session=course_session,
|
||||
assignment=learning_content.content_assignment,
|
||||
participants=participants,
|
||||
),
|
||||
pending_evaluations=submitted_count,
|
||||
completions=completions,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue