2025-09-24 22:51:53 -06:00
< style >
. fake {
background-image : url ( img/bg03.jpg ) ;
background-repeat : no-repeat ;
background-position : center ;
background-size : cover ;
}
. hr-style {
opacity : 1 ;
width : 25 % ;
}
. bg-inst {
background-color : #e3ece8 ;
}
. btn-answer {
cursor : pointer ;
border-radius : 10 px ;
box-shadow : 0 0 2 px rgba ( 0 , 0 , 0 , .5 ) ;
}
. letter {
background-color : #6c9d7a ;
border-radius : 10 px ;
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 ;
}
# svg-container {
width : 100 % ;
height : auto ;
}
# svg-container svg {
width : 100 % ;
height : 100 % ;
}
. piece-puzzle {
transition : all 0.5 s ease ;
}
< / 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" > Control de líquidos< / h2 >
< hr class = "border border-3 border-verde-oscuro hr-style mx-auto my-0" / >
< / div >
< div class = "col-12 px-0 mb-3 animate__animated animate__lightSpeedInLeft" id = "col-instrucciones" >
< div class = "card bg-inst border-0 my-2 rounded-0 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 > Lee cada una de las preguntas acerca del control de líquidos y contesta correctamente. Por cada acierto obtendrás una
pieza del rompecabezas, el reto es descubrir la imagen oculta.< / p >
< / div >
< / div >
< / div >
< div class = "col-12" >
< div class = "row justify-content-center align-items-center" >
< div class = "col-4 text-center" >
< div id = "svg-container" > < / div >
< / div >
< div class = "col-7 col-actividad" >
< div id = "card-content-quiz-rompecabezas" class = "card bg-white border-0 rounded-15 p-3 card-content-quiz animate__animated animate__zoomIn" style = "box-shadow: 0 0 12px rgba(0,0,0,.5);" >
< div class = "row justify-content-center" >
< div class = "col-12 text-center fw-bold text-verde-oscuro txt-question mb-3" > < / div >
< div class = "col-12 content-answers" > < / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< div class = "d-none" >
< 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' ) ;
function loadSVG ( ) {
$ . get ( 'img/puzzle.svg' , function ( data ) {
var svg = $ ( data ) . find ( 'svg' ) ;
$ ( '#svg-container' ) . html ( svg ) ;
// Remove width and height attributes to make SVG responsive
svg . removeAttr ( 'width' ) . removeAttr ( 'height' ) ;
// Ocultar elementos con id que inicie con 'pz' y agregar clase 'piece-puzzle'
svg . find ( '[id^="pz"]' ) . hide ( ) . addClass ( 'piece-puzzle' ) ;
} , 'xml' ) ;
}
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 . trim ( ) ,
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 ;
}
function displayQuestion ( ) {
if ( currentQuestionIndex < questions . length ) {
currentQuestion = questions [ currentQuestionIndex ] ;
$ ( '.txt-question' ) . text ( currentQuestion . pregunta ) ;
$ ( '.content-answers' ) . empty ( ) ;
// Shuffle answers for current question
const shuffledAnswers = shuffleArray ( [ ... currentQuestion . opciones ] ) ;
shuffledAnswers . forEach ( ( opcion , index ) => {
const answerHtml = `
<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>
` ;
$ ( '.content-answers' ) . append ( answerHtml ) ;
} ) ;
}
}
function initializeAnswers ( ) {
$ ( '#card-content-quiz-rompecabezas' ) . on ( 'click' , '.btn-answer' , function ( ) {
const isCorrect = $ ( this ) . data ( 'correct' ) ;
if ( isCorrect ) {
CourseNav . audioController . stopAllSoundsAndPlay ( good ) ;
correctQuestions ++ ;
2025-09-25 13:03:23 -06:00
$ ( ` #pz ${ correctQuestions - 1 } ` ) . show ( ) ;
2025-09-24 22:51:53 -06:00
currentQuestionIndex ++ ;
if ( currentQuestionIndex < questions . length ) {
$ ( '.card-content-quiz' ) . removeClass ( 'animate__zoomIn' ) . addClass ( 'animate__zoomOut' ) ;
setTimeout ( ( ) => {
$ ( '.card-content-quiz' ) . removeClass ( 'animate__zoomOut' ) . addClass ( 'animate__zoomIn' ) ;
displayQuestion ( ) ;
} , 500 ) ;
} else {
$ ( '.col-actividad' ) . hide ( ) ;
setTimeout ( ( ) => {
checkAllCompleted ( ) ;
} , 300 ) ;
}
} else {
CourseNav . audioController . stopAllSoundsAndPlay ( bad ) ;
}
$ ( '.btn-answer' ) . off ( 'click' ) ;
} ) ;
}
function checkAllCompleted ( ) {
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 ) ;
}
readExcelFile ( urlExcelFile , function ( data ) {
const hojaDatos = data [ "Diapositiva 17" ] ;
questions = shuffleArray ( procesarPreguntas ( hojaDatos ) ) ;
loadSVG ( ) ;
displayQuestion ( ) ;
initializeAnswers ( ) ;
} ) ;
} ) ;
< / script >