49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
require_once __DIR__.'/auth_guard.php';
|
||
|
|
error_reporting(0);
|
||
|
|
require_once "../config.php";
|
||
|
|
|
||
|
|
$idevaluacion = $_POST['idevaluacion-options'];
|
||
|
|
$titulo = $_POST['pregunta'];
|
||
|
|
$desc = $_POST['desc_pregunta'];
|
||
|
|
$puntos = $_POST['puntos'];
|
||
|
|
$tipo = $_POST['tipo_p'];
|
||
|
|
$habilitado = $_POST['habilitado-options'];
|
||
|
|
$idpregunta;
|
||
|
|
global $link;
|
||
|
|
dbConnect();
|
||
|
|
$return = new stdClass();
|
||
|
|
|
||
|
|
|
||
|
|
$sqlCount = "SELECT
|
||
|
|
COUNT(*) as num
|
||
|
|
FROM
|
||
|
|
evaluaciones_preguntas
|
||
|
|
WHERE
|
||
|
|
habilitado = 1";
|
||
|
|
|
||
|
|
$resultCount = mysqli_query($link, $sqlCount);
|
||
|
|
|
||
|
|
while ($row = mysqli_fetch_assoc ($resultCount)){
|
||
|
|
$orden = $row['num'];
|
||
|
|
}
|
||
|
|
|
||
|
|
$orden = ($orden+1);
|
||
|
|
|
||
|
|
$sql = "INSERT INTO evaluaciones_preguntas (idevaluacion,titulo,descripcion,puntos,orden,tipo,habilitado) VALUES ($idevaluacion,'$titulo','$desc',$puntos, $orden,'$tipo',$habilitado)";
|
||
|
|
|
||
|
|
if($result = mysqli_query($link, $sql)){
|
||
|
|
$idpregunta = mysqli_insert_id($link);
|
||
|
|
$return->pregunta = $idpregunta;
|
||
|
|
$return->code = "200";
|
||
|
|
$return->icon = "success";
|
||
|
|
$return->msg = "Pregunta registrada exitosamente";
|
||
|
|
}else{
|
||
|
|
$return->code = "400";
|
||
|
|
$return->icon = "error";
|
||
|
|
$return->msg = "Consulta fallo! SQL: ".$sql."<br><br> Error: ".mysqli_error($link);
|
||
|
|
}
|
||
|
|
|
||
|
|
echo json_encode($return, JSON_UNESCAPED_UNICODE);
|
||
|
|
exit;
|
||
|
|
?>
|