Add detetecion for last learning unit

This commit is contained in:
Lorenz Padberg 2022-08-30 14:50:31 +02:00
parent eceeff559a
commit a560d86061
2 changed files with 14 additions and 20 deletions

View File

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

View File

@ -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 () => {
<template>
<div class="bg-gray-200" v-if="learningPathStore.learningPath">
<Teleport to="body">
<Teleport to="body">
<LearningPathViewVertical
:show="learningPathStore.page === 'OVERVIEW'"
@closemodal="learningPathStore.page = 'INDEX'"
@ -56,7 +51,8 @@ onMounted(async () => {
Listen Ansicht anzeigen
</button>
</div>
<LearningPathDiagram class="max-w-[1680px] w-full" identifier="mainVisualization" v-bind:vertical="false"></LearningPathDiagram>
<LearningPathDiagram class="max-w-[1680px] w-full" identifier="mainVisualization"
v-bind:vertical="false"></LearningPathDiagram>
</div>
<h1 class="m-12">{{ learningPathStore.learningPath.title }}</h1>
@ -64,18 +60,17 @@ onMounted(async () => {
<div
class="bg-white m-12 p-8 flex flex-col lg:flex-row divide-y lg:divide-y-0 lg:divide-x divide-gray-500 justify-start">
<div class="p-8 flex-auto">
<h2>Willkommmen zurück, {{ userStore.first_name }}</h2>
<h2 translate>Willkommmen zurück, {{ userStore.first_name }}</h2>
<p class="mt-4 text-xl">
Du hast bereits drei circles bearbeitet, mach weiter so!
</p>
</div>
<div class="p-8 flex-1" v-if="learningPathStore.learningPath.nextCircle">
<div class="p-8 flex-2" v-if="learningPathStore.learningPath.nextCircle" translate>
Nächster Schirtt
<h3>{{learningPathStore.learningPath.nextCircle.title}}: {{learningPathStore.learningPath.nextLearningSequence.title}}</h3>
<!-- <router-link class="mt-4 btn-blue" v-bind:to="this.continueRoute">-->
<h3>{{ learningPathStore.learningPath.nextCircle.title }}: {{ learningPathStore.learningPath.nextLearningSequence.title }}</h3>
<router-link class="mt-4 btn-blue" v-bind:to="this.continueRoute" translate>
Los geht's
<!-- </router-link>-->
</router-link>
</div>
</div>
<div class="topic"></div>