Open Assignment evaluation on last step when not in progress

This commit is contained in:
Daniel Egger 2023-09-14 17:31:00 +02:00
parent 00a36b52c8
commit b4638e372f
4 changed files with 27 additions and 16 deletions

View File

@ -88,11 +88,11 @@ const performanceCriteriaStatusCount = computed(() => {
</div>
<div class="mt-4 lg:mt-0">
<span class="text-bold">
{{ assignmentsMaxEvaluationPoints(certificate.assignments) }}
{{ assignmentsUserPoints(certificate.assignments) }}
</span>
{{
$t("assignment.von x Punkten", {
x: assignmentsUserPoints(certificate.assignments),
x: assignmentsMaxEvaluationPoints(certificate.assignments),
})
}}
</div>

View File

@ -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);

View File

@ -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);

View File

@ -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 {