fix: include learning units without feedback requested
This commit is contained in:
parent
3f8420ed61
commit
67188a5b73
|
|
@ -46,6 +46,7 @@ from vbv_lernwelt.learnpath.models import (
|
||||||
LearningContentAssignment,
|
LearningContentAssignment,
|
||||||
LearningContentEdoniqTest,
|
LearningContentEdoniqTest,
|
||||||
LearningPath,
|
LearningPath,
|
||||||
|
LearningUnit,
|
||||||
)
|
)
|
||||||
from vbv_lernwelt.learnpath.tests.learning_path_factories import (
|
from vbv_lernwelt.learnpath.tests.learning_path_factories import (
|
||||||
CircleFactory,
|
CircleFactory,
|
||||||
|
|
@ -268,13 +269,18 @@ def create_course_session_edoniq_test(
|
||||||
return cset
|
return cset
|
||||||
|
|
||||||
|
|
||||||
def create_learning_unit(circle: Circle, course: Course):
|
def create_learning_unit(
|
||||||
|
circle: Circle,
|
||||||
|
course: Course,
|
||||||
|
) -> LearningUnit:
|
||||||
cat, _ = CourseCategory.objects.get_or_create(
|
cat, _ = CourseCategory.objects.get_or_create(
|
||||||
course=course, title="Course Category"
|
course=course, title="Course Category"
|
||||||
)
|
)
|
||||||
|
|
||||||
return LearningUnitFactory(
|
return LearningUnitFactory(
|
||||||
title="Learning Unit", parent=circle, course_category=cat
|
title="Learning Unit",
|
||||||
|
parent=circle,
|
||||||
|
course_category=cat,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,17 @@
|
||||||
from typing import List, Set, Tuple
|
from typing import List, Set, Tuple
|
||||||
|
|
||||||
from django.db.models import Prefetch
|
|
||||||
|
|
||||||
from vbv_lernwelt.core.models import User
|
from vbv_lernwelt.core.models import User
|
||||||
|
from vbv_lernwelt.course.models import Course
|
||||||
from vbv_lernwelt.learning_mentor.entities import (
|
from vbv_lernwelt.learning_mentor.entities import (
|
||||||
MentorAssignmentCompletion,
|
MentorAssignmentCompletion,
|
||||||
MentorAssignmentStatus,
|
MentorAssignmentStatus,
|
||||||
MentorAssignmentStatusType,
|
MentorAssignmentStatusType,
|
||||||
MentorCompletionStatus,
|
MentorCompletionStatus,
|
||||||
)
|
)
|
||||||
|
from vbv_lernwelt.learnpath.models import (
|
||||||
|
LearningUnit,
|
||||||
|
LearningUnitPerformanceFeedbackType,
|
||||||
|
)
|
||||||
from vbv_lernwelt.self_evaluation_feedback.models import SelfEvaluationFeedback
|
from vbv_lernwelt.self_evaluation_feedback.models import SelfEvaluationFeedback
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -37,7 +40,9 @@ def create_blank_completions_non_requesters(
|
||||||
|
|
||||||
|
|
||||||
def get_self_feedback_evaluation(
|
def get_self_feedback_evaluation(
|
||||||
participants: List[User], evaluation_user: User
|
participants: List[User],
|
||||||
|
evaluation_user: User,
|
||||||
|
course: Course,
|
||||||
) -> Tuple[List[MentorAssignmentStatus], Set[int]]:
|
) -> Tuple[List[MentorAssignmentStatus], Set[int]]:
|
||||||
records: List[MentorAssignmentStatus] = []
|
records: List[MentorAssignmentStatus] = []
|
||||||
circle_ids: Set[int] = set()
|
circle_ids: Set[int] = set()
|
||||||
|
|
@ -45,21 +50,24 @@ def get_self_feedback_evaluation(
|
||||||
if not participants:
|
if not participants:
|
||||||
return records, circle_ids
|
return records, circle_ids
|
||||||
|
|
||||||
feedbacks = SelfEvaluationFeedback.objects.prefetch_related(
|
# very unfortunate: we can't simply get all SelfEvaluationFeedback objects since then
|
||||||
Prefetch("learning_unit")
|
# we would miss the one where no feedback was requested -> so we get all learning units
|
||||||
).filter(
|
# and check if we have to take them into account (course, feedback type, etc.)
|
||||||
feedback_requester_user__in=participants,
|
for learning_unit in LearningUnit.objects.filter(
|
||||||
feedback_provider_user=evaluation_user,
|
feedback_user=LearningUnitPerformanceFeedbackType.MENTOR_FEEDBACK.value,
|
||||||
)
|
):
|
||||||
|
circle_page = learning_unit.get_parent()
|
||||||
|
circle = circle_page.specific
|
||||||
|
|
||||||
feedback_by_learning_unit = {}
|
if circle.get_course() != course:
|
||||||
|
continue
|
||||||
|
|
||||||
for feedback in feedbacks:
|
feedbacks = SelfEvaluationFeedback.objects.filter(
|
||||||
feedback_by_learning_unit.setdefault(feedback.learning_unit, []).append(
|
learning_unit=learning_unit,
|
||||||
feedback
|
feedback_requester_user__in=participants,
|
||||||
|
feedback_provider_user=evaluation_user,
|
||||||
)
|
)
|
||||||
|
|
||||||
for learning_unit, feedbacks in feedback_by_learning_unit.items():
|
|
||||||
circle_id = learning_unit.get_circle().id
|
circle_id = learning_unit.get_circle().id
|
||||||
circle_ids.add(circle_id)
|
circle_ids.add(circle_id)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ from vbv_lernwelt.course.creators.test_utils import (
|
||||||
)
|
)
|
||||||
from vbv_lernwelt.course.models import CourseSessionUser
|
from vbv_lernwelt.course.models import CourseSessionUser
|
||||||
from vbv_lernwelt.learning_mentor.models import LearningMentor
|
from vbv_lernwelt.learning_mentor.models import LearningMentor
|
||||||
|
from vbv_lernwelt.learnpath.models import LearningUnitPerformanceFeedbackType
|
||||||
from vbv_lernwelt.self_evaluation_feedback.models import SelfEvaluationFeedback
|
from vbv_lernwelt.self_evaluation_feedback.models import SelfEvaluationFeedback
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -131,6 +132,13 @@ class LearningMentorAPITest(APITestCase):
|
||||||
course=self.course,
|
course=self.course,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# performance criteria under this learning unit shall be evaluated by the mentor
|
||||||
|
learning_unit.feedback_user = (
|
||||||
|
LearningUnitPerformanceFeedbackType.MENTOR_FEEDBACK.name
|
||||||
|
)
|
||||||
|
|
||||||
|
learning_unit.save()
|
||||||
|
|
||||||
# 1: we already evaluated
|
# 1: we already evaluated
|
||||||
SelfEvaluationFeedback.objects.create(
|
SelfEvaluationFeedback.objects.create(
|
||||||
feedback_requester_user=self.participant_1.user,
|
feedback_requester_user=self.participant_1.user,
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ def mentor_summary(request, course_session_id: int):
|
||||||
) = get_self_feedback_evaluation(
|
) = get_self_feedback_evaluation(
|
||||||
participants=users,
|
participants=users,
|
||||||
evaluation_user=request.user, # noqa
|
evaluation_user=request.user, # noqa
|
||||||
|
course=course_session.course,
|
||||||
)
|
)
|
||||||
|
|
||||||
circle_ids.update(praxis_assignments_circle_ids)
|
circle_ids.update(praxis_assignments_circle_ids)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue