2025-12-05 10:31:16 -06:00

392 lines
12 KiB
HTML

<style>
.fake {
background-image: url(img/bg04.jpg);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.hr-style {
opacity: 1;
width: 40%;
}
.bg-custom {
box-shadow: 0 0 10px rgba(0, 0, 0, .5);
}
.btn-answer {
background-color: #808080;
border-radius: 20px;
cursor: pointer;
}
.btn-answer:hover {
background-color: #925c8d;
}
.btn-answer.selected {
background-color: #925c8d;
}
.completed {
filter: grayscale(1);
}
.disabled {
pointer-events: none;
}
.object-btn {
cursor: pointer;
}
.content-medidor {
background-color: #fff;
box-shadow: 0 0 12px rgba(0, 0, 0, .5);
border-radius: 40px;
}
.termometro {
position: relative;
display: grid;
grid-template-columns: repeat(6, 1fr);
grid-template-rows: auto;
gap: 0;
background: #E7E7E7;
background: linear-gradient(to left, #E7E7E7 0%, #C3C3C3 100%);
border-radius: 40px;
}
.med_style {
border-radius: 0;
border: 1px solid #000;
border-right: 3px solid #c3c3c3;
width: 80px;
height: 30px;
}
.med_style:nth-child(6) {
border-top-right-radius: 40px;
border-bottom-right-radius: 40px;
border-left: 0;
border-right: 1px solid #000;
background: #76c300;
background: linear-gradient(to top, #76c300 0%, #386100 100%);
}
.med_style:first-child {
border-top-left-radius: 40px;
border-bottom-left-radius: 40px;
background: #DF0000;
background: linear-gradient(to top, #DF0000 0%, #4F0700 100%);
}
.med_style:nth-child(2),
.med_style:nth-child(3),
.med_style:nth-child(4),
.med_style:nth-child(5) {
border-left: 0;
}
.med_style:nth-child(3) {
background: #ffce00;
background: linear-gradient(to top, #ffce00 0%, #fe6a00 100%);
}
.med_style:nth-child(2) {
background: #ff8400;
background: linear-gradient(to top, #ff8400 0%, #c93000 100%);
}
.med_style:nth-child(4) {
background: #a4f800;
background: linear-gradient(to top, #a4f800 0%, #ffe600 100%);
}
.med_style:nth-child(5) {
background: #aaff00;
background: linear-gradient(to top, #aaff00 0%, #4e8600 100%);
}
.indicador-med {
position: absolute;
width: 60px;
height: 60px;
border-radius: 100%;
bottom: -60px;
left: 10px;
transition: left 0.5s ease;
}
</style>
<div class='page-sco py-2 py-md-4 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">
<h2 class="text-center fw-bold text-primary">Tipos de diálisis peritoneal</h2>
<hr class="border border-3 border-verde-oscuro hr-style mx-auto my-0">
</div>
<div class="col-12 px-0 mb-3">
<div class="card bg-white border-0 my-2 rounded-0 bg-custom p-3 text-center">
<div class="d-flex justify-content-center align-items-center flex-row">
<img src="img/3.1.png" class="img-fluid mx-3">
<p class="mb-0"><strong>Instrucciones:</strong> Presiona cada ícono, lee con atención las oraciones que se presentan acerca de los tipos de diálisis y determina si son falsas o verdaderas. <!-- para llenar el medidor de salud del paciente. --></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-5">
<div class="content-medidor p-2 d-inline-flex flex-row justify-content-center align-items-center gap-3">
<img src="img/07.7.png" class="img-fluid">
<div class="termometro p-1">
<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 id="#med5" class="med_style"></div>
<div id="indicador" class="indicador-med d-flex flex-row justify-content-center align-items-center">
<img src="img/07.5.png" class="img-fluid">
</div>
</div>
<img src="img/07.6.png" class="img-fluid">
</div>
</div>
<div class="col-12">
<div class="d-flex flex-row justify-content-center align-items-center gap-3">
<div class="object-btn text-center d-inline-block animate__animated animate__pulse animate__infinite" data-obj="0">
<img src="img/07.4.png" class="img-fluid">
</div>
<div class="object-btn text-center d-inline-block animate__animated animate__pulse animate__infinite" data-obj="1">
<img src="img/07.3.png" class="img-fluid">
</div>
<div class="object-btn text-center d-inline-block animate__animated animate__pulse animate__infinite" data-obj="2">
<img src="img/07.2.png" class="img-fluid">
</div>
<div class="object-btn text-center d-inline-block animate__animated animate__pulse animate__infinite" data-obj="3">
<img src="img/07.1.png" class="img-fluid">
</div>
<div class="object-btn text-center d-inline-block animate__animated animate__pulse animate__infinite" data-obj="4">
<img src="img/07.0.png" class="img-fluid">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="d-none">
<div id="pops-questions">
<div class="container-fluid">
<div class="row justify-content-center align-items-center">
<div id="txt-question" class="col-12 text-center text-verde-oscuro fw-bold mb-3"></div>
<div class="col-12">
<div id="txt-answers" class="d-flex flex-row justify-content-center align-items-center gap-3"></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;
let currentObjectBtn;
let isCorrectAnswer = false;
const bad = CourseNav.createSound('audio/feedback-incorrect.mpeg');
const good = CourseNav.createSound('audio/feedback-correct.mpeg');
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;
}
// Cargar preguntas al inicio
readExcelFile(urlExcelFile, function(data) {
const hojaDatos = data["Diapositiva 7"];
questions = procesarPreguntas(hojaDatos);
});
$('.object-btn').click(function (e) {
e.preventDefault();
if ($(this).hasClass('disabled')) return;
CourseNav.soundClick();
currentObjectBtn = $(this);
if (questions && questions.length > 0) {
showRandomQuestion();
}
});
function showRandomQuestion() {
// Seleccionar pregunta en orden secuencial
currentQuestion = questions[currentQuestionIndex];
currentQuestionIndex = (currentQuestionIndex + 1) % questions.length;
const html = $("#pops-questions").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: false,
allowOutsideClick: false,
allowEscapeKey: false,
focusConfirm: false,
backdrop: "rgba(65, 60, 60, .95)",
width: "45em",
didOpen: () => {
displayQuestion();
},
didClose: () => {
CourseNav.audioController.stopAudio();
if (currentObjectBtn) {
currentObjectBtn.addClass('completed disabled');
checkAllCompleted();
}
},
});
}
function displayQuestion() {
const contentSwal = $(Swal.getHtmlContainer());
const txtPregunta = contentSwal.find('#txt-question');
const txtAnswers = contentSwal.find('#txt-answers');
txtPregunta.html(currentQuestion.pregunta);
// Aleatorizar respuestas
const shuffledOpciones = shuffleArray([...currentQuestion.opciones]);
let answersHtml = '';
shuffledOpciones.forEach((opcion, index) => {
answersHtml += `<div class="btn-answer text-white p-2 px-3" data-correct="${opcion.correct}">${opcion.text}</div>`;
});
txtAnswers.html(answersHtml);
// Event listener para respuestas
contentSwal.find('.btn-answer').click(function() {
isCorrectAnswer = $(this).data('correct');
$(this).addClass('selected');
if (isCorrectAnswer) {
good.play();
correctQuestions++;
moveIndicator();
Swal.close();
} else {
bad.play();
}
});
}
function moveIndicator() {
const positions = ['left: 90px', 'left: 170px', 'left: 250px', 'left: 330px', 'left: 410px'];
if (correctQuestions <= 5) {
$('#indicador').attr('style', positions[correctQuestions - 1]);
}
}
function checkAllCompleted() {
const totalButtons = $('.object-btn').length;
const completedButtons = $('.object-btn.completed').length;
if (totalButtons === completedButtons) {
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>