From a560d860618407fb1c4c61260a4b1d9248b1f711 Mon Sep 17 00:00:00 2001 From: Lorenz Padberg Date: Tue, 30 Aug 2022 14:50:31 +0200 Subject: [PATCH] Add detetecion for last learning unit --- client/src/stores/learningPath.ts | 5 ++--- client/src/views/LearningPathView.vue | 29 +++++++++++---------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/client/src/stores/learningPath.ts b/client/src/stores/learningPath.ts index ed7c224c..0f3c5668 100644 --- a/client/src/stores/learningPath.ts +++ b/client/src/stores/learningPath.ts @@ -14,7 +14,7 @@ export type LearningPathStoreState = { function getLastCompleted(completionData: any) { - return _.filter(_.orderBy(completionData, ['updated_at'], 'desc'), 'completed')[0] + return _.filter(_.orderBy(completionData, ['updated_at'], 'desc'), c =>{return c.completed && c.page_type === "learnpath.LearningContent" })[0] } @@ -37,14 +37,13 @@ function getNextLearningContent(lastCopleted, learningPathData) { const circles = _.filter(learningPathData.children, {'type': 'learnpath.Circle'}) _.forEach(circles, circle => { _.forEach(Circle.fromJson(circle).learningSequences, learningSequence => { - currentLearningSequence = learningSequence _.forEach(learningSequence.learningUnits, learningUnit => { _.forEach(learningUnit.learningContents, content => { - console.log(lastCopleted, content) if (lastCopleted.page_key === content.translation_key) { currentCircle = Circle.fromJson(circle) currentLearningSequence = learningSequence currentLearningUnit = content + } }) }) diff --git a/client/src/views/LearningPathView.vue b/client/src/views/LearningPathView.vue index a4407dfc..63462132 100644 --- a/client/src/views/LearningPathView.vue +++ b/client/src/views/LearningPathView.vue @@ -20,14 +20,9 @@ const learningPathStore = useLearningPathStore(); const userStore = useUserStore(); - -// const continueRoute = computed(() => { -// if (learningPathStore.learningPath) { -// return"/cirlce/"+learningPathStore.learningPath.nextCircle.slug; -// } -// -// return false; -// }) +const continueRoute = computed(() => { + return "/circle/" + learningPathStore.learningPath.nextCircle.slug + "/"; +}) onMounted(async () => { log.info('LearningPathView mounted'); @@ -39,7 +34,7 @@ onMounted(async () => {