2025-12-10 12:06:52 -06:00

358 lines
13 KiB
HTML

<style>
.fake {
background-image: url(img/bg03.jpg);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.hr-style {
opacity: 1;
width: 23%;
}
.bg-inst {
background-color: #e3ece8;
}
.med_style {
position: relative;
width: 35px;
height: 35px;
background: #4d4d4d;
border: 4px solid #808080;
box-shadow: 0 0 15px rgba(0,0,0,.5);
}
.med_style.visited {
background: #8EBA1F;
background: linear-gradient(to right, #8EBA1F 0%, #105742 100%);
border: 4px solid #ffffff;
}
.pop_html_style.padd_perso .swal2-html-container {
padding: 0;
}
.object-btn {
cursor: pointer;
position: relative;
width: 19%;
}
.btn-answer {
cursor: pointer;
border-radius: 10px;
box-shadow: 0 0 2px rgba(0,0,0,.5);
width: 95%;
}
.letter {
background-color: #6c9d7a;
border-radius: 10px;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.btn-answer.selected {
background-color: #d9c5d7;
}
.btn-answer.selected .letter {
background-color: #925c8d;
}
.btn-answer:hover {
background-color: #d9c5d7;
}
.btn-answer:hover .letter {
background-color: #925c8d;
}
.object-btn.completed::before {
content: url(img/18.5.png);
position: absolute;
top: 65px;
left: 0;
right: 0;
margin: 0 auto;
}
.phone-numbers {
pointer-events: none!important;
user-select: text;
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
}
</style>
<div class='page-sco py-2 py-md-0 h-100'>
<div class='container h-100'>
<div class='row justify-content-center align-items-center h-100'>
<div class='col-12'>
<div class='row justify-content-center'>
<div class="col-10 mb-2 animate__animated animate__bounceInDown">
<h2 class="text-center fw-bold text-primary">Consejos útiles</h2>
<hr class="border border-3 border-verde-oscuro hr-style mx-auto my-0" />
</div>
<div class="col-8 px-0 mb-3 animate__animated animate__lightSpeedInLeft" id="col-instrucciones">
<div class="card bg-inst border-0 my-2 rounded-3 bg-custom ps-4 pe-3 py-2 text-center">
<div class="d-flex justify-content-center align-items-center flex-row gap-2">
<img src="img/3.1.png" class="img-fluid mx-3" />
<p class="mb-0 text-start"><strong>Instrucciones:</strong> Da clic en cada una de las salas y contesta la pregunta correspondiente al tema para ganar los puntos.</p>
</div>
</div>
</div>
<div id="actividad-objects" class="col-12">
<div class="row justify-content-center align-items-center">
<div class="col-12 text-center mb-3">
<div class="content-medidor bg-white rounded-5 p-3 d-inline-flex flex-row justify-content-center align-items-center gap-3">
<h4 class="mb-0 fw-bold text-verde-pino">Puntos:</h4>
<div class="grids-med d-flex flex-row justify-content-center align-items-center gap-3">
<div id="#med0" class="med_style"></div>
<div id="#med1" class="med_style"></div>
<div id="#med2" class="med_style"></div>
<div id="#med3" class="med_style"></div>
<div id="#med4" class="med_style"></div>
</div>
</div>
</div>
<div class="col-11">
<div class="d-flex flex-row justify-content-center gap-2">
<div class="object-btn text-center d-inline-block" data-obj="0">
<img src="img/18.0.png" class="img-fluid mb-2 animate__animated animate__pulse animate__infinite"><br>
<h4 class="fw-bold text-center text-primary">Sala: Estilo de vida</h4>
</div>
<div class="object-btn text-center d-inline-block" data-obj="1">
<img src="img/18.1.png" class="img-fluid mb-2 animate__animated animate__pulse animate__infinite"><br>
<h4 class="fw-bold text-center text-primary">Sala: Desecho de residuos</h4>
</div>
<div class="object-btn text-center d-inline-block" data-obj="2">
<img src="img/18.2.png" class="img-fluid mb-2 animate__animated animate__pulse animate__infinite"><br>
<h4 class="fw-bold text-center text-primary">Sala: Entrega domiciliaria</h4>
</div>
<div class="object-btn text-center d-inline-block" data-obj="3">
<img src="img/18.3.png" class="img-fluid mb-2 animate__animated animate__pulse animate__infinite"><br>
<h4 class="fw-bold text-center text-primary">Sala: Soporte técnico</h4>
<h4 class="mb-0 text-primary fw-bold phone-numbers">777 329 6162 <br> 777 160 7199</h4>
</div>
<div class="object-btn text-center d-inline-block" data-obj="4">
<img src="img/18.4.png" class="img-fluid mb-2 animate__animated animate__pulse animate__infinite"><br>
<h4 class="fw-bold text-center text-primary">Sala: Reportes</h4>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="d-none">
<div id="pops-questions">
<div class="container-fluid px-0" style="overflow: hidden;border-top-left-radius: 12px;border-top-right-radius: 12px;">
<div class="row justify-content-center align-items-center">
<div class="col-12 text-center mb-3 img-pregunta bg-secondary"></div>
<div id="txt-question" class="col-12 text-center text-verde-oscuro fw-bold mb-3 px-4"></div>
<div class="col-12 px-4">
<div id="txt-answers" class="d-flex flex-column justify-content-center align-items-center gap-3 text-start"></div>
</div>
</div>
</div>
</div>
<div id="pop0">
<div class="container-fluid">
<div class=" w-100 text-center">
<img src="img/3.5.png" class="img-fluid">
</div>
<div class="row justify-content-center">
<div class="col-12 text-center mb-2">
<h3 class="text-secondary-dark fw-bold">¡Bien hecho!</h3>
</div>
<div class="col-12 text-center">
<p class="mb-0">Has concluido la actividad.</p>
</div>
</div>
</div>
</div>
</div>
<script>
$(function () {
"use strict";
$('.wrap-course-content').addClass('fake');
let questions;
let currentQuestionIndex = 0;
let currentQuestion;
let correctQuestions = 0;
const bad = CourseNav.createSound('audio/feedback-incorrect.mpeg');
const good = CourseNav.createSound('audio/feedback-correct.mpeg');
const imganesPop = ['<img src="img/18.0.png" class="img-fluid">', '<img src="img/18.1.png" class="img-fluid">', '<img src="img/18.2.png" class="img-fluid">', '<img src="img/18.3.png" class="img-fluid">', '<img src="img/18.4.png" class="img-fluid">'];
const urlExcelFile = 'Actividades_Rotafolio_Vantive.xlsx';
function readExcelFile(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function (e) {
var arrayBuffer = xhr.response;
var data = new Uint8Array(arrayBuffer);
var workbook = XLSX.read(data, { type: "array" });
var result = {};
workbook.SheetNames.forEach(sheetName => {
var sheet = workbook.Sheets[sheetName];
result[sheetName] = XLSX.utils.sheet_to_json(sheet);
});
callback(result);
};
xhr.send();
}
function procesarPreguntas(data) {
const preguntas = data.map(fila => {
const opciones = [];
Object.keys(fila).forEach(key => {
if (key.startsWith('opcion')) {
opciones.push({
text: fila[key].trim(),
correct: key === 'opcion_c'
});
}
});
return {
pregunta: fila.pregunta.trim(),
opciones: opciones,
retroalimentacion_correcta: fila.retroalimentacion_correcta ? fila.retroalimentacion_correcta.trim() : '',
retroalimentacion_incorrecta: fila.retroalimentacion_incorrecta ? fila.retroalimentacion_incorrecta.trim() : ''
};
});
return preguntas;
}
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
let currentObjectBtn;
let isCorrectAnswer = false;
readExcelFile(urlExcelFile, function (data) {
const hojaDatos = data["Diapositiva 20"];
questions = procesarPreguntas(hojaDatos);
// Enable click handlers after questions are loaded
$('.object-btn').click(function (e) {
e.preventDefault();
if ($(this).hasClass('disabled')) return;
CourseNav.soundClick();
currentObjectBtn = $(this);
showRandomQuestion();
});
});
function showRandomQuestion() {
// Seleccionar pregunta por índice del botón
const objIndex = currentObjectBtn.data('obj');
currentQuestion = questions[objIndex];
const html = $("#pops-questions").html();
Swal.fire({
html: html,
target: document.getElementById('wrap-course-content'),
customClass: {
popup: 'pop_html_style padd_perso border border-3 border-primary rounded-4',
confirmButton: 'btn text-white bg-primary amor fw-semibold animate__animated animate__pulse animate__infinite'
},
confirmButtonText: "Cerrar",
showConfirmButton: false,
allowOutsideClick: false,
allowEscapeKey: false,
focusConfirm: false,
backdrop: "rgba(65, 60, 60, .95)",
width: "50em",
didOpen: () => {
displayQuestion();
},
didClose: () => {
//CourseNav.audioController.stopAudio();
checkAllCompleted();
},
});
}
function displayQuestion() {
const objIndex = currentObjectBtn.data('obj');
const container = Swal.getHtmlContainer();
$(container).find('.img-pregunta').html(imganesPop[objIndex]);
$(container).find('#txt-question').html(`<p class="fw-bold">${currentQuestion.pregunta}</p>`);
const shuffledAnswers = shuffleArray([...currentQuestion.opciones]);
let answersHTML = '';
shuffledAnswers.forEach((opcion, index) => {
answersHTML += `<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 ps-3">${opcion.text}</div>
</div>`;
});
$(container).find('#txt-answers').html(answersHTML);
$(container).find('.btn-answer').click(function() {
const isCorrect = $(this).data('correct');
handleAnswer(isCorrect);
});
}
function handleAnswer(isCorrect) {
if (isCorrect) {
CourseNav.audioController.stopAllSoundsAndPlay(good);
correctQuestions++;
// Marcar medidor como visitado
$(`.med_style:eq(${correctQuestions - 1})`).addClass('visited');
// Marcar botón como disabled
currentObjectBtn.addClass('disabled completed');
currentObjectBtn.find('img').removeClass('animate__pulse animate__infinite');
Swal.close();
} else {
CourseNav.audioController.stopAllSoundsAndPlay(bad);
}
}
function checkAllCompleted() {
if (correctQuestions >= 5) {
setTimeout(() => {
const html = $("#pop0").html();
Swal.fire({
html: html,
target: document.getElementById('wrap-course-content'),
customClass: {
popup: 'pop_html_style border border-3 border-primary rounded-4',
confirmButton: 'btn text-white bg-primary amor fw-semibold animate__animated animate__pulse animate__infinite'
},
confirmButtonText: "Cerrar",
showConfirmButton: true,
allowOutsideClick: false,
allowEscapeKey: false,
backdrop: "rgba(65, 60, 60, .95)",
width: "35em",
didClose: () => {
CourseNav.setSlideVisited();
}
});
}, 250);
}
}
});
</script>