Add self evaluation back button

This commit is contained in:
Christian Cueni 2022-10-25 16:43:50 +02:00
parent 5ce25fe4da
commit fc4bda0895
4 changed files with 41 additions and 20 deletions

View File

@ -30,8 +30,8 @@ const block = computed(() => {
<LearningContentContainer <LearningContentContainer
:title="learningContent.title" :title="learningContent.title"
next-button-text="Abschliessen und weiter" next-button-text="Abschliessen und weiter"
back-text="zurück zum Circle" exit-text="zurück zum Circle"
@back="circleStore.closeLearningContent(props.learningContent)" @exit="circleStore.closeLearningContent(props.learningContent)"
@next="circleStore.continueFromLearningContent(props.learningContent)" @next="circleStore.continueFromLearningContent(props.learningContent)"
> >
<div v-if="block.type === 'exercise' || block.type === 'test'" class="h-screen"> <div v-if="block.type === 'exercise' || block.type === 'test'" class="h-screen">

View File

@ -4,12 +4,13 @@ import * as log from "loglevel";
log.debug("LeariningContentContainer.vue setup"); log.debug("LeariningContentContainer.vue setup");
const props = defineProps<{ const props = defineProps<{
backText: string; exitText: string;
title: string; title: string;
nextButtonText: string; nextButtonText: string;
showBackButton?: boolean;
}>(); }>();
const emit = defineEmits(["back", "next"]); const emit = defineEmits(["back", "next", "exit"]);
</script> </script>
<template> <template>
@ -19,24 +20,34 @@ const emit = defineEmits(["back", "next"]);
type="button" type="button"
class="btn-text inline-flex items-center px-3 py-2" class="btn-text inline-flex items-center px-3 py-2"
data-cy="close-learning-content" data-cy="close-learning-content"
@click="$emit('back')" @click="$emit('exit')"
> >
<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">{{ backText }}</span> <span class="hidden lg:inline">{{ exitText }}</span>
</button> </button>
<h1 class="text-large hidden lg:block" data-cy="ln-title"> <h1 class="text-large hidden lg:block" data-cy="ln-title">
{{ title }} {{ title }}
</h1> </h1>
<div>
<button <button
type="button" v-if="showBackButton"
class="btn-blue" type="button"
data-cy="complete-and-continue" class="btn-secondary mr-4"
@click="$emit('next')" data-cy="cancel-and-back"
> @click="$emit('back')"
{{ nextButtonText }} >
</button> Zurück
</button>
<button
type="button"
class="btn-blue"
data-cy="complete-and-continue"
@click="$emit('next')"
>
{{ nextButtonText }}
</button>
</div>
</nav> </nav>
<slot></slot> <slot></slot>
</div> </div>

View File

@ -20,6 +20,7 @@ const props = defineProps<{
const questions = computed(() => props.learningUnit?.children); const questions = computed(() => props.learningUnit?.children);
const currentQuestion = computed(() => questions.value[state.questionIndex]); const currentQuestion = computed(() => questions.value[state.questionIndex]);
const showBackButton = computed(() => state.questionIndex != 0);
function handleContinue() { function handleContinue() {
log.debug("handleContinue"); log.debug("handleContinue");
@ -31,16 +32,25 @@ function handleContinue() {
circleStore.continueFromSelfEvaluation(props.learningUnit); circleStore.continueFromSelfEvaluation(props.learningUnit);
} }
} }
function handleBack() {
log.debug("handleBack");
if (state.questionIndex > 0 && state.questionIndex < questions.value.length) {
state.questionIndex -= 1;
}
}
</script> </script>
<template> <template>
<div v-if="learningUnit"> <div v-if="learningUnit">
<LearningContentContainer <LearningContentContainer
:title="`Selbsteinschätzung ${learningUnit.title}`" :title="`Selbsteinschätzung ${learningUnit.title}`"
:back-text="'zurück zum Circle'" :exit-text="'zurück zum Circle'"
:next-button-text="'Weiter'" :next-button-text="'Weiter'"
@back="circleStore.closeSelfEvaluation(props.learningUnit)" :show-back-button="showBackButton"
@exit="circleStore.closeSelfEvaluation(props.learningUnit)"
@next="handleContinue()" @next="handleContinue()"
@back="handleBack()"
> >
<div class="container-medium"> <div class="container-medium">
<div class="mt-2 lg:mt-8 text-gray-700"> <div class="mt-2 lg:mt-8 text-gray-700">

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { useCircleStore } from "@/stores/circle"; import { useCircleStore } from "@/stores/circle";
import { useCompetenceStore } from "@/stores/competence"; import { useCompetenceStore } from "@/stores/competence";
import type { CompetencePage, LearningUnit, PerformanceCriteria } from "@/types"; import type { CompetencePage, PerformanceCriteria } from "@/types";
import * as log from "loglevel"; import * as log from "loglevel";
import LearningContentContainer from "@/components/learningPath/LearningContentContainer.vue"; import LearningContentContainer from "@/components/learningPath/LearningContentContainer.vue";
@ -58,9 +58,9 @@ findCriteria();
<div v-if="competencePage" class="absolute top-0 w-full bottom-0 bg-white"> <div v-if="competencePage" class="absolute top-0 w-full bottom-0 bg-white">
<LearningContentContainer <LearningContentContainer
:title="''" :title="''"
:back-text="'zurück'" :exit-text="'zurück'"
:next-button-text="'Speichern'" :next-button-text="'Speichern'"
@back="router.back()" @exit="router.back()"
@next="router.back()" @next="router.back()"
> >
<div v-if="currentQuestion" class="container-medium"> <div v-if="currentQuestion" class="container-medium">