chore: version inicial del codigo fuente del LMS Estafeta
This commit is contained in:
@@ -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