chore: version inicial del codigo fuente del LMS Estafeta
This commit is contained in:
@@ -0,0 +1,768 @@
|
||||
jQuery(document).ready(function ($) {
|
||||
var cat;
|
||||
var retro;
|
||||
//---------------------------------------------------------------
|
||||
//-------------------- BOTON REGRESAR ---------------------------
|
||||
//---------------------------------------------------------------
|
||||
$(".btn-return").click(function(){
|
||||
location.href ="recursos.php?idcat="+cat;
|
||||
//let prevUrl = document.referrer;
|
||||
//window.location=prevUrl;
|
||||
});
|
||||
|
||||
//---------------------------------------------------------------
|
||||
//-------------------- DATA ENCUESTA ---------------------------
|
||||
//---------------------------------------------------------------
|
||||
function getEvaluacion(evaluacion,numempl){
|
||||
$('.progress-evaluacion').hide();
|
||||
$('.instrucciones-evaluacion').show();
|
||||
|
||||
$.ajax({
|
||||
url: 'evaluaciones/getEvaluacion.php',
|
||||
type:'POST',
|
||||
data:{idevaluacion:evaluacion,numempl:numempl},
|
||||
success: function(response) {
|
||||
var _data = JSON.parse(response);
|
||||
if (_data.codeDatos == '200') {
|
||||
//INICIALIZAR CARGANDO
|
||||
$('#evaname').html('Cargando...');
|
||||
$('._instrucciones').html('Cargando...');
|
||||
$('._preguntas').html('Cargando...');
|
||||
$('._calificacion').html('Cargando...');
|
||||
$('._intentos').html('Cargando...');
|
||||
$('._tiempo').html('Cargando...');
|
||||
//INICIALIZAR RESET CAMPOS
|
||||
$('#evaname').html('');
|
||||
$('._instrucciones').html('');
|
||||
$('._preguntas').html('');
|
||||
$('._calificacion').html('');
|
||||
$('._intentos').html('');
|
||||
$('._tiempo').html('');
|
||||
|
||||
//INICIALIZAR DATOS EVALUACION
|
||||
cat = _data.datos.categoria;
|
||||
retro = _data.datos.retroalimentacion;
|
||||
$('#btn-constancia').attr('href','certificate.php?idcourse='+cat);
|
||||
$('#evaname').html(_data.datos.titulo);
|
||||
$('._instrucciones').html(_data.datos.instrucciones);
|
||||
$('._preguntas').html(_data.datos.preguntas+' preguntas');
|
||||
$('._calificacion').html(_data.datos.calificacion);
|
||||
commit.postCalificacion(_data.datos.preguntas,_data.datos.calificacion);
|
||||
$('#btn_init').attr('data-type',_data.datos.tipopreguntas);
|
||||
|
||||
if (_data.datos.tipointentos == 'Limitado') {
|
||||
$('._intentos').html(_data.datos.intentos+' intentos');
|
||||
$('#btn_init').show();
|
||||
if ( _data.progreso.aplicado >= _data.datos.intentos) {
|
||||
$('#btn_init').hide();
|
||||
resultados(_data.progreso);
|
||||
}else{
|
||||
resultados(_data.progreso);
|
||||
}
|
||||
}else{
|
||||
resultados(_data.progreso);
|
||||
$('._intentos').html(_data.datos.tipointentos);
|
||||
$('#btn_init').show();
|
||||
}
|
||||
if (_data.datos.tipotiempo == 'Limitado') {
|
||||
$('._tiempo').html(_data.datos.tiempo+' minutos');
|
||||
$('._timelimit').html(_data.datos.tiempo);
|
||||
timer.postLimit(_data.datos.tiempo);
|
||||
}else{
|
||||
$('.progress_bar').hide();
|
||||
$('._tiempo').html(_data.datos.tipotiempo);
|
||||
$('._timelimit').html(_data.datos.tipotiempo);
|
||||
}
|
||||
|
||||
$('.layer-load').hide();
|
||||
}else{
|
||||
Swal.fire({
|
||||
html: _data.msgDatos,
|
||||
icon: _data.iconDatos,
|
||||
onBeforeOpen: function () {},
|
||||
onOpen: function () {
|
||||
$('.layer-load').hide();
|
||||
},
|
||||
onRender: function () {},
|
||||
onClose: function () {
|
||||
//$('.btn-return').click();
|
||||
location.href ="dashboard.php";
|
||||
},
|
||||
onAfterClose: function () {}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
error: function() {
|
||||
Swal.fire({
|
||||
html: 'Hubo un error al procesar los datos',
|
||||
icon: 'error',
|
||||
onBeforeOpen: function () {},
|
||||
onOpen: function () {
|
||||
$('.layer-load').hide();
|
||||
},
|
||||
onRender: function () {},
|
||||
onClose: function () {
|
||||
$('.btn-return').click();
|
||||
},
|
||||
onAfterClose: function () {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
//--------------------- BOTON INICIAR ---------------------------
|
||||
//---------------------------------------------------------------
|
||||
$("#btn_init").click(function(){
|
||||
$('layer-load').show();
|
||||
var type = $(this).attr('data-type');
|
||||
var mode = $(this).attr('data-mode');
|
||||
$('.constancia-evaluacion').hide();
|
||||
$('.instrucciones-evaluacion').hide();
|
||||
$('.result-evaluacion').hide();
|
||||
$('.progress-evaluacion').show();
|
||||
evaluacion(mode,type,$('#idevaluacion').val(),$('#numerodeempleado').val());
|
||||
});
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
//------------------- INICIAR EVALUACION ------------------------
|
||||
//---------------------------------------------------------------
|
||||
function evaluacion(mode,orden,evaluacion,numempl){
|
||||
|
||||
$.ajax({
|
||||
url: 'evaluaciones/getPreguntas.php',
|
||||
type:'POST',
|
||||
data:{mode:mode,orden:orden,evaluacion:evaluacion,numempl:numempl},
|
||||
success: function(respuesta) {
|
||||
var _data = JSON.parse(respuesta);
|
||||
|
||||
if (_data.code == '200') {
|
||||
if (mode == 'progress') {
|
||||
$('#cronometro').val(_data.preguntas[0].tiempo);
|
||||
$('#estado').val(_data.preguntas[0].estado);
|
||||
timer.reload(_data.preguntas[0].tiempo);
|
||||
}else{
|
||||
timer.init();
|
||||
commit.init();
|
||||
}
|
||||
|
||||
$('.nav-tabs').html('');
|
||||
$('.tab-content').html('');
|
||||
var navs = '';
|
||||
var tabs = '';
|
||||
var btn = '';
|
||||
var totaltabs = _data.preguntas.length;
|
||||
|
||||
//Contruccion de tabs
|
||||
$.each(_data.preguntas, function (index, val) {
|
||||
navs = '';
|
||||
tabs = '';
|
||||
if (index == 0) {
|
||||
navs = '<li class="nav-item">'+
|
||||
'<a class="nav-link active disabled" data-toggle="tab" href="#eva'+index+'" data-nav="'+index+'" id="nav'+index+'">Pregunta '+(index+1)+'</a>'+
|
||||
'</li>';
|
||||
|
||||
tabs = '<div class="tab-pane container active" id="eva'+index+'">'+
|
||||
'<div class="row">'+
|
||||
'<input type="hidden" name="idpregunta" id="idpregunta'+index+'" value="'+val.idpregunta+'">'+
|
||||
'<input type="hidden" name="scorepregunta" id="scorepregunta'+index+'" value="'+val.puntos+'">'+
|
||||
'<input type="hidden" name="type" id="type'+index+'" value="'+val.tipo+'">'+
|
||||
'<div class="col-lg-12 col-md-12 col-12 mt-3">'+
|
||||
'<p><b>Puntos: </b>'+val.puntos+'</p>'+
|
||||
'<p id="eva'+index+'"><b>Pregunta '+(index+1)+':</b>'+val.titulo+'</p>'+
|
||||
'<p class="evadesc'+index+'">'+val.descripcion+'</p>'+
|
||||
'<div id="answerseva'+index+'" class="answers">'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<div class="col-lg-6 col-md-6 col-6" id="btns_'+index+'">'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'</div>';
|
||||
}else{
|
||||
navs = '<li class="nav-item">'+
|
||||
'<a class="nav-link disabled" data-toggle="tab" href="#eva'+index+'" data-nav="'+index+'" id="nav'+index+'">Pregunta '+(index+1)+'</a>'+
|
||||
'</li>';
|
||||
|
||||
tabs = '<div class="tab-pane container fade" id="eva'+index+'">'+
|
||||
'<div class="row">'+
|
||||
'<input type="hidden" name="idpregunta" id="idpregunta'+index+'" value="'+val.idpregunta+'" disabled>'+
|
||||
'<input type="hidden" name="scorepregunta" id="scorepregunta'+index+'" value="'+val.puntos+'" disabled>'+
|
||||
'<input type="hidden" name="type" id="type'+index+'" value="'+val.tipo+'" disabled>'+
|
||||
'<div class="col-lg-12 col-md-12 col-12 mt-3">'+
|
||||
'<p><b>Puntos: </b>'+val.puntos+'</p>'+
|
||||
'<p id="eva'+index+'"><b>Pregunta '+(index+1)+':</b>'+val.titulo+'</p>'+
|
||||
'<p class="evadesc'+index+'">'+val.descripcion+'</p>'+
|
||||
'<div id="answerseva'+index+'" class="answers">'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<div class="col-lg-6 col-md-6 col-6" id="btns_'+index+'">'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'</div>';
|
||||
|
||||
}
|
||||
|
||||
$('.nav-tabs').append(navs);
|
||||
$('.tab-content').append(tabs);
|
||||
|
||||
$.each(val.respuestas, function (indexanswers, answers) {
|
||||
if (val.tipo == 'textarea') {
|
||||
if (indexanswers == 1) {
|
||||
answers = '<div class="form-group">'+
|
||||
'<textarea class="form-control" rows="5" data-sec="'+index+'" id="answers'+answers.idpregunta+'" name="answers'+answers.idpregunta+'[]" required="required"></textarea>'+
|
||||
'</div>';
|
||||
$('#answerseva'+index).append(answers);
|
||||
}
|
||||
}else{
|
||||
answers = '<label class="container-check">'+answers.texto+
|
||||
'<input type="'+val.tipo+'" data-sec="'+index+'" name="answers'+answers.idpregunta+'[]" id="answers'+answers.idpregunta+'" value="'+answers.idopcion+'">'+
|
||||
'<span class="checkmark"></span>'+
|
||||
'</label>';
|
||||
$('#answerseva'+index).append(answers);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (totaltabs == (index+1)) {
|
||||
btn = '<button type="submit" name="btnSave" value="terminar" id="btn-'+index+'" data-tab="'+index+'" class="btn-next btn btn-primary btn-sm" style="display:none;">Enviar</button>';
|
||||
}else{
|
||||
btn = '<button type="submit" name="btnSave" value="siguiente" id="btn-'+index+'" data-tab="'+index+'" class="btn-next btn btn-primary btn-sm" style="display:none;">Siguiente</button>';
|
||||
}
|
||||
$('#btns_'+index).append(btn);
|
||||
|
||||
$('.answers input').click(function () {
|
||||
seccion = $(this).attr('data-sec');
|
||||
$('#btn-'+seccion).show();
|
||||
});
|
||||
|
||||
$('.answers .form-control').focus(function () {
|
||||
console.log('escribiendo');
|
||||
seccion = $(this).attr('data-sec');
|
||||
$('#btn-'+seccion).show();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(".btn-next").click(function(){
|
||||
tabant = $(this).attr('data-tab');
|
||||
valor = $(this).attr('value');
|
||||
console.log(valor);
|
||||
tabsig = parseInt(tabant);
|
||||
tabsig = (tabsig+1);
|
||||
$('#eva'+tabant).removeClass('active');
|
||||
$('#nav'+tabant).removeClass('active');
|
||||
$('#cronometro').val(timer.getTime());
|
||||
//$('#idpregunta'+tabant).attr('disabled',true);
|
||||
if (valor != 'terminar') {
|
||||
$('#eva'+tabsig).tab('show');
|
||||
$('#nav'+tabsig).addClass('active');
|
||||
}else{
|
||||
$('.progress-evaluacion').hide();
|
||||
$('.layer-load').show();
|
||||
}
|
||||
|
||||
});
|
||||
//fin construcción
|
||||
$('layer-load').hide();
|
||||
}else{
|
||||
Swal.fire({
|
||||
html: _data.msg,
|
||||
icon: _data.icon,
|
||||
onBeforeOpen: function () {},
|
||||
onOpen: function () {
|
||||
$('.layer-load').hide();
|
||||
},
|
||||
onRender: function () {},
|
||||
onClose: function () {
|
||||
$('.btn-return').click();
|
||||
},
|
||||
onAfterClose: function () {}
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
error: function() {
|
||||
Swal.fire({
|
||||
html: 'Hubo un error al procesar los datos',
|
||||
icon: 'error',
|
||||
onBeforeOpen: function () {},
|
||||
onOpen: function () {
|
||||
$('.layer-load').hide();
|
||||
},
|
||||
onRender: function () {},
|
||||
onClose: function () {
|
||||
$('.btn-return').click();
|
||||
},
|
||||
onAfterClose: function () {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
//--------------------- COMMIT PROGRESO --------------------------
|
||||
//---------------------------------------------------------------
|
||||
class Commit{
|
||||
constructor(evaluacion,numempleado){
|
||||
this.idestado = '';
|
||||
this.evaluacion = evaluacion;
|
||||
this.numempleado = numempleado;
|
||||
this.estado = 'incomplete';
|
||||
this.calificacion = 0;
|
||||
this.aciertos = 0;
|
||||
this.puntos = 0;
|
||||
this.calificacionletra = 'Sin calificación';
|
||||
this.tiempo = '00:00:00';
|
||||
this.cronometro = '0';
|
||||
this.status = 'init';
|
||||
this.calificacionrequerida = 0;
|
||||
this.numpreguntas = 0;
|
||||
}
|
||||
|
||||
getPuntos(){
|
||||
return this.puntos;
|
||||
}
|
||||
|
||||
getAciertos(){
|
||||
return this.aciertos;
|
||||
}
|
||||
|
||||
postData(estado){
|
||||
this.idestado = estado;
|
||||
this.status = 'push';
|
||||
$('#estado').val(this.idestado);
|
||||
}
|
||||
|
||||
postPoint(puntos,aciertos){
|
||||
this.puntos = parseFloat(puntos);
|
||||
this.aciertos = parseInt(aciertos);
|
||||
}
|
||||
|
||||
postCalificacion(preguntas,calificacionrequerida){
|
||||
this.numpreguntas = preguntas;
|
||||
this.calificacionrequerida = calificacionrequerida;
|
||||
}
|
||||
|
||||
calculate(){
|
||||
this.calificacion = (this.aciertos/this.numpreguntas)*10;
|
||||
|
||||
if (this.calificacion >= this.calificacionrequerida) {
|
||||
this.calificacionletra = 'Aprobado';
|
||||
}else{
|
||||
this.calificacionletra = 'Reprobado';
|
||||
}
|
||||
}
|
||||
|
||||
init(){
|
||||
$.ajax({
|
||||
url: 'evaluaciones/initEvaluacion.php',
|
||||
type:'POST',
|
||||
data:{numempl:this.numempleado,evaluacion:this.evaluacion,estado:this.estado,calificacion:this.calificacion,aciertos:this.aciertos,puntos:this.puntos,calificacionletra:this.calificacionletra,tiempo:this.tiempo,status:this.status,idestado:this.idestado,cronometro:this.cronometro},
|
||||
success: function(respuesta) {
|
||||
var _data = JSON.parse(respuesta);
|
||||
if (_data.code == '200') {
|
||||
$('#estado').val(_data.idestado);
|
||||
|
||||
}else{
|
||||
Swal.fire({
|
||||
html: _data.msg,
|
||||
icon: _data.icon,
|
||||
onBeforeOpen: function () {},
|
||||
onOpen: function () {
|
||||
$('.layer-load').hide();
|
||||
},
|
||||
onRender: function () {},
|
||||
onClose: function () {
|
||||
$('.btn-return').click();
|
||||
},
|
||||
onAfterClose: function () {}
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
Swal.fire({
|
||||
html: 'Hubo un error al procesar los datos',
|
||||
icon: 'error',
|
||||
onBeforeOpen: function () {},
|
||||
onOpen: function () {
|
||||
$('.layer-load').hide();
|
||||
},
|
||||
onRender: function () {},
|
||||
onClose: function () {
|
||||
$('.btn-return').click();
|
||||
},
|
||||
onAfterClose: function () {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
push(tiempo,estado){
|
||||
this.tiempo = tiempo;
|
||||
this.idestado = estado;
|
||||
this.cronometro = timer.getProgress();
|
||||
this.status = 'push';
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
finish(tiempo,estado){
|
||||
this.tiempo = tiempo;
|
||||
this.idestado = estado;
|
||||
this.status = 'finish';
|
||||
this.estado = 'completed';
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
cancel(){
|
||||
this.estado = 'cancel';
|
||||
this.tiempo = timer.getTime();
|
||||
this.init();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
//----------------------- CRONOMETRO ----------------------------
|
||||
//---------------------------------------------------------------
|
||||
class Temporizador {
|
||||
constructor() {
|
||||
this.interval;
|
||||
this.time = '00:00:00';
|
||||
this.limit;
|
||||
this.length;
|
||||
this.aux = 0;
|
||||
this.switch = 60;
|
||||
this.segundos = 0;
|
||||
this.minutos = 0;
|
||||
this.hora = 0;
|
||||
this.formatsegundos = '00';
|
||||
this.formatminutos = '00';
|
||||
this.formathoras = '00';
|
||||
}
|
||||
getTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
getProgress() {
|
||||
return this.aux;
|
||||
}
|
||||
|
||||
postLimit(limit){
|
||||
this.limit = limit;
|
||||
let sec = this.limit*60;
|
||||
this.length = 100/sec;
|
||||
}
|
||||
|
||||
init(limit) {
|
||||
|
||||
this.interval = setInterval(() => {
|
||||
|
||||
if (this.segundos%5 == 0) {
|
||||
commit.push(this.getTime(),$('#estado').val());
|
||||
}
|
||||
|
||||
|
||||
this.segundos++;
|
||||
this.aux;
|
||||
$('.progress-bar').width(this.aux+'%');
|
||||
//console.log(this.aux);
|
||||
this.aux = (this.aux+this.length);
|
||||
|
||||
if (this.segundos == this.switch) {
|
||||
this.minutos++;
|
||||
this.segundos = 0;
|
||||
}
|
||||
|
||||
if (this.minutos == this.switch) {
|
||||
this.hora++;
|
||||
this.minutos = 0;
|
||||
}
|
||||
|
||||
if (this.minutos == this.limit) {
|
||||
alert();
|
||||
}
|
||||
|
||||
|
||||
if (this.segundos <= 9) {
|
||||
this.formatsegundos = '0'+this.segundos;
|
||||
}else{
|
||||
this.formatsegundos = this.segundos;
|
||||
}
|
||||
|
||||
if (this.minutos <= 9) {
|
||||
this.formatminutos = '0'+this.minutos;
|
||||
}else{
|
||||
this.formatminutos = this.minutos;
|
||||
}
|
||||
|
||||
if (this.hora <= 0) {
|
||||
this.formathoras = '0'+this.hora;
|
||||
}else{
|
||||
this.formathoras = this.hora;
|
||||
}
|
||||
|
||||
this.time = this.formathoras+':'+this.formatminutos+':'+this.formatsegundos;
|
||||
$('._time').html(this.time);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
reload(tiempo,cronometro) {
|
||||
var str = tiempo;
|
||||
var res = str.split(":");
|
||||
let horaint = parseInt(res[0]);
|
||||
let minutosint = parseInt(res[1]);
|
||||
let segundosint = parseInt(res[2]);
|
||||
|
||||
this.hora = horaint;
|
||||
this.minutos = minutosint;
|
||||
this.segundos = segundosint;
|
||||
this.aux = parseInt(cronometro);
|
||||
this.time = tiempo;
|
||||
}
|
||||
|
||||
stop() {
|
||||
console.log('stop');
|
||||
clearInterval(this.interval)
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
//------- RESULTADO DE EVALUACIONES APLICADAS -------------------
|
||||
//---------------------------------------------------------------
|
||||
function resultados(data){
|
||||
$('.table-data tbody').empty();
|
||||
|
||||
if (data.aplicado >= 1) {
|
||||
|
||||
$.each(data.datos, function (k, col) {
|
||||
|
||||
let estado;
|
||||
//console.log(col[5]);
|
||||
switch(col[5]) {
|
||||
case 'completed':
|
||||
estado = 'Completado';
|
||||
$('#btn_init').html('Comenzar evaluación');
|
||||
$('#btn_init').attr('data-mode','new');
|
||||
break;
|
||||
case 'cancel':
|
||||
estado = 'Cancelado por limite de tiempo';
|
||||
$('#btn_init').html('Comenzar evaluación');
|
||||
$('#btn_init').attr('data-mode','new');
|
||||
break;
|
||||
case 'incomplete':
|
||||
$('#btn_init').html('Continuar evaluación');
|
||||
$('#btn_init').attr('data-mode','recove');
|
||||
timer.reload(col[3],col[4]);
|
||||
commit.postData(col[0]);
|
||||
//$('#aciertos').val(col[7]);
|
||||
//$('#puntos').val(col[8]);
|
||||
commit.postPoint(col[8],col[7]);
|
||||
estado = 'No completado';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (col[2] == 'Aprobado') {
|
||||
$('.constancia-evaluacion').show();
|
||||
column = '<tr class="table-success">'+
|
||||
'<td >'+col[1]+'</td>'+
|
||||
'<td >'+col[2]+'</td>'+
|
||||
'<td >'+col[3]+'</td>'+
|
||||
'<td >'+estado+'</td>'+
|
||||
'<td >'+col[6]+'</td>'+
|
||||
'</tr>';
|
||||
}else if(col[2] == 'Reprobado'){
|
||||
column = '<tr class="table-danger">'+
|
||||
'<td >'+col[1]+'</td>'+
|
||||
'<td >'+col[2]+'</td>'+
|
||||
'<td >'+col[3]+'</td>'+
|
||||
'<td >'+estado+'</td>'+
|
||||
'<td >'+col[6]+'</td>'+
|
||||
'</tr>';
|
||||
}else{
|
||||
column = '<tr>'+
|
||||
'<td >'+col[1]+'</td>'+
|
||||
'<td >'+col[2]+'</td>'+
|
||||
'<td >'+col[3]+'</td>'+
|
||||
'<td >'+estado+'</td>'+
|
||||
'<td >'+col[6]+'</td>'+
|
||||
'</tr>';
|
||||
}
|
||||
|
||||
$(".table-data tbody").append(column);
|
||||
});
|
||||
$('.result-evaluacion').show();
|
||||
}else{
|
||||
$('#btn_init').attr('mode','new');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
//--------------------- SEND PREGUNTA ---------------------------
|
||||
//---------------------------------------------------------------
|
||||
function alert(){
|
||||
Swal.fire({
|
||||
html: 'Se ha agotado el tiempo para completar la evaluación',
|
||||
icon: 'warning',
|
||||
onBeforeOpen: function () {},
|
||||
onOpen: function () {
|
||||
commit.cancel();
|
||||
timer.stop();
|
||||
},
|
||||
onRender: function () {},
|
||||
onClose: function () {
|
||||
location.reload();
|
||||
},
|
||||
onAfterClose: function () {}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------
|
||||
//--------------------- SEND PREGUNTA ---------------------------
|
||||
//---------------------------------------------------------------
|
||||
$(".formcontroller").validate({
|
||||
submitHandler: function (form) {
|
||||
$('.layer-load').show();
|
||||
|
||||
var controller = 'evaluaciones/saveEvaluacion.php';
|
||||
$.ajax({
|
||||
url: controller,
|
||||
type: 'POST',
|
||||
data: $(".formcontroller").serializeArray(),
|
||||
})
|
||||
.done(function (response) {
|
||||
var _data = JSON.parse(response);
|
||||
|
||||
if (_data.code == '200') {
|
||||
var tabsig;
|
||||
var tabant;
|
||||
$(".nav-link").each(function() {
|
||||
if($(this).hasClass('active')){
|
||||
tabsig = $(this).attr('data-nav');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (retro == 'Activado'){
|
||||
var html = '';
|
||||
var icon = '';
|
||||
if (_data.acertadas == true) {
|
||||
html = 'Respuesta correcta';
|
||||
icon = 'success';
|
||||
}else{
|
||||
html = 'Respuesta incorrecta';
|
||||
icon = 'error';
|
||||
}
|
||||
|
||||
|
||||
Swal.fire({
|
||||
html: html,
|
||||
icon: icon,
|
||||
onBeforeOpen: function () {},
|
||||
onOpen: function () {
|
||||
$('.layer-load').hide();
|
||||
},
|
||||
onRender: function () {},
|
||||
onClose: function () {
|
||||
if (_data.section == 'terminar') {
|
||||
$('.layer-load').hide();
|
||||
timer.stop();
|
||||
let puntos = (parseFloat(commit.getPuntos())+parseFloat(_data.puntos));
|
||||
let aciertos = (parseInt(commit.getAciertos())+parseInt(_data.aciertos));
|
||||
commit.postPoint(puntos,aciertos);
|
||||
commit.push(timer.getTime(),$('#estado').val());
|
||||
commit.calculate();
|
||||
commit.finish(timer.getTime(),$('#estado').val());
|
||||
|
||||
setTimeout(function(){ location.reload(); }, 1000);
|
||||
}else{
|
||||
tabant = parseInt(tabsig)-1;
|
||||
$('#idpregunta'+tabant).attr('disabled',true);
|
||||
$('#answerseva'+tabant+' input').attr('disabled',true);
|
||||
$('#idpregunta'+tabsig).attr('disabled',false);
|
||||
$('#scorepregunta'+tabsig).attr('disabled',false);
|
||||
$('#type'+tabsig).attr('disabled',false);
|
||||
let puntos = (parseFloat(commit.getPuntos())+parseFloat(_data.puntos));
|
||||
let aciertos = (parseInt(commit.getAciertos())+parseInt(_data.aciertos));
|
||||
commit.postPoint(puntos,aciertos);
|
||||
commit.push(timer.getTime(),$('#estado').val());
|
||||
$('.layer-load').hide();
|
||||
}
|
||||
},
|
||||
onAfterClose: function () {}
|
||||
});
|
||||
}else{
|
||||
if (_data.section == 'terminar') {
|
||||
$('.layer-load').hide();
|
||||
timer.stop();
|
||||
let puntos = (parseFloat(commit.getPuntos())+parseFloat(_data.puntos));
|
||||
let aciertos = (parseInt(commit.getAciertos())+parseInt(_data.aciertos));
|
||||
commit.postPoint(puntos,aciertos);
|
||||
commit.push(timer.getTime(),$('#estado').val());
|
||||
commit.calculate();
|
||||
commit.finish(timer.getTime(),$('#estado').val());
|
||||
|
||||
setTimeout(function(){ location.reload(); }, 1000);
|
||||
}else{
|
||||
tabant = parseInt(tabsig)-1;
|
||||
$('#idpregunta'+tabant).attr('disabled',true);
|
||||
$('#answerseva'+tabant+' input').attr('disabled',true);
|
||||
$('#idpregunta'+tabsig).attr('disabled',false);
|
||||
$('#scorepregunta'+tabsig).attr('disabled',false);
|
||||
$('#type'+tabsig).attr('disabled',false);
|
||||
let puntos = (parseFloat(commit.getPuntos())+parseFloat(_data.puntos));
|
||||
let aciertos = (parseInt(commit.getAciertos())+parseInt(_data.aciertos));
|
||||
commit.postPoint(puntos,aciertos);
|
||||
commit.push(timer.getTime(),$('#estado').val());
|
||||
$('.layer-load').hide();
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
Swal.fire({
|
||||
html: _data.msg,
|
||||
icon: _data.icon,
|
||||
onBeforeOpen: function () {},
|
||||
onOpen: function () {},
|
||||
onRender: function () {},
|
||||
onClose: function () {},
|
||||
onAfterClose: function () {}
|
||||
});
|
||||
}
|
||||
})
|
||||
.fail(function () {
|
||||
Swal.fire({
|
||||
html: 'Hubo un error al procesar los datos',
|
||||
icon: 'error',
|
||||
onBeforeOpen: function () {},
|
||||
onOpen: function () {
|
||||
$('.layer-load').hide();
|
||||
},
|
||||
onRender: function () {},
|
||||
onClose: function () {
|
||||
$('.btn-return').click();
|
||||
},
|
||||
onAfterClose: function () {}
|
||||
});
|
||||
})
|
||||
.always(function () {
|
||||
//console.log("complete");
|
||||
});
|
||||
},
|
||||
rules: {
|
||||
idencuesta: {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
getEvaluacion($('#idevaluacion').val(),$('#numerodeempleado').val());
|
||||
const timer = new Temporizador();
|
||||
const commit = new Commit($('#idevaluacion').val(),$('#numerodeempleado').val());
|
||||
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
error_reporting(0);
|
||||
require_once "../config.php";
|
||||
|
||||
$idevaluacion = $_POST['evaluacion'];
|
||||
$numempl = $_POST['numempl'];
|
||||
|
||||
$sqlEstado = "SELECT
|
||||
*
|
||||
FROM
|
||||
evaluaciones_estado AS ee
|
||||
WHERE
|
||||
ee.idevaluacion = $idevaluacion AND ee.numempl = '$numempl'";
|
||||
|
||||
|
||||
global $link;
|
||||
dbConnect();
|
||||
$return = new stdClass();
|
||||
|
||||
if($resultEstado = mysqli_query($link, $sqlEstado)){
|
||||
while ($row = mysqli_fetch_assoc($resultEstado)){
|
||||
$return->progreso = $row;
|
||||
}
|
||||
$return->code = "200";
|
||||
}else{
|
||||
$return->code = "400";
|
||||
$return->icon = "error";
|
||||
$return->msg = "No se pudieron cargar los datos de la evaluación intenta más tarde.";
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo json_encode($return, JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
error_reporting(0);
|
||||
require_once "../config.php";
|
||||
require_once "../runtime/mencrypt.php";
|
||||
|
||||
$idevaluacion = $desencriptar($_POST['idevaluacion']);
|
||||
$numempl = $_POST['numempl'];
|
||||
$progreso = [];
|
||||
|
||||
$sql="SELECT
|
||||
e.idevaluacion,
|
||||
e.categoria,
|
||||
e.titulo,
|
||||
e.descripcion,
|
||||
e.instrucciones,
|
||||
e.tipointentos,
|
||||
e.intentos,
|
||||
e.tipotiempo,
|
||||
e.tiempo,
|
||||
e.calificacion,
|
||||
e.tipopreguntas,
|
||||
e.retroalimentacion,
|
||||
COUNT(ep.idpregunta) AS preguntas
|
||||
FROM
|
||||
evaluaciones AS e
|
||||
INNER JOIN evaluaciones_preguntas AS ep ON ep.idevaluacion = e.idevaluacion
|
||||
WHERE
|
||||
e.idevaluacion = $idevaluacion AND ep.habilitado = 1";
|
||||
|
||||
|
||||
$sqlEstado = "SELECT
|
||||
ee.idevaestado,
|
||||
ee.calificacion,
|
||||
ee.calificacionletra as aprobado,
|
||||
ee.tiempo as tiempo,
|
||||
ee.cronometro,
|
||||
ee.estado,
|
||||
ee.creacion as fecha,
|
||||
ee.correctas,
|
||||
ee.puntos
|
||||
FROM
|
||||
evaluaciones_estado AS ee
|
||||
WHERE
|
||||
ee.idevaluacion = $idevaluacion AND ee.numempl = '$numempl'";
|
||||
|
||||
global $link;
|
||||
dbConnect();
|
||||
$return = new stdClass();
|
||||
|
||||
if($result = mysqli_query($link, $sql)){
|
||||
while ($row = mysqli_fetch_assoc($result)){
|
||||
$return->datos = $row;
|
||||
}
|
||||
$return->codeDatos = "200";
|
||||
}else{
|
||||
$return->codeDatos = "400";
|
||||
$return->iconDatos = "error";
|
||||
$return->msgDatos ="No se pudieron cargar los datos de la evaluación intenta más tarde.";
|
||||
}
|
||||
|
||||
if($resultEstado = mysqli_query($link, $sqlEstado)){
|
||||
|
||||
while ($row = mysqli_fetch_assoc ($resultEstado)){
|
||||
$columns = array_keys($row);
|
||||
}
|
||||
|
||||
mysqli_data_seek($resultEstado, 0);
|
||||
while ($row = mysqli_fetch_row ($resultEstado)){
|
||||
$progreso[] = $row;
|
||||
}
|
||||
$return->progreso['aplicado'] = sizeof($progreso);
|
||||
$return->progreso['columnas'] = $columns;
|
||||
$return->progreso['datos'] = $progreso;
|
||||
$return->codeEstado = "200";
|
||||
}else{
|
||||
$return->codeEstado = "400";
|
||||
$return->iconEstado = "error";
|
||||
$return->msgEstado = "No se pudieron cargar los datos de la evaluación intenta más tarde.";
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo json_encode($return, JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
error_reporting(0);
|
||||
require_once "../config.php";
|
||||
require_once "../runtime/mencrypt.php";
|
||||
|
||||
$idevaluacion = $desencriptar($_POST['evaluacion']);
|
||||
$numempl = $_POST['numempl'];
|
||||
$mode = $_POST['mode'];
|
||||
$orden= $_POST['orden'];
|
||||
|
||||
|
||||
global $link;
|
||||
dbConnect();
|
||||
$return = new stdClass();
|
||||
$sql = "";
|
||||
|
||||
if ($mode == 'new') {
|
||||
$sql.="SELECT
|
||||
ep.idpregunta,
|
||||
ep.idevaluacion,
|
||||
ep.titulo,
|
||||
ep.descripcion,
|
||||
ep.puntos,
|
||||
ep.tipo,
|
||||
ep.orden
|
||||
FROM
|
||||
evaluaciones_preguntas as ep
|
||||
WHERE
|
||||
ep.habilitado = 1 AND ep.idevaluacion = $idevaluacion";
|
||||
}else{
|
||||
$sql.="SELECT
|
||||
*
|
||||
FROM evaluaciones_preguntas as ep
|
||||
WHERE
|
||||
ep.idpregunta NOT IN (
|
||||
SELECT er.idpregunta
|
||||
FROM evaluaciones_estado as ee
|
||||
INNER JOIN evaluaciones_respuestas as er ON er.idestado = ee.idevaestado
|
||||
WHERE ee.numempl = '$numempl' AND ee.idevaluacion = $idevaluacion AND ee.estado = 'incomplete'
|
||||
ORDER BY er.idpregunta ASC
|
||||
)
|
||||
AND
|
||||
ep.habilitado = 1";
|
||||
}
|
||||
|
||||
if ($orden == 'Aleatorio') {
|
||||
$sql .= " ORDER BY RAND()";
|
||||
}else{
|
||||
$sql .= " ORDER BY ep.orden ASC";
|
||||
}
|
||||
|
||||
|
||||
if($result = mysqli_query($link, $sql)){
|
||||
if ( mysqli_num_rows($result) <= 0 ) {
|
||||
$return->code = "300";
|
||||
$return->icon = "warning";
|
||||
$return->msg ="No se encontraron preguntas vigentes para esta evaluación, intente más tarde.";
|
||||
}else{
|
||||
while ($row = mysqli_fetch_assoc($result)){
|
||||
$questions[] = $row;
|
||||
}
|
||||
|
||||
$alerts = [];
|
||||
$totalPreguntasRespuestas = 0;
|
||||
|
||||
foreach ($questions as $key => $q) {
|
||||
$answers = [];
|
||||
$sqlAns = "SELECT
|
||||
*
|
||||
FROM
|
||||
evaluaciones_opciones as eo
|
||||
WHERE
|
||||
eo.idpregunta = ".$q['idpregunta']." AND eo.habilitado = 1
|
||||
ORDER BY RAND()";
|
||||
|
||||
if($resultAns = mysqli_query($link, $sqlAns)){
|
||||
if ( mysqli_num_rows($resultAns) <= 0) {
|
||||
array_push($alerts, "Sin respuestas");
|
||||
$answers = [];
|
||||
}else{
|
||||
$totalPreguntasRespuestas++;
|
||||
while ($row = mysqli_fetch_assoc($resultAns)){
|
||||
$answers[] = $row;
|
||||
}
|
||||
}
|
||||
$questions[$key]['respuestas'] = $answers;
|
||||
}else{
|
||||
$return->code = "300";
|
||||
$return->icon = "warning";
|
||||
$return->msg="Sin respuestas";
|
||||
array_push($alerts, "Consulta fallo! SQL: ".$sqlAns."<br><br> Error: ".mysqli_error($link));
|
||||
}
|
||||
}
|
||||
|
||||
if ($totalPreguntasRespuestas == sizeof($questions)) {
|
||||
$return->preguntas = $questions;
|
||||
$return->code = "200";
|
||||
$return->icon = "success";
|
||||
$return->msg="Evaluaciones";
|
||||
}else{
|
||||
$return->code = "300";
|
||||
$return->icon = "error";
|
||||
$return->msg="Ocurrio un error al recuperar las respuestas";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$return->code = "400";
|
||||
$return->icon = "error";
|
||||
$return->msg ="No se pudieron cargar los datos de la evaluación intenta más tarde.";
|
||||
}
|
||||
|
||||
echo json_encode($return, JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
?>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
//error_reporting(0);
|
||||
require_once "../config.php";
|
||||
require_once "../runtime/mencrypt.php";
|
||||
|
||||
global $link;
|
||||
dbConnect();
|
||||
$return = new stdClass();
|
||||
|
||||
|
||||
$idevaluacion = $desencriptar($_POST['evaluacion']);
|
||||
$numempl = $_POST['numempl'];
|
||||
$estado = $_POST['estado'];
|
||||
$calificacion = $_POST['calificacion'];
|
||||
$aciertos = $_POST['aciertos'];
|
||||
$puntos = $_POST['puntos'];
|
||||
$calificacionletra = $_POST['calificacionletra'];
|
||||
$tiempo = $_POST['tiempo'];
|
||||
$cronometro = $_POST['cronometro'];
|
||||
$status = $_POST['status'];
|
||||
$idestado = $_POST['idestado'];
|
||||
|
||||
if ($status == 'init') {
|
||||
$sql = "INSERT INTO evaluaciones_estado(numempl,idevaluacion,estado,calificacion,correctas,puntos,calificacionletra,tiempo,cronometro) VALUES ($numempl,$idevaluacion,'$estado',$calificacion,$aciertos, '$puntos','$calificacionletra','$tiempo','$cronometro')";
|
||||
|
||||
if($result = mysqli_query($link, $sql)){
|
||||
$return->idestado = mysqli_insert_id($link);
|
||||
$return->code = '200';
|
||||
$return->icon = 'success';
|
||||
$return->msg = 'commit';
|
||||
}else{
|
||||
$return->code = '400';
|
||||
$return->icon = 'error';
|
||||
$return->msg = 'No se ha podido iniciar la evaluación';
|
||||
$return->debug = 'Consulta fallo! SQL: '.$sql.'<br><br> Error: '.mysqli_error($link);
|
||||
}
|
||||
}
|
||||
|
||||
if ($status == 'push') {
|
||||
$sql = "UPDATE evaluaciones_estado SET tiempo = '$tiempo', cronometro = '$cronometro', estado = '$estado', correctas = $aciertos, puntos = '$puntos' WHERE idevaestado = $idestado ";
|
||||
|
||||
if($result = mysqli_query($link, $sql)){
|
||||
$return->idestado = $idestado;
|
||||
$return->code = '200';
|
||||
$return->icon = 'success';
|
||||
$return->msg = 'commit';
|
||||
}else{
|
||||
$return->code = '400';
|
||||
$return->icon = 'error';
|
||||
$return->msg = 'No se ha podido iniciar la evaluación';
|
||||
$return->debug = 'Consulta fallo! SQL: '.$sql.'<br><br> Error: '.mysqli_error($link);
|
||||
}
|
||||
}
|
||||
|
||||
if ($status == 'finish') {
|
||||
$sql = "UPDATE evaluaciones_estado SET tiempo = '$tiempo', estado = '$estado', calificacion = $calificacion, calificacionletra = '$calificacionletra' WHERE idevaestado = $idestado ";
|
||||
|
||||
if($result = mysqli_query($link, $sql)){
|
||||
$return->idestado = $idestado;
|
||||
$return->code = '200';
|
||||
$return->icon = 'success';
|
||||
$return->msg = 'commit';
|
||||
}else{
|
||||
$return->code = '400';
|
||||
$return->icon = 'error';
|
||||
$return->msg = 'No se ha podido iniciar la evaluación';
|
||||
$return->debug = 'Consulta fallo! SQL: '.$sql.'<br><br> Error: '.mysqli_error($link);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
echo json_encode($return, JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
?>
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
//error_reporting(0);
|
||||
require_once "../config.php";
|
||||
require_once "../runtime/mencrypt.php";
|
||||
|
||||
global $link;
|
||||
dbConnect();
|
||||
$return = new stdClass();
|
||||
$respuesta = [];
|
||||
|
||||
$idevaluacion = $desencriptar($_POST['idevaluacion']);
|
||||
$idpregunta = $_POST['idpregunta'];
|
||||
$respuesta = $_POST['answers'.$idpregunta];
|
||||
$puntos = $_POST['scorepregunta'];
|
||||
$type = $_POST['type'];
|
||||
$estado = $_POST['estado'];
|
||||
$tiempo = $_POST['cronometro'];
|
||||
$numempl = $_POST['numerodeempleado'];
|
||||
$btn = $_POST['btnSave'];
|
||||
$return->section = $btn;
|
||||
|
||||
|
||||
$contador = 0;
|
||||
foreach ($respuesta as $key => $val) {
|
||||
if($type == 'textarea'){
|
||||
$sql = "INSERT INTO evaluaciones_respuestas(idestado, idevaluacion, numempl, idpregunta, texto, tiempo) VALUES ($estado,$idevaluacion,'$numempl',$idpregunta,'$val','$tiempo')";
|
||||
}else{
|
||||
$sql = "INSERT INTO evaluaciones_respuestas(idestado, idevaluacion, numempl, idpregunta, idopcion, tiempo) VALUES ($estado,$idevaluacion,'$numempl',$idpregunta,$val,'$tiempo')";
|
||||
}
|
||||
|
||||
if($result = mysqli_query($link, $sql)){
|
||||
$contador++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($contador == sizeof($respuesta)){
|
||||
|
||||
|
||||
$correct = false;
|
||||
$aciertos = 0;
|
||||
$sqlrespuestascorrectas = "SELECT
|
||||
ep.tipo,
|
||||
eo.idopcion,
|
||||
eo.respuesta,
|
||||
eo.texto
|
||||
FROM
|
||||
evaluaciones_preguntas as ep
|
||||
INNER JOIN evaluaciones_opciones as eo ON eo.idpregunta = ep.idpregunta
|
||||
WHERE
|
||||
ep.habilitado = 1 AND ep.idpregunta = $idpregunta AND eo.habilitado = 1 AND eo.respuesta = 1";
|
||||
|
||||
if($result = mysqli_query($link, $sqlrespuestascorrectas)){
|
||||
while ($row = mysqli_fetch_assoc($result)){
|
||||
$answers[] = $row;
|
||||
}
|
||||
}else{
|
||||
$return->debug = 'Consulta fallo! SQL: '.$sqlrespuestascorrectas.'<br><br> Error: '.mysqli_error($link);
|
||||
}
|
||||
|
||||
$answer = sizeof($answers);
|
||||
|
||||
sort($respuesta);
|
||||
|
||||
if ($type == 'radio' || $type == 'checkbox') {
|
||||
if ($contador == $answer) {
|
||||
foreach ($answers as $key => $val) {
|
||||
|
||||
if ($val['idopcion'] == $respuesta[$key]) {
|
||||
$correct = true;
|
||||
}else{
|
||||
$correct = false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$correct = false;
|
||||
}
|
||||
}else if($type == 'textarea'){
|
||||
foreach ($answers as $key => $val) {
|
||||
$return->texto = $respuesta[0];
|
||||
if ($val['texto'] == $respuesta[0]) {
|
||||
$correct = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($correct == true) {
|
||||
$aciertos = 1;
|
||||
}else{
|
||||
$puntos = 0;
|
||||
}
|
||||
|
||||
|
||||
$return->acertadas = $correct;
|
||||
$return->aciertos = $aciertos;
|
||||
$return->puntos = $puntos;
|
||||
$return->code = '200';
|
||||
$return->msg = 'Guardado';
|
||||
}else{
|
||||
$return->code = '400';
|
||||
$return->icon = 'error';
|
||||
$return->msg = 'No se pudo guardar la respuesta guardada';
|
||||
$return->debug = 'Consulta fallo! SQL: '.$sql.'<br><br> Error: '.mysqli_error($link);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($btn == 'terminar') {
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
evaluaciones_estado as ee
|
||||
WHERE
|
||||
ee.estado = 'incomplete' AND ee.numempl = '10101010' AND ee.idevaluacion = 12";
|
||||
|
||||
if($result = mysqli_query($link, $sql)){
|
||||
if ( mysqli_num_rows($result) <= 0 ) {
|
||||
$return->calificacion = 0;
|
||||
}else{
|
||||
while ($row = mysqli_fetch_assoc($result)){
|
||||
$final[] = $row;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$return->debugrespuestas = 'Consulta fallo! SQL: '.$sql.'<br><br> Error: '.mysqli_error($link);
|
||||
}
|
||||
|
||||
$return->estado = $final;
|
||||
}
|
||||
|
||||
|
||||
echo json_encode($return, JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
?>
|
||||
Reference in New Issue
Block a user