remove cuestionario from all project. answers validated, time error reports
This commit is contained in:
@@ -66,19 +66,43 @@ const getOld = async (body) => {
|
||||
|
||||
|
||||
const get = async (body) => {
|
||||
const version = body.version
|
||||
|
||||
const year = validarNumero(body.year, 'año', true, 4);
|
||||
const path = `server/uploads/${year}_cuestionario_programa.csv`;
|
||||
const data = [];
|
||||
|
||||
let temp
|
||||
|
||||
if(version == 'v1'){
|
||||
|
||||
return CuestionarioPrograma2.findAll({
|
||||
temp = CuestionarioPrograma.findAll({
|
||||
where: {
|
||||
idCuestionarioPrograma2: {
|
||||
idCuestionarioPrograma: {
|
||||
[Op.not]: null,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(version == 'v2'){
|
||||
|
||||
temp = CuestionarioPrograma2.findAll({
|
||||
where: {
|
||||
idCuestionarioPrograma2: {
|
||||
[Op.not]: null,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return temp
|
||||
|
||||
.then(async (res) => {
|
||||
console.log("segunda parte", res);
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
|
||||
const CuestionarioPrograma2 = require(`${dbPath}/CuestionarioPrograma2`);
|
||||
const Cuestionario = require(`${dbPath}/Cuestionario`);
|
||||
|
||||
|
||||
|
||||
@@ -88,7 +87,7 @@ const nuevo = async (body) => {
|
||||
// console.log(body);
|
||||
|
||||
let idServicio = body.idServicio;
|
||||
body = validar.validarCuestionarioAlumno2(body);
|
||||
body = validar.validarCuestionarioPrograma2(body);
|
||||
|
||||
/*
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
@@ -101,12 +100,12 @@ const nuevo = async (body) => {
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then(async (res) => {
|
||||
if (!res) throw new Error('No existe este Servicio Social.');
|
||||
/* if (res.idCuestionarioAlumno)
|
||||
if (res.idCuestionarioPrograma2)
|
||||
throw new Error(
|
||||
'Este Servicio Social ya cuenta con cuestionario de programa'
|
||||
); */
|
||||
);
|
||||
|
||||
console.log('el servicio social si existe');
|
||||
console.log('el servicio social si existe', res);
|
||||
// console.log(res);
|
||||
|
||||
/**
|
||||
@@ -133,14 +132,14 @@ const nuevo = async (body) => {
|
||||
|
||||
// if (res.idStatus) return CuestionarioPrograma2.create({ ...body });
|
||||
// si idStatus está en el objeto, arrojamos el mensaje
|
||||
/* if (messageByStatus.hasOwnProperty(res.idStatus))
|
||||
throw new Error(messageByStatus[res.idStatus]); */
|
||||
if (messageByStatus.hasOwnProperty(res.idStatus))
|
||||
throw new Error(messageByStatus[res.idStatus]);
|
||||
// throw new Error('Id status no valido.'); // si no coincide con nada, error por defecto
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
let dataCuestionario = await Cuestionario.findOne({
|
||||
where: { idServicio, dirigidoA: 'programas' },
|
||||
});
|
||||
@@ -150,9 +149,6 @@ const nuevo = async (body) => {
|
||||
throw new Error('Ya existe un cuestionario para este servicio social');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
let cuestionarioRegistro = await Cuestionario.create({
|
||||
idServicio,
|
||||
//idCuestionarioPrograma: respuestasRegistradas.idCuestionarioPrograma,
|
||||
@@ -164,15 +160,16 @@ const nuevo = async (body) => {
|
||||
});
|
||||
|
||||
console.log('cuestionario registrado', cuestionarioRegistro);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// falta verificar que tenga solo un cuestionario
|
||||
|
||||
|
||||
|
||||
let respuestasRegistradas = await CuestionarioPrograma2.create({
|
||||
...body,
|
||||
idCuestionario: cuestionarioRegistro.idCuestionario
|
||||
});
|
||||
|
||||
console.log('despues de registrar cuestionario', respuestasRegistradas);
|
||||
@@ -194,7 +191,7 @@ const nuevo = async (body) => {
|
||||
|
||||
|
||||
|
||||
return cuestionarioRegistro;
|
||||
return respuestasRegistradas;
|
||||
})
|
||||
|
||||
.then((res) => validar.validarPreTermino(idServicio))
|
||||
|
||||
Reference in New Issue
Block a user