Scroll behaviour in Lernpfad
This commit is contained in:
parent
7872125167
commit
22b2491136
|
|
@ -30,7 +30,7 @@ const block = computed(() => {
|
||||||
type="button"
|
type="button"
|
||||||
class="btn-text inline-flex items-center px-3 py-2 font-normal"
|
class="btn-text inline-flex items-center px-3 py-2 font-normal"
|
||||||
data-cy="close-learning-content"
|
data-cy="close-learning-content"
|
||||||
@click="circleStore.closeLearningContent()"
|
@click="circleStore.closeLearningContent(props.learningContent)"
|
||||||
>
|
>
|
||||||
<it-icon-arrow-left class="-ml-1 mr-1 h-5 w-5"></it-icon-arrow-left>
|
<it-icon-arrow-left class="-ml-1 mr-1 h-5 w-5"></it-icon-arrow-left>
|
||||||
<span class="hidden lg:inline">zurück zum Circle</span>
|
<span class="hidden lg:inline">zurück zum Circle</span>
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ function handleContinue() {
|
||||||
state.questionIndex += 1;
|
state.questionIndex += 1;
|
||||||
} else {
|
} else {
|
||||||
log.debug("continue to next learning content");
|
log.debug("continue to next learning content");
|
||||||
circleStore.continueFromSelfEvaluation();
|
circleStore.continueFromSelfEvaluation(props.learningUnit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -39,7 +39,7 @@ function handleContinue() {
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn-text inline-flex items-center px-3 py-2 font-normal"
|
class="btn-text inline-flex items-center px-3 py-2 font-normal"
|
||||||
@click="circleStore.closeSelfEvaluation()"
|
@click="circleStore.closeSelfEvaluation(props.learningUnit)"
|
||||||
>
|
>
|
||||||
<it-icon-arrow-left class="-ml-1 mr-1 h-5 w-5"></it-icon-arrow-left>
|
<it-icon-arrow-left class="-ml-1 mr-1 h-5 w-5"></it-icon-arrow-left>
|
||||||
<span class="hidden lg:inline">zurück zum Circle</span>
|
<span class="hidden lg:inline">zurück zum Circle</span>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,13 @@ import { createRouter, createWebHistory } from "vue-router";
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
|
scrollBehavior(to, from, savedPosition) {
|
||||||
|
if (savedPosition) {
|
||||||
|
return savedPosition;
|
||||||
|
} else {
|
||||||
|
return { top: 0 };
|
||||||
|
}
|
||||||
|
},
|
||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
path: "/login",
|
path: "/login",
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import type {
|
||||||
LearningContent,
|
LearningContent,
|
||||||
LearningSequence,
|
LearningSequence,
|
||||||
LearningUnit,
|
LearningUnit,
|
||||||
LearningUnitQuestion,
|
LearningUnitPerformanceCriteria,
|
||||||
} from "@/types";
|
} from "@/types";
|
||||||
|
|
||||||
function _createEmptyLearningUnit(
|
function _createEmptyLearningUnit(
|
||||||
|
|
@ -66,6 +66,7 @@ export function parseLearningSequences(
|
||||||
learningUnit = Object.assign(child, {
|
learningUnit = Object.assign(child, {
|
||||||
learningContents: [],
|
learningContents: [],
|
||||||
parentLearningSequence: learningSequence,
|
parentLearningSequence: learningSequence,
|
||||||
|
parentCircle: circle,
|
||||||
children: child.children.map((c) => {
|
children: child.children.map((c) => {
|
||||||
c.parentLearningUnit = learningUnit;
|
c.parentLearningUnit = learningUnit;
|
||||||
c.parentLearningSequence = learningSequence;
|
c.parentLearningSequence = learningSequence;
|
||||||
|
|
@ -158,12 +159,12 @@ export class Circle implements CourseWagtailPage {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get flatChildren(): (LearningContent | LearningUnitQuestion)[] {
|
public get flatChildren(): (LearningContent | LearningUnitPerformanceCriteria)[] {
|
||||||
const result: (LearningContent | LearningUnitQuestion)[] = [];
|
const result: (LearningContent | LearningUnitPerformanceCriteria)[] = [];
|
||||||
this.learningSequences.forEach((learningSequence) => {
|
this.learningSequences.forEach((learningSequence) => {
|
||||||
learningSequence.learningUnits.forEach((learningUnit) => {
|
learningSequence.learningUnits.forEach((learningUnit) => {
|
||||||
learningUnit.children.forEach((learningUnitQuestion) => {
|
learningUnit.children.forEach((performanceCriteria) => {
|
||||||
result.push(learningUnitQuestion);
|
result.push(performanceCriteria);
|
||||||
});
|
});
|
||||||
learningUnit.learningContents.forEach((learningContent) => {
|
learningUnit.learningContents.forEach((learningContent) => {
|
||||||
result.push(learningContent);
|
result.push(learningContent);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import type {
|
||||||
CourseCompletionStatus,
|
CourseCompletionStatus,
|
||||||
LearningContent,
|
LearningContent,
|
||||||
LearningUnit,
|
LearningUnit,
|
||||||
LearningUnitQuestion,
|
LearningUnitPerformanceCriteria,
|
||||||
} from "@/types";
|
} from "@/types";
|
||||||
|
|
||||||
export type CircleStoreState = {
|
export type CircleStoreState = {
|
||||||
|
|
@ -17,6 +17,16 @@ export type CircleStoreState = {
|
||||||
page: "INDEX" | "OVERVIEW";
|
page: "INDEX" | "OVERVIEW";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function createLearningUnitHash(learningUnit: LearningUnit | undefined) {
|
||||||
|
const luSlug = learningUnit?.slug;
|
||||||
|
const circleSlug = learningUnit?.parentCircle?.slug;
|
||||||
|
if (luSlug && circleSlug) {
|
||||||
|
return "#" + luSlug.replace(`${circleSlug}-`, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
export const useCircleStore = defineStore({
|
export const useCircleStore = defineStore({
|
||||||
id: "circle",
|
id: "circle",
|
||||||
state: () => {
|
state: () => {
|
||||||
|
|
@ -76,7 +86,7 @@ export const useCircleStore = defineStore({
|
||||||
return learningUnit;
|
return learningUnit;
|
||||||
},
|
},
|
||||||
async markCompletion(
|
async markCompletion(
|
||||||
page: LearningContent | LearningUnitQuestion,
|
page: LearningContent | LearningUnitPerformanceCriteria,
|
||||||
completion_status: CourseCompletionStatus = "success"
|
completion_status: CourseCompletionStatus = "success"
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -98,9 +108,10 @@ export const useCircleStore = defineStore({
|
||||||
path: learningContent.frontend_url,
|
path: learningContent.frontend_url,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
closeLearningContent() {
|
closeLearningContent(learningContent: LearningContent) {
|
||||||
this.router.push({
|
this.router.push({
|
||||||
path: `${this.circle?.frontend_url}`,
|
path: `${this.circle?.frontend_url}`,
|
||||||
|
hash: createLearningUnitHash(learningContent.parentLearningUnit),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
openSelfEvaluation(learningUnit: LearningUnit) {
|
openSelfEvaluation(learningUnit: LearningUnit) {
|
||||||
|
|
@ -108,9 +119,10 @@ export const useCircleStore = defineStore({
|
||||||
path: learningUnit.frontend_url,
|
path: learningUnit.frontend_url,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
closeSelfEvaluation() {
|
closeSelfEvaluation(learningUnit: LearningUnit) {
|
||||||
this.router.push({
|
this.router.push({
|
||||||
path: `${this.circle?.frontend_url}`,
|
path: `${this.circle?.frontend_url}`,
|
||||||
|
hash: createLearningUnitHash(learningUnit),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
calcSelfEvaluationStatus(learningUnit: LearningUnit) {
|
calcSelfEvaluationStatus(learningUnit: LearningUnit) {
|
||||||
|
|
@ -139,42 +151,26 @@ export const useCircleStore = defineStore({
|
||||||
currentParent.children.length > 0
|
currentParent.children.length > 0
|
||||||
) {
|
) {
|
||||||
// go to self evaluation
|
// go to self evaluation
|
||||||
// this.openSelfEvaluation(currentParent);
|
this.openSelfEvaluation(currentParent);
|
||||||
this.closeLearningContent();
|
|
||||||
} else if (currentLearningContent.nextLearningContent) {
|
} else if (currentLearningContent.nextLearningContent) {
|
||||||
if (
|
if (
|
||||||
currentLearningContent.parentLearningSequence &&
|
currentLearningContent.parentLearningUnit &&
|
||||||
currentLearningContent.parentLearningSequence.id ===
|
currentLearningContent.parentLearningUnit.id ===
|
||||||
nextLearningContent?.parentLearningSequence?.id
|
nextLearningContent?.parentLearningUnit?.id
|
||||||
) {
|
) {
|
||||||
this.openLearningContent(currentLearningContent.nextLearningContent);
|
this.openLearningContent(currentLearningContent.nextLearningContent);
|
||||||
} else {
|
} else {
|
||||||
this.closeLearningContent();
|
this.closeLearningContent(currentLearningContent);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.closeLearningContent();
|
this.closeLearningContent(currentLearningContent);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.error("currentLearningContent is undefined");
|
log.error("currentLearningContent is undefined");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
continueFromSelfEvaluation() {
|
continueFromSelfEvaluation(learningUnit: LearningUnit) {
|
||||||
this.closeSelfEvaluation();
|
this.closeSelfEvaluation(learningUnit);
|
||||||
// if (this.currentSelfEvaluation) {
|
|
||||||
// const nextContent = this.currentSelfEvaluation.learningContents[this.currentSelfEvaluation.learningContents.length - 1].nextLearningContent;
|
|
||||||
//
|
|
||||||
// if (nextContent) {
|
|
||||||
// if (this.currentSelfEvaluation?.parentLearningSequence?.id === nextContent?.parentLearningSequence?.id) {
|
|
||||||
// this.openLearningContent(nextContent);
|
|
||||||
// } else {
|
|
||||||
// this.closeSelfEvaluation();
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// this.closeSelfEvaluation();
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// log.error('currentSelfEvaluation is undefined');
|
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -145,8 +145,8 @@ export interface LearningContent extends CourseWagtailPage {
|
||||||
previousLearningContent?: LearningContent;
|
previousLearningContent?: LearningContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LearningUnitQuestion extends CourseWagtailPage {
|
export interface LearningUnitPerformanceCriteria extends CourseWagtailPage {
|
||||||
type: "learnpath.LearningUnitQuestion";
|
type: "competence.PerformanceCriteria";
|
||||||
parentLearningSequence?: LearningSequence;
|
parentLearningSequence?: LearningSequence;
|
||||||
parentLearningUnit?: LearningUnit;
|
parentLearningUnit?: LearningUnit;
|
||||||
}
|
}
|
||||||
|
|
@ -156,7 +156,8 @@ export interface LearningUnit extends CourseWagtailPage {
|
||||||
learningContents: LearningContent[];
|
learningContents: LearningContent[];
|
||||||
minutes: number;
|
minutes: number;
|
||||||
parentLearningSequence?: LearningSequence;
|
parentLearningSequence?: LearningSequence;
|
||||||
children: LearningUnitQuestion[];
|
parentCircle?: Circle;
|
||||||
|
children: LearningUnitPerformanceCriteria[];
|
||||||
last?: boolean;
|
last?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -171,7 +172,7 @@ export type CircleChild =
|
||||||
| LearningContent
|
| LearningContent
|
||||||
| LearningUnit
|
| LearningUnit
|
||||||
| LearningSequence
|
| LearningSequence
|
||||||
| LearningUnitQuestion;
|
| LearningUnitPerformanceCriteria;
|
||||||
|
|
||||||
export interface WagtailCircle extends CourseWagtailPage {
|
export interface WagtailCircle extends CourseWagtailPage {
|
||||||
type: "learnpath.Circle";
|
type: "learnpath.Circle";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue