chore: moar _ids + id -> _id fix

This commit is contained in:
Livio Bieri 2023-10-26 15:24:25 +02:00
parent c96472dbe6
commit ae4f4d2611
3 changed files with 34 additions and 19 deletions

View File

@ -27,7 +27,8 @@ class PresenceRecordStatisticsType(graphene.ObjectType):
details_url = graphene.String(required=True)
class AttendanceDayPresences(graphene.ObjectType):
class AttendanceDayPresencesStatisticsType(graphene.ObjectType):
_id = graphene.ID(required=True)
records = graphene.List(PresenceRecordStatisticsType, required=True)
summary = graphene.Field(AttendanceSummaryStatisticsType, required=True)
@ -35,7 +36,7 @@ class AttendanceDayPresences(graphene.ObjectType):
def attendance_day_presences(
course_id: graphene.ID,
course_session_selection_ids: graphene.List(graphene.ID),
) -> AttendanceDayPresences:
) -> AttendanceDayPresencesStatisticsType:
completed = CourseSessionAttendanceCourse.objects.filter(
course_session_id__in=course_session_selection_ids,
due_date__end__lt=timezone.now(),
@ -81,7 +82,9 @@ def attendance_day_presences(
participants_present=calculate_avg_participation(records), # noqa
)
return AttendanceDayPresences(summary=summary, records=records) # noqa
return AttendanceDayPresencesStatisticsType(
summary=summary, records=records, _id=course_id # noqa
)
def calculate_avg_participation(records: List[PresenceRecordStatisticsType]) -> float:

View File

@ -8,7 +8,7 @@ from vbv_lernwelt.dashboard.graphql.types.assignment import (
)
from vbv_lernwelt.dashboard.graphql.types.attendance import (
attendance_day_presences,
AttendanceDayPresences,
AttendanceDayPresencesStatisticsType,
)
from vbv_lernwelt.dashboard.graphql.types.competence import (
CompetencePerformanceStatisticsSummaryType,
@ -17,7 +17,7 @@ from vbv_lernwelt.dashboard.graphql.types.competence import (
)
from vbv_lernwelt.dashboard.graphql.types.feedback import (
feedback_responses,
FeedbackResponses,
FeedbackStatisticsResponsesType,
)
from vbv_lernwelt.learnpath.models import Circle
@ -96,20 +96,25 @@ class CourseStatisticsType(graphene.ObjectType):
course_session_selection_metrics = graphene.Field(
StatisticsCourseSessionsSelectionMetricType, required=True
)
attendance_day_presences = graphene.Field(AttendanceDayPresences, required=True)
feedback_responses = graphene.Field(FeedbackResponses, required=True)
attendance_day_presences = graphene.Field(
AttendanceDayPresencesStatisticsType, required=True
)
feedback_responses = graphene.Field(FeedbackStatisticsResponsesType, required=True)
assignments = graphene.Field(AssignmentsStatisticsType, required=True)
competences = graphene.Field(CompetencesStatisticsType, required=True)
def resolve_attendance_day_presences(root, info) -> AttendanceDayPresences:
def resolve_attendance_day_presences(
root, info
) -> AttendanceDayPresencesStatisticsType:
return attendance_day_presences(
course_id=root.course_id,
course_session_selection_ids=root.course_session_selection_ids,
)
def resolve_feedback_responses(root, info) -> FeedbackResponses:
def resolve_feedback_responses(root, info) -> FeedbackStatisticsResponsesType:
return feedback_responses(
course_session_selection_ids=root.course_session_selection_ids,
course_id=root.course_id,
course_slug=root.course_slug,
)
@ -210,7 +215,7 @@ class CourseStatisticsType(graphene.ObjectType):
)
return StatisticsCourseSessionPropertiesType(
_id=root.id, # noqa
_id=root._id, # noqa
sessions=course_session_data, # noqa
generations=list(generations), # noqa
circles=circle_data, # noqa

View File

@ -7,13 +7,15 @@ from vbv_lernwelt.feedback.models import FeedbackResponse
from vbv_lernwelt.feedback.utils import feedback_users
class FeedbackSummary(graphene.ObjectType):
class FeedbackStatisticsSummaryType(graphene.ObjectType):
_id = graphene.ID(required=True)
satisfaction_average = graphene.Float(required=True)
satisfaction_max = graphene.Int(required=True)
total_responses = graphene.Int(required=True)
class FeedbackRecord(graphene.ObjectType):
class FeedbackStatisticsRecordType(graphene.ObjectType):
_id = graphene.ID(required=True)
course_session_id = graphene.ID(required=True)
generation = graphene.String(required=True)
circle_id = graphene.ID(required=True)
@ -22,15 +24,17 @@ class FeedbackRecord(graphene.ObjectType):
details_url = graphene.String(required=True)
class FeedbackResponses(graphene.ObjectType):
records = graphene.List(FeedbackRecord, required=True)
summary = graphene.Field(FeedbackSummary, required=True)
class FeedbackStatisticsResponsesType(graphene.ObjectType):
_id = graphene.ID(required=True)
records = graphene.List(FeedbackStatisticsRecordType, required=True)
summary = graphene.Field(FeedbackStatisticsSummaryType, required=True)
def feedback_responses(
course_session_selection_ids: graphene.List(graphene.ID),
course_id: graphene.ID,
course_slug: graphene.String,
) -> FeedbackResponses:
) -> FeedbackStatisticsResponsesType:
# Get all course sessions for this user in the given course
course_sessions = CourseSession.objects.filter(
id__in=course_session_selection_ids,
@ -58,9 +62,11 @@ def feedback_responses(
circle_feedbacks
)
return FeedbackResponses(
return FeedbackStatisticsResponsesType(
_id=course_id, # noqa
records=circle_feedbacks, # noqa
summary=FeedbackSummary( # noqa
summary=FeedbackStatisticsSummaryType( # noqa
_id=course_id, # noqa
satisfaction_average=avg, # noqa
satisfaction_max=4, # noqa
total_responses=len(fbs), # noqa
@ -93,7 +99,8 @@ def circle_feedback_average(
for circle_id, data in circle_data.items():
details_url = f"/course/{course_slug}/cockpit/feedback/{circle_id}?courseSessionId={course_session_id}"
records.append(
FeedbackRecord(
FeedbackStatisticsRecordType(
_id=circle_id, # noqa
course_session_id=course_session_id, # noqa
generation=generation, # noqa
circle_id=circle_id, # noqa