From b4638e372f3cf1b9cb22796ba7b62807ab39fb03 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Thu, 14 Sep 2023 17:31:00 +0200 Subject: [PATCH] Open Assignment evaluation on last step when not in progress --- .../pages/competence/CompetenceIndexPage.vue | 4 +-- .../circlePage/LearningSequence.vue | 2 +- .../assignment/AssignmentView.vue | 35 ++++++++++++------- client/src/types.ts | 2 +- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/client/src/pages/competence/CompetenceIndexPage.vue b/client/src/pages/competence/CompetenceIndexPage.vue index bbea6509..ce475151 100644 --- a/client/src/pages/competence/CompetenceIndexPage.vue +++ b/client/src/pages/competence/CompetenceIndexPage.vue @@ -88,11 +88,11 @@ const performanceCriteriaStatusCount = computed(() => {
- {{ assignmentsMaxEvaluationPoints(certificate.assignments) }} + {{ assignmentsUserPoints(certificate.assignments) }} {{ $t("assignment.von x Punkten", { - x: assignmentsUserPoints(certificate.assignments), + x: assignmentsMaxEvaluationPoints(certificate.assignments), }) }}
diff --git a/client/src/pages/learningPath/circlePage/LearningSequence.vue b/client/src/pages/learningPath/circlePage/LearningSequence.vue index 6e6cd218..0f693cc2 100644 --- a/client/src/pages/learningPath/circlePage/LearningSequence.vue +++ b/client/src/pages/learningPath/circlePage/LearningSequence.vue @@ -181,7 +181,7 @@ function checkboxIconUncheckedTailwindClass(lc: LearningContent) { " @toggle="toggleCompleted(learningContent)" @click=" - (event) => { + (event: MouseEvent) => { // when disabled open the learning content directly if (!learningContent.can_user_self_toggle_course_completion) { circleStore.openLearningContent(learningContent); diff --git a/client/src/pages/learningPath/learningContentPage/assignment/AssignmentView.vue b/client/src/pages/learningPath/learningContentPage/assignment/AssignmentView.vue index b7fe02a0..392f1fb2 100644 --- a/client/src/pages/learningPath/learningContentPage/assignment/AssignmentView.vue +++ b/client/src/pages/learningPath/learningContentPage/assignment/AssignmentView.vue @@ -20,7 +20,7 @@ import { useMutation, useQuery } from "@urql/vue"; import { useRouteQuery } from "@vueuse/router"; import dayjs from "dayjs"; import * as log from "loglevel"; -import { computed, onMounted, reactive } from "vue"; +import { computed, onMounted, reactive, ref, watchEffect } from "vue"; import { useTranslation } from "i18next-vue"; import { bustItGetCache } from "@/fetchHelpers"; import { learningContentTypeData } from "@/utils/typeMaps"; @@ -75,6 +75,28 @@ const completionStatus = computed(() => { return assignmentCompletion.value?.completion_status ?? "IN_PROGRESS"; }); +const hasRunUseQueryPostFetch = ref(false); +watchEffect(() => { + if ( + queryResult.data.value && + !queryResult.error.value && + !hasRunUseQueryPostFetch.value + ) { + // workaround for setting step to last when not IN_PROGRESS anymore + hasRunUseQueryPostFetch.value = true; + try { + if ( + stepIndex.value === 0 && + (completionStatus.value ?? "IN_PROGRESS") !== "IN_PROGRESS" + ) { + stepIndex.value = numPages.value - 1; + } + } catch (error) { + log.error(error); + } + } +}); + onMounted(async () => { log.debug( "AssignmentView mounted", @@ -90,17 +112,6 @@ onMounted(async () => { // have reactivity problem accessing it. await initUpsertAssignmentCompletion(); queryResult.resume(); - - try { - if ( - stepIndex.value === 0 && - (completionStatus.value ?? "IN_PROGRESS") !== "IN_PROGRESS" - ) { - stepIndex.value = numPages.value - 1; - } - } catch (error) { - log.error(error); - } }); const numTasks = computed(() => assignment.value?.tasks?.length ?? 0); diff --git a/client/src/types.ts b/client/src/types.ts index 802dcbc6..62e85168 100644 --- a/client/src/types.ts +++ b/client/src/types.ts @@ -395,7 +395,7 @@ export interface PerformanceCriteria extends BaseCourseWagtailPage { readonly competence_id: string; readonly circle: CircleLight; readonly course_category: CourseCategory; - readonly learning_unit: BaseCourseWagtailPage; + readonly learning_unit: BaseCourseWagtailPage & { evaluate_url: string }; } export interface CompetencePage extends BaseCourseWagtailPage {