remove cuestionario from all project. answers validated, time error reports
This commit is contained in:
@@ -84,19 +84,37 @@ const getOld = async (body) => {
|
||||
const get = async (body) => {
|
||||
console.log(body);
|
||||
|
||||
const version = body.version
|
||||
const year = validarNumero(body.year, 'año', true, 4);
|
||||
const path = `server/uploads/${year}_cuestionario_alumno.csv`;
|
||||
const data = [];
|
||||
|
||||
console.log(year);
|
||||
let temp
|
||||
|
||||
return CuestionarioAlumno2.findAll({
|
||||
if(version == 'v1'){
|
||||
temp = CuestionarioAlumno.findAll({
|
||||
where: {
|
||||
idCuestionarioAlumno: {
|
||||
[Op.not]: null,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
if(version == 'v2'){
|
||||
temp = CuestionarioAlumno2.findAll({
|
||||
where: {
|
||||
idCuestionarioAlumno2: {
|
||||
[Op.not]: null,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
return temp
|
||||
.then(async (res) => {
|
||||
console.log('segunda parte', res);
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
|
||||
const CuestionarioAlumno2 = require(`${dbPath}/CuestionarioAlumno2`);
|
||||
const Cuestionario = require(`${dbPath}/Cuestionario`);
|
||||
|
||||
|
||||
const nuevoOld = async (body) => {
|
||||
@@ -187,12 +186,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.idCuestionarioAlumno2)
|
||||
throw new Error(
|
||||
'Este Servicio Social ya cuenta con cuestionario de alumno'
|
||||
);
|
||||
*/
|
||||
|
||||
|
||||
console.log('el servicio social si existe');
|
||||
// console.log(res);
|
||||
@@ -223,24 +222,24 @@ const nuevo = async (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
|
||||
|
||||
// Cuestionario.findOne({});
|
||||
|
||||
let dataCuestionario = await Cuestionario.findOne({
|
||||
/* let dataCuestionario = await Cuestionario.findOne({
|
||||
where: { idServicio, dirigidoA: 'estudiantes' },
|
||||
});
|
||||
console.log('data cuestionario', dataCuestionario);
|
||||
|
||||
if (dataCuestionario) {
|
||||
throw new Error('Ya existe un cuestionario para este servicio social');
|
||||
}
|
||||
} */
|
||||
|
||||
|
||||
let cuestionarioRegistro = await Cuestionario.create({
|
||||
/* let cuestionarioRegistro = await Cuestionario.create({
|
||||
idServicio,
|
||||
// idCuestionarioAlumno: respuestasRegistradas.idCuestionarioAlumno,
|
||||
version: '2',
|
||||
@@ -248,14 +247,13 @@ const nuevo = async (body) => {
|
||||
titulo: 'Cuestionario de Alumn v2',
|
||||
desc: 'Cuestionario de Alumno v2',
|
||||
createdAt: new Date(),
|
||||
});
|
||||
}); */
|
||||
|
||||
|
||||
console.log("datos a registrar en la tabla cuestionarioAlumno2", { ...body, idCuestionario: cuestionarioRegistro.idCuestionario } );
|
||||
console.log("datos a registrar en la tabla cuestionarioAlumno2", { ...body} );
|
||||
|
||||
let respuestasRegistradas = await CuestionarioAlumno2.create({ ...body, idCuestionario: cuestionarioRegistro.idCuestionario });
|
||||
let respuestasRegistradas = await CuestionarioAlumno2.create({ ...body });
|
||||
console.log('despues de registrar cuestionario', respuestasRegistradas);
|
||||
console.log('cuestionario registrado', cuestionarioRegistro);
|
||||
|
||||
|
||||
|
||||
@@ -271,7 +269,7 @@ console.log("datos a registrar en la tabla cuestionarioAlumno2", { ...body, idC
|
||||
|
||||
|
||||
|
||||
return cuestionarioRegistro;
|
||||
return respuestasRegistradas;
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -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