From 49a3fa99e1b9910627e8fdf717f3eec8834146cc Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Tue, 10 Oct 2023 13:11:13 +0200 Subject: [PATCH] Document handling via REST --- client/src/gql/gql.ts | 4 +- client/src/gql/graphql.ts | 4 +- client/src/graphql/queries.ts | 15 ----- .../pages/TestCourseSessionComposablePage.vue | 22 -------- .../pages/cockpit/CockpitUserProfilePage.vue | 2 - .../cockpitPage/SubmissionsOverview.vue | 2 +- .../cockpit/documentPage/DocumentPage.vue | 45 +++++++++++---- .../circlePage/DocumentSection.vue | 27 +++++++-- client/src/router/index.ts | 5 -- client/src/services/files.ts | 36 ++++++------ client/src/stores/competence.ts | 35 ++---------- client/src/stores/courseSessions.ts | 56 ------------------- client/src/types.ts | 1 - server/config/urls.py | 13 +++-- server/vbv_lernwelt/course/graphql/types.py | 6 +- server/vbv_lernwelt/course/models.py | 3 + server/vbv_lernwelt/course/serializers.py | 16 ++++++ .../course_session/graphql/types.py | 2 +- server/vbv_lernwelt/course_session/views.py | 22 +++++++- .../vbv_lernwelt/learnpath/graphql/queries.py | 2 +- 20 files changed, 137 insertions(+), 181 deletions(-) delete mode 100644 client/src/pages/TestCourseSessionComposablePage.vue diff --git a/client/src/gql/gql.ts b/client/src/gql/gql.ts index 8c76ff4b..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 content_assignment {\n id\n title\n assignment_type\n }\n }\n }\n documents {\n id\n name\n file_name\n url\n learning_sequence {\n id\n title\n circle {\n id\n slug\n title\n }\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 content_assignment {\n id\n title\n assignment_type\n }\n }\n }\n documents {\n id\n name\n file_name\n url\n learning_sequence {\n id\n title\n circle {\n id\n slug\n title\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 documents {\n id\n name\n file_name\n url\n learning_sequence {\n id\n title\n circle {\n id\n slug\n title\n }\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 ec613366..0f417008 100644 --- a/client/src/gql/graphql.ts +++ b/client/src/gql/graphql.ts @@ -897,7 +897,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, content_assignment?: { __typename?: 'AssignmentObjectType', id?: string | null, title?: string | null, assignment_type: AssignmentAssignmentAssignmentTypeChoices } | null } | null } | null> | null, documents?: Array<{ __typename?: 'CircleDocumentObjectType', id: any, name: string, file_name?: string | null, url?: string | null, learning_sequence: { __typename?: 'LearningSequenceObjectType', id?: string | null, title?: string | null, circle?: { __typename?: 'CircleObjectType', id?: string | null, slug?: 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']; @@ -916,5 +916,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"}},{"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":"documents"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"file_name"}},{"kind":"Field","name":{"kind":"Name","value":"url"}},{"kind":"Field","name":{"kind":"Name","value":"learning_sequence"},"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":"slug"}},{"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 4cea1214..68268a6d 100644 --- a/client/src/graphql/queries.ts +++ b/client/src/graphql/queries.ts @@ -204,21 +204,6 @@ export const COURSE_SESSION_DETAIL_QUERY = graphql(` } } } - documents { - id - name - file_name - url - learning_sequence { - id - title - circle { - id - slug - title - } - } - } } } `); diff --git a/client/src/pages/TestCourseSessionComposablePage.vue b/client/src/pages/TestCourseSessionComposablePage.vue deleted file mode 100644 index 689ab876..00000000 --- a/client/src/pages/TestCourseSessionComposablePage.vue +++ /dev/null @@ -1,22 +0,0 @@ - - - diff --git a/client/src/pages/cockpit/CockpitUserProfilePage.vue b/client/src/pages/cockpit/CockpitUserProfilePage.vue index c3c0c722..ff19ab89 100644 --- a/client/src/pages/cockpit/CockpitUserProfilePage.vue +++ b/client/src/pages/cockpit/CockpitUserProfilePage.vue @@ -1,5 +1,4 @@ diff --git a/client/src/router/index.ts b/client/src/router/index.ts index 0aac3682..805a1e9c 100644 --- a/client/src/router/index.ts +++ b/client/src/router/index.ts @@ -98,11 +98,6 @@ const router = createRouter({ }, ], }, - { - path: "/course/:courseSlug/test-composable", - component: () => import("../pages/TestCourseSessionComposablePage.vue"), - props: true, - }, { path: "/course/:courseSlug/learn", component: () => diff --git a/client/src/services/files.ts b/client/src/services/files.ts index 726d1bb2..54d9584d 100644 --- a/client/src/services/files.ts +++ b/client/src/services/files.ts @@ -1,6 +1,6 @@ -import { itDelete, itFetch, itPost } from "@/fetchHelpers"; +import { bustItGetCache, itDelete, itFetch, itGetCached, itPost } from "@/fetchHelpers"; import { getCookieValue } from "@/router/guards"; -import type { CircleDocument, DocumentUploadData } from "@/types"; +import type { DocumentUploadData } from "@/types"; type FileData = { fields: Record; @@ -73,8 +73,9 @@ function handleUpload(url: string, options: RequestInit) { export async function uploadCircleDocument( data: DocumentUploadData, - courseSessionId: number -): Promise { + courseSessionId: number, + bustCacheUrlKey = "" +) { if (data.file === null) { throw new Error("No file selected"); } @@ -82,22 +83,25 @@ export async function uploadCircleDocument( const startData = await startFileUpload(data, courseSessionId); await uploadFile(startData, data.file); - const response = await itPost(`/api/core/file/finish/`, { + const response = itPost(`/api/core/file/finish/`, { file_id: startData.file_id, }); - const newDocument: CircleDocument = { - id: startData.id, - name: data.name, - file_name: data.file.name, - url: response.url, - course_session: courseSessionId, - learning_sequence: data.learningSequence.id, - }; + if (bustCacheUrlKey) { + bustItGetCache(bustCacheUrlKey); + } - return Promise.resolve(newDocument); + return response; } -export async function deleteCircleDocument(documentId: string) { - return itDelete(`/api/core/document/${documentId}/`); +export async function deleteCircleDocument(documentId: string, bustCacheUrlKey = "") { + const result = itDelete(`/api/core/document/${documentId}/`); + if (bustCacheUrlKey) { + bustItGetCache(bustCacheUrlKey); + } + return result; +} + +export async function fetchCourseSessionDocuments(courseSessionId: number) { + return itGetCached(`/api/core/document/list/${courseSessionId}/`); } diff --git a/client/src/stores/competence.ts b/client/src/stores/competence.ts index 4ce74c16..4197a245 100644 --- a/client/src/stores/competence.ts +++ b/client/src/stores/competence.ts @@ -8,7 +8,6 @@ import type { CompetenceProfilePage, PerformanceCriteria, } from "@/types"; -import i18next from "i18next"; import _ from "lodash"; import cloneDeep from "lodash/cloneDeep"; import groupBy from "lodash/groupBy"; @@ -17,9 +16,6 @@ import { defineStore } from "pinia"; export type CompetenceStoreState = { competenceProfilePages: Map; - - selectedCircle: { id: string; name: string }; - availableCircles: { id: string; name: string }[]; circles: CircleLight[]; }; @@ -28,8 +24,6 @@ export const useCompetenceStore = defineStore({ state: () => { return { competenceProfilePages: new Map(), - selectedCircle: { id: "all", name: `Circle: ${i18next.t("Alle")}` }, - availableCircles: [], circles: [], } as CompetenceStoreState; }, @@ -52,13 +46,7 @@ export const useCompetenceStore = defineStore({ }; }, criteriaByCompetence(competence: CompetencePage) { - return competence.children.filter((criteria) => { - if (this.selectedCircle.id != "all") { - return criteria.circle.translation_key === this.selectedCircle.id; - } - - return competence.children; - }); + return competence.children; }, competenceProfilePage(userId: string | undefined = undefined) { if (!userId) { @@ -88,14 +76,10 @@ export const useCompetenceStore = defineStore({ ["asc"] ); - if (this.selectedCircle.id !== "all") { - criteria = criteria.filter( - (c) => c.circle.translation_key === this.selectedCircle.id - ); - } - if (circleId) { - criteria = criteria.filter((c) => circleId === c.circle.id); + criteria = criteria.filter( + (c) => circleId.toString() === c.circle.id.toString() + ); } return criteria; @@ -116,12 +100,7 @@ export const useCompetenceStore = defineStore({ if (competenceProfilePage?.children.length) { return _.orderBy( competenceProfilePage.children.filter((competence) => { - let criteria = competence.children; - if (this.selectedCircle.id != "all") { - criteria = criteria.filter((criteria) => { - return criteria.circle.translation_key === this.selectedCircle.id; - }); - } + const criteria = competence.children; return criteria.length > 0; }), ["competence_id"], @@ -159,10 +138,6 @@ export const useCompetenceStore = defineStore({ this.competenceProfilePages.set(userId, cloneDeep(competenceProfilePage)); this.circles = competenceProfilePage.circles; - const circles = competenceProfilePage.circles.map((c: CircleLight) => { - return { id: c.translation_key, name: `Circle: ${c.title}` }; - }); - this.availableCircles = [{ id: "all", name: "Circle: Alle" }, ...circles]; await this.parseCompletionData(userId); diff --git a/client/src/stores/courseSessions.ts b/client/src/stores/courseSessions.ts index f409b01a..ebfa3cb1 100644 --- a/client/src/stores/courseSessions.ts +++ b/client/src/stores/courseSessions.ts @@ -146,35 +146,6 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => { return Boolean(isCourseExpert && (inLearningPath() || inCompetenceProfile())); }); - // const canUploadCircleDocuments = computed(() => { - // const userStore = useUserStore(); - // return ( - // circleExperts.value.filter((expert) => expert.user_id === userStore.id).length > 0 - // ); - // }); - - // const circleDocuments = computed(() => { - // const circleStore = useCircleStore(); - // - // return ( - // circleStore.circle?.learningSequences - // .map((ls) => ({ id: ls.id, title: ls.title, documents: [] })) - // .map((ls: { id: number; title: string; documents: CircleDocument[] }) => { - // if (currentCourseSession.value === undefined) { - // return ls; - // } - // - // for (const document of currentCourseSession.value.documents) { - // if (document.learning_sequence === ls.id) { - // ls.documents.push(document); - // } - // } - // return ls; - // }) - // .filter((ls) => ls.documents.length > 0) || [] - // ); - // }); - function hasCockpit(courseSession: CourseSession) { const userStore = useUserStore(); return ( @@ -183,10 +154,6 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => { ); } - // function addDocument(document: CircleDocument) { - // currentCourseSession.value?.documents.push(document); - // } - function allDueDates() { const allDueDatesReturn: DueDate[] = []; @@ -211,26 +178,6 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => { }); } - // async function startUpload() { - // log.debug("loadCourseSessionsData called"); - // allCourseSessions.value = await itPost(`/api/core/file/start`, { - // file_type: "image/png", - // file_name: "test.png", - // }); - // } - // - // async function removeDocument(documentId: string) { - // await deleteCircleDocument(documentId); - // - // if (currentCourseSession.value === undefined) { - // return; - // } - // - // currentCourseSession.value.documents = currentCourseSession.value?.documents.filter( - // (d) => d.id !== documentId - // ); - // } - return { uniqueCourseSessionsByCourse, allCurrentCourseSessions, @@ -240,9 +187,6 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => { hasCockpit, hasCourseSessionPreview, currentCourseSessionHasCockpit, - // addDocument, - // startUpload, - // removeDocument, allDueDates, // use `useCurrentCourseSession` whenever possible diff --git a/client/src/types.ts b/client/src/types.ts index 86c096ba..4a0015c2 100644 --- a/client/src/types.ts +++ b/client/src/types.ts @@ -569,7 +569,6 @@ export interface CourseSessionDetail { assignments: CourseSessionAssignment[]; attendance_courses: CourseSessionAttendanceCourse[]; edoniq_tests: CourseSessionEdoniqTest[]; - documents: CircleDocument[]; users: CourseSessionUser[]; } diff --git a/server/config/urls.py b/server/config/urls.py index 75e92863..44c43545 100644 --- a/server/config/urls.py +++ b/server/config/urls.py @@ -31,12 +31,12 @@ from vbv_lernwelt.course.views import ( document_direct_upload, document_upload_finish, document_upload_start, - get_course_session_users, get_course_sessions, mark_course_completion_view, request_course_completion, request_course_completion_for_user, ) +from vbv_lernwelt.course_session.views import get_course_session_documents from vbv_lernwelt.edoniq_test.views import ( export_students, export_students_and_trainers, @@ -90,6 +90,10 @@ urlpatterns = [ path('server/documents/', include(wagtaildocs_urls)), path('server/pages/', include(wagtail_urls)), + # core + re_path(r"server/core/icons/$", generate_web_component_icons, + name="generate_web_component_icons"), + # user management path("sso/", include("vbv_lernwelt.sso.urls")), re_path(r'api/core/me/$', me_user_view, name='me_user_view'), @@ -104,10 +108,6 @@ urlpatterns = [ re_path(r"api/notify/email_notification_settings/$", email_notification_settings, name='email_notification_settings'), - # core - re_path(r"server/core/icons/$", generate_web_component_icons, - name="generate_web_component_icons"), - # course path(r"api/course/sessions/", get_course_sessions, name="get_course_sessions"), # path(r"api/course/sessions//users/", @@ -139,6 +139,9 @@ urlpatterns = [ name='file_upload_finish'), path(r"api/core/document/local//", document_direct_upload, name='file_upload_local'), + path(r'api/core/document/list//', + get_course_session_documents, + name='get_course_session_documents'), # feedback path(r'api/core/feedback//summary/', diff --git a/server/vbv_lernwelt/course/graphql/types.py b/server/vbv_lernwelt/course/graphql/types.py index bbf194b3..5059b0f7 100644 --- a/server/vbv_lernwelt/course/graphql/types.py +++ b/server/vbv_lernwelt/course/graphql/types.py @@ -8,22 +8,22 @@ from graphql import GraphQLError from rest_framework.exceptions import PermissionDenied from vbv_lernwelt.course.models import ( + CircleDocument, Course, CourseBasePage, CoursePage, CourseSession, CourseSessionUser, - CircleDocument, ) from vbv_lernwelt.course.permissions import has_course_access from vbv_lernwelt.course_session.graphql.types import ( - CourseSessionAttendanceCourseObjectType, CourseSessionAssignmentObjectType, + CourseSessionAttendanceCourseObjectType, CourseSessionEdoniqTestObjectType, ) from vbv_lernwelt.course_session.models import ( - CourseSessionAttendanceCourse, CourseSessionAssignment, + CourseSessionAttendanceCourse, CourseSessionEdoniqTest, ) from vbv_lernwelt.learnpath.graphql.types import LearningPathObjectType diff --git a/server/vbv_lernwelt/course/models.py b/server/vbv_lernwelt/course/models.py index a040dc95..1e5cf9f8 100644 --- a/server/vbv_lernwelt/course/models.py +++ b/server/vbv_lernwelt/course/models.py @@ -322,6 +322,9 @@ class CircleDocument(models.Model): "learnpath.LearningSequence", on_delete=models.CASCADE ) + def get_circle(self): + return self.learning_sequence.get_circle() + @property def url(self) -> str: return self.file.url diff --git a/server/vbv_lernwelt/course/serializers.py b/server/vbv_lernwelt/course/serializers.py index 01a1b743..2fc27dbd 100644 --- a/server/vbv_lernwelt/course/serializers.py +++ b/server/vbv_lernwelt/course/serializers.py @@ -89,6 +89,8 @@ class CourseSessionSerializer(serializers.ModelSerializer): class CircleDocumentSerializer(serializers.ModelSerializer): + learning_sequence = serializers.SerializerMethodField() + class Meta: model = CircleDocument fields = [ @@ -100,6 +102,20 @@ class CircleDocumentSerializer(serializers.ModelSerializer): "learning_sequence", ] + def get_learning_sequence(self, obj): + ls = obj.learning_sequence + circle = ls.get_circle() + return { + "title": ls.title, + "id": ls.id, + "slug": ls.slug, + "circle": { + "title": circle.title, + "id": circle.id, + "slug": circle.slug, + }, + } + class DocumentUploadStartInputSerializer(serializers.Serializer): file_name = serializers.CharField() diff --git a/server/vbv_lernwelt/course_session/graphql/types.py b/server/vbv_lernwelt/course_session/graphql/types.py index cff6b75c..be8e7800 100644 --- a/server/vbv_lernwelt/course_session/graphql/types.py +++ b/server/vbv_lernwelt/course_session/graphql/types.py @@ -3,8 +3,8 @@ from graphene_django import DjangoObjectType from vbv_lernwelt.course.permissions import is_course_session_expert from vbv_lernwelt.course_session.models import ( - CourseSessionAttendanceCourse, CourseSessionAssignment, + CourseSessionAttendanceCourse, CourseSessionEdoniqTest, ) from vbv_lernwelt.course_session.services.attendance import AttendanceUserStatus diff --git a/server/vbv_lernwelt/course_session/views.py b/server/vbv_lernwelt/course_session/views.py index 91ea44a2..6cf3dbfc 100644 --- a/server/vbv_lernwelt/course_session/views.py +++ b/server/vbv_lernwelt/course_session/views.py @@ -1,3 +1,21 @@ -from django.shortcuts import render +from rest_framework.decorators import api_view +from rest_framework.exceptions import PermissionDenied +from rest_framework.response import Response -# Create your views here. +from vbv_lernwelt.course.models import CircleDocument +from vbv_lernwelt.course.permissions import has_course_session_access +from vbv_lernwelt.course.serializers import CircleDocumentSerializer + + +@api_view(["GET"]) +def get_course_session_documents(request, course_session_id): + if not has_course_session_access(request.user, course_session_id): + raise PermissionDenied() + + circle_documents = CircleDocument.objects.filter( + course_session_id=course_session_id + ) + + return Response( + status=200, data=CircleDocumentSerializer(circle_documents, many=True).data + ) diff --git a/server/vbv_lernwelt/learnpath/graphql/queries.py b/server/vbv_lernwelt/learnpath/graphql/queries.py index b4517fe2..7f68088c 100644 --- a/server/vbv_lernwelt/learnpath/graphql/queries.py +++ b/server/vbv_lernwelt/learnpath/graphql/queries.py @@ -6,12 +6,12 @@ from vbv_lernwelt.learnpath.graphql.types import ( LearningContentAssignmentObjectType, LearningContentAttendanceCourseObjectType, LearningContentDocumentListObjectType, + LearningContentEdoniqTestObjectType, LearningContentFeedbackObjectType, LearningContentLearningModuleObjectType, LearningContentMediaLibraryObjectType, LearningContentPlaceholderObjectType, LearningContentRichTextObjectType, - LearningContentEdoniqTestObjectType, LearningContentVideoObjectType, LearningPathObjectType, )