diff --git a/frontend/src/components/assignments/AssignmentForm.vue b/frontend/src/components/assignments/AssignmentForm.vue deleted file mode 100644 index 75fb2060..00000000 --- a/frontend/src/components/assignments/AssignmentForm.vue +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - diff --git a/frontend/src/components/assignments/DeadlineSelector.vue b/frontend/src/components/assignments/DeadlineSelector.vue index 3907af96..7c78296f 100644 --- a/frontend/src/components/assignments/DeadlineSelector.vue +++ b/frontend/src/components/assignments/DeadlineSelector.vue @@ -1,5 +1,5 @@ + diff --git a/frontend/src/views/assignments/SingleAssignment.vue b/frontend/src/views/assignments/SingleAssignment.vue index 9f740f56..0461bb63 100644 --- a/frontend/src/views/assignments/SingleAssignment.vue +++ b/frontend/src/views/assignments/SingleAssignment.vue @@ -4,27 +4,14 @@ import auth from "@/services/auth/auth-service.ts"; import {computed, ref} from "vue"; import StudentAssignment from "@/views/assignments/StudentAssignment.vue"; import TeacherAssignment from "@/views/assignments/TeacherAssignment.vue"; -import {asyncComputed} from "@vueuse/core"; -import {GroupController} from "@/controllers/groups.ts"; import {useRoute} from "vue-router"; const role = auth.authState.activeRole; const isTeacher = computed(() => role === 'teacher'); -// Get the user's username/id -const username = asyncComputed(async () => { - const user = await auth.loadUser(); - return user?.profile?.preferred_username ?? undefined -}); - const route = useRoute(); +const classId = ref(route.params.classId as string); const assignmentId = ref(Number(route.params.id)); -const classId = window.history.state?.class_id; - -const groupController = new GroupController(classId, assignmentId.value); - -const groupDTOs = asyncComputed(async () => await groupController.getAll(true)); -console.log(groupDTOs.value); @@ -32,14 +19,12 @@ console.log(groupDTOs.value); diff --git a/frontend/src/views/assignments/StudentAssignment.vue b/frontend/src/views/assignments/StudentAssignment.vue index 88a58d0f..0750ed48 100644 --- a/frontend/src/views/assignments/StudentAssignment.vue +++ b/frontend/src/views/assignments/StudentAssignment.vue @@ -5,16 +5,13 @@ import {useI18n} from "vue-i18n"; import {useAssignmentQuery} from "@/queries/assignments.ts"; import UsingQueryResult from "@/components/UsingQueryResult.vue"; import type {AssignmentResponse} from "@/controllers/assignments.ts"; -import type {GroupDTO} from "@dwengo-1/common/interfaces/group"; import {asyncComputed} from "@vueuse/core"; import {useStudentsByUsernamesQuery} from "@/queries/students.ts"; -import {AssignmentDTO} from "@dwengo-1/common/dist/interfaces/assignment.ts"; -import {StudentDTO} from "@dwengo-1/common/dist/interfaces/student.ts"; +import {useGroupsQuery} from "@/queries/groups.ts"; const props = defineProps<{ classId: string assignmentId: number - groups: GroupDTO[] | undefined }>(); const {t, locale} = useI18n(); @@ -26,23 +23,19 @@ const username = asyncComputed(async () => { }); const assignmentQueryResult = useAssignmentQuery(() => props.classId, props.assignmentId); +const submitted = ref(false);//TODO: update by fetching submissions and check if group submitted -const submitted = ref(true);//TODO: update by fetching submissions and check group - -const submitAssignment = async () => { - //TODO -}; - -const group = computed(() => { - return props?.groups?.find(group => - group.members.some(m => m.username === username.value) - ); +const groupsQueryResult = useGroupsQuery(props.classId, props.assignmentId, true); +const group = computed(() => + groupsQueryResult?.data.value?.groups.find(group => + group.members?.some(m => m.username === username.value) + ) /** For testing - return {assignment: 1, - groupNumber: 1, - members: ["testleerling1"]} - */ -}); + return {assignment: 1, + groupNumber: 1, + members: ["testleerling1"]} + */ +); // Assuming group.value.members is a list of usernames TODO: case when it's StudentDTO's const studentQueries = useStudentsByUsernamesQuery(() => group.value?.members as string[]); @@ -75,10 +68,10 @@ const studentQueries = useStudentsByUsernamesQuery(() => group.value?.members as {{ t("submitted") }} - {{ data.title }} + {{ data.assignment.title }} @@ -87,30 +80,20 @@ const studentQueries = useStudentsByUsernamesQuery(() => group.value?.members as - {{ data.description }} + {{ data.assignment.description }}

{{ t("group") }}

    -
  • - {{ student.data?.student.firstName + ' ' + student.data?.student.lastName }} +
  • + {{ student.firstName + ' ' + student.lastName }}
- - - {{ t("submit") }} - - diff --git a/frontend/src/views/assignments/TeacherAssignment.vue b/frontend/src/views/assignments/TeacherAssignment.vue index 5fb28e57..14c0568a 100644 --- a/frontend/src/views/assignments/TeacherAssignment.vue +++ b/frontend/src/views/assignments/TeacherAssignment.vue @@ -1,15 +1,17 @@ @@ -50,45 +85,93 @@ const deleteAssignment = async () => { mdi-delete - {{ data.title }} + {{ data.assignment.title }} - - {{ t("learning-path") }} - + + {{ t("learning-path") }} + + + - {{ data.description }} + {{ data.assignment.description }} -

{{ t("group") }}

+

{{ t("groups") }}

+
+ + - + + + + + +
+ + + + Group Members + + + + + {{ + member.firstName + ' ' + member.lastName + }} + + + + + + + Close + + + + @@ -105,5 +189,10 @@ const deleteAssignment = async () => { diff --git a/frontend/src/views/assignments/UserAssignments.vue b/frontend/src/views/assignments/UserAssignments.vue index 63547477..c81d96cf 100644 --- a/frontend/src/views/assignments/UserAssignments.vue +++ b/frontend/src/views/assignments/UserAssignments.vue @@ -27,25 +27,25 @@ if (isTeacher.value) { classesQueryResults = useStudentClassesQuery(username, true); } -//TODO: replace with query from classes +//TODO: remove later const classController = new ClassController(); + //TODO: replace by query that fetches all user's assignment const assignments = asyncComputed(async () => { const classes = classesQueryResults?.data?.value?.classes; if (!classes) return []; const result = await Promise.all( (classes as ClassDTO[]).map(async (cls) => { - //TODO: replace by class queries const {assignments} = await classController.getAssignments(cls.id); return assignments.map(a => ({ id: a.id, - class: cls, // replace by the whole ClassDTO object + class: cls, title: a.title, description: a.description, learningPath: a.learningPath, language: a.language, - groups: [] + groups: a.groups })); }) ); @@ -54,23 +54,20 @@ const assignments = asyncComputed(async () => { }, []); -const goToCreateAssignment = async () => { +async function goToCreateAssignment(): Promise { await router.push('/assignment/create'); -}; +} -const goToAssignmentDetails = async (id: number, class_id: string) => { - await router.push({ - path: `/assignment/${id}`, - state: {class_id}, - }); -}; +async function goToAssignmentDetails(id: number, clsId: string): Promise { + await router.push(`/assignment/${clsId}/${id}`); +} -const goToDeleteAssignment = async (id: number, class_id: string) => { +async function goToDeleteAssignment(id: number, clsId: string): Promise { //TODO: replace with query - const controller = new AssignmentController(class_id); + const controller = new AssignmentController(clsId); await controller.deleteAssignment(id); -}; +} onMounted(async () => { const user = await auth.loadUser();