Switch course session on jump to assignment in circle

This commit is contained in:
Elia Bieri 2024-08-07 10:38:19 +02:00
parent f70569f319
commit 51f71fb3f1
4 changed files with 38 additions and 4 deletions

View File

@ -337,7 +337,7 @@ const mentorTabTitle = computed(() =>
v-if="selectedCourseSessionTitle"
class="nav-item hidden items-center lg:inline-flex"
>
<div class="">
<div class="" data-cy="current-course-session-title">
{{ selectedCourseSessionTitle }}
</div>
</div>

View File

@ -1,9 +1,15 @@
<script setup lang="ts">
import type { CompetenceCertificateAssignment } from "@/types";
import { useCurrentCourseSession } from "@/composables";
import router from "@/router";
import { useCourseSessionsStore } from "@/stores/courseSessions";
import type { Assignment, CompetenceCertificateAssignment } from "@/types";
import * as log from "loglevel";
log.debug("CompetenceAssignmentRow setup");
const currentCourseSession = useCurrentCourseSession();
const { switchCourseSessionById } = useCourseSessionsStore();
export interface Props {
assignment: CompetenceCertificateAssignment;
showCourseSession: boolean;
@ -20,6 +26,13 @@ const getIconName = () => {
}
return "it-icon-assignment-large";
};
const openInCircle = (assignment: CompetenceCertificateAssignment) => {
if (assignment.completion?.course_session !== currentCourseSession.value) {
switchCourseSessionById(assignment.completion!.course_session.id);
}
router.push(assignment.frontend_url);
};
</script>
<template>
@ -38,9 +51,10 @@ const getIconName = () => {
{{ assignment?.completion?.course_session.title }}
</p>
<p class="text-gray-800">
<a
<button
v-if="assignment.learning_content"
:href="assignment.frontend_url"
@click="() => openInCircle(assignment)"
class="link"
data-cy="open-learning-content"
>
@ -49,7 +63,7 @@ const getIconName = () => {
x: assignment.learning_content.circle.title,
})
}}
</a>
</button>
<span v-else>Fehler, Lerninhalt nicht korrekt verknüpft</span>
</p>
</div>

View File

@ -409,6 +409,7 @@ export interface CompetenceCertificateAssignment extends BaseCourseWagtailPage {
evaluation_max_points: number | null;
evaluation_passed: boolean | null;
course_session: {
id: string;
title: string;
};
} | null;

View File

@ -258,6 +258,25 @@ describe("competenceCertificate.cy.js", () => {
cy.get('[data-cy="assignment-test-lehrgang-assignment-edoniq-wissens-und-verständisfragen-circle-fahrzeug-demo-course-session"]').should("contain", "Test Zürich 2022 a")
})
it("check show assignment in different course session", () => {
const TEST_TRAINER2_USER_ID = "299941ae-1e4b-4f45-8180-876c3ad340b4"
const TEST_STUDENT2_USER_ID = "19c40d94-15cc-4198-aaad-ef707c4b0900"
const TEST_COURSE_SESSION_ZURICH_ID = -2
cy.manageCommand(
`cypress_reset --create-assignment-evaluation --assignment-evaluation-user-id ${TEST_TRAINER2_USER_ID} --assignment-completion-user-id ${TEST_STUDENT2_USER_ID} --edoniq-user-id ${TEST_STUDENT2_USER_ID} --edoniq-course-session-id '${TEST_COURSE_SESSION_ZURICH_ID}' --create-edoniq-test-results 19 24 0`
)
login("test-student2@example.com", "test")
cy.visit("course/test-lehrgang/competence/certificates/kompetenznachweis-1")
cy.get('[data-cy="current-course-session-title"]').should("contain", "Test Bern 2022 a")
cy.get(
'[data-cy="assignment-test-lehrgang-assignment-edoniq-wissens-und-verständisfragen-circle-fahrzeug-demo"] [data-cy="open-learning-content"]'
).click()
cy.get('[data-cy="current-course-session-title"]').should("contain", "Test Zürich 2022 a")
})
it("check with finished edoniq test with deducted points", () => {
cy.manageCommand(
"cypress_reset --create-assignment-completion --create-edoniq-test-results 19 24 8"