tablas y controllers actualizados de cuestionarios
This commit is contained in:
@@ -168,11 +168,10 @@ const nuevoOld = async (body) => {
|
||||
|
||||
|
||||
|
||||
|
||||
const nuevo = async (body) => {
|
||||
// console.log(body);
|
||||
|
||||
let idServicio = body.idServicio;
|
||||
let idServicio = body.idServicio;
|
||||
/*
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
@@ -229,7 +228,7 @@ const nuevo = async (body) => {
|
||||
|
||||
// throw new Error('Id status no valido.'); // si no coincide con nada, error por defecto
|
||||
|
||||
Cuestionario.findOne({});
|
||||
// Cuestionario.findOne({});
|
||||
|
||||
let dataCuestionario = await Cuestionario.findOne({
|
||||
where: { idServicio, dirigidoA: 'estudiantes' },
|
||||
@@ -240,12 +239,10 @@ const nuevo = async (body) => {
|
||||
throw new Error('Ya existe un cuestionario para este servicio social');
|
||||
}
|
||||
|
||||
let respuestasRegistradas = await CuestionarioAlumno2.create({ ...body });
|
||||
console.log('despues de registrar cuestionario', respuestasRegistradas);
|
||||
|
||||
let cuestionarioRegistro = await Cuestionario.create({
|
||||
idServicio,
|
||||
idCuestionarioAlumno: respuestasRegistradas.idCuestionarioAlumno,
|
||||
// idCuestionarioAlumno: respuestasRegistradas.idCuestionarioAlumno,
|
||||
version: '2',
|
||||
dirigidoA: 'estudiantes',
|
||||
titulo: 'Cuestionario de Alumn v2',
|
||||
@@ -253,6 +250,13 @@ const nuevo = async (body) => {
|
||||
createdAt: new Date(),
|
||||
});
|
||||
|
||||
|
||||
console.log("datos a registrar en la tabla cuestionarioAlumno2", { ...body, idCuestionario: cuestionarioRegistro.idCuestionario } );
|
||||
|
||||
let respuestasRegistradas = await CuestionarioAlumno2.create({ ...body, idCuestionario: cuestionarioRegistro.idCuestionario });
|
||||
console.log('despues de registrar cuestionario', respuestasRegistradas);
|
||||
|
||||
|
||||
console.log('cuestionario registrado', cuestionarioRegistro);
|
||||
|
||||
return cuestionarioRegistro;
|
||||
@@ -263,4 +267,5 @@ const nuevo = async (body) => {
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
module.exports = nuevo;
|
||||
|
||||
@@ -135,6 +135,10 @@ const nuevo = async (body) => {
|
||||
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' },
|
||||
});
|
||||
@@ -144,14 +148,9 @@ const nuevo = async (body) => {
|
||||
throw new Error('Ya existe un cuestionario para este servicio social');
|
||||
}
|
||||
|
||||
let respuestasRegistradas = await CuestionarioPrograma2.create({
|
||||
...body,
|
||||
});
|
||||
|
||||
console.log('despues de registrar cuestionario', respuestasRegistradas);
|
||||
|
||||
// si el cuestionario ya existe solo hay que actualizar el id de cuestionarioprograma o alumno
|
||||
|
||||
|
||||
let cuestionarioRegistro = await Cuestionario.create({
|
||||
idServicio,
|
||||
idCuestionarioPrograma: respuestasRegistradas.idCuestionarioPrograma,
|
||||
@@ -164,6 +163,21 @@ const nuevo = async (body) => {
|
||||
|
||||
console.log('cuestionario registrado', cuestionarioRegistro);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let respuestasRegistradas = await CuestionarioPrograma2.create({
|
||||
...body,
|
||||
idCuestionario: cuestionarioRegistro.idCuestionario
|
||||
});
|
||||
|
||||
console.log('despues de registrar cuestionario', respuestasRegistradas);
|
||||
|
||||
// si el cuestionario ya existe solo hay que actualizar el id de cuestionarioprograma o alumno
|
||||
|
||||
|
||||
return cuestionarioRegistro;
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user