Merge branch 'fix/questions-toon-enkel-groep' of https://github.com/SELab-2/Dwengo-1 into fix/questions-toon-enkel-groep

This commit is contained in:
Gerald Schmittinger 2025-05-20 19:00:24 +02:00
commit fe28770016
5 changed files with 48 additions and 27 deletions

View file

@ -1,11 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import UsingQueryResult from "@/components/UsingQueryResult.vue"; import UsingQueryResult from "@/components/UsingQueryResult.vue";
import { useAssignmentSubmissionsQuery } from "@/queries/assignments.ts";
import type { SubmissionsResponse } from "@/controllers/submissions.ts"; import type { SubmissionsResponse } from "@/controllers/submissions.ts";
import { watch } from "vue"; import { ref, watch } from "vue";
import { useGetLearningPathQuery } from "@/queries/learning-paths.ts";
const props = defineProps<{ const props = defineProps<{
learningPathHruid: string;
language: string;
group: object; group: object;
assignmentId: number; assignmentId: number;
classId: string; classId: string;
@ -15,18 +17,24 @@
const emit = defineEmits<(e: "update:hasSubmission", hasSubmission: boolean) => void>(); const emit = defineEmits<(e: "update:hasSubmission", hasSubmission: boolean) => void>();
const { t } = useI18n(); const { t } = useI18n();
const submissionsQuery = useAssignmentSubmissionsQuery( const hasMadeProgress = ref(false);
() => props.classId,
() => props.assignmentId, const getLearningPathQuery = useGetLearningPathQuery(
() => props.group.originalGroupNo, () => props.learningPathHruid,
() => true, () => props.language,
() => ({
forGroup: props.group.originalGroupNo,
assignmentNo: props.assignmentId,
classId: props.classId,
}),
); );
watch( watch(
() => submissionsQuery.data.value, () => getLearningPathQuery.data.value,
(data) => { (learningPath) => {
if (data) { if (learningPath) {
emit("update:hasSubmission", data.submissions.length > 0); hasMadeProgress.value = learningPath.amountOfNodes !== learningPath.amountOfNodesLeft;
emit("update:hasSubmission", hasMadeProgress.value);
} }
}, },
{ immediate: true }, { immediate: true },
@ -35,16 +43,16 @@
<template> <template>
<using-query-result <using-query-result
:query-result="submissionsQuery" :query-result="getLearningPathQuery"
v-slot="{ data }: { data: SubmissionsResponse }" v-slot="{ data }: { data: SubmissionsResponse }"
> >
<v-btn <v-btn
:color="data?.submissions?.length > 0 ? 'green' : 'red'" :color="hasMadeProgress ? 'green' : 'red'"
variant="text" variant="text"
:to="data.submissions.length > 0 ? goToGroupSubmissionLink(props.group.originalGroupNo) : undefined" :to="hasMadeProgress ? goToGroupSubmissionLink(props.group.originalGroupNo) : undefined"
:disabled="data.submissions.length === 0" :disabled="!hasMadeProgress"
> >
{{ data.submissions.length > 0 ? t("submission") : t("noSubmissionsYet") }} {{ hasMadeProgress ? t("submission") : t("noSubmissionsYet") }}
</v-btn> </v-btn>
</using-query-result> </using-query-result>
</template> </template>

View file

@ -48,4 +48,12 @@ export class AssignmentController extends BaseController {
async getGroups(assignmentNumber: number, full = true): Promise<GroupsResponse> { async getGroups(assignmentNumber: number, full = true): Promise<GroupsResponse> {
return this.get<GroupsResponse>(`/${assignmentNumber}/groups`, { full }); return this.get<GroupsResponse>(`/${assignmentNumber}/groups`, { full });
} }
async getSubmissionsByGroup(
assignmentNumber: number,
groupNumber: number,
full = true,
): Promise<SubmissionsResponse> {
return this.get<SubmissionsResponse>(`/${assignmentNumber}/groups/${groupNumber}/submissions`, { full });
}
} }

View file

@ -181,7 +181,7 @@ export function useAssignmentSubmissionsQuery(
return useQuery({ return useQuery({
queryKey: computed(() => assignmentSubmissionsQueryKey(cid!, an!, f)), queryKey: computed(() => assignmentSubmissionsQueryKey(cid!, an!, f)),
queryFn: async () => new AssignmentController(cid!).getSubmissions(an!, f), queryFn: async () => new AssignmentController(cid!).getSubmissionsByGroup(an!, gn!, f),
enabled: () => checkEnabled(cid, an, gn), enabled: () => checkEnabled(cid, an, gn),
}); });
} }

View file

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref, watch, watchEffect } from "vue"; import { computed, ref, watchEffect } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { import {
useAssignmentQuery, useAssignmentQuery,
@ -14,7 +14,7 @@
import type { GroupDTO, GroupDTOId } from "@dwengo-1/common/interfaces/group"; import type { GroupDTO, GroupDTOId } from "@dwengo-1/common/interfaces/group";
import GroupSubmissionStatus from "@/components/GroupSubmissionStatus.vue"; import GroupSubmissionStatus from "@/components/GroupSubmissionStatus.vue";
import GroupProgressRow from "@/components/GroupProgressRow.vue"; import GroupProgressRow from "@/components/GroupProgressRow.vue";
import type { AssignmentDTO } from "@dwengo-1/common/dist/interfaces/assignment.ts"; import type { AssignmentDTO } from "@dwengo-1/common/interfaces/assignment";
import GroupSelector from "@/components/assignments/GroupSelector.vue"; import GroupSelector from "@/components/assignments/GroupSelector.vue";
import DeadlineSelector from "@/components/assignments/DeadlineSelector.vue"; import DeadlineSelector from "@/components/assignments/DeadlineSelector.vue";
@ -132,7 +132,7 @@
const updateAssignmentMutate = useUpdateAssignmentMutation(); const updateAssignmentMutate = useUpdateAssignmentMutation();
function updateAssignment(assignmentDTO) { function updateAssignment(assignmentDTO): void {
updateAssignmentMutate.mutate( updateAssignmentMutate.mutate(
{ {
cid: assignmentQueryResult.data.value?.assignment.within, cid: assignmentQueryResult.data.value?.assignment.within,
@ -408,13 +408,14 @@
<td> <td>
<GroupSubmissionStatus <GroupSubmissionStatus
:learning-path-hruid="learningPath.hruid"
:language="lang"
:group="g" :group="g"
:assignment-id="assignmentId" :assignment-id="assignmentId"
:class-id="classId" :class-id="classId"
:language="lang"
:go-to-group-submission-link="goToGroupSubmissionLink" :go-to-group-submission-link="goToGroupSubmissionLink"
@update:hasSubmission=" @update:hasSubmission="
(hasSubmission) => (hasSubmissions = hasSubmission) (hasSubmission) => (hasSubmissions = hasSubmissions || hasSubmission)
" "
/> />
</td> </td>

View file

@ -56,9 +56,12 @@
const learningObjectListQueryResult = useLearningObjectListForPathQuery(learningPathQueryResult.data); const learningObjectListQueryResult = useLearningObjectListForPathQuery(learningPathQueryResult.data);
const nodesList: ComputedRef<LearningPathNode[] | null> = computed( const nodesList: ComputedRef<LearningPathNode[] | null> = computed(
() => learningPathQueryResult.data.value?.nodesAsList.filter(node => () =>
authService.authState.activeRole === AccountType.Teacher || !getLearningObjectForNode(node)?.teacherExclusive learningPathQueryResult.data.value?.nodesAsList.filter(
) ?? null, (node) =>
authService.authState.activeRole === AccountType.Teacher ||
!getLearningObjectForNode(node)?.teacherExclusive,
) ?? null,
); );
const currentNode = computed(() => { const currentNode = computed(() => {
@ -110,8 +113,9 @@
const navigationDrawerShown = ref(true); const navigationDrawerShown = ref(true);
function getLearningObjectForNode(node: LearningPathNode): LearningObject | undefined { function getLearningObjectForNode(node: LearningPathNode): LearningObject | undefined {
return learningObjectListQueryResult.data.value?.find(obj => return learningObjectListQueryResult.data.value?.find(
obj.key === node.learningobjectHruid && obj.language === node.language && obj.version === node.version (obj) =>
obj.key === node.learningobjectHruid && obj.language === node.language && obj.version === node.version,
); );
} }