Show result in EdoniqTestBlock

This commit is contained in:
Daniel Egger 2023-09-08 16:54:59 +02:00
parent 2e4ba6ad53
commit dbab03228b
2 changed files with 79 additions and 40 deletions

View File

@ -3,7 +3,6 @@ import * as log from "loglevel";
import type { CompetenceCertificate } from "@/types";
import CompetenceAssignmentRow from "@/pages/competence/CompetenceAssignmentRow.vue";
import { computed } from "vue";
import type { StatusCount } from "@/components/ui/ItProgress.vue";
import ItProgress from "@/components/ui/ItProgress.vue";
import {
assignmentsMaxEvaluationPoints,

View File

@ -2,10 +2,17 @@
import { useTranslation } from "i18next-vue";
import ItCheckbox from "@/components/ui/ItCheckbox.vue";
import LearningContentSimpleLayout from "@/pages/learningPath/learningContentPage/layouts/LearningContentSimpleLayout.vue";
import type { LearningContentEdoniqTest } from "@/types";
import { ref } from "vue";
import type {
Assignment,
AssignmentCompletion,
LearningContentEdoniqTest,
} from "@/types";
import { computed, ref } from "vue";
import * as log from "loglevel";
import { itPost } from "@/fetchHelpers";
import { useQuery } from "@urql/vue";
import { ASSIGNMENT_COMPLETION_QUERY } from "@/graphql/queries";
import { useCurrentCourseSession } from "@/composables";
const { t } = useTranslation();
@ -13,6 +20,29 @@ const props = defineProps<{
content: LearningContentEdoniqTest;
}>();
const courseSession = useCurrentCourseSession();
const queryResult = useQuery({
query: ASSIGNMENT_COMPLETION_QUERY,
variables: {
courseSessionId: courseSession.value.id.toString(),
assignmentId: props.content.content_assignment_id.toString(),
learningContentId: props.content.id.toString(),
},
});
const assignment = computed(
() => queryResult.data.value?.assignment as Assignment | undefined
);
const assignmentCompletion = computed(
() =>
queryResult.data.value?.assignment_completion as AssignmentCompletion | undefined
);
const completionStatus = computed(() => {
return assignmentCompletion.value?.completion_status ?? "IN_PROGRESS";
});
const termsAccepted = ref(false);
const extendedTimeTest = ref(false);
@ -33,7 +63,16 @@ async function startTest() {
:learning-content="props.content"
>
<!-- eslint-disable vue/no-v-html -->
<div class="container-medium">
<div v-if="queryResult.data" class="container-medium">
<div v-if="completionStatus !== 'IN_PROGRESS'">
<div v-if="completionStatus === 'EVALUATION_SUBMITTED'">
{{ $t("a.Bewertung") }}:
{{ assignmentCompletion?.evaluation_points }}
{{ $t("assignment.von x Punkten", { x: assignment?.max_points }) }}
</div>
<div v-else>Ergebnisse abgeben, Bewertung ausstehend</div>
</div>
<div v-else>
<p
v-if="props.content.description"
class="default-wagtail-rich-text text-large my-4"
@ -74,5 +113,6 @@ async function startTest() {
</button>
</div>
</div>
</div>
</LearningContentSimpleLayout>
</template>