chore: remove getCircleTitleById

This commit is contained in:
Livio Bieri 2024-03-15 13:45:02 +01:00
parent 514649f358
commit f6d9cc9b63
9 changed files with 18 additions and 26 deletions

View File

@ -76,7 +76,7 @@ const filteredAssignments: Ref<Assignment[]> = computed(() => {
<template v-for="item in filteredAssignments" :key="item.id"> <template v-for="item in filteredAssignments" :key="item.id">
<PraxisAssignmentItem <PraxisAssignmentItem
v-if="item.type === 'praxis_assignment'" v-if="item.type === 'praxis_assignment'"
:circle-title="learningMentees.getCircleTitleById(item.circle_id)" :circle-title="item.circle_name"
:pending-tasks="item.pending_evaluations" :pending-tasks="item.pending_evaluations"
:task-link="{ :task-link="{
name: 'learningMentorPraxisAssignments', name: 'learningMentorPraxisAssignments',
@ -86,7 +86,7 @@ const filteredAssignments: Ref<Assignment[]> = computed(() => {
/> />
<SelfAssignmentFeedbackAssignmentItem <SelfAssignmentFeedbackAssignmentItem
v-else-if="item.type === 'self_evaluation_feedback'" v-else-if="item.type === 'self_evaluation_feedback'"
:circle-title="learningMentees.getCircleTitleById(item.circle_id)" :circle-title="item.circle_name"
:pending-tasks="item.pending_evaluations" :pending-tasks="item.pending_evaluations"
:task-link="{ :task-link="{
name: 'learningMentorSelfEvaluationFeedbackAssignments', name: 'learningMentorSelfEvaluationFeedbackAssignments',

View File

@ -30,9 +30,7 @@ onMounted(() => {
<div v-if="praxisAssignment"> <div v-if="praxisAssignment">
<div class="p-6"> <div class="p-6">
<h2 class="mb-2">{{ $t("a.Praxisauftrag") }}: {{ praxisAssignment.title }}</h2> <h2 class="mb-2">{{ $t("a.Praxisauftrag") }}: {{ praxisAssignment.title }}</h2>
<span class="text-gray-800"> <span class="text-gray-800">Circle «{{ praxisAssignment.circle_name }}»</span>
Circle «{{ learningMentees.getCircleTitleById(praxisAssignment.circle_id) }}»
</span>
<template v-if="praxisAssignment.pending_evaluations > 0"> <template v-if="praxisAssignment.pending_evaluations > 0">
<div class="flex flex-row items-center space-x-2 pt-4"> <div class="flex flex-row items-center space-x-2 pt-4">
<div <div

View File

@ -33,9 +33,7 @@ const getParticipantById = (id: string): Participant | null => {
{{ $t("a.Selbsteinschätzung") }}: {{ selfEvaluationFeedback.title }} {{ $t("a.Selbsteinschätzung") }}: {{ selfEvaluationFeedback.title }}
</h2> </h2>
<span class="text-gray-800"> <span class="text-gray-800">
Circle «{{ Circle «{{ selfEvaluationFeedback.circle_name }}»
learningMentees.getCircleTitleById(selfEvaluationFeedback.circle_id)
}}»
</span> </span>
<template v-if="selfEvaluationFeedback.pending_evaluations > 0"> <template v-if="selfEvaluationFeedback.pending_evaluations > 0">
<div class="flex flex-row items-center space-x-2 pt-4"> <div class="flex flex-row items-center space-x-2 pt-4">

View File

@ -34,12 +34,13 @@ export interface Assignment {
id: string; id: string;
title: string; title: string;
circle_id: string; circle_id: string;
circle_name: string;
pending_evaluations: number; pending_evaluations: number;
completions: Completion[]; completions: Completion[];
type: string; type: string;
} }
interface Summary { export interface Summary {
participants: Participant[]; participants: Participant[];
circles: Circle[]; circles: Circle[];
assignments: Assignment[]; assignments: Assignment[];
@ -52,14 +53,6 @@ export const useLearningMentees = (
const summary: Ref<Summary | null> = ref(null); const summary: Ref<Summary | null> = ref(null);
const error = ref(null); const error = ref(null);
const getCircleTitleById = (id: string): string => {
if (summary.value?.circles) {
const circle = summary.value.circles.find((circle) => String(circle.id) === id);
return circle ? circle.title : "";
}
return "";
};
const getAssignmentById = (id: string): Assignment | null => { const getAssignmentById = (id: string): Assignment | null => {
if (summary.value?.assignments) { if (summary.value?.assignments) {
const found = summary.value.assignments.find( const found = summary.value.assignments.find(
@ -92,7 +85,6 @@ export const useLearningMentees = (
isLoading, isLoading,
summary, summary,
error, error,
getCircleTitleById,
fetchData, fetchData,
getAssignmentById, getAssignmentById,
}; };

View File

@ -110,19 +110,19 @@ def get_praxis_assignments(
] ]
) )
circle_id = learning_content.get_circle().id circle = learning_content.get_circle()
circle_ids.add(circle.id)
records.append( records.append(
MentorAssignmentStatus( MentorAssignmentStatus(
id=course_session_assignment.id, id=course_session_assignment.id,
title=learning_content.content_assignment.title, title=learning_content.content_assignment.title,
circle_id=circle_id, circle_id=circle.id,
circle_name=circle.title,
pending_evaluations=submitted_count, pending_evaluations=submitted_count,
completions=completions, completions=completions,
type=MentorAssignmentStatusType.PRAXIS_ASSIGNMENT, type=MentorAssignmentStatusType.PRAXIS_ASSIGNMENT,
) )
) )
circle_ids.add(circle_id)
return records, circle_ids return records, circle_ids

View File

@ -64,9 +64,6 @@ def get_self_feedback_evaluation(
feedback_provider_user=evaluation_user, feedback_provider_user=evaluation_user,
) )
circle_id = learning_unit.get_circle().id
circle_ids.add(circle_id)
pending_evaluations = len([f for f in feedbacks if not f.feedback_submitted]) pending_evaluations = len([f for f in feedbacks if not f.feedback_submitted])
completions = [ completions = [
@ -90,11 +87,15 @@ def get_self_feedback_evaluation(
participants=participants, participants=participants,
) )
circle = learning_unit.get_circle()
circle_ids.add(circle.id)
records.append( records.append(
MentorAssignmentStatus( MentorAssignmentStatus(
id=learning_unit.id, id=learning_unit.id,
title=learning_unit.title, title=learning_unit.title,
circle_id=circle_id, circle_id=circle.id,
circle_name=circle.title,
pending_evaluations=pending_evaluations, pending_evaluations=pending_evaluations,
completions=completions, completions=completions,
type=MentorAssignmentStatusType.SELF_EVALUATION_FEEDBACK, type=MentorAssignmentStatusType.SELF_EVALUATION_FEEDBACK,

View File

@ -27,6 +27,7 @@ class MentorAssignmentStatus:
id: str id: str
title: str title: str
circle_id: str circle_id: str
circle_name: str
pending_evaluations: int pending_evaluations: int
completions: List[MentorAssignmentCompletion] completions: List[MentorAssignmentCompletion]
type: MentorAssignmentStatusType type: MentorAssignmentStatusType

View File

@ -19,6 +19,7 @@ class MentorAssignmentStatusSerializer(serializers.Serializer):
id = serializers.CharField() id = serializers.CharField()
title = serializers.CharField() title = serializers.CharField()
circle_id = serializers.CharField() circle_id = serializers.CharField()
circle_name = serializers.CharField()
pending_evaluations = serializers.IntegerField() pending_evaluations = serializers.IntegerField()
completions = MentorAssignmentCompletionSerializer(many=True) completions = MentorAssignmentCompletionSerializer(many=True)
type = serializers.ReadOnlyField() type = serializers.ReadOnlyField()

View File

@ -108,5 +108,6 @@ class AttendanceServicesTestCase(TestCase):
assignment = assignments[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_name, "Circle")
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) self.assertEqual(list(circle_ids)[0], self.circle.id)