From f75590dd0b658d6eed9832287072bed9716230d6 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Fri, 6 Oct 2023 15:43:21 +0200 Subject: [PATCH] Refactor code to use `useCourseSessionDetailQuery` --- client/src/composables.ts | 32 ++++++++++++- client/src/gql/gql.ts | 4 +- client/src/gql/graphql.ts | 4 +- client/src/graphql/queries.ts | 5 ++ .../EvaluationContainer.vue | 4 +- .../assignmentsPage/AssignmentDetails.vue | 4 +- .../learningPath/circlePage/CirclePage.vue | 21 +++++---- .../assignment/AssignmentIntroductionView.vue | 13 ++--- .../assignment/AssignmentSubmissionView.vue | 27 +++++++---- .../assignment/AssignmentView.vue | 43 +++++++---------- .../attendanceCourse/AttendanceCourse.vue | 10 ++-- .../blocks/AttendanceCourseBlock.vue | 8 ++-- .../blocks/EdoniqTestBlock.vue | 13 +++-- .../feedback/FeedbackBlock.vue | 19 +++++--- client/src/stores/courseSessions.ts | 47 ------------------- client/src/types.ts | 13 +++-- server/vbv_lernwelt/course/graphql/types.py | 19 ++++---- server/vbv_lernwelt/course/serializers.py | 46 ------------------ .../course_session/graphql/types.py | 10 ++-- 19 files changed, 151 insertions(+), 191 deletions(-) diff --git a/client/src/composables.ts b/client/src/composables.ts index 9e0442d2..36c70c78 100644 --- a/client/src/composables.ts +++ b/client/src/composables.ts @@ -48,12 +48,30 @@ export function useCourseSessionDetailQuery(courSessionId?: string | number) { return queryResult.data.value?.course_session as CourseSessionDetail | undefined; }); - function findAssignmentDetail(assignmentId: string) { + function findAssignmentByAssignmentId(assignmentId: string) { return (courseSessionDetail.value?.assignments ?? []).find((a) => { return a.learning_content?.content_assignment?.id === assignmentId; }); } + function findAssignment(learningContentId: string) { + return (courseSessionDetail.value?.assignments ?? []).find((a) => { + return a.learning_content.id === learningContentId; + }); + } + + function findEdoniqTest(learningContentId: string) { + return (courseSessionDetail.value?.edoniq_tests ?? []).find((e) => { + return e.learning_content.id === learningContentId; + }); + } + + function findAttendanceCourse(learningContentId: string) { + return (courseSessionDetail.value?.attendance_courses ?? []).find((e) => { + return e.learning_content.id === learningContentId; + }); + } + function findUser(userId: string) { return (courseSessionDetail.value?.users ?? []).find((u) => { return u.user_id === userId; @@ -72,6 +90,12 @@ export function useCourseSessionDetailQuery(courSessionId?: string | number) { }); } + function filterCircleExperts(circleSlug: string) { + return (courseSessionDetail.value?.users ?? []).filter((u) => { + return u.role === "EXPERT" && u.circles.map((c) => c.slug).includes(circleSlug); + }); + } + const dataLoaded = ref(false); function waitForData() { @@ -89,9 +113,13 @@ export function useCourseSessionDetailQuery(courSessionId?: string | number) { ...queryResult, courseSessionDetail, waitForData, - findAssignmentDetail, + findAssignmentByAssignmentId, + findAssignment, + findEdoniqTest, + findAttendanceCourse, findUser, findCurrentUser, filterMembers, + filterCircleExperts, }; } diff --git a/client/src/gql/gql.ts b/client/src/gql/gql.ts index 214c2739..fdde1523 100644 --- a/client/src/gql/gql.ts +++ b/client/src/gql/gql.ts @@ -20,7 +20,7 @@ const documents = { "\n query assignmentCompletionQuery(\n $assignmentId: ID!\n $courseSessionId: ID!\n $learningContentId: ID\n $assignmentUserId: UUID\n ) {\n assignment(id: $assignmentId) {\n assignment_type\n needs_expert_evaluation\n max_points\n content_type\n effort_required\n evaluation_description\n evaluation_document_url\n evaluation_tasks\n id\n intro_text\n performance_objectives\n slug\n tasks\n title\n translation_key\n competence_certificate {\n ...CoursePageFields\n }\n }\n assignment_completion(\n assignment_id: $assignmentId\n course_session_id: $courseSessionId\n assignment_user_id: $assignmentUserId\n learning_content_page_id: $learningContentId\n ) {\n id\n completion_status\n submitted_at\n evaluation_submitted_at\n evaluation_user {\n id\n }\n assignment_user {\n id\n }\n evaluation_points\n evaluation_max_points\n evaluation_passed\n edoniq_extended_time_flag\n completion_data\n }\n }\n": types.AssignmentCompletionQueryDocument, "\n query courseQuery($courseId: ID!) {\n course(id: $courseId) {\n id\n slug\n title\n category_name\n learning_path {\n id\n }\n }\n }\n": types.CourseQueryDocument, "\n query competenceCertificateQuery($courseSlug: String!, $courseSessionId: ID!) {\n competence_certificate_list(course_slug: $courseSlug) {\n ...CoursePageFields\n competence_certificates {\n ...CoursePageFields\n assignments {\n ...CoursePageFields\n assignment_type\n max_points\n completion(course_session_id: $courseSessionId) {\n id\n completion_status\n submitted_at\n evaluation_points\n evaluation_max_points\n evaluation_passed\n }\n learning_content {\n title\n id\n slug\n content_type\n frontend_url\n circle {\n ...CoursePageFields\n }\n }\n }\n }\n }\n }\n": types.CompetenceCertificateQueryDocument, - "\n query courseSessionDetail($courseSessionId: ID!) {\n course_session(id: $courseSessionId) {\n id\n title\n course {\n id\n title\n slug\n }\n users {\n id\n user_id\n first_name\n last_name\n email\n avatar_url\n role\n circles {\n id\n title\n slug\n }\n }\n attendance_courses {\n id\n location\n trainer\n due_date {\n id\n start\n end\n }\n learning_content_id\n learning_content {\n id\n title\n circle {\n id\n title\n slug\n }\n }\n }\n assignments {\n id\n submission_deadline {\n id\n start\n }\n evaluation_deadline {\n id\n start\n }\n learning_content {\n id\n title\n content_assignment {\n id\n title\n assignment_type\n }\n }\n }\n edoniq_tests {\n id\n deadline {\n id\n start\n end\n }\n learning_content {\n id\n title\n }\n }\n }\n }\n": types.CourseSessionDetailDocument, + "\n query courseSessionDetail($courseSessionId: ID!) {\n course_session(id: $courseSessionId) {\n id\n title\n course {\n id\n title\n slug\n }\n users {\n id\n user_id\n first_name\n last_name\n email\n avatar_url\n role\n circles {\n id\n title\n slug\n }\n }\n attendance_courses {\n id\n location\n trainer\n due_date {\n id\n start\n end\n }\n learning_content_id\n learning_content {\n id\n title\n circle {\n id\n title\n slug\n }\n }\n }\n assignments {\n id\n submission_deadline {\n id\n start\n }\n evaluation_deadline {\n id\n start\n }\n learning_content {\n id\n title\n content_assignment {\n id\n title\n assignment_type\n }\n }\n }\n edoniq_tests {\n id\n deadline {\n id\n start\n end\n }\n learning_content {\n id\n title\n content_assignment {\n id\n title\n assignment_type\n }\n }\n }\n }\n }\n": types.CourseSessionDetailDocument, "\n mutation SendFeedbackMutation(\n $courseSessionId: ID!\n $learningContentId: ID!\n $data: GenericScalar!\n $submitted: Boolean\n ) {\n send_feedback(\n course_session_id: $courseSessionId\n learning_content_page_id: $learningContentId\n data: $data\n submitted: $submitted\n ) {\n feedback_response {\n id\n data\n submitted\n }\n errors {\n field\n messages\n }\n }\n }\n": types.SendFeedbackMutationDocument, }; @@ -69,7 +69,7 @@ export function graphql(source: "\n query competenceCertificateQuery($courseSlu /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "\n query courseSessionDetail($courseSessionId: ID!) {\n course_session(id: $courseSessionId) {\n id\n title\n course {\n id\n title\n slug\n }\n users {\n id\n user_id\n first_name\n last_name\n email\n avatar_url\n role\n circles {\n id\n title\n slug\n }\n }\n attendance_courses {\n id\n location\n trainer\n due_date {\n id\n start\n end\n }\n learning_content_id\n learning_content {\n id\n title\n circle {\n id\n title\n slug\n }\n }\n }\n assignments {\n id\n submission_deadline {\n id\n start\n }\n evaluation_deadline {\n id\n start\n }\n learning_content {\n id\n title\n content_assignment {\n id\n title\n assignment_type\n }\n }\n }\n edoniq_tests {\n id\n deadline {\n id\n start\n end\n }\n learning_content {\n id\n title\n }\n }\n }\n }\n"): (typeof documents)["\n query courseSessionDetail($courseSessionId: ID!) {\n course_session(id: $courseSessionId) {\n id\n title\n course {\n id\n title\n slug\n }\n users {\n id\n user_id\n first_name\n last_name\n email\n avatar_url\n role\n circles {\n id\n title\n slug\n }\n }\n attendance_courses {\n id\n location\n trainer\n due_date {\n id\n start\n end\n }\n learning_content_id\n learning_content {\n id\n title\n circle {\n id\n title\n slug\n }\n }\n }\n assignments {\n id\n submission_deadline {\n id\n start\n }\n evaluation_deadline {\n id\n start\n }\n learning_content {\n id\n title\n content_assignment {\n id\n title\n assignment_type\n }\n }\n }\n edoniq_tests {\n id\n deadline {\n id\n start\n end\n }\n learning_content {\n id\n title\n }\n }\n }\n }\n"]; +export function graphql(source: "\n query courseSessionDetail($courseSessionId: ID!) {\n course_session(id: $courseSessionId) {\n id\n title\n course {\n id\n title\n slug\n }\n users {\n id\n user_id\n first_name\n last_name\n email\n avatar_url\n role\n circles {\n id\n title\n slug\n }\n }\n attendance_courses {\n id\n location\n trainer\n due_date {\n id\n start\n end\n }\n learning_content_id\n learning_content {\n id\n title\n circle {\n id\n title\n slug\n }\n }\n }\n assignments {\n id\n submission_deadline {\n id\n start\n }\n evaluation_deadline {\n id\n start\n }\n learning_content {\n id\n title\n content_assignment {\n id\n title\n assignment_type\n }\n }\n }\n edoniq_tests {\n id\n deadline {\n id\n start\n end\n }\n learning_content {\n id\n title\n content_assignment {\n id\n title\n assignment_type\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query courseSessionDetail($courseSessionId: ID!) {\n course_session(id: $courseSessionId) {\n id\n title\n course {\n id\n title\n slug\n }\n users {\n id\n user_id\n first_name\n last_name\n email\n avatar_url\n role\n circles {\n id\n title\n slug\n }\n }\n attendance_courses {\n id\n location\n trainer\n due_date {\n id\n start\n end\n }\n learning_content_id\n learning_content {\n id\n title\n circle {\n id\n title\n slug\n }\n }\n }\n assignments {\n id\n submission_deadline {\n id\n start\n }\n evaluation_deadline {\n id\n start\n }\n learning_content {\n id\n title\n content_assignment {\n id\n title\n assignment_type\n }\n }\n }\n edoniq_tests {\n id\n deadline {\n id\n start\n end\n }\n learning_content {\n id\n title\n content_assignment {\n id\n title\n assignment_type\n }\n }\n }\n }\n }\n"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/client/src/gql/graphql.ts b/client/src/gql/graphql.ts index 87d68def..d649c127 100644 --- a/client/src/gql/graphql.ts +++ b/client/src/gql/graphql.ts @@ -886,7 +886,7 @@ export type CourseSessionDetailQueryVariables = Exact<{ }>; -export type CourseSessionDetailQuery = { __typename?: 'Query', course_session?: { __typename?: 'CourseSessionObjectType', id: string, title: string, course: { __typename?: 'CourseObjectType', id: string, title: string, slug: string }, users?: Array<{ __typename?: 'CourseSessionUserObjectsType', id: any, user_id?: any | null, first_name?: string | null, last_name?: string | null, email?: string | null, avatar_url?: string | null, role?: string | null, circles?: Array<{ __typename?: 'CourseSessionUserExpertCircleType', id?: string | null, title?: string | null, slug?: string | null } | null> | null } | null> | null, attendance_courses?: Array<{ __typename?: 'CourseSessionAttendanceCourseObjectType', id: string, location: string, trainer: string, learning_content_id?: string | null, due_date?: { __typename?: 'DueDateObjectType', id: string, start?: any | null, end?: any | null } | null, learning_content?: { __typename?: 'LearningContentAttendanceCourseObjectType', id?: string | null, title?: string | null, circle?: { __typename?: 'CircleObjectType', id?: string | null, title?: string | null, slug?: string | null } | null } | null } | null> | null, assignments?: Array<{ __typename?: 'CourseSessionAssignmentObjectType', id: string, submission_deadline?: { __typename?: 'DueDateObjectType', id: string, start?: any | null } | null, evaluation_deadline?: { __typename?: 'DueDateObjectType', id: string, start?: any | null } | null, learning_content?: { __typename?: 'LearningContentAssignmentObjectType', id?: string | null, title?: string | null, content_assignment: { __typename?: 'AssignmentObjectType', id?: string | null, title?: string | null, assignment_type: AssignmentAssignmentAssignmentTypeChoices } } | null } | null> | null, edoniq_tests?: Array<{ __typename?: 'CourseSessionEdoniqTestObjectType', id: string, deadline?: { __typename?: 'DueDateObjectType', id: string, start?: any | null, end?: any | null } | null, learning_content?: { __typename?: 'LearningContentEdoniqTestObjectType', id?: string | null, title?: string | null } | null } | null> | null } | null }; +export type CourseSessionDetailQuery = { __typename?: 'Query', course_session?: { __typename?: 'CourseSessionObjectType', id: string, title: string, course: { __typename?: 'CourseObjectType', id: string, title: string, slug: string }, users?: Array<{ __typename?: 'CourseSessionUserObjectsType', id: any, user_id?: any | null, first_name?: string | null, last_name?: string | null, email?: string | null, avatar_url?: string | null, role?: string | null, circles?: Array<{ __typename?: 'CourseSessionUserExpertCircleType', id?: string | null, title?: string | null, slug?: string | null } | null> | null } | null> | null, attendance_courses?: Array<{ __typename?: 'CourseSessionAttendanceCourseObjectType', id: string, location: string, trainer: string, learning_content_id?: string | null, due_date?: { __typename?: 'DueDateObjectType', id: string, start?: any | null, end?: any | null } | null, learning_content?: { __typename?: 'LearningContentAttendanceCourseObjectType', id?: string | null, title?: string | null, circle?: { __typename?: 'CircleObjectType', id?: string | null, title?: string | null, slug?: string | null } | null } | null } | null> | null, assignments?: Array<{ __typename?: 'CourseSessionAssignmentObjectType', id: string, submission_deadline?: { __typename?: 'DueDateObjectType', id: string, start?: any | null } | null, evaluation_deadline?: { __typename?: 'DueDateObjectType', id: string, start?: any | null } | null, learning_content?: { __typename?: 'LearningContentAssignmentObjectType', id?: string | null, title?: string | null, content_assignment: { __typename?: 'AssignmentObjectType', id?: string | null, title?: string | null, assignment_type: AssignmentAssignmentAssignmentTypeChoices } } | null } | null> | null, edoniq_tests?: Array<{ __typename?: 'CourseSessionEdoniqTestObjectType', id: string, deadline?: { __typename?: 'DueDateObjectType', id: string, start?: any | null, end?: any | null } | null, learning_content?: { __typename?: 'LearningContentEdoniqTestObjectType', id?: string | null, title?: string | null, content_assignment?: { __typename?: 'AssignmentObjectType', id?: string | null, title?: string | null, assignment_type: AssignmentAssignmentAssignmentTypeChoices } | null } | null } | null> | null } | null }; export type SendFeedbackMutationMutationVariables = Exact<{ courseSessionId: Scalars['ID']['input']; @@ -905,5 +905,5 @@ export const AttendanceCheckQueryDocument = {"kind":"Document","definitions":[{" export const AssignmentCompletionQueryDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"assignmentCompletionQuery"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"assignmentId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"courseSessionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"learningContentId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"assignmentUserId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"assignment"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"assignmentId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"assignment_type"}},{"kind":"Field","name":{"kind":"Name","value":"needs_expert_evaluation"}},{"kind":"Field","name":{"kind":"Name","value":"max_points"}},{"kind":"Field","name":{"kind":"Name","value":"content_type"}},{"kind":"Field","name":{"kind":"Name","value":"effort_required"}},{"kind":"Field","name":{"kind":"Name","value":"evaluation_description"}},{"kind":"Field","name":{"kind":"Name","value":"evaluation_document_url"}},{"kind":"Field","name":{"kind":"Name","value":"evaluation_tasks"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"intro_text"}},{"kind":"Field","name":{"kind":"Name","value":"performance_objectives"}},{"kind":"Field","name":{"kind":"Name","value":"slug"}},{"kind":"Field","name":{"kind":"Name","value":"tasks"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"translation_key"}},{"kind":"Field","name":{"kind":"Name","value":"competence_certificate"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoursePageFields"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"assignment_completion"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"assignment_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"assignmentId"}}},{"kind":"Argument","name":{"kind":"Name","value":"course_session_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"courseSessionId"}}},{"kind":"Argument","name":{"kind":"Name","value":"assignment_user_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"assignmentUserId"}}},{"kind":"Argument","name":{"kind":"Name","value":"learning_content_page_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"learningContentId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"completion_status"}},{"kind":"Field","name":{"kind":"Name","value":"submitted_at"}},{"kind":"Field","name":{"kind":"Name","value":"evaluation_submitted_at"}},{"kind":"Field","name":{"kind":"Name","value":"evaluation_user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}},{"kind":"Field","name":{"kind":"Name","value":"assignment_user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evaluation_points"}},{"kind":"Field","name":{"kind":"Name","value":"evaluation_max_points"}},{"kind":"Field","name":{"kind":"Name","value":"evaluation_passed"}},{"kind":"Field","name":{"kind":"Name","value":"edoniq_extended_time_flag"}},{"kind":"Field","name":{"kind":"Name","value":"completion_data"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoursePageFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"CoursePageInterface"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"slug"}},{"kind":"Field","name":{"kind":"Name","value":"content_type"}},{"kind":"Field","name":{"kind":"Name","value":"frontend_url"}}]}}]} as unknown as DocumentNode; export const CourseQueryDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"courseQuery"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"courseId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"course"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"courseId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"slug"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"category_name"}},{"kind":"Field","name":{"kind":"Name","value":"learning_path"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]}}]} as unknown as DocumentNode; export const CompetenceCertificateQueryDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"competenceCertificateQuery"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"courseSlug"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"courseSessionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"competence_certificate_list"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"course_slug"},"value":{"kind":"Variable","name":{"kind":"Name","value":"courseSlug"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoursePageFields"}},{"kind":"Field","name":{"kind":"Name","value":"competence_certificates"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoursePageFields"}},{"kind":"Field","name":{"kind":"Name","value":"assignments"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoursePageFields"}},{"kind":"Field","name":{"kind":"Name","value":"assignment_type"}},{"kind":"Field","name":{"kind":"Name","value":"max_points"}},{"kind":"Field","name":{"kind":"Name","value":"completion"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"course_session_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"courseSessionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"completion_status"}},{"kind":"Field","name":{"kind":"Name","value":"submitted_at"}},{"kind":"Field","name":{"kind":"Name","value":"evaluation_points"}},{"kind":"Field","name":{"kind":"Name","value":"evaluation_max_points"}},{"kind":"Field","name":{"kind":"Name","value":"evaluation_passed"}}]}},{"kind":"Field","name":{"kind":"Name","value":"learning_content"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"slug"}},{"kind":"Field","name":{"kind":"Name","value":"content_type"}},{"kind":"Field","name":{"kind":"Name","value":"frontend_url"}},{"kind":"Field","name":{"kind":"Name","value":"circle"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CoursePageFields"}}]}}]}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CoursePageFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"CoursePageInterface"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"slug"}},{"kind":"Field","name":{"kind":"Name","value":"content_type"}},{"kind":"Field","name":{"kind":"Name","value":"frontend_url"}}]}}]} as unknown as DocumentNode; -export const CourseSessionDetailDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"courseSessionDetail"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"courseSessionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"course_session"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"courseSessionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"course"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"slug"}}]}},{"kind":"Field","name":{"kind":"Name","value":"users"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"user_id"}},{"kind":"Field","name":{"kind":"Name","value":"first_name"}},{"kind":"Field","name":{"kind":"Name","value":"last_name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"avatar_url"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"circles"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"slug"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"attendance_courses"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"location"}},{"kind":"Field","name":{"kind":"Name","value":"trainer"}},{"kind":"Field","name":{"kind":"Name","value":"due_date"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"start"}},{"kind":"Field","name":{"kind":"Name","value":"end"}}]}},{"kind":"Field","name":{"kind":"Name","value":"learning_content_id"}},{"kind":"Field","name":{"kind":"Name","value":"learning_content"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"circle"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"slug"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"assignments"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"submission_deadline"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"start"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evaluation_deadline"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"start"}}]}},{"kind":"Field","name":{"kind":"Name","value":"learning_content"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"content_assignment"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"assignment_type"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"edoniq_tests"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"start"}},{"kind":"Field","name":{"kind":"Name","value":"end"}}]}},{"kind":"Field","name":{"kind":"Name","value":"learning_content"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}}]}}]}}]}}]}}]} as unknown as DocumentNode; +export const CourseSessionDetailDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"courseSessionDetail"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"courseSessionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"course_session"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"courseSessionId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"course"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"slug"}}]}},{"kind":"Field","name":{"kind":"Name","value":"users"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"user_id"}},{"kind":"Field","name":{"kind":"Name","value":"first_name"}},{"kind":"Field","name":{"kind":"Name","value":"last_name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"avatar_url"}},{"kind":"Field","name":{"kind":"Name","value":"role"}},{"kind":"Field","name":{"kind":"Name","value":"circles"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"slug"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"attendance_courses"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"location"}},{"kind":"Field","name":{"kind":"Name","value":"trainer"}},{"kind":"Field","name":{"kind":"Name","value":"due_date"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"start"}},{"kind":"Field","name":{"kind":"Name","value":"end"}}]}},{"kind":"Field","name":{"kind":"Name","value":"learning_content_id"}},{"kind":"Field","name":{"kind":"Name","value":"learning_content"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"circle"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"slug"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"assignments"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"submission_deadline"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"start"}}]}},{"kind":"Field","name":{"kind":"Name","value":"evaluation_deadline"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"start"}}]}},{"kind":"Field","name":{"kind":"Name","value":"learning_content"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"content_assignment"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"assignment_type"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"edoniq_tests"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"deadline"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"start"}},{"kind":"Field","name":{"kind":"Name","value":"end"}}]}},{"kind":"Field","name":{"kind":"Name","value":"learning_content"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"content_assignment"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"assignment_type"}}]}}]}}]}}]}}]}}]} as unknown as DocumentNode; export const SendFeedbackMutationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"SendFeedbackMutation"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"courseSessionId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"learningContentId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"data"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"GenericScalar"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"submitted"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Boolean"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"send_feedback"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"course_session_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"courseSessionId"}}},{"kind":"Argument","name":{"kind":"Name","value":"learning_content_page_id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"learningContentId"}}},{"kind":"Argument","name":{"kind":"Name","value":"data"},"value":{"kind":"Variable","name":{"kind":"Name","value":"data"}}},{"kind":"Argument","name":{"kind":"Name","value":"submitted"},"value":{"kind":"Variable","name":{"kind":"Name","value":"submitted"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"feedback_response"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"data"}},{"kind":"Field","name":{"kind":"Name","value":"submitted"}}]}},{"kind":"Field","name":{"kind":"Name","value":"errors"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"field"}},{"kind":"Field","name":{"kind":"Name","value":"messages"}}]}}]}}]}}]} as unknown as DocumentNode; \ No newline at end of file diff --git a/client/src/graphql/queries.ts b/client/src/graphql/queries.ts index d67e909a..68268a6d 100644 --- a/client/src/graphql/queries.ts +++ b/client/src/graphql/queries.ts @@ -197,6 +197,11 @@ export const COURSE_SESSION_DETAIL_QUERY = graphql(` learning_content { id title + content_assignment { + id + title + assignment_type + } } } } diff --git a/client/src/pages/cockpit/assignmentEvaluationPage/EvaluationContainer.vue b/client/src/pages/cockpit/assignmentEvaluationPage/EvaluationContainer.vue index a68856c1..80ccdc3d 100644 --- a/client/src/pages/cockpit/assignmentEvaluationPage/EvaluationContainer.vue +++ b/client/src/pages/cockpit/assignmentEvaluationPage/EvaluationContainer.vue @@ -61,7 +61,9 @@ function editTask(task: AssignmentEvaluationTask) { const courseSessionDetailResult = useCourseSessionDetailQuery(); const assignmentDetail = computed(() => { - return courseSessionDetailResult.findAssignmentDetail(props.assignment.id.toString()); + return courseSessionDetailResult.findAssignmentByAssignmentId( + props.assignment.id.toString() + ); }); const dueDate = computed(() => diff --git a/client/src/pages/cockpit/assignmentsPage/AssignmentDetails.vue b/client/src/pages/cockpit/assignmentsPage/AssignmentDetails.vue index 481e992b..d4ec65c2 100644 --- a/client/src/pages/cockpit/assignmentsPage/AssignmentDetails.vue +++ b/client/src/pages/cockpit/assignmentsPage/AssignmentDetails.vue @@ -33,8 +33,8 @@ const state = reactive({ }); const assignmentDetail = computed(() => { - return courseSessionDetailResult.findAssignmentDetail( - props.learningContentAssignment.content_assignment_id.toString() + return courseSessionDetailResult.findAssignment( + props.learningContentAssignment.id.toString() ); }); diff --git a/client/src/pages/learningPath/circlePage/CirclePage.vue b/client/src/pages/learningPath/circlePage/CirclePage.vue index 77e0d90d..37ecea11 100644 --- a/client/src/pages/learningPath/circlePage/CirclePage.vue +++ b/client/src/pages/learningPath/circlePage/CirclePage.vue @@ -1,6 +1,5 @@ @@ -40,9 +40,10 @@ const step = useRouteQuery("step");

{{ $t("assignment.dueDateSubmission") }}

-

+ +

{{ $t("assignment.dueDateIntroduction") }} - +

{{ $t("assignment.dueDateNotSet") }} diff --git a/client/src/pages/learningPath/learningContentPage/assignment/AssignmentSubmissionView.vue b/client/src/pages/learningPath/learningContentPage/assignment/AssignmentSubmissionView.vue index 1e127da7..24c4f672 100644 --- a/client/src/pages/learningPath/learningContentPage/assignment/AssignmentSubmissionView.vue +++ b/client/src/pages/learningPath/learningContentPage/assignment/AssignmentSubmissionView.vue @@ -3,34 +3,36 @@ import DateEmbedding from "@/components/dueDates/DateEmbedding.vue"; import ItButton from "@/components/ui/ItButton.vue"; import ItCheckbox from "@/components/ui/ItCheckbox.vue"; import ItSuccessAlert from "@/components/ui/ItSuccessAlert.vue"; -import { useCurrentCourseSession } from "@/composables"; +import { useCourseSessionDetailQuery, useCurrentCourseSession } from "@/composables"; import { bustItGetCache } from "@/fetchHelpers"; import { UPSERT_ASSIGNMENT_COMPLETION_MUTATION } from "@/graphql/mutations"; import AssignmentSubmissionResponses from "@/pages/learningPath/learningContentPage/assignment/AssignmentSubmissionResponses.vue"; -import { useCourseSessionsStore } from "@/stores/courseSessions"; import { useUserStore } from "@/stores/user"; import type { Assignment, AssignmentCompletion, AssignmentTask } from "@/types"; import { useMutation } from "@urql/vue"; -import type { Dayjs } from "dayjs"; import log from "loglevel"; import { computed, reactive } from "vue"; import { useTranslation } from "i18next-vue"; import eventBus from "@/utils/eventBus"; +import dayjs from "dayjs"; +import { useCircleStore } from "@/stores/circle"; const props = defineProps<{ assignment: Assignment; learningContentId: number; assignmentCompletion?: AssignmentCompletion; courseSessionId: number; - dueDate: Dayjs; + submissionDeadlineStart?: string; }>(); const emit = defineEmits<{ (e: "editTask", task: AssignmentTask): void; }>(); -const courseSessionsStore = useCourseSessionsStore(); const courseSession = useCurrentCourseSession(); +const courseSessionDetailResult = useCourseSessionDetailQuery(); +const circleStore = useCircleStore(); + const { t } = useTranslation(); const state = reactive({ @@ -38,8 +40,15 @@ const state = reactive({ confirmPerson: false, }); +const circleExperts = computed(() => { + if (circleStore.circle) { + return courseSessionDetailResult.filterCircleExperts(circleStore.circle.slug); + } + return []; +}); + const circleExpert = computed(() => { - return courseSessionsStore.circleExperts[0]; + return circleExperts.value[0]; }); const circleExpertName = computed(() => { @@ -138,9 +147,11 @@ const onSubmit = async () => { {{ $t("assignment.showAssessmentDocument") }} -

+

{{ $t("assignment.dueDateSubmission") }} - +

-import { useCurrentCourseSession } from "@/composables"; +import { useCourseSessionDetailQuery, useCurrentCourseSession } from "@/composables"; import { UPSERT_ASSIGNMENT_COMPLETION_MUTATION } from "@/graphql/mutations"; import { ASSIGNMENT_COMPLETION_QUERY } from "@/graphql/queries"; import AssignmentIntroductionView from "@/pages/learningPath/learningContentPage/assignment/AssignmentIntroductionView.vue"; import AssignmentSubmissionView from "@/pages/learningPath/learningContentPage/assignment/AssignmentSubmissionView.vue"; import AssignmentTaskView from "@/pages/learningPath/learningContentPage/assignment/AssignmentTaskView.vue"; import LearningContentMultiLayout from "@/pages/learningPath/learningContentPage/layouts/LearningContentMultiLayout.vue"; -import { useCourseSessionsStore } from "@/stores/courseSessions"; import { useUserStore } from "@/stores/user"; import type { Assignment, AssignmentCompletion, AssignmentTask, - CourseSessionAssignment, - CourseSessionUser, LearningContentAssignment, } from "@/types"; import { useMutation, useQuery } from "@urql/vue"; import { useRouteQuery } from "@vueuse/router"; -import dayjs from "dayjs"; import * as log from "loglevel"; -import { computed, onMounted, reactive, ref, watchEffect } from "vue"; +import { computed, onMounted, ref, watchEffect } from "vue"; import { useTranslation } from "i18next-vue"; import { bustItGetCache } from "@/fetchHelpers"; import { learningContentTypeData } from "@/utils/typeMaps"; @@ -30,14 +26,6 @@ const { t } = useTranslation(); const courseSession = useCurrentCourseSession(); const userStore = useUserStore(); -interface State { - courseSessionAssignment: CourseSessionAssignment | undefined; -} - -const state: State = reactive({ - courseSessionAssignment: undefined, -}); - const props = defineProps<{ learningContent: LearningContentAssignment; }>(); @@ -52,10 +40,17 @@ const queryResult = useQuery({ pause: true, }); +const courseSessionDetailResult = useCourseSessionDetailQuery(); + const upsertAssignmentCompletionMutation = useMutation( UPSERT_ASSIGNMENT_COMPLETION_MUTATION ); +const submissionDeadline = computed(() => { + return courseSessionDetailResult.findAssignment(props.learningContent.id.toString()) + ?.submission_deadline; +}); + // FIXME daniel: `useRouteQuery` from usevue is currently the reason that we have to // fix the version of @vueuse/router and @vueuse/core to 10.1.0 // it fails with version 10.2.0. I have a reminder to check out the situation @@ -104,10 +99,6 @@ onMounted(async () => { props.learningContent ); - state.courseSessionAssignment = useCourseSessionsStore().findCourseSessionAssignment( - props.learningContent.id - ); - // create initial `AssignmentCompletion` first, so that it exists and we don't // have reactivity problem accessing it. await initUpsertAssignmentCompletion(); @@ -120,9 +111,7 @@ const numPages = computed(() => { }); const showPreviousButton = computed(() => stepIndex.value != 0); const showNextButton = computed(() => stepIndex.value + 1 < numPages.value); -const dueDate = computed(() => - dayjs(state.courseSessionAssignment?.submission_deadline_start) -); + const currentTask = computed(() => { if (stepIndex.value > 0 && stepIndex.value <= numTasks.value) { return assignment.value?.tasks[stepIndex.value - 1]; @@ -194,9 +183,9 @@ const subTitle = computed(() => { }); const assignmentUser = computed(() => { - return courseSession.value.users.find( - (user) => user.user_id === userStore.id - ) as CourseSessionUser; + return (courseSessionDetailResult.courseSessionDetail.value?.users ?? []).find( + (u) => u.user_id === userStore.id + ); }); @@ -204,7 +193,7 @@ const assignmentUser = computed(() => {
{{ queryResult.error.value }}
-
+
{
{ >
diff --git a/client/src/pages/learningPath/learningContentPage/attendanceCourse/AttendanceCourse.vue b/client/src/pages/learningPath/learningContentPage/attendanceCourse/AttendanceCourse.vue index 84d09904..83ae00db 100644 --- a/client/src/pages/learningPath/learningContentPage/attendanceCourse/AttendanceCourse.vue +++ b/client/src/pages/learningPath/learningContentPage/attendanceCourse/AttendanceCourse.vue @@ -3,7 +3,12 @@

{{ $t("a.Datum") }}

- {{ formatDueDate(props.attendanceCourse.start, props.attendanceCourse.end) }} + {{ + formatDueDate( + props.attendanceCourse.due_date.start, + props.attendanceCourse.due_date.end + ) + }}

@@ -24,8 +29,6 @@ diff --git a/client/src/pages/learningPath/learningContentPage/blocks/AttendanceCourseBlock.vue b/client/src/pages/learningPath/learningContentPage/blocks/AttendanceCourseBlock.vue index a13b41d4..6b1ad5da 100644 --- a/client/src/pages/learningPath/learningContentPage/blocks/AttendanceCourseBlock.vue +++ b/client/src/pages/learningPath/learningContentPage/blocks/AttendanceCourseBlock.vue @@ -1,18 +1,18 @@ diff --git a/client/src/pages/learningPath/learningContentPage/blocks/EdoniqTestBlock.vue b/client/src/pages/learningPath/learningContentPage/blocks/EdoniqTestBlock.vue index 1cb19b05..aabdf41f 100644 --- a/client/src/pages/learningPath/learningContentPage/blocks/EdoniqTestBlock.vue +++ b/client/src/pages/learningPath/learningContentPage/blocks/EdoniqTestBlock.vue @@ -8,8 +8,7 @@ import * as log from "loglevel"; import { itPost } from "@/fetchHelpers"; import { useQuery } from "@urql/vue"; import { ASSIGNMENT_COMPLETION_QUERY } from "@/graphql/queries"; -import { useCurrentCourseSession } from "@/composables"; -import { useCourseSessionsStore } from "@/stores/courseSessions"; +import { useCourseSessionDetailQuery, useCurrentCourseSession } from "@/composables"; import dayjs from "dayjs"; import ItSuccessAlert from "@/components/ui/ItSuccessAlert.vue"; import { @@ -24,10 +23,10 @@ const props = defineProps<{ }>(); const courseSession = useCurrentCourseSession(); -const courseSessionsStore = useCourseSessionsStore(); +const courseSessionDetailResult = useCourseSessionDetailQuery(); const courseSessionEdoniqTest = computed(() => { - return courseSessionsStore.findCourseSessionEdoniqTest(props.content.id); + return courseSessionDetailResult.findEdoniqTest(props.content.id.toString()); }); const queryResult = useQuery({ @@ -53,7 +52,7 @@ const extendedTimeTest = ref(false); const deadlineInPast = computed(() => { // with 16 minutes buffer - return dayjs(courseSessionEdoniqTest.value?.deadline_start) + return dayjs(courseSessionEdoniqTest.value?.deadline.start) .add(16, "minute") .isBefore(dayjs()); }); @@ -90,7 +89,7 @@ async function startTest() {

{{ $t("edoniqTest.submitDateDescription", { - x: formatDueDate(courseSessionEdoniqTest.deadline_start), + x: formatDueDate(courseSessionEdoniqTest.deadline.start), }) }}

@@ -158,7 +157,7 @@ async function startTest() {
{{ $t("a.Abgabetermin") }}: - {{ getDateString(dayjs(courseSessionEdoniqTest?.deadline_start)) }} + {{ getDateString(dayjs(courseSessionEdoniqTest?.deadline.start)) }}
diff --git a/client/src/pages/learningPath/learningContentPage/feedback/FeedbackBlock.vue b/client/src/pages/learningPath/learningContentPage/feedback/FeedbackBlock.vue index 4ddb9bcc..563cad49 100644 --- a/client/src/pages/learningPath/learningContentPage/feedback/FeedbackBlock.vue +++ b/client/src/pages/learningPath/learningContentPage/feedback/FeedbackBlock.vue @@ -10,21 +10,21 @@ import { } from "@/pages/learningPath/learningContentPage/feedback/feedback.constants"; import LearningContentMultiLayout from "@/pages/learningPath/learningContentPage/layouts/LearningContentMultiLayout.vue"; import { useCircleStore } from "@/stores/circle"; -import { useCourseSessionsStore } from "@/stores/courseSessions"; import type { LearningContentFeedback } from "@/types"; import { useMutation } from "@urql/vue"; import { useRouteQuery } from "@vueuse/router"; import log from "loglevel"; import { computed, onMounted, reactive, ref } from "vue"; import { useTranslation } from "i18next-vue"; -import { useCurrentCourseSession } from "@/composables"; +import { useCourseSessionDetailQuery, useCurrentCourseSession } from "@/composables"; const props = defineProps<{ content: LearningContentFeedback; }>(); -const courseSessionsStore = useCourseSessionsStore(); const courseSession = useCurrentCourseSession(); const circleStore = useCircleStore(); +const courseSessionDetailResult = useCourseSessionDetailQuery(); + const { t } = useTranslation(); const stepNo = useRouteQuery("step", "0", { transform: Number, mode: "push" }); @@ -33,6 +33,13 @@ const title = computed( () => `«${circleStore.circle?.title}»: ${t("feedback.areYouSatisfied")}` ); +const circleExperts = computed(() => { + if (circleStore.circle) { + return courseSessionDetailResult.filterCircleExperts(circleStore.circle.slug); + } + return []; +}); + const stepLabels = [ t("general.introduction"), t("feedback.satisfactionLabel"), @@ -244,7 +251,7 @@ onMounted(async () => {

{{ $t("feedback.intro", { - name: `${courseSessionsStore.circleExperts[0]?.first_name} ${courseSessionsStore.circleExperts[0]?.last_name}`, + name: `${circleExperts[0]?.first_name} ${circleExperts[0]?.last_name}`, }) }}

@@ -265,10 +272,10 @@ onMounted(async () => {
{ return Boolean(isCourseExpert && (inLearningPath() || inCompetenceProfile())); }); - // const circleExperts = computed(() => { - // const circleStore = useCircleStore(); - // const circleTranslationKey = circleStore.circle?.translation_key; - // - // if (currentCourseSession.value && circleTranslationKey) { - // return currentCourseSession.value.users.filter((u) => { - // if (u.role === "EXPERT") { - // return (u as ExpertSessionUser).circles - // .map((c) => c.translation_key) - // .includes(circleTranslationKey); - // } - // return false; - // }) as ExpertSessionUser[]; - // } - // return []; - // }); - // const canUploadCircleDocuments = computed(() => { // const userStore = useUserStore(); // return ( @@ -249,36 +232,6 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => { ); } - // function findAttendanceCourse( - // contentId: number - // ): CourseSessionAttendanceCourse | undefined { - // if (currentCourseSession.value) { - // return currentCourseSession.value.attendance_courses.find( - // (attendanceCourse) => attendanceCourse.learning_content_id === contentId - // ); - // } - // } - - // function findCourseSessionAssignment( - // contentId?: number - // ): CourseSessionAssignment | undefined { - // if (contentId && currentCourseSession.value) { - // return currentCourseSession.value.assignments.find( - // (a) => a.learning_content_id === contentId - // ); - // } - // } - // - // function findCourseSessionEdoniqTest( - // contentId?: number - // ): CourseSessionEdoniqTest | undefined { - // if (contentId && currentCourseSession.value) { - // return currentCourseSession.value.edoniq_tests.find( - // (a) => a.learning_content_id === contentId - // ); - // } - // } - return { uniqueCourseSessionsByCourse, allCurrentCourseSessions, diff --git a/client/src/types.ts b/client/src/types.ts index 179f1c5c..c4acaf85 100644 --- a/client/src/types.ts +++ b/client/src/types.ts @@ -496,9 +496,15 @@ export interface CourseSessionAssignment { export interface CourseSessionEdoniqTest { id: number; course_session_id: number; - learning_content_id: number; - deadline_id: number; - deadline_start: string; + deadline: SimpleDueDate; + learning_content: { + id: string; + content_assignment: { + id: string; + title: string; + assignment_type: AssignmentType; + }; + }; } export interface CourseSession { @@ -559,6 +565,7 @@ export interface CourseSessionDetail { }; assignments: CourseSessionAssignment[]; attendance_courses: CourseSessionAttendanceCourse[]; + edoniq_tests: CourseSessionEdoniqTest[]; users: CourseSessionUser[]; } diff --git a/server/vbv_lernwelt/course/graphql/types.py b/server/vbv_lernwelt/course/graphql/types.py index 0f8040ec..27afea36 100644 --- a/server/vbv_lernwelt/course/graphql/types.py +++ b/server/vbv_lernwelt/course/graphql/types.py @@ -7,8 +7,13 @@ from graphene_django import DjangoObjectType from graphql import GraphQLError from rest_framework.exceptions import PermissionDenied -from vbv_lernwelt.course.models import Course, CourseBasePage, CoursePage, \ - CourseSession, CourseSessionUser +from vbv_lernwelt.course.models import ( + Course, + CourseBasePage, + CoursePage, + CourseSession, + CourseSessionUser, +) from vbv_lernwelt.course.permissions import has_course_access from vbv_lernwelt.course_session.graphql.types import ( CourseSessionAttendanceCourseObjectType, @@ -134,9 +139,7 @@ class CourseSessionUserObjectsType(DjangoObjectType): return self.role def resolve_circles(self, info): - return self.expert.all().values( - "id", "title", "slug", "translation_key" - ) + return self.expert.all().values("id", "title", "slug", "translation_key") class CourseSessionObjectType(DjangoObjectType): @@ -165,10 +168,8 @@ class CourseSessionObjectType(DjangoObjectType): def resolve_assignments(self, info): return CourseSessionAssignment.objects.filter(course_session=self) - def resolve_edoniq_test(self, info): + def resolve_edoniq_tests(self, info): return CourseSessionEdoniqTest.objects.filter(course_session=self) def resolve_users(self, info): - return CourseSessionUser.objects.filter( - course_session_id=self.id - ).distinct() + return CourseSessionUser.objects.filter(course_session_id=self.id).distinct() diff --git a/server/vbv_lernwelt/course/serializers.py b/server/vbv_lernwelt/course/serializers.py index 25e29421..01a1b743 100644 --- a/server/vbv_lernwelt/course/serializers.py +++ b/server/vbv_lernwelt/course/serializers.py @@ -7,16 +7,6 @@ from vbv_lernwelt.course.models import ( CourseCompletion, CourseSession, ) -from vbv_lernwelt.course_session.models import ( - CourseSessionAssignment, - CourseSessionAttendanceCourse, - CourseSessionEdoniqTest, -) -from vbv_lernwelt.course_session.serializers import ( - CourseSessionAssignmentSerializer, - CourseSessionAttendanceCourseSerializer, - CourseSessionEdoniqTestSerializer, -) from vbv_lernwelt.duedate.models import DueDate from vbv_lernwelt.duedate.serializers import DueDateSerializer @@ -73,39 +63,12 @@ class CourseSessionSerializer(serializers.ModelSerializer): def get_course_url(self, obj): return obj.course.get_course_url() - def get_learning_path_url(self, obj): - return obj.course.get_learning_path_url() - - def get_cockpit_url(self, obj): - return obj.course.get_cockpit_url() - - def get_media_library_url(self, obj): - return obj.course.get_media_library_url() - - def get_competence_url(self, obj): - return obj.course.get_competence_url() - def get_documents(self, obj): documents = CircleDocument.objects.filter( course_session=obj, file__upload_finished_at__isnull=False ) return CircleDocumentSerializer(documents, many=True).data - def get_attendance_courses(self, obj): - return CourseSessionAttendanceCourseSerializer( - CourseSessionAttendanceCourse.objects.filter(course_session=obj), many=True - ).data - - def get_assignments(self, obj): - return CourseSessionAssignmentSerializer( - CourseSessionAssignment.objects.filter(course_session=obj), many=True - ).data - - def get_edoniq_tests(self, obj): - return CourseSessionEdoniqTestSerializer( - CourseSessionEdoniqTest.objects.filter(course_session=obj), many=True - ).data - def get_due_dates(self, obj): due_dates = DueDate.objects.filter(course_session=obj) return DueDateSerializer(due_dates, many=True).data @@ -120,16 +83,7 @@ class CourseSessionSerializer(serializers.ModelSerializer): "title", "start_date", "end_date", - # "additional_json_data", - # "attendance_courses", - # "assignments", - # "edoniq_tests", - # "learning_path_url", - # "cockpit_url", - # "competence_url", - # "media_library_url", "course_url", - # "documents", "due_dates", ] diff --git a/server/vbv_lernwelt/course_session/graphql/types.py b/server/vbv_lernwelt/course_session/graphql/types.py index 7067defa..cff6b75c 100644 --- a/server/vbv_lernwelt/course_session/graphql/types.py +++ b/server/vbv_lernwelt/course_session/graphql/types.py @@ -5,6 +5,7 @@ from vbv_lernwelt.course.permissions import is_course_session_expert from vbv_lernwelt.course_session.models import ( CourseSessionAttendanceCourse, CourseSessionAssignment, + CourseSessionEdoniqTest, ) from vbv_lernwelt.course_session.services.attendance import AttendanceUserStatus from vbv_lernwelt.duedate.graphql.types import DueDateObjectType @@ -39,7 +40,6 @@ class CourseSessionAttendanceCourseObjectType(DjangoObjectType): fields = ( "id", "course_session_id", - "learning_content_id", "learning_content", "location", "trainer", @@ -64,10 +64,9 @@ class CourseSessionAssignmentObjectType(DjangoObjectType): fields = ( "id", "course_session_id", - "learning_content_id", + "learning_content", "submission_deadline", "evaluation_deadline", - "learning_content", ) @@ -78,11 +77,10 @@ class CourseSessionEdoniqTestObjectType(DjangoObjectType): learning_content = graphene.Field(LearningContentEdoniqTestObjectType) class Meta: - model = CourseSessionAssignment + model = CourseSessionEdoniqTest fields = ( "id", "course_session_id", - "learning_content_id", - "deadline", "learning_content", + "deadline", )