feat: drag and drop en random selection voor groepen
This commit is contained in:
parent
936a34b709
commit
a3185ed1c1
10 changed files with 4347 additions and 1249 deletions
|
@ -1,72 +1,72 @@
|
|||
<script setup lang="ts">
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { assignmentTitleRules, classRules, learningPathRules } from "@/utils/assignment-rules.ts";
|
||||
import auth from "@/services/auth/auth-service.ts";
|
||||
import { useTeacherClassesQuery } from "@/queries/teachers.ts";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { useGetAllLearningPaths } from "@/queries/learning-paths.ts";
|
||||
import UsingQueryResult from "@/components/UsingQueryResult.vue";
|
||||
import type { LearningPath } from "@/data-objects/learning-paths/learning-path.ts";
|
||||
import type { ClassesResponse } from "@/controllers/classes.ts";
|
||||
import type { AssignmentDTO } from "@dwengo-1/common/interfaces/assignment";
|
||||
import { useCreateAssignmentMutation } from "@/queries/assignments.ts";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { assignmentTitleRules, classRules, learningPathRules } from "@/utils/assignment-rules.ts";
|
||||
import auth from "@/services/auth/auth-service.ts";
|
||||
import { useTeacherClassesQuery } from "@/queries/teachers.ts";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { useGetAllLearningPaths } from "@/queries/learning-paths.ts";
|
||||
import UsingQueryResult from "@/components/UsingQueryResult.vue";
|
||||
import type { LearningPath } from "@/data-objects/learning-paths/learning-path.ts";
|
||||
import type { ClassesResponse } from "@/controllers/classes.ts";
|
||||
import type { AssignmentDTO } from "@dwengo-1/common/interfaces/assignment";
|
||||
import { useCreateAssignmentMutation } from "@/queries/assignments.ts";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { t, locale } = useI18n();
|
||||
const role = ref(auth.authState.activeRole);
|
||||
const username = ref<string>("");
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { t, locale } = useI18n();
|
||||
const role = ref(auth.authState.activeRole);
|
||||
const username = ref<string>("");
|
||||
|
||||
onMounted(async () => {
|
||||
if (role.value === "student") {
|
||||
await router.push("/user");
|
||||
onMounted(async () => {
|
||||
if (role.value === "student") {
|
||||
await router.push("/user");
|
||||
}
|
||||
const user = await auth.loadUser();
|
||||
username.value = user?.profile?.preferred_username ?? "";
|
||||
});
|
||||
|
||||
const language = computed(() => locale.value);
|
||||
const form = ref();
|
||||
|
||||
const learningPathsQueryResults = useGetAllLearningPaths(language);
|
||||
const classesQueryResults = useTeacherClassesQuery(username, true);
|
||||
|
||||
const selectedClass = ref(undefined);
|
||||
const assignmentTitle = ref("");
|
||||
const selectedLearningPath = ref(route.query.hruid || undefined);
|
||||
const lpIsSelected = route.query.hruid !== undefined;
|
||||
|
||||
const { mutate, data, isSuccess } = useCreateAssignmentMutation();
|
||||
|
||||
watch([isSuccess, data], async ([success, newData]) => {
|
||||
if (success && newData?.assignment) {
|
||||
await router.push(`/assignment/${newData.assignment.within}/${newData.assignment.id}`);
|
||||
}
|
||||
});
|
||||
|
||||
async function submitFormHandler(): Promise<void> {
|
||||
const { valid } = await form.value.validate();
|
||||
if (!valid) return;
|
||||
|
||||
let lp = selectedLearningPath.value;
|
||||
if (!lpIsSelected) {
|
||||
lp = selectedLearningPath.value?.hruid;
|
||||
}
|
||||
|
||||
const assignmentDTO: AssignmentDTO = {
|
||||
id: 0,
|
||||
within: selectedClass.value?.id || "",
|
||||
title: assignmentTitle.value,
|
||||
description: "",
|
||||
learningPath: lp || "",
|
||||
deadline: new Date(),
|
||||
language: language.value,
|
||||
groups: [],
|
||||
};
|
||||
|
||||
mutate({ cid: assignmentDTO.within, data: assignmentDTO });
|
||||
}
|
||||
const user = await auth.loadUser();
|
||||
username.value = user?.profile?.preferred_username ?? "";
|
||||
});
|
||||
|
||||
const language = computed(() => locale.value);
|
||||
const form = ref();
|
||||
|
||||
const learningPathsQueryResults = useGetAllLearningPaths(language);
|
||||
const classesQueryResults = useTeacherClassesQuery(username, true);
|
||||
|
||||
const selectedClass = ref(undefined);
|
||||
const assignmentTitle = ref("");
|
||||
const selectedLearningPath = ref(route.query.hruid || undefined);
|
||||
const lpIsSelected = route.query.hruid !== undefined;
|
||||
|
||||
const { mutate, data, isSuccess } = useCreateAssignmentMutation();
|
||||
|
||||
watch([isSuccess, data], async ([success, newData]) => {
|
||||
if (success && newData?.assignment) {
|
||||
await router.push(`/assignment/${newData.assignment.within}/${newData.assignment.id}`);
|
||||
}
|
||||
});
|
||||
|
||||
async function submitFormHandler(): Promise<void> {
|
||||
const { valid } = await form.value.validate();
|
||||
if (!valid) return;
|
||||
|
||||
let lp = selectedLearningPath.value;
|
||||
if (!lpIsSelected) {
|
||||
lp = selectedLearningPath.value?.hruid;
|
||||
}
|
||||
|
||||
const assignmentDTO: AssignmentDTO = {
|
||||
id: 0,
|
||||
within: selectedClass.value?.id || "",
|
||||
title: assignmentTitle.value,
|
||||
description: "",
|
||||
learningPath: lp || "",
|
||||
deadline: new Date(),
|
||||
language: language.value,
|
||||
groups: [],
|
||||
};
|
||||
|
||||
mutate({ cid: assignmentDTO.within, data: assignmentDTO });
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -74,9 +74,13 @@ async function submitFormHandler(): Promise<void> {
|
|||
<h1 class="h1">{{ t("new-assignment") }}</h1>
|
||||
|
||||
<v-card class="form-card elevation-2 pa-6">
|
||||
<v-form ref="form" class="form-container" validate-on="submit lazy" @submit.prevent="submitFormHandler">
|
||||
<v-form
|
||||
ref="form"
|
||||
class="form-container"
|
||||
validate-on="submit lazy"
|
||||
@submit.prevent="submitFormHandler"
|
||||
>
|
||||
<v-container class="step-container pa-0">
|
||||
|
||||
<!-- Titel veld -->
|
||||
<v-text-field
|
||||
v-model="assignmentTitle"
|
||||
|
@ -90,7 +94,10 @@ async function submitFormHandler(): Promise<void> {
|
|||
/>
|
||||
|
||||
<!-- Learning Path keuze -->
|
||||
<using-query-result :query-result="learningPathsQueryResults" v-slot="{ data }: { data: LearningPath[] }">
|
||||
<using-query-result
|
||||
:query-result="learningPathsQueryResults"
|
||||
v-slot="{ data }: { data: LearningPath[] }"
|
||||
>
|
||||
<v-combobox
|
||||
v-model="selectedLearningPath"
|
||||
:items="data"
|
||||
|
@ -111,7 +118,10 @@ async function submitFormHandler(): Promise<void> {
|
|||
</using-query-result>
|
||||
|
||||
<!-- Klas keuze -->
|
||||
<using-query-result :query-result="classesQueryResults" v-slot="{ data }: { data: ClassesResponse }">
|
||||
<using-query-result
|
||||
:query-result="classesQueryResults"
|
||||
v-slot="{ data }: { data: ClassesResponse }"
|
||||
>
|
||||
<v-combobox
|
||||
v-model="selectedClass"
|
||||
:items="data?.classes ?? []"
|
||||
|
@ -153,7 +163,6 @@ async function submitFormHandler(): Promise<void> {
|
|||
{{ t("cancel") }}
|
||||
</v-btn>
|
||||
</div>
|
||||
|
||||
</v-container>
|
||||
</v-form>
|
||||
</v-card>
|
||||
|
@ -161,65 +170,59 @@ async function submitFormHandler(): Promise<void> {
|
|||
</template>
|
||||
|
||||
<style scoped>
|
||||
.main-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: start;
|
||||
padding-top: 32px;
|
||||
text-align: center;
|
||||
}
|
||||
.main-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: start;
|
||||
padding-top: 32px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.form-card {
|
||||
width: 100%;
|
||||
max-width: 720px;
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
.form-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.step-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
@media (max-width: 1000px) {
|
||||
.form-card {
|
||||
width: 85%;
|
||||
padding: 1%;
|
||||
width: 100%;
|
||||
max-width: 720px;
|
||||
border-radius: 16px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
|
||||
h1 {
|
||||
font-size: 32px;
|
||||
text-align: center;
|
||||
margin-left: 0;
|
||||
.form-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 400px) {
|
||||
|
||||
h1 {
|
||||
font-size: 24px;
|
||||
text-align: center;
|
||||
margin-left: 0;
|
||||
.step-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.v-card {
|
||||
border: 2px solid #0e6942;
|
||||
border-radius: 12px;
|
||||
}
|
||||
@media (max-width: 1000px) {
|
||||
.form-card {
|
||||
width: 85%;
|
||||
padding: 1%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
h1 {
|
||||
font-size: 32px;
|
||||
text-align: center;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 400px) {
|
||||
h1 {
|
||||
font-size: 24px;
|
||||
text-align: center;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.v-card {
|
||||
border: 2px solid #0e6942;
|
||||
border-radius: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
|
|
@ -1,90 +1,87 @@
|
|||
<script setup lang="ts">
|
||||
import {ref, computed, watchEffect} from "vue";
|
||||
import auth from "@/services/auth/auth-service.ts";
|
||||
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 {asyncComputed} from "@vueuse/core";
|
||||
import {useStudentsByUsernamesQuery} from "@/queries/students.ts";
|
||||
import {useGroupsQuery} from "@/queries/groups.ts";
|
||||
import {useGetLearningPathQuery} from "@/queries/learning-paths.ts";
|
||||
import type {Language} from "@/data-objects/language.ts";
|
||||
import {calculateProgress} from "@/utils/assignment-utils.ts";
|
||||
import { ref, computed, watchEffect } from "vue";
|
||||
import auth from "@/services/auth/auth-service.ts";
|
||||
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 { asyncComputed } from "@vueuse/core";
|
||||
import { useStudentsByUsernamesQuery } from "@/queries/students.ts";
|
||||
import { useGroupsQuery } from "@/queries/groups.ts";
|
||||
import { useGetLearningPathQuery } from "@/queries/learning-paths.ts";
|
||||
import type { Language } from "@/data-objects/language.ts";
|
||||
import { calculateProgress } from "@/utils/assignment-utils.ts";
|
||||
|
||||
const props = defineProps<{
|
||||
classId: string;
|
||||
assignmentId: number;
|
||||
}>();
|
||||
const props = defineProps<{
|
||||
classId: string;
|
||||
assignmentId: number;
|
||||
}>();
|
||||
|
||||
const {t} = useI18n();
|
||||
const lang = ref();
|
||||
const learningPath = ref();
|
||||
// Get the user's username/id
|
||||
const username = asyncComputed(async () => {
|
||||
const user = await auth.loadUser();
|
||||
return user?.profile?.preferred_username ?? undefined;
|
||||
});
|
||||
const { t } = useI18n();
|
||||
const lang = ref();
|
||||
const learningPath = ref();
|
||||
// Get the user's username/id
|
||||
const username = asyncComputed(async () => {
|
||||
const user = await auth.loadUser();
|
||||
return user?.profile?.preferred_username ?? undefined;
|
||||
});
|
||||
|
||||
const assignmentQueryResult = useAssignmentQuery(() => props.classId, props.assignmentId);
|
||||
learningPath.value = assignmentQueryResult.data.value?.assignment?.learningPath;
|
||||
|
||||
|
||||
const groupsQueryResult = useGroupsQuery(props.classId, props.assignmentId, true);
|
||||
const group = computed(() => {
|
||||
const groups = groupsQueryResult.data.value?.groups;
|
||||
|
||||
if (!groups) return undefined;
|
||||
|
||||
// Sort by original groupNumber
|
||||
const sortedGroups = [...groups].sort((a, b) => a.groupNumber - b.groupNumber);
|
||||
|
||||
return sortedGroups
|
||||
.map((group, index) => ({
|
||||
...group,
|
||||
groupNo: index + 1, // Renumbered index
|
||||
}))
|
||||
.find((group) => group.members?.some((m) => m.username === username.value));
|
||||
});
|
||||
|
||||
|
||||
watchEffect(() => {
|
||||
const assignmentQueryResult = useAssignmentQuery(() => props.classId, props.assignmentId);
|
||||
learningPath.value = assignmentQueryResult.data.value?.assignment?.learningPath;
|
||||
lang.value = assignmentQueryResult.data.value?.assignment?.language as Language;
|
||||
});
|
||||
|
||||
const learningPathParams = computed(() => {
|
||||
if (!group.value || !learningPath.value || !lang.value) return undefined;
|
||||
const groupsQueryResult = useGroupsQuery(props.classId, props.assignmentId, true);
|
||||
const group = computed(() => {
|
||||
const groups = groupsQueryResult.data.value?.groups;
|
||||
|
||||
return {
|
||||
forGroup: group.value.groupNumber,
|
||||
assignmentNo: props.assignmentId,
|
||||
classId: props.classId,
|
||||
};
|
||||
});
|
||||
if (!groups) return undefined;
|
||||
|
||||
const lpQueryResult = useGetLearningPathQuery(
|
||||
() => learningPath.value,
|
||||
() => lang.value,
|
||||
() => learningPathParams.value
|
||||
);
|
||||
// Sort by original groupNumber
|
||||
const sortedGroups = [...groups].sort((a, b) => a.groupNumber - b.groupNumber);
|
||||
|
||||
return sortedGroups
|
||||
.map((group, index) => ({
|
||||
...group,
|
||||
groupNo: index + 1, // Renumbered index
|
||||
}))
|
||||
.find((group) => group.members?.some((m) => m.username === username.value));
|
||||
});
|
||||
|
||||
const progressColor = computed(() => {
|
||||
const progress = calculateProgress(lpQueryResult.data.value);
|
||||
if (progress >= 100) return "success";
|
||||
if (progress >= 50) return "warning";
|
||||
return "error";
|
||||
});
|
||||
watchEffect(() => {
|
||||
learningPath.value = assignmentQueryResult.data.value?.assignment?.learningPath;
|
||||
lang.value = assignmentQueryResult.data.value?.assignment?.language as Language;
|
||||
});
|
||||
|
||||
const studentQueries = useStudentsByUsernamesQuery(() => group.value?.members as string[] ?? undefined);
|
||||
const learningPathParams = computed(() => {
|
||||
if (!group.value || !learningPath.value || !lang.value) return undefined;
|
||||
|
||||
return {
|
||||
forGroup: group.value.groupNumber,
|
||||
assignmentNo: props.assignmentId,
|
||||
classId: props.classId,
|
||||
};
|
||||
});
|
||||
|
||||
const lpQueryResult = useGetLearningPathQuery(
|
||||
() => learningPath.value,
|
||||
() => lang.value,
|
||||
() => learningPathParams.value,
|
||||
);
|
||||
|
||||
const progressColor = computed(() => {
|
||||
const progress = calculateProgress(lpQueryResult.data.value);
|
||||
if (progress >= 100) return "success";
|
||||
if (progress >= 50) return "warning";
|
||||
return "error";
|
||||
});
|
||||
|
||||
const studentQueries = useStudentsByUsernamesQuery(() => (group.value?.members as string[]) ?? undefined);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="container">
|
||||
<using-query-result
|
||||
:query-result="assignmentQueryResult"
|
||||
v-slot="assignmentResponse : { data: AssignmentResponse }"
|
||||
v-slot="assignmentResponse: { data: AssignmentResponse }"
|
||||
>
|
||||
<v-card
|
||||
v-if="assignmentResponse"
|
||||
|
@ -100,9 +97,8 @@ const studentQueries = useStudentsByUsernamesQuery(() => group.value?.members as
|
|||
<v-icon>mdi-arrow-left</v-icon>
|
||||
</v-btn>
|
||||
</div>
|
||||
<v-card-title class="text-h4 assignmentTopTitle">{{
|
||||
assignmentResponse.data.assignment.title
|
||||
}}
|
||||
<v-card-title class="text-h4 assignmentTopTitle"
|
||||
>{{ assignmentResponse.data.assignment.title }}
|
||||
</v-card-title>
|
||||
|
||||
<v-card-subtitle class="subtitle-section">
|
||||
|
@ -112,14 +108,17 @@ const studentQueries = useStudentsByUsernamesQuery(() => group.value?.members as
|
|||
>
|
||||
<v-btn
|
||||
v-if="lpData"
|
||||
:to="group ? `/learningPath/${lpData.hruid}/${assignmentResponse.data.assignment?.language}/${lpData.startNode.learningobjectHruid}?forGroup=${0}&assignmentNo=${assignmentId}&classId=${classId}` : undefined"
|
||||
:to="
|
||||
group
|
||||
? `/learningPath/${lpData.hruid}/${assignmentResponse.data.assignment?.language}/${lpData.startNode.learningobjectHruid}?forGroup=${0}&assignmentNo=${assignmentId}&classId=${classId}`
|
||||
: undefined
|
||||
"
|
||||
:disabled="!group"
|
||||
variant="tonal"
|
||||
color="primary"
|
||||
>
|
||||
{{ t("learning-path") }}
|
||||
</v-btn>
|
||||
|
||||
</using-query-result>
|
||||
</v-card-subtitle>
|
||||
|
||||
|
@ -163,21 +162,23 @@ const studentQueries = useStudentsByUsernamesQuery(() => group.value?.members as
|
|||
</div>
|
||||
|
||||
<div v-else>
|
||||
<v-alert type="info" variant="text">
|
||||
<v-alert
|
||||
type="info"
|
||||
variant="text"
|
||||
>
|
||||
{{ t("not-in-group-message") }}
|
||||
</v-alert>
|
||||
</div>
|
||||
</v-card-text>
|
||||
|
||||
</v-card>
|
||||
</using-query-result>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@import "@/assets/assignment.css";
|
||||
@import "@/assets/assignment.css";
|
||||
|
||||
.progress-bar {
|
||||
width: 40%;
|
||||
}
|
||||
.progress-bar {
|
||||
width: 40%;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,150 +1,146 @@
|
|||
<script setup lang="ts">
|
||||
import {computed, type Ref, ref, watch, watchEffect} from "vue";
|
||||
import {useI18n} from "vue-i18n";
|
||||
import {
|
||||
useAssignmentQuery,
|
||||
useDeleteAssignmentMutation,
|
||||
useUpdateAssignmentMutation
|
||||
} from "@/queries/assignments.ts";
|
||||
import UsingQueryResult from "@/components/UsingQueryResult.vue";
|
||||
import {useGroupsQuery} from "@/queries/groups.ts";
|
||||
import {useGetAllLearningPaths, useGetLearningPathQuery} from "@/queries/learning-paths.ts";
|
||||
import type {Language} from "@/data-objects/language.ts";
|
||||
import type {AssignmentResponse} from "@/controllers/assignments.ts";
|
||||
import type {GroupDTO, GroupDTOId} from "@dwengo-1/common/interfaces/group";
|
||||
import type {LearningPath} from "@/data-objects/learning-paths/learning-path";
|
||||
import {descriptionRules, learningPathRules} from "@/utils/assignment-rules.ts";
|
||||
import GroupSubmissionStatus from "@/components/GroupSubmissionStatus.vue"
|
||||
import GroupProgressRow from "@/components/GroupProgressRow.vue"
|
||||
import type {AssignmentDTO} from "@dwengo-1/common/dist/interfaces/assignment.ts";
|
||||
import GroupSelector from "@/components/assignments/GroupSelector.vue";
|
||||
import { computed, type Ref, ref, watch, watchEffect } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import {
|
||||
useAssignmentQuery,
|
||||
useDeleteAssignmentMutation,
|
||||
useUpdateAssignmentMutation,
|
||||
} from "@/queries/assignments.ts";
|
||||
import UsingQueryResult from "@/components/UsingQueryResult.vue";
|
||||
import { useGroupsQuery } from "@/queries/groups.ts";
|
||||
import { useGetAllLearningPaths, useGetLearningPathQuery } from "@/queries/learning-paths.ts";
|
||||
import type { Language } from "@/data-objects/language.ts";
|
||||
import type { AssignmentResponse } from "@/controllers/assignments.ts";
|
||||
import type { GroupDTO, GroupDTOId } from "@dwengo-1/common/interfaces/group";
|
||||
import type { LearningPath } from "@/data-objects/learning-paths/learning-path";
|
||||
import { descriptionRules, learningPathRules } from "@/utils/assignment-rules.ts";
|
||||
import GroupSubmissionStatus from "@/components/GroupSubmissionStatus.vue";
|
||||
import GroupProgressRow from "@/components/GroupProgressRow.vue";
|
||||
import type { AssignmentDTO } from "@dwengo-1/common/dist/interfaces/assignment.ts";
|
||||
import GroupSelector from "@/components/assignments/GroupSelector.vue";
|
||||
|
||||
const props = defineProps<{
|
||||
classId: string;
|
||||
assignmentId: number;
|
||||
useGroupsWithProgress: (
|
||||
groups: Ref<GroupDTO[]>,
|
||||
hruid: Ref<string>,
|
||||
language: Ref<Language>,
|
||||
) => { groupProgressMap: Map<number, number> };
|
||||
}>();
|
||||
const props = defineProps<{
|
||||
classId: string;
|
||||
assignmentId: number;
|
||||
useGroupsWithProgress: (
|
||||
groups: Ref<GroupDTO[]>,
|
||||
hruid: Ref<string>,
|
||||
language: Ref<Language>,
|
||||
) => { groupProgressMap: Map<number, number> };
|
||||
}>();
|
||||
|
||||
const isEditing = ref(false);
|
||||
const isEditing = ref(false);
|
||||
|
||||
const {t} = useI18n();
|
||||
const lang = ref();
|
||||
const groups = ref<GroupDTO[] | GroupDTOId[]>([]);
|
||||
const learningPath = ref();
|
||||
const form = ref();
|
||||
const { t } = useI18n();
|
||||
const lang = ref();
|
||||
const groups = ref<GroupDTO[] | GroupDTOId[]>([]);
|
||||
const learningPath = ref();
|
||||
const form = ref();
|
||||
|
||||
const editingLearningPath = ref(learningPath);
|
||||
const description = ref("");
|
||||
const editGroups = ref(false);
|
||||
|
||||
const editingLearningPath = ref(learningPath);
|
||||
const description = ref("");
|
||||
const editGroups = ref(false);
|
||||
|
||||
|
||||
const assignmentQueryResult = useAssignmentQuery(() => props.classId, props.assignmentId);
|
||||
// Get learning path object
|
||||
const lpQueryResult = useGetLearningPathQuery(
|
||||
computed(() => assignmentQueryResult.data.value?.assignment?.learningPath ?? ""),
|
||||
computed(() => assignmentQueryResult.data.value?.assignment?.language as Language),
|
||||
);
|
||||
|
||||
// Get all the groups withing the assignment
|
||||
const groupsQueryResult = useGroupsQuery(props.classId, props.assignmentId, true);
|
||||
groups.value = groupsQueryResult.data.value?.groups ?? [];
|
||||
|
||||
watchEffect(() => {
|
||||
learningPath.value = assignmentQueryResult.data.value?.assignment?.learningPath;
|
||||
lang.value = assignmentQueryResult.data.value?.assignment?.language as Language;
|
||||
});
|
||||
|
||||
const allGroups = computed(() => {
|
||||
const groups = groupsQueryResult.data.value?.groups;
|
||||
|
||||
if (!groups) return [];
|
||||
|
||||
// Sort by original groupNumber
|
||||
const sortedGroups = [...groups].sort((a, b) => a.groupNumber - b.groupNumber);
|
||||
|
||||
// Assign new sequential numbers starting from 1
|
||||
return sortedGroups.map((group, index) => ({
|
||||
groupNo: index + 1, // New group number that will be used
|
||||
name: `${t("group")} ${index + 1}`,
|
||||
members: group.members,
|
||||
originalGroupNo: group.groupNumber, // Keep original number if needed
|
||||
}));
|
||||
});
|
||||
|
||||
const dialog = ref(false);
|
||||
const selectedGroup = ref({});
|
||||
|
||||
function openGroupDetails(group): void {
|
||||
selectedGroup.value = group;
|
||||
dialog.value = true;
|
||||
}
|
||||
|
||||
async function deleteAssignment(num: number, clsId: string): Promise<void> {
|
||||
const {mutate} = useDeleteAssignmentMutation();
|
||||
mutate(
|
||||
{cid: clsId, an: num},
|
||||
{
|
||||
onSuccess: () => {
|
||||
window.location.href = "/user/assignment";
|
||||
},
|
||||
},
|
||||
const assignmentQueryResult = useAssignmentQuery(() => props.classId, props.assignmentId);
|
||||
// Get learning path object
|
||||
const lpQueryResult = useGetLearningPathQuery(
|
||||
computed(() => assignmentQueryResult.data.value?.assignment?.learningPath ?? ""),
|
||||
computed(() => assignmentQueryResult.data.value?.assignment?.language as Language),
|
||||
);
|
||||
}
|
||||
|
||||
function goToLearningPathLink(): string | undefined {
|
||||
const assignment = assignmentQueryResult.data.value?.assignment;
|
||||
const lp = lpQueryResult.data.value;
|
||||
// Get all the groups withing the assignment
|
||||
const groupsQueryResult = useGroupsQuery(props.classId, props.assignmentId, true);
|
||||
groups.value = groupsQueryResult.data.value?.groups ?? [];
|
||||
|
||||
if (!assignment || !lp) return undefined;
|
||||
|
||||
return `/learningPath/${lp.hruid}/${assignment.language}/${lp.startNode.learningobjectHruid}?assignmentNo=${props.assignmentId}&classId=${props.classId}`;
|
||||
}
|
||||
|
||||
function goToGroupSubmissionLink(groupNo: number): string | undefined {
|
||||
const lp = lpQueryResult.data.value;
|
||||
if (!lp) return undefined;
|
||||
|
||||
return `/learningPath/${lp.hruid}/${lp.language}/${lp.startNode.learningobjectHruid}?forGroup=${groupNo}&assignmentNo=${props.assignmentId}&classId=${props.classId}`;
|
||||
}
|
||||
|
||||
const learningPathsQueryResults = useGetAllLearningPaths(lang);
|
||||
|
||||
const {mutate, data, isSuccess} = useUpdateAssignmentMutation();
|
||||
|
||||
watch([isSuccess, data], ([success, newData]) => {
|
||||
if (success && newData?.assignment) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
async function saveChanges(): Promise<void> {
|
||||
const {valid} = await form.value.validate();
|
||||
if (!valid) return;
|
||||
|
||||
isEditing.value = false;
|
||||
|
||||
const lp = learningPath.value;
|
||||
|
||||
const assignmentDTO: AssignmentDTO = {
|
||||
id: assignmentQueryResult.data.value?.assignment.id,
|
||||
description: description.value,
|
||||
learningPath: lp || "",
|
||||
deadline: new Date(),
|
||||
};
|
||||
|
||||
mutate({
|
||||
cid: assignmentQueryResult.data.value?.assignment.within,
|
||||
an: assignmentQueryResult.data.value?.assignment.id,
|
||||
data: assignmentDTO
|
||||
watchEffect(() => {
|
||||
learningPath.value = assignmentQueryResult.data.value?.assignment?.learningPath;
|
||||
lang.value = assignmentQueryResult.data.value?.assignment?.language as Language;
|
||||
});
|
||||
}
|
||||
|
||||
const allGroups = computed(() => {
|
||||
const groups = groupsQueryResult.data.value?.groups;
|
||||
|
||||
if (!groups) return [];
|
||||
|
||||
// Sort by original groupNumber
|
||||
const sortedGroups = [...groups].sort((a, b) => a.groupNumber - b.groupNumber);
|
||||
|
||||
// Assign new sequential numbers starting from 1
|
||||
return sortedGroups.map((group, index) => ({
|
||||
groupNo: index + 1, // New group number that will be used
|
||||
name: `${t("group")} ${index + 1}`,
|
||||
members: group.members,
|
||||
originalGroupNo: group.groupNumber, // Keep original number if needed
|
||||
}));
|
||||
});
|
||||
|
||||
const dialog = ref(false);
|
||||
const selectedGroup = ref({});
|
||||
|
||||
function openGroupDetails(group): void {
|
||||
selectedGroup.value = group;
|
||||
dialog.value = true;
|
||||
}
|
||||
|
||||
async function deleteAssignment(num: number, clsId: string): Promise<void> {
|
||||
const { mutate } = useDeleteAssignmentMutation();
|
||||
mutate(
|
||||
{ cid: clsId, an: num },
|
||||
{
|
||||
onSuccess: () => {
|
||||
window.location.href = "/user/assignment";
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function goToLearningPathLink(): string | undefined {
|
||||
const assignment = assignmentQueryResult.data.value?.assignment;
|
||||
const lp = lpQueryResult.data.value;
|
||||
|
||||
if (!assignment || !lp) return undefined;
|
||||
|
||||
return `/learningPath/${lp.hruid}/${assignment.language}/${lp.startNode.learningobjectHruid}?assignmentNo=${props.assignmentId}&classId=${props.classId}`;
|
||||
}
|
||||
|
||||
function goToGroupSubmissionLink(groupNo: number): string | undefined {
|
||||
const lp = lpQueryResult.data.value;
|
||||
if (!lp) return undefined;
|
||||
|
||||
return `/learningPath/${lp.hruid}/${lp.language}/${lp.startNode.learningobjectHruid}?forGroup=${groupNo}&assignmentNo=${props.assignmentId}&classId=${props.classId}`;
|
||||
}
|
||||
|
||||
const learningPathsQueryResults = useGetAllLearningPaths(lang);
|
||||
|
||||
const { mutate, data, isSuccess } = useUpdateAssignmentMutation();
|
||||
|
||||
watch([isSuccess, data], ([success, newData]) => {
|
||||
if (success && newData?.assignment) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
async function saveChanges(): Promise<void> {
|
||||
const { valid } = await form.value.validate();
|
||||
if (!valid) return;
|
||||
|
||||
isEditing.value = false;
|
||||
|
||||
const lp = learningPath.value;
|
||||
|
||||
const assignmentDTO: AssignmentDTO = {
|
||||
id: assignmentQueryResult.data.value?.assignment.id,
|
||||
description: description.value,
|
||||
learningPath: lp || "",
|
||||
deadline: new Date(),
|
||||
};
|
||||
|
||||
mutate({
|
||||
cid: assignmentQueryResult.data.value?.assignment.within,
|
||||
an: assignmentQueryResult.data.value?.assignment.id,
|
||||
data: assignmentDTO,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -167,7 +163,11 @@ async function saveChanges(): Promise<void> {
|
|||
md="6"
|
||||
class="responsive-col"
|
||||
>
|
||||
<v-form ref="form" validate-on="submit lazy" @submit.prevent="saveChanges">
|
||||
<v-form
|
||||
ref="form"
|
||||
validate-on="submit lazy"
|
||||
@submit.prevent="saveChanges"
|
||||
>
|
||||
<v-card
|
||||
v-if="assignmentResponse"
|
||||
class="assignment-card"
|
||||
|
@ -189,11 +189,11 @@ async function saveChanges(): Promise<void> {
|
|||
variant="text"
|
||||
class="top_next_to_right_button"
|
||||
@click="
|
||||
() => {
|
||||
isEditing = true;
|
||||
description = assignmentResponse.data.assignment.description;
|
||||
}
|
||||
"
|
||||
() => {
|
||||
isEditing = true;
|
||||
description = assignmentResponse.data.assignment.description;
|
||||
}
|
||||
"
|
||||
>
|
||||
<v-icon>mdi-pencil</v-icon>
|
||||
</v-btn>
|
||||
|
@ -201,10 +201,14 @@ async function saveChanges(): Promise<void> {
|
|||
v-else
|
||||
variant="text"
|
||||
class="top-right-btn"
|
||||
@click="() => {isEditing = false; editingLearningPath=learningPath}"
|
||||
>{{ t("cancel") }}
|
||||
</v-btn
|
||||
>
|
||||
@click="
|
||||
() => {
|
||||
isEditing = false;
|
||||
editingLearningPath = learningPath;
|
||||
}
|
||||
"
|
||||
>{{ t("cancel") }}
|
||||
</v-btn>
|
||||
|
||||
<v-btn
|
||||
v-if="!isEditing"
|
||||
|
@ -212,11 +216,11 @@ async function saveChanges(): Promise<void> {
|
|||
variant="text"
|
||||
class="top-right-btn"
|
||||
@click="
|
||||
deleteAssignment(
|
||||
assignmentResponse.data.assignment.id,
|
||||
assignmentResponse.data.assignment.within,
|
||||
)
|
||||
"
|
||||
deleteAssignment(
|
||||
assignmentResponse.data.assignment.id,
|
||||
assignmentResponse.data.assignment.within,
|
||||
)
|
||||
"
|
||||
>
|
||||
<v-icon>mdi-delete</v-icon>
|
||||
</v-btn>
|
||||
|
@ -233,9 +237,8 @@ async function saveChanges(): Promise<void> {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<v-card-title class="text-h4 assignmentTopTitle">{{
|
||||
assignmentResponse.data.assignment.title
|
||||
}}
|
||||
<v-card-title class="text-h4 assignmentTopTitle"
|
||||
>{{ assignmentResponse.data.assignment.title }}
|
||||
</v-card-title>
|
||||
<v-card-subtitle
|
||||
v-if="!isEditing"
|
||||
|
@ -275,9 +278,9 @@ async function saveChanges(): Promise<void> {
|
|||
item-value="hruid"
|
||||
required
|
||||
:filter="
|
||||
(item, query: string) =>
|
||||
item.title.toLowerCase().includes(query.toLowerCase())
|
||||
"
|
||||
(item, query: string) =>
|
||||
item.title.toLowerCase().includes(query.toLowerCase())
|
||||
"
|
||||
></v-combobox>
|
||||
</v-card-text>
|
||||
</using-query-result>
|
||||
|
@ -317,7 +320,7 @@ async function saveChanges(): Promise<void> {
|
|||
>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title
|
||||
>{{ member.firstName + " " + member.lastName }}
|
||||
>{{ member.firstName + " " + member.lastName }}
|
||||
</v-list-item-title>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
|
@ -327,24 +330,22 @@ async function saveChanges(): Promise<void> {
|
|||
<v-btn
|
||||
color="primary"
|
||||
@click="dialog = false"
|
||||
>Close
|
||||
</v-btn
|
||||
>
|
||||
>Close
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-col>
|
||||
|
||||
<!-- The second column of the screen -->
|
||||
<template v-if="!editGroups">
|
||||
<v-col
|
||||
cols="12"
|
||||
sm="6"
|
||||
md="6"
|
||||
class="responsive-col"
|
||||
>
|
||||
<v-table class="table">
|
||||
<thead>
|
||||
<v-col
|
||||
cols="12"
|
||||
sm="6"
|
||||
md="6"
|
||||
class="responsive-col"
|
||||
>
|
||||
<v-table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="header">{{ t("group") }}</th>
|
||||
<th class="header">{{ t("progress") }}</th>
|
||||
|
@ -356,11 +357,10 @@ async function saveChanges(): Promise<void> {
|
|||
>
|
||||
<v-icon>mdi-pencil</v-icon>
|
||||
</v-btn>
|
||||
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="g in allGroups"
|
||||
:key="g.originalGroupNo"
|
||||
|
@ -403,133 +403,138 @@ async function saveChanges(): Promise<void> {
|
|||
>
|
||||
<v-icon color="red">mdi-delete</v-icon>
|
||||
</v-btn>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</v-table>
|
||||
</v-col>
|
||||
</template>
|
||||
<template v-else>
|
||||
</tbody>
|
||||
</v-table>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-dialog
|
||||
v-model="editGroups"
|
||||
max-width="800"
|
||||
persistent
|
||||
>
|
||||
<v-card-text>
|
||||
<GroupSelector
|
||||
:groups="allGroups"
|
||||
:class-id="classId"
|
||||
@groupsUpdated="handleUpdatedGroups"
|
||||
:class-id="props.classId"
|
||||
:assignment-id="props.assignmentId"
|
||||
@close="editGroups = false"
|
||||
/>
|
||||
</template>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
</v-dialog>
|
||||
</v-container>
|
||||
</using-query-result>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@import "@/assets/assignment.css";
|
||||
@import "@/assets/assignment.css";
|
||||
|
||||
.table-scroll {
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.header {
|
||||
font-weight: bold !important;
|
||||
background-color: #0e6942;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
table thead th:first-child {
|
||||
border-top-left-radius: 10px;
|
||||
}
|
||||
|
||||
.table thead th:last-child {
|
||||
border-top-right-radius: 10px;
|
||||
}
|
||||
|
||||
.table tbody tr:nth-child(odd) {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.table tbody tr:nth-child(even) {
|
||||
background-color: #f6faf2;
|
||||
}
|
||||
|
||||
td,
|
||||
th {
|
||||
border-bottom: 1px solid #0e6942;
|
||||
border-top: 1px solid #0e6942;
|
||||
}
|
||||
|
||||
.table {
|
||||
width: 90%;
|
||||
padding-top: 10px;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #0e6942;
|
||||
text-transform: uppercase;
|
||||
font-weight: bolder;
|
||||
padding-top: 2%;
|
||||
font-size: 50px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: #0e6942;
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
.join {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.link {
|
||||
color: #0b75bb;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
main {
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 850px) {
|
||||
h1 {
|
||||
text-align: center;
|
||||
padding-left: 0;
|
||||
.table-scroll {
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.join {
|
||||
text-align: center;
|
||||
align-items: center;
|
||||
margin-left: 0;
|
||||
.header {
|
||||
font-weight: bold !important;
|
||||
background-color: #0e6942;
|
||||
color: white;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.sheet {
|
||||
width: 100%;
|
||||
table thead th:first-child {
|
||||
border-top-left-radius: 10px;
|
||||
}
|
||||
|
||||
main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 5px;
|
||||
.table thead th:last-child {
|
||||
border-top-right-radius: 10px;
|
||||
}
|
||||
|
||||
.custom-breakpoint {
|
||||
flex-direction: column !important;
|
||||
.table tbody tr:nth-child(odd) {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.table tbody tr:nth-child(even) {
|
||||
background-color: #f6faf2;
|
||||
}
|
||||
|
||||
td,
|
||||
th {
|
||||
border-bottom: 1px solid #0e6942;
|
||||
border-top: 1px solid #0e6942;
|
||||
}
|
||||
|
||||
.table {
|
||||
width: 100%;
|
||||
width: 90%;
|
||||
padding-top: 10px;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.responsive-col {
|
||||
max-width: 100% !important;
|
||||
flex-basis: 100% !important;
|
||||
h1 {
|
||||
color: #0e6942;
|
||||
text-transform: uppercase;
|
||||
font-weight: bolder;
|
||||
padding-top: 2%;
|
||||
font-size: 50px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color: #0e6942;
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
.join {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.link {
|
||||
color: #0b75bb;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
main {
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 850px) {
|
||||
h1 {
|
||||
text-align: center;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.join {
|
||||
text-align: center;
|
||||
align-items: center;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.sheet {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.custom-breakpoint {
|
||||
flex-direction: column !important;
|
||||
}
|
||||
|
||||
.table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.responsive-col {
|
||||
max-width: 100% !important;
|
||||
flex-basis: 100% !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,141 +1,143 @@
|
|||
<script setup lang="ts">
|
||||
import {ref, computed, onMounted, watch} from "vue";
|
||||
import {useI18n} from "vue-i18n";
|
||||
import {useRouter} from "vue-router";
|
||||
import authState from "@/services/auth/auth-service.ts";
|
||||
import auth from "@/services/auth/auth-service.ts";
|
||||
import {useTeacherAssignmentsQuery, useTeacherClassesQuery} from "@/queries/teachers.ts";
|
||||
import {useStudentAssignmentsQuery, useStudentClassesQuery} from "@/queries/students.ts";
|
||||
import {useDeleteAssignmentMutation} from "@/queries/assignments.ts";
|
||||
import UsingQueryResult from "@/components/UsingQueryResult.vue";
|
||||
import {asyncComputed} from "@vueuse/core";
|
||||
import { ref, computed, onMounted, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRouter } from "vue-router";
|
||||
import authState from "@/services/auth/auth-service.ts";
|
||||
import auth from "@/services/auth/auth-service.ts";
|
||||
import { useTeacherAssignmentsQuery, useTeacherClassesQuery } from "@/queries/teachers.ts";
|
||||
import { useStudentAssignmentsQuery, useStudentClassesQuery } from "@/queries/students.ts";
|
||||
import { useDeleteAssignmentMutation } from "@/queries/assignments.ts";
|
||||
import UsingQueryResult from "@/components/UsingQueryResult.vue";
|
||||
import { asyncComputed } from "@vueuse/core";
|
||||
|
||||
const {t, locale} = useI18n();
|
||||
const router = useRouter();
|
||||
const { t, locale } = useI18n();
|
||||
const router = useRouter();
|
||||
|
||||
const role = ref(auth.authState.activeRole);
|
||||
const username = ref<string | undefined>(undefined);
|
||||
const isLoading = ref(false);
|
||||
const isError = ref(false);
|
||||
const errorMessage = ref<string>("");
|
||||
const role = ref(auth.authState.activeRole);
|
||||
const username = ref<string | undefined>(undefined);
|
||||
const isLoading = ref(false);
|
||||
const isError = ref(false);
|
||||
const errorMessage = ref<string>("");
|
||||
|
||||
// Load current user before rendering the page
|
||||
onMounted(async () => {
|
||||
isLoading.value = true;
|
||||
try {
|
||||
const userObject = await authState.loadUser();
|
||||
username.value = userObject!.profile.preferred_username;
|
||||
} catch (error) {
|
||||
isError.value = true;
|
||||
errorMessage.value = error instanceof Error ? error.message : String(error);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
const isTeacher = computed(() => role.value === "teacher");
|
||||
const classesQueryResult = isTeacher.value ? useTeacherClassesQuery(username, true) : useStudentClassesQuery(username, true);
|
||||
|
||||
const assignmentsQueryResult = isTeacher.value ? useTeacherAssignmentsQuery(username, true) : useStudentAssignmentsQuery(username, true);
|
||||
|
||||
const allAssignments = asyncComputed(
|
||||
async () => {
|
||||
const assignments = assignmentsQueryResult.data.value?.assignments;
|
||||
if (!assignments) return [];
|
||||
|
||||
const classes = classesQueryResult.data.value?.classes;
|
||||
if (!classes) return [];
|
||||
|
||||
const result = assignments.map((a) => ({
|
||||
id: a.id,
|
||||
class: classes.find((cls) => cls?.id === a.within) ?? undefined,
|
||||
title: a.title,
|
||||
description: a.description,
|
||||
learningPath: a.learningPath,
|
||||
language: a.language,
|
||||
deadline: a.deadline,
|
||||
groups: a.groups,
|
||||
}));
|
||||
|
||||
// Order the assignments by deadline
|
||||
return result.flat().sort((a, b) => {
|
||||
const now = Date.now();
|
||||
const aTime = new Date(a.deadline).getTime();
|
||||
const bTime = new Date(b.deadline).getTime();
|
||||
|
||||
const aIsPast = aTime < now;
|
||||
const bIsPast = bTime < now;
|
||||
|
||||
if (aIsPast && !bIsPast) return 1;
|
||||
if (!aIsPast && bIsPast) return -1;
|
||||
|
||||
return aTime - bTime;
|
||||
});
|
||||
},
|
||||
[],
|
||||
{evaluating: true},
|
||||
);
|
||||
|
||||
async function goToCreateAssignment(): Promise<void> {
|
||||
await router.push("/assignment/create");
|
||||
}
|
||||
|
||||
async function goToAssignmentDetails(id: number, clsId: string): Promise<void> {
|
||||
await router.push(`/assignment/${clsId}/${id}`);
|
||||
}
|
||||
|
||||
const {mutate, data, isSuccess} = useDeleteAssignmentMutation();
|
||||
|
||||
watch([isSuccess, data], async ([success, oldData]) => {
|
||||
if (success && oldData?.assignment) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
async function goToDeleteAssignment(num: number, clsId: string): Promise<void> {
|
||||
mutate({cid: clsId, an: num});
|
||||
}
|
||||
|
||||
function formatDate(date?: string | Date): string {
|
||||
if (!date) return "–";
|
||||
const d = new Date(date);
|
||||
|
||||
// Choose locale based on selected language
|
||||
const currentLocale = locale.value;
|
||||
|
||||
return d.toLocaleDateString(currentLocale, {
|
||||
weekday: "short",
|
||||
day: "2-digit",
|
||||
month: "long",
|
||||
year: "numeric",
|
||||
hour: "numeric",
|
||||
minute: "2-digit",
|
||||
// Load current user before rendering the page
|
||||
onMounted(async () => {
|
||||
isLoading.value = true;
|
||||
try {
|
||||
const userObject = await authState.loadUser();
|
||||
username.value = userObject!.profile.preferred_username;
|
||||
} catch (error) {
|
||||
isError.value = true;
|
||||
errorMessage.value = error instanceof Error ? error.message : String(error);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getDeadlineClass(deadline?: string | Date): string {
|
||||
if (!deadline) return "";
|
||||
const isTeacher = computed(() => role.value === "teacher");
|
||||
const classesQueryResult = isTeacher.value
|
||||
? useTeacherClassesQuery(username, true)
|
||||
: useStudentClassesQuery(username, true);
|
||||
|
||||
const date = new Date(deadline);
|
||||
const now = new Date();
|
||||
const in24Hours = new Date(now.getTime() + 24 * 60 * 60 * 1000);
|
||||
const assignmentsQueryResult = isTeacher.value
|
||||
? useTeacherAssignmentsQuery(username, true)
|
||||
: useStudentAssignmentsQuery(username, true);
|
||||
|
||||
if (date.getTime() < now.getTime()) return "deadline-passed";
|
||||
if (date.getTime() <= in24Hours.getTime()) return "deadline-in24hours";
|
||||
return "deadline-upcoming";
|
||||
}
|
||||
const allAssignments = asyncComputed(
|
||||
async () => {
|
||||
const assignments = assignmentsQueryResult.data.value?.assignments;
|
||||
if (!assignments) return [];
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await auth.loadUser();
|
||||
username.value = user?.profile?.preferred_username ?? "";
|
||||
});
|
||||
const classes = classesQueryResult.data.value?.classes;
|
||||
if (!classes) return [];
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await auth.loadUser();
|
||||
username.value = user?.profile?.preferred_username ?? "";
|
||||
});
|
||||
const result = assignments.map((a) => ({
|
||||
id: a.id,
|
||||
class: classes.find((cls) => cls?.id === a.within) ?? undefined,
|
||||
title: a.title,
|
||||
description: a.description,
|
||||
learningPath: a.learningPath,
|
||||
language: a.language,
|
||||
deadline: a.deadline,
|
||||
groups: a.groups,
|
||||
}));
|
||||
|
||||
// Order the assignments by deadline
|
||||
return result.flat().sort((a, b) => {
|
||||
const now = Date.now();
|
||||
const aTime = new Date(a.deadline).getTime();
|
||||
const bTime = new Date(b.deadline).getTime();
|
||||
|
||||
const aIsPast = aTime < now;
|
||||
const bIsPast = bTime < now;
|
||||
|
||||
if (aIsPast && !bIsPast) return 1;
|
||||
if (!aIsPast && bIsPast) return -1;
|
||||
|
||||
return aTime - bTime;
|
||||
});
|
||||
},
|
||||
[],
|
||||
{ evaluating: true },
|
||||
);
|
||||
|
||||
async function goToCreateAssignment(): Promise<void> {
|
||||
await router.push("/assignment/create");
|
||||
}
|
||||
|
||||
async function goToAssignmentDetails(id: number, clsId: string): Promise<void> {
|
||||
await router.push(`/assignment/${clsId}/${id}`);
|
||||
}
|
||||
|
||||
const { mutate, data, isSuccess } = useDeleteAssignmentMutation();
|
||||
|
||||
watch([isSuccess, data], async ([success, oldData]) => {
|
||||
if (success && oldData?.assignment) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
async function goToDeleteAssignment(num: number, clsId: string): Promise<void> {
|
||||
mutate({ cid: clsId, an: num });
|
||||
}
|
||||
|
||||
function formatDate(date?: string | Date): string {
|
||||
if (!date) return "–";
|
||||
const d = new Date(date);
|
||||
|
||||
// Choose locale based on selected language
|
||||
const currentLocale = locale.value;
|
||||
|
||||
return d.toLocaleDateString(currentLocale, {
|
||||
weekday: "short",
|
||||
day: "2-digit",
|
||||
month: "long",
|
||||
year: "numeric",
|
||||
hour: "numeric",
|
||||
minute: "2-digit",
|
||||
});
|
||||
}
|
||||
|
||||
function getDeadlineClass(deadline?: string | Date): string {
|
||||
if (!deadline) return "";
|
||||
|
||||
const date = new Date(deadline);
|
||||
const now = new Date();
|
||||
const in24Hours = new Date(now.getTime() + 24 * 60 * 60 * 1000);
|
||||
|
||||
if (date.getTime() < now.getTime()) return "deadline-passed";
|
||||
if (date.getTime() <= in24Hours.getTime()) return "deadline-in24hours";
|
||||
return "deadline-upcoming";
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await auth.loadUser();
|
||||
username.value = user?.profile?.preferred_username ?? "";
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
const user = await auth.loadUser();
|
||||
username.value = user?.profile?.preferred_username ?? "";
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -151,9 +153,7 @@ onMounted(async () => {
|
|||
{{ t("new-assignment") }}
|
||||
</v-btn>
|
||||
|
||||
<using-query-result
|
||||
:query-result="assignmentsQueryResult"
|
||||
>
|
||||
<using-query-result :query-result="assignmentsQueryResult">
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-col
|
||||
|
@ -167,8 +167,8 @@ onMounted(async () => {
|
|||
<div class="assignment-class">
|
||||
{{ t("class") }}:
|
||||
<span class="class-name">
|
||||
{{ assignment?.class?.displayName }}
|
||||
</span>
|
||||
{{ assignment?.class?.displayName }}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="assignment-deadline"
|
||||
|
@ -214,87 +214,88 @@ onMounted(async () => {
|
|||
</template>
|
||||
|
||||
<style scoped>
|
||||
.assignments-container {
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.assignments-container {
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.center-btn {
|
||||
display: block;
|
||||
margin: 0 auto 2rem auto;
|
||||
font-weight: 600;
|
||||
background-color: #10ad61;
|
||||
color: white;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
.center-btn {
|
||||
display: block;
|
||||
margin: 0 auto 2rem auto;
|
||||
font-weight: 600;
|
||||
background-color: #10ad61;
|
||||
color: white;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.center-btn:hover {
|
||||
background-color: #0e6942;
|
||||
}
|
||||
.center-btn:hover {
|
||||
background-color: #0e6942;
|
||||
}
|
||||
|
||||
.assignment-card {
|
||||
padding: 1.25rem;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
||||
background-color: white;
|
||||
transition: transform 0.2s,
|
||||
box-shadow 0.2s;
|
||||
}
|
||||
.assignment-card {
|
||||
padding: 1.25rem;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
||||
background-color: white;
|
||||
transition:
|
||||
transform 0.2s,
|
||||
box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.assignment-card:hover {
|
||||
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
.assignment-card:hover {
|
||||
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.top-content {
|
||||
margin-bottom: 1rem;
|
||||
word-break: break-word;
|
||||
}
|
||||
.top-content {
|
||||
margin-bottom: 1rem;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.assignment-title {
|
||||
font-weight: 700;
|
||||
font-size: 1.4rem;
|
||||
color: #0e6942;
|
||||
margin-bottom: 0.3rem;
|
||||
}
|
||||
.assignment-title {
|
||||
font-weight: 700;
|
||||
font-size: 1.4rem;
|
||||
color: #0e6942;
|
||||
margin-bottom: 0.3rem;
|
||||
}
|
||||
|
||||
.assignment-class,
|
||||
.assignment-deadline {
|
||||
font-size: 0.95rem;
|
||||
color: #444;
|
||||
margin-bottom: 0.2rem;
|
||||
}
|
||||
.assignment-class,
|
||||
.assignment-deadline {
|
||||
font-size: 0.95rem;
|
||||
color: #444;
|
||||
margin-bottom: 0.2rem;
|
||||
}
|
||||
|
||||
.class-name {
|
||||
font-weight: 600;
|
||||
color: #097180;
|
||||
}
|
||||
.class-name {
|
||||
font-weight: 600;
|
||||
color: #097180;
|
||||
}
|
||||
|
||||
.assignment-deadline.deadline-passed {
|
||||
color: #d32f2f;
|
||||
font-weight: bold;
|
||||
}
|
||||
.assignment-deadline.deadline-passed {
|
||||
color: #d32f2f;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.assignment-deadline.deadline-in24hours {
|
||||
color: #f57c00;
|
||||
font-weight: bold;
|
||||
}
|
||||
.assignment-deadline.deadline-in24hours {
|
||||
color: #f57c00;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.spacer {
|
||||
flex: 1;
|
||||
}
|
||||
.spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.button-row {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.75rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.button-row {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.75rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.no-assignments {
|
||||
text-align: center;
|
||||
font-size: 1.2rem;
|
||||
color: #777;
|
||||
padding: 3rem 0;
|
||||
}
|
||||
.no-assignments {
|
||||
text-align: center;
|
||||
font-size: 1.2rem;
|
||||
color: #777;
|
||||
padding: 3rem 0;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue