actualizacion de super indices, cambios de imagenes y textos. Asi como funcionabilidad de actividades
This commit is contained in:
+28
-51
@@ -323,7 +323,7 @@
|
||||
});
|
||||
return {
|
||||
pregunta: fila.pregunta.trim(),
|
||||
opciones: opciones,
|
||||
opciones: shuffleArray(opciones),
|
||||
retroalimentacion_correcta: fila.retroalimentacion_correcta
|
||||
? fila.retroalimentacion_correcta.trim()
|
||||
: "",
|
||||
@@ -347,10 +347,9 @@
|
||||
if (questionIndex >= questions.length) return;
|
||||
|
||||
const pregunta = questions[questionIndex];
|
||||
const opcionesBarajadas = shuffleArray([...pregunta.opciones]);
|
||||
|
||||
let opcionesHTML = "";
|
||||
opcionesBarajadas.forEach((opcion, index) => {
|
||||
pregunta.opciones.forEach((opcion, index) => {
|
||||
opcionesHTML += `<div class="position-relative d-flex flex-row align-items-center gap-0 mb-2 btn-answer" data-correct="${opcion.correct}">
|
||||
<div class="d-flex flex-row justify-content-center align-items-center letter text-white text-center p-3">${String.fromCharCode(97 + index)}</div>
|
||||
<div class="txt-answer text-start ps-3">${opcion.text}</div>
|
||||
@@ -375,34 +374,34 @@
|
||||
backdrop: "rgba(65, 60, 60, .95)",
|
||||
width: "50em",
|
||||
didOpen: () => {
|
||||
$(".btn-answer").click(function () {
|
||||
function handleAnswer() {
|
||||
const isCorrect = $(this).data("correct") === true;
|
||||
$(".btn-answer").off("click").css("pointer-events", "none");
|
||||
|
||||
if (isCorrect) {
|
||||
correctQuestions++;
|
||||
}
|
||||
|
||||
CourseNav.audioController.stopAllSoundsAndPlay(isCorrect ? good : bad);
|
||||
|
||||
setTimeout(() => {
|
||||
Swal.close();
|
||||
mostrarFeedback(isCorrect, pregunta, questionIndex);
|
||||
}, 250);
|
||||
});
|
||||
if (isCorrect) {
|
||||
correctQuestions++;
|
||||
setTimeout(() => {
|
||||
Swal.close();
|
||||
mostrarFeedback(pregunta, questionIndex);
|
||||
}, 250);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
$(".btn-answer").css("pointer-events", "").on("click", handleAnswer);
|
||||
}, 600);
|
||||
}
|
||||
}
|
||||
$(".btn-answer").on("click", handleAnswer);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function mostrarFeedback(isCorrect, pregunta, questionIndex) {
|
||||
const retroalimentacion = isCorrect
|
||||
? pregunta.retroalimentacion_correcta
|
||||
: pregunta.retroalimentacion_incorrecta;
|
||||
|
||||
function mostrarFeedback(pregunta, questionIndex) {
|
||||
Swal.fire({
|
||||
target: document.getElementById("wrap-course-content"),
|
||||
imageUrl: isCorrect ? "img/good.png" : "img/bad.png",
|
||||
text: retroalimentacion || "",
|
||||
imageUrl: "img/good.png",
|
||||
text: pregunta.retroalimentacion_correcta || "",
|
||||
showConfirmButton: true,
|
||||
customClass: {
|
||||
popup: "pop_retros bg-transparent border-0 rounded-0 shadow-none",
|
||||
@@ -415,23 +414,13 @@
|
||||
didClose: () => {
|
||||
const currentPaquete = $(`#paquete${questionIndex}`);
|
||||
currentPaquete.removeClass("animate__pulse animate__infinite").addClass("completed");
|
||||
currentPaquete.find(".check-question img").attr("src", "img/14.11.png");
|
||||
|
||||
// Cambiar imagen del check
|
||||
const checkImg = currentPaquete.find(".check-question img");
|
||||
checkImg.attr("src", isCorrect ? "img/14.11.png" : "img/14.10.png");
|
||||
const camion = $("#camion-transporte");
|
||||
const paqueteWidth = currentPaquete.outerWidth() + 15;
|
||||
const currentX = camion.css("transform") === "none" ? 0 : parseFloat(camion.css("transform").split(",")[4]) || 0;
|
||||
camion.css("transform", `translateX(${currentX + paqueteWidth}px)`);
|
||||
|
||||
if (isCorrect) {
|
||||
// Mover camión
|
||||
const camion = $("#camion-transporte");
|
||||
const paqueteWidth = currentPaquete.outerWidth() + 15; // incluye gap
|
||||
const currentTransform = camion.css("transform");
|
||||
const currentX =
|
||||
currentTransform === "none" ? 0 : parseFloat(currentTransform.split(",")[4]) || 0;
|
||||
const newX = currentX + paqueteWidth;
|
||||
camion.css("transform", `translateX(${newX}px)`);
|
||||
}
|
||||
|
||||
// Habilitar siguiente paquete
|
||||
if (questionIndex < questions.length - 1) {
|
||||
$(`#paquete${questionIndex + 1}`).removeClass("disabled");
|
||||
}
|
||||
@@ -439,23 +428,11 @@
|
||||
currentQuestionIndex++;
|
||||
|
||||
if (currentQuestionIndex >= questions.length) {
|
||||
// Si respondió todas correctamente, mover al destino final
|
||||
if (correctQuestions === questions.length) {
|
||||
setTimeout(() => {
|
||||
const camion = $("#camion-transporte");
|
||||
const currentTransform = camion.css("transform");
|
||||
const currentX =
|
||||
currentTransform === "none" ? 0 : parseFloat(currentTransform.split(",")[4]) || 0;
|
||||
const paqueteWidth = currentPaquete.outerWidth() + 25;
|
||||
const newX = currentX + paqueteWidth;
|
||||
camion.css("transform", `translateX(${newX}px)`);
|
||||
console.log("Moviendo camión al fin:", newX);
|
||||
}, 1000);
|
||||
}
|
||||
const delay = correctQuestions === questions.length ? 3000 : 1500;
|
||||
setTimeout(() => {
|
||||
finalizarJuego();
|
||||
}, delay);
|
||||
const newX = (parseFloat(camion.css("transform").split(",")[4]) || 0) + currentPaquete.outerWidth() + 25;
|
||||
camion.css("transform", `translateX(${newX}px)`);
|
||||
}, 1000);
|
||||
setTimeout(() => finalizarJuego(), 3000);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user