recomendaciones finales

This commit is contained in:
María
2025-10-22 10:38:05 +02:00
committed by María
parent da5b74b295
commit 840cb1c5aa
10 changed files with 2496 additions and 156 deletions

View File

@@ -82,15 +82,15 @@ export default {
}
},
mounted() {
// Al montar, escuchar el evento de recarga/cierre
window.addEventListener("beforeunload", this.clearStorageOnReload)
},
// mounted() {
// // Al montar, escuchar el evento de recarga/cierre
// window.addEventListener("beforeunload", this.clearStorageOnReload)
// },
beforeUnmount() {
// Limpiar el listener al desmontar el componente
window.removeEventListener("beforeunload", this.clearStorageOnReload)
},
// beforeUnmount() {
// // Limpiar el listener al desmontar el componente
// window.removeEventListener("beforeunload", this.clearStorageOnReload)
// },
methods: {
@@ -100,10 +100,11 @@ export default {
localStorage.removeItem("score")
localStorage.removeItem("results")
localStorage.removeItem("final-score")
localStorage.removeItem("grouped-results")
},
goToNext(event) {
console.log("Evento recibido para ir al siguiente slice:", event)
//console.log("Evento recibido para ir al siguiente slice:", event)
if (this.currentSlice.type === "question" && event !== undefined) {
const answerObj = {
sectionId: this.currentSlice.section.id,
@@ -117,7 +118,7 @@ export default {
}
const nextConfig = this.currentSlice.next
console.log("Navegando desde slice:", this.currentSliceId, "con configuración next:", nextConfig)
//console.log("Navegando desde slice:", this.currentSliceId, "con configuración next:", nextConfig)
if (!nextConfig) {
////console.log("Encuesta finalizada", this.answers)
return
@@ -132,11 +133,11 @@ export default {
if (typeof nextConfig === "string") {
// Navegación lineal
console.log("--- Navegación LINEAL (string) al slice:", nextConfig)
// console.log("--- Navegación LINEAL (string) al slice:", nextConfig)
this.currentSliceId = nextConfig
} else if (typeof nextConfig === "object") {
// Navegación condicional por valor de respuesta
console.log("--- Navegación CONDICIONAL (object) al slice:", nextConfig)
//console.log("--- Navegación CONDICIONAL (object) al slice:", nextConfig)
const nextSlice = nextConfig[event.value]
if (nextSlice) {
this.currentSliceId = nextSlice
@@ -211,6 +212,9 @@ export default {
}
},
calculateFinalScore() {
const results = JSON.parse(localStorage.getItem('results'))
if (results && results.length > 0) {