Refactor SelfEvaluation to its own route
This commit is contained in:
parent
5d6e94ebd6
commit
dc5adb6214
|
|
@ -46,6 +46,11 @@ const router = createRouter({
|
||||||
component: () => import('../views/CircleView.vue'),
|
component: () => import('../views/CircleView.vue'),
|
||||||
props: true,
|
props: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/learn/:learningPathSlug/:circleSlug/evaluate/:learningUnitSlug',
|
||||||
|
component: () => import('../views/LearningUnitSelfEvaluationView.vue'),
|
||||||
|
props: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/learn/:learningPathSlug/:circleSlug/:contentSlug',
|
path: '/learn/:learningPathSlug/:circleSlug/:contentSlug',
|
||||||
component: () => import('../views/LearningContentView.vue'),
|
component: () => import('../views/LearningContentView.vue'),
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,16 @@ export class Circle implements LearningWagtailPage {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get flatLearningUnits(): LearningUnit[] {
|
||||||
|
const result: LearningUnit[] = [];
|
||||||
|
this.learningSequences.forEach((learningSequence) => {
|
||||||
|
learningSequence.learningUnits.forEach((learningUnit) => {
|
||||||
|
result.push(learningUnit);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public someFinishedInLearningSequence(translationKey: string): boolean {
|
public someFinishedInLearningSequence(translationKey: string): boolean {
|
||||||
if (translationKey) {
|
if (translationKey) {
|
||||||
return this.flatChildren.filter((lc) => {
|
return this.flatChildren.filter((lc) => {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import { defineStore } from 'pinia'
|
||||||
import type { LearningContent, LearningUnit, LearningUnitQuestion } from '@/types'
|
import type { LearningContent, LearningUnit, LearningUnitQuestion } from '@/types'
|
||||||
import type { Circle } from '@/services/circle'
|
import type { Circle } from '@/services/circle'
|
||||||
import { itPost } from '@/fetchHelpers'
|
import { itPost } from '@/fetchHelpers'
|
||||||
import { useAppStore } from '@/stores/app'
|
|
||||||
import { useLearningPathStore } from '@/stores/learningPath'
|
import { useLearningPathStore } from '@/stores/learningPath'
|
||||||
|
|
||||||
export type CircleStoreState = {
|
export type CircleStoreState = {
|
||||||
|
|
@ -58,6 +57,21 @@ export const useCircleStore = defineStore({
|
||||||
|
|
||||||
return this.currentLearningContent;
|
return this.currentLearningContent;
|
||||||
},
|
},
|
||||||
|
async loadSelfEvaluation(learningPathSlug: string, circleSlug: string, learningUnitSlug: string) {
|
||||||
|
const circle = await this.loadCircle(learningPathSlug, circleSlug);
|
||||||
|
if (circle) {
|
||||||
|
this.currentSelfEvaluation = circle.flatLearningUnits.find((child) => {
|
||||||
|
return child.slug.endsWith(learningUnitSlug)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.currentSelfEvaluation) {
|
||||||
|
throw `No self evaluation found with slug: ${learningUnitSlug}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.currentLearningContent;
|
||||||
|
|
||||||
|
},
|
||||||
async markCompletion(page: LearningContent | LearningUnitQuestion, flag = true) {
|
async markCompletion(page: LearningContent | LearningUnitQuestion, flag = true) {
|
||||||
try {
|
try {
|
||||||
page.completed = flag;
|
page.completed = flag;
|
||||||
|
|
@ -86,16 +100,16 @@ export const useCircleStore = defineStore({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
openSelfEvaluation(learningUnit: LearningUnit) {
|
openSelfEvaluation(learningUnit: LearningUnit) {
|
||||||
this.page = 'SELF_EVALUATION';
|
|
||||||
const appStore = useAppStore();
|
|
||||||
appStore.showMainNavigationBar = false;
|
|
||||||
this.currentSelfEvaluation = learningUnit;
|
this.currentSelfEvaluation = learningUnit;
|
||||||
|
const shortSlug = learningUnit.slug.replace(`${this.circle?.slug}-lu-`, '');
|
||||||
|
this.router.push({
|
||||||
|
path: `${this.circle?.getUrl()}/evaluate/${shortSlug}`,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
closeSelfEvaluation() {
|
closeSelfEvaluation() {
|
||||||
this.currentSelfEvaluation = undefined;
|
this.router.push({
|
||||||
const appStore = useAppStore();
|
path: `${this.circle?.getUrl()}`
|
||||||
appStore.showMainNavigationBar = true;
|
});
|
||||||
this.page = 'INDEX';
|
|
||||||
},
|
},
|
||||||
calcSelfEvaluationStatus(learningUnit: LearningUnit) {
|
calcSelfEvaluationStatus(learningUnit: LearningUnit) {
|
||||||
if (learningUnit.children.length > 0) {
|
if (learningUnit.children.length > 0) {
|
||||||
|
|
@ -141,21 +155,22 @@ export const useCircleStore = defineStore({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
continueFromSelfEvaluation() {
|
continueFromSelfEvaluation() {
|
||||||
if (this.currentSelfEvaluation) {
|
this.closeSelfEvaluation()
|
||||||
const nextContent = this.currentSelfEvaluation.learningContents[this.currentSelfEvaluation.learningContents.length - 1].nextLearningContent;
|
// if (this.currentSelfEvaluation) {
|
||||||
|
// const nextContent = this.currentSelfEvaluation.learningContents[this.currentSelfEvaluation.learningContents.length - 1].nextLearningContent;
|
||||||
if (nextContent) {
|
//
|
||||||
if (this.currentSelfEvaluation?.parentLearningSequence?.id === nextContent?.parentLearningSequence?.id) {
|
// if (nextContent) {
|
||||||
this.openLearningContent(nextContent);
|
// if (this.currentSelfEvaluation?.parentLearningSequence?.id === nextContent?.parentLearningSequence?.id) {
|
||||||
} else {
|
// this.openLearningContent(nextContent);
|
||||||
this.closeSelfEvaluation();
|
// } else {
|
||||||
}
|
// this.closeSelfEvaluation();
|
||||||
} else {
|
// }
|
||||||
this.closeSelfEvaluation();
|
// } else {
|
||||||
}
|
// this.closeSelfEvaluation();
|
||||||
} else {
|
// }
|
||||||
log.error('currentSelfEvaluation is undefined');
|
// } else {
|
||||||
}
|
// log.error('currentSelfEvaluation is undefined');
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import LearningContent from '@/components/circle/LearningContent.vue'
|
||||||
|
|
||||||
import { onMounted } from 'vue'
|
import { onMounted } from 'vue'
|
||||||
import { useCircleStore } from '@/stores/circle'
|
import { useCircleStore } from '@/stores/circle'
|
||||||
import SelfEvaluation from '@/components/circle/SelfEvaluation.vue'
|
|
||||||
import { useAppStore } from '@/stores/app'
|
import { useAppStore } from '@/stores/app'
|
||||||
|
|
||||||
log.debug('CircleView.vue created')
|
log.debug('CircleView.vue created')
|
||||||
|
|
@ -46,9 +45,6 @@ onMounted(async () => {
|
||||||
<div v-if="circleStore.page === 'LEARNING_CONTENT'">
|
<div v-if="circleStore.page === 'LEARNING_CONTENT'">
|
||||||
<LearningContent :key="circleStore.currentLearningContent.translation_key" />
|
<LearningContent :key="circleStore.currentLearningContent.translation_key" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="circleStore.page === 'SELF_EVALUATION'">
|
|
||||||
<SelfEvaluation :key="circleStore.currentSelfEvaluation.translation_key" />
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div class="circle-container">
|
<div class="circle-container">
|
||||||
<div class="circle">
|
<div class="circle">
|
||||||
|
|
|
||||||
|
|
@ -37,23 +37,4 @@ onMounted(async () => {
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="postcss" scoped>
|
<style lang="postcss" scoped></style>
|
||||||
.circle-container {
|
|
||||||
background: linear-gradient(to right, white 0%, white 50%, theme(colors.gray.200) 50%, theme(colors.gray.200) 100%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.circle {
|
|
||||||
max-width: 1440px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.v-enter-active,
|
|
||||||
.v-leave-active {
|
|
||||||
transition: opacity 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.v-enter-from,
|
|
||||||
.v-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import * as log from 'loglevel'
|
||||||
|
|
||||||
|
import SelfEvaluation from '@/components/circle/SelfEvaluation.vue'
|
||||||
|
|
||||||
|
import { onMounted } from 'vue'
|
||||||
|
import { useCircleStore } from '@/stores/circle'
|
||||||
|
import { useAppStore } from '@/stores/app'
|
||||||
|
|
||||||
|
log.debug('LearningUnitSelfEvaluationView created')
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
learningPathSlug: string
|
||||||
|
circleSlug: string
|
||||||
|
learningUnitSlug: string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const appStore = useAppStore()
|
||||||
|
appStore.showMainNavigationBar = false
|
||||||
|
|
||||||
|
const circleStore = useCircleStore()
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
log.debug('LearningUnitSelfEvaluationView mounted', props.learningPathSlug, props.circleSlug, props.learningUnitSlug)
|
||||||
|
|
||||||
|
try {
|
||||||
|
await circleStore.loadSelfEvaluation(props.learningPathSlug, props.circleSlug, props.learningUnitSlug)
|
||||||
|
} catch (error) {
|
||||||
|
log.error(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<SelfEvaluation v-if="circleStore.currentSelfEvaluation" :key="circleStore.currentSelfEvaluation.translation_key" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="postcss" scoped></style>
|
||||||
|
|
@ -74,7 +74,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$START_BACKGROUND" = true ]; then
|
if [ "$START_BACKGROUND" = true ]; then
|
||||||
python3 server/manage.py runserver_plus "${DJANGO_PORT}" --settings="$DJANGO_SETTINGS_MODULE" > /dev/null &
|
python3 server/manage.py runserver "${DJANGO_PORT}" --settings="$DJANGO_SETTINGS_MODULE" > /dev/null &
|
||||||
else
|
else
|
||||||
python3 server/manage.py runserver_plus "${DJANGO_PORT}" --settings="$DJANGO_SETTINGS_MODULE"
|
python3 server/manage.py runserver "${DJANGO_PORT}" --settings="$DJANGO_SETTINGS_MODULE"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue