nuevos cuestionarios de programa y alumno, sql de update, falta revisar el proceso de servicio para actualizar el get de los id cuestionarios
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const helperPath = '../../helper';
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
// const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
@@ -63,14 +63,14 @@ const nuevo = async (body, file) => {
|
||||
where: { idUsuario },
|
||||
});
|
||||
})
|
||||
.then(async (res) => {
|
||||
/* .then(async (res) => {
|
||||
if (res) throw new Error('Este alumno ya tienen un Caso Especial.');
|
||||
return drive.folder(numeroCuenta);
|
||||
})
|
||||
.then((res) => {
|
||||
carpeta = res;
|
||||
return drive.uploadFile(path, `archivos.zip`, 'application/zip', carpeta);
|
||||
})
|
||||
}) */
|
||||
.then((res) =>
|
||||
CasoEspecial.create({
|
||||
idUsuario,
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
const { convertArrayToCSV } = require('convert-array-to-csv');
|
||||
const { Op } = require('sequelize');
|
||||
const helperPath = '../../helper';
|
||||
const helper = require(`${helperPath}/helper`);
|
||||
const { validarNumero } = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const CuestionarioAlumno2 = require(`${dbPath}/CuestionarioAlumno2`);
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
|
||||
|
||||
const get = async (body) => {
|
||||
const year = validarNumero(body.year, 'año', true, 4);
|
||||
const path = `server/uploads/${year}_cuestionario_alumno.csv`;
|
||||
const data = [];
|
||||
|
||||
console.log(year);
|
||||
|
||||
|
||||
/*
|
||||
return Servicio.findAll({
|
||||
include: [
|
||||
{
|
||||
model: CuestionarioAlumno2,
|
||||
where: { idCuestionarioAlumno: { [Op.not]: null } },
|
||||
},
|
||||
{ model: Programa, where: { clavePrograma: { [Op.like]: `${year}%` } } },
|
||||
{ model: Usuario },
|
||||
{ model: Carrera },
|
||||
],
|
||||
order: [['createdAt']],
|
||||
})
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* return CuestionarioAlumno2.findAll({
|
||||
where: {
|
||||
idCuestionarioAlumno2: {
|
||||
[Op.not]: null,
|
||||
},
|
||||
},
|
||||
// order: [['createdAt', 'ASC']], // Descomentar si se requiere ordenamiento
|
||||
})
|
||||
.then(async (res) => {
|
||||
|
||||
console.log("segunda parte",res);
|
||||
|
||||
for (let i = 0; i < res.length; i++)
|
||||
data.push({ ...res})
|
||||
|
||||
|
||||
data.push({
|
||||
idServicio: res[i].idServicio,
|
||||
clavePrograma: res[i].Programa.clavePrograma,
|
||||
usuario: res[i].Usuario.usuario,
|
||||
nombre: res[i].Usuario.nombre,
|
||||
carrera: res[i].Carrera.carrera,
|
||||
idCuestionarioAlumno: res[i].CuestionarioAlumno.idCuestionarioAlumno,
|
||||
sexo: res[i].CuestionarioAlumno.sexo,
|
||||
edad: res[i].CuestionarioAlumno.edad,
|
||||
servicioMedico: res[i].CuestionarioAlumno.servicioMedico,
|
||||
p1: res[i].CuestionarioAlumno.p1,
|
||||
p2: res[i].CuestionarioAlumno.p2,
|
||||
p3: res[i].CuestionarioAlumno.p3,
|
||||
p4: res[i].CuestionarioAlumno.p4,
|
||||
p5: res[i].CuestionarioAlumno.p5,
|
||||
p6: res[i].CuestionarioAlumno.p6,
|
||||
p7: res[i].CuestionarioAlumno.p7,
|
||||
p8: res[i].CuestionarioAlumno.p8,
|
||||
p9: res[i].CuestionarioAlumno.p9,
|
||||
p10: res[i].CuestionarioAlumno.p10,
|
||||
p11: res[i].CuestionarioAlumno.p11,
|
||||
p12: res[i].CuestionarioAlumno.p12,
|
||||
p13: res[i].CuestionarioAlumno.p13,
|
||||
p14: res[i].CuestionarioAlumno.p14,
|
||||
p15: res[i].CuestionarioAlumno.p15,
|
||||
p16: res[i].CuestionarioAlumno.p16,
|
||||
p17: res[i].CuestionarioAlumno.p17,
|
||||
p18: res[i].CuestionarioAlumno.p18,
|
||||
p19: res[i].CuestionarioAlumno.p19,
|
||||
p20: res[i].CuestionarioAlumno.p20,
|
||||
p21: res[i].CuestionarioAlumno.p21,
|
||||
p22: res[i].CuestionarioAlumno.p22,
|
||||
p23: res[i].CuestionarioAlumno.p23,
|
||||
p24: res[i].CuestionarioAlumno.p24,
|
||||
p25: res[i].CuestionarioAlumno.p25,
|
||||
p26: res[i].CuestionarioAlumno.p26,
|
||||
p27: res[i].CuestionarioAlumno.p27,
|
||||
p28: res[i].CuestionarioAlumno.p28,
|
||||
p29: res[i].CuestionarioAlumno.p29,
|
||||
p30: res[i].CuestionarioAlumno.p30,
|
||||
createdAt: res[i].CuestionarioAlumno.createdAt,
|
||||
});
|
||||
await helper.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => path);
|
||||
}; */
|
||||
|
||||
|
||||
|
||||
return CuestionarioAlumno2.findAll({
|
||||
where: {
|
||||
idCuestionarioAlumno2: {
|
||||
[Op.not]: null,
|
||||
},
|
||||
},
|
||||
})
|
||||
.then(async (res) => {
|
||||
console.log("segunda parte", res);
|
||||
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
data.push(res[i].get({ plain: true }));
|
||||
}
|
||||
|
||||
// Alternativa manual si necesitas campos específicos
|
||||
/* for (let i = 0; i < res.length; i++) {
|
||||
const row = res[i].get({ plain: true });
|
||||
data.push({
|
||||
idCuestionarioAlumno2: row.idCuestionarioAlumno2,
|
||||
p1: row.p1,
|
||||
p2: row.p2,
|
||||
p3: row.p3,
|
||||
p4: row.p4,
|
||||
p5: row.p5,
|
||||
// Agrega los demás campos según sea necesario
|
||||
});
|
||||
} */
|
||||
|
||||
await helper.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = get;
|
||||
@@ -0,0 +1,241 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const CuestionarioAlumno = require(`${dbPath}/CuestionarioAlumno`);
|
||||
const CuestionarioAlumno2 = require(`${dbPath}/CuestionarioAlumno2`);
|
||||
|
||||
const Cuestionario = require(`${dbPath}/Cuestionario`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
const nuevo = async (body) => {
|
||||
// console.log(body);
|
||||
|
||||
let idServicio = body.idServicio;
|
||||
/*
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
); */
|
||||
|
||||
|
||||
body = validar.validarCuestionarioAlumno2(body);
|
||||
|
||||
|
||||
// pasar preguntas de array a string
|
||||
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then(async (res) => {
|
||||
if (!res) throw new Error('No existe este Servicio Social.');
|
||||
/*
|
||||
if (res.idCuestionarioAlumno)
|
||||
throw new Error(
|
||||
'Este Servicio Social ya cuenta con cuestionario de alumno'
|
||||
);
|
||||
*/
|
||||
|
||||
console.log('el servicio social si existe');
|
||||
// console.log(res);
|
||||
|
||||
/**
|
||||
* existe el servicio social?
|
||||
* tiene cuestionario alumno en la tabla cuestionario? select * from cuestionario where idServicio = 1
|
||||
* si no existe, entonces se puede crear el cuestionario
|
||||
* creamos el cuestionario y guardamos las respuestas
|
||||
*/
|
||||
|
||||
const messageByStatus = {
|
||||
1: 'Aun no se puede contestar el cuestionario este Servicio Social.',
|
||||
2: 'Aun no se puede contestar el cuestionario este Servicio Social.',
|
||||
3: 'Aun no se puede contestar el cuestionario este Servicio Social.',
|
||||
5: 'Este Servicio Social ya paso la fase de contestar el cuestionario.',
|
||||
6: 'Este Servicio Social ya paso la fase de contestar el cuestionario.',
|
||||
7: 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corrija lo necesario.',
|
||||
8: 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corrija lo necesario.',
|
||||
9: 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corrija lo necesario.',
|
||||
10: 'Este Servicio Social fue cancelado.',
|
||||
};
|
||||
|
||||
// if (res.idStatus === 4) return CuestionarioAlumno2.create({ ...body });
|
||||
console.log('antes de create ques2');
|
||||
|
||||
// if (res.idStatus) return CuestionarioAlumno2.create({ ...body });
|
||||
|
||||
// si idStatus está en el objeto, arrojamos el mensaje
|
||||
|
||||
/* 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({
|
||||
where: { idServicio, dirigidoA: 'estudiantes' },
|
||||
});
|
||||
console.log('data cuestionario', dataCuestionario);
|
||||
|
||||
if (dataCuestionario) {
|
||||
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,
|
||||
version: '2',
|
||||
dirigidoA: 'estudiantes',
|
||||
titulo: 'Cuestionario de Alumn v2',
|
||||
desc: 'Cuestionario de Alumno v2',
|
||||
createdAt: new Date(),
|
||||
});
|
||||
|
||||
console.log('cuestionario registrado', cuestionarioRegistro);
|
||||
|
||||
return cuestionarioRegistro;
|
||||
})
|
||||
|
||||
.then((res) => ({
|
||||
message: `Se guardaron tus respuestas correctamente. ${res}`,
|
||||
}));
|
||||
};
|
||||
|
||||
const convertirSTR = () => {
|
||||
for (let i = 0; i < body.p3.length; i++) {
|
||||
p3 += body.p3[i];
|
||||
if (i < body.p3.length - 1) p3 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p5.length; i++) {
|
||||
p5 += body.p5[i];
|
||||
if (i < body.p5.length - 1) p5 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p8.length; i++) {
|
||||
p8 += body.p8[i];
|
||||
if (i < body.p8.length - 1) p8 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p14.length; i++) {
|
||||
p14 += body.p14[i];
|
||||
if (i < body.p14.length - 1) p14 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p15.length; i++) {
|
||||
p15 += body.p15[i];
|
||||
if (i < body.p15.length - 1) p15 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p17.length; i++) {
|
||||
p17 += body.p17[i];
|
||||
if (i < body.p17.length - 1) p17 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p21.length; i++) {
|
||||
p21 += body.p21[i];
|
||||
if (i < body.p21.length - 1) p21 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p22.length; i++) {
|
||||
p22 += body.p22[i];
|
||||
if (i < body.p22.length - 1) p22 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p23.length; i++) {
|
||||
p23 += body.p23[i];
|
||||
if (i < body.p23.length - 1) p23 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p24.length; i++) {
|
||||
p24 += body.p24[i];
|
||||
if (i < body.p24.length - 1) p24 += ',';
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = nuevo;
|
||||
|
||||
/*
|
||||
|
||||
<!-- respuestas de cuestionario formulario2
|
||||
todas las preguntas se guardan correctamente
|
||||
{
|
||||
"p3_A_1": "Deficiente",
|
||||
"p3_A_2": "Deficiente",
|
||||
"p3_A_3": "Deficiente",
|
||||
"p3_A_4": "Deficiente",
|
||||
"p3_B_1": "Básico",
|
||||
"p3_B_2": "Básico",
|
||||
"p3_B_3": "Básico",
|
||||
"p3_B_4": "Básico",
|
||||
"p3_C_1": "Intermedio",
|
||||
"p3_C_2": "Intermedio",
|
||||
"p3_C_3": "Intermedio",
|
||||
"p3_C_4": "Intermedio",
|
||||
"p3_C_5": "Intermedio",
|
||||
"p3_D_1": "Destacado",
|
||||
"p3_D_2": "Destacado",
|
||||
"p3_D_3": "Destacado",
|
||||
"p3_D_4": "Destacado",
|
||||
"p3_D_5": "Destacado",
|
||||
"p3_E_1": "Deficiente",
|
||||
"p1": "respuesta1",
|
||||
"p2": "Excelente",
|
||||
"p4": "respuesta4",
|
||||
"p5": "Sí",
|
||||
"p6": "respuesta 6"
|
||||
}
|
||||
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- respuestas de cuestionario formulario alumno
|
||||
|
||||
|
||||
{
|
||||
"p1": [
|
||||
"Dependencia de la UNAM",
|
||||
"Asesoría académica",
|
||||
"Oportunidad de desarrollo de tesis"
|
||||
],
|
||||
"p12_A_1": "Deficiente",
|
||||
"p12_A_2": "Deficiente",
|
||||
"p12_A_3": "Deficiente",
|
||||
"p12_A_4": "Deficiente",
|
||||
"p12_B_1": "Básico",
|
||||
"p12_B_2": "Básico",
|
||||
"p12_B_3": "Básico",
|
||||
"p12_B_4": "Básico",
|
||||
"p12_C_1": "Intermedio",
|
||||
"p12_C_2": "Intermedio",
|
||||
"p12_C_3": "Intermedio",
|
||||
"p12_C_4": "Intermedio",
|
||||
"p10_1": "si",
|
||||
"p10_2": "si",
|
||||
"p10_3": "si",
|
||||
"p11_1": "Nunca",
|
||||
"p11_2": "Rara vez",
|
||||
"p11_3": "Algunas veces",
|
||||
"p11_4": "Siempre",
|
||||
"p17_1": "si",
|
||||
"p17_2": "no",
|
||||
"p17_3": "si",
|
||||
"p3_1": "si",
|
||||
"p3_2": "si",
|
||||
"p3_3": "si",
|
||||
"p3_4": "si",
|
||||
"p12_D_1": "Destacado",
|
||||
"p12_D_2": "Destacado",
|
||||
"p12_D_3": "Destacado",
|
||||
"p12_D_4": "Destacado",
|
||||
"p12_D_5": "Destacado",
|
||||
"p2": "Deficiente",
|
||||
"p4": "No",
|
||||
"p5": "respuesta5",
|
||||
"p6": "Sí",
|
||||
"p7": "Sí",
|
||||
"p8": "respuesta8",
|
||||
"p9": "Sí",
|
||||
"p13": "Responsable directo del programa",
|
||||
"p14": "Se te otorgó de acuerdo a lo establecido",
|
||||
"p15": "Sí",
|
||||
"p16": "respuesta 16",
|
||||
"p18": "respuesta18"
|
||||
}
|
||||
|
||||
|
||||
-->
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,105 @@
|
||||
const fs = require('fs');
|
||||
const { convertArrayToCSV } = require('convert-array-to-csv');
|
||||
const { Op } = require('sequelize');
|
||||
const helperPath = '../../helper';
|
||||
const helper = require(`${helperPath}/helper`);
|
||||
const { validarNumero } = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const CuestionarioPrograma2 = require(`${dbPath}/CuestionarioPrograma`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const get = async (body) => {
|
||||
const year = validarNumero(body.year, 'año', true, 4);
|
||||
const path = `server/uploads/${year}_cuestionario_programa.csv`;
|
||||
const data = [];
|
||||
|
||||
|
||||
|
||||
return CuestionarioPrograma2.findAll({
|
||||
where: {
|
||||
idCuestionarioPrograma2: {
|
||||
[Op.not]: null,
|
||||
},
|
||||
},
|
||||
})
|
||||
.then(async (res) => {
|
||||
console.log("segunda parte", res);
|
||||
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
data.push(res[i].get({ plain: true }));
|
||||
}
|
||||
|
||||
// Alternativa manual si necesitas campos específicos
|
||||
/* for (let i = 0; i < res.length; i++) {
|
||||
const row = res[i].get({ plain: true });
|
||||
data.push({
|
||||
idCuestionarioPrograma2: row.idCuestionarioPrograma2,
|
||||
p1: row.p1,
|
||||
p2: row.p2,
|
||||
p3: row.p3,
|
||||
p4: row.p4,
|
||||
p5: row.p5,
|
||||
// Agrega los demás campos según sea necesario
|
||||
});
|
||||
} */
|
||||
|
||||
await helper.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* return Servicio.findAll({
|
||||
include: [
|
||||
{
|
||||
model: CuestionarioPrograma,
|
||||
where: { idCuestionarioPrograma: { [Op.not]: null } },
|
||||
},
|
||||
{ model: Programa, where: { clavePrograma: { [Op.like]: `${year}-%` } } },
|
||||
{ model: Usuario },
|
||||
{ model: Carrera },
|
||||
],
|
||||
order: [['createdAt']],
|
||||
})
|
||||
.then(async (res) => {
|
||||
for (let i = 0; i < res.length; i++)
|
||||
data.push({
|
||||
idServicio: res[i].idServicio,
|
||||
clavePrograma: res[i].Programa.clavePrograma,
|
||||
usuario: res[i].Usuario.usuario,
|
||||
nombre: res[i].Usuario.nombre,
|
||||
carrera: res[i].Carrera.carrera,
|
||||
idCuestionarioPrograma:
|
||||
res[i].CuestionarioPrograma.idCuestionarioPrograma,
|
||||
actividad1: res[i].CuestionarioPrograma.actividad1,
|
||||
actividad2: res[i].CuestionarioPrograma.actividad2,
|
||||
actividad3: res[i].CuestionarioPrograma.actividad3,
|
||||
actividad4: res[i].CuestionarioPrograma.actividad4,
|
||||
actividad5: res[i].CuestionarioPrograma.actividad5,
|
||||
retroalimentacion: res[i].CuestionarioPrograma.retroalimentacion,
|
||||
p6: res[i].CuestionarioPrograma.p6,
|
||||
p7: res[i].CuestionarioPrograma.p7,
|
||||
createdAt: res[i].CuestionarioPrograma.createdAt,
|
||||
});
|
||||
await helper.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => path);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
module.exports = get;
|
||||
@@ -0,0 +1,235 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const CuestionarioAlumno = require(`${dbPath}/CuestionarioAlumno`);
|
||||
const CuestionarioPrograma2 = require(`${dbPath}/CuestionarioPrograma2`);
|
||||
|
||||
const Cuestionario = require(`${dbPath}/Cuestionario`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
const nuevo = async (body) => {
|
||||
// console.log(body);
|
||||
|
||||
let idServicio = body.idServicio;
|
||||
/*
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
); */
|
||||
|
||||
// pasar preguntas de array a string
|
||||
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then(async (res) => {
|
||||
if (!res) throw new Error('No existe este Servicio Social.');
|
||||
/* if (res.idCuestionarioAlumno)
|
||||
throw new Error(
|
||||
'Este Servicio Social ya cuenta con cuestionario de programa'
|
||||
); */
|
||||
|
||||
console.log('el servicio social si existe');
|
||||
// console.log(res);
|
||||
|
||||
/**
|
||||
* existe el servicio social?
|
||||
* tiene cuestionario alumno en la tabla cuestionario? select * from cuestionario where idServicio = 1
|
||||
* si no existe, entonces se puede crear el cuestionario
|
||||
* creamos el cuestionario y guardamos las respuestas
|
||||
*/
|
||||
|
||||
const messageByStatus = {
|
||||
1: 'Aun no se puede contestar el cuestionario este Servicio Social.',
|
||||
2: 'Aun no se puede contestar el cuestionario este Servicio Social.',
|
||||
3: 'Aun no se puede contestar el cuestionario este Servicio Social.',
|
||||
5: 'Este Servicio Social ya paso la fase de contestar el cuestionario.',
|
||||
6: 'Este Servicio Social ya paso la fase de contestar el cuestionario.',
|
||||
7: 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corrija lo necesario.',
|
||||
8: 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corrija lo necesario.',
|
||||
9: 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corrija lo necesario.',
|
||||
10: 'Este Servicio Social fue cancelado.',
|
||||
};
|
||||
|
||||
// if (res.idStatus === 4) return CuestionarioPrograma2.create({ ...body });
|
||||
console.log('antes de create ques2');
|
||||
|
||||
// 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]); */
|
||||
// throw new Error('Id status no valido.'); // si no coincide con nada, error por defecto
|
||||
|
||||
let dataCuestionario = await Cuestionario.findOne({
|
||||
where: { idServicio, dirigidoA: 'programas' },
|
||||
});
|
||||
console.log('data cuestionario', dataCuestionario);
|
||||
|
||||
if (dataCuestionario) {
|
||||
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,
|
||||
version: '2',
|
||||
dirigidoA: 'programas',
|
||||
titulo: 'Cuestionario de programa v2',
|
||||
desc: 'Cuestionario de programa v2',
|
||||
createdAt: new Date(),
|
||||
});
|
||||
|
||||
console.log('cuestionario registrado', cuestionarioRegistro);
|
||||
|
||||
return cuestionarioRegistro;
|
||||
})
|
||||
|
||||
.then((res) => ({
|
||||
message: `Se guardaron tus respuestas correctamente. ${res}`,
|
||||
}));
|
||||
};
|
||||
|
||||
const convertirSTR = () => {
|
||||
for (let i = 0; i < body.p3.length; i++) {
|
||||
p3 += body.p3[i];
|
||||
if (i < body.p3.length - 1) p3 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p5.length; i++) {
|
||||
p5 += body.p5[i];
|
||||
if (i < body.p5.length - 1) p5 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p8.length; i++) {
|
||||
p8 += body.p8[i];
|
||||
if (i < body.p8.length - 1) p8 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p14.length; i++) {
|
||||
p14 += body.p14[i];
|
||||
if (i < body.p14.length - 1) p14 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p15.length; i++) {
|
||||
p15 += body.p15[i];
|
||||
if (i < body.p15.length - 1) p15 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p17.length; i++) {
|
||||
p17 += body.p17[i];
|
||||
if (i < body.p17.length - 1) p17 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p21.length; i++) {
|
||||
p21 += body.p21[i];
|
||||
if (i < body.p21.length - 1) p21 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p22.length; i++) {
|
||||
p22 += body.p22[i];
|
||||
if (i < body.p22.length - 1) p22 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p23.length; i++) {
|
||||
p23 += body.p23[i];
|
||||
if (i < body.p23.length - 1) p23 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p24.length; i++) {
|
||||
p24 += body.p24[i];
|
||||
if (i < body.p24.length - 1) p24 += ',';
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = nuevo;
|
||||
|
||||
/*
|
||||
|
||||
<!-- respuestas de cuestionario formulario2
|
||||
todas las preguntas se guardan correctamente
|
||||
{
|
||||
"p3_A_1": "Deficiente",
|
||||
"p3_A_2": "Deficiente",
|
||||
"p3_A_3": "Deficiente",
|
||||
"p3_A_4": "Deficiente",
|
||||
"p3_B_1": "Básico",
|
||||
"p3_B_2": "Básico",
|
||||
"p3_B_3": "Básico",
|
||||
"p3_B_4": "Básico",
|
||||
"p3_C_1": "Intermedio",
|
||||
"p3_C_2": "Intermedio",
|
||||
"p3_C_3": "Intermedio",
|
||||
"p3_C_4": "Intermedio",
|
||||
"p3_C_5": "Intermedio",
|
||||
"p3_D_1": "Destacado",
|
||||
"p3_D_2": "Destacado",
|
||||
"p3_D_3": "Destacado",
|
||||
"p3_D_4": "Destacado",
|
||||
"p3_D_5": "Destacado",
|
||||
"p3_E_1": "Deficiente",
|
||||
"p1": "respuesta1",
|
||||
"p2": "Excelente",
|
||||
"p4": "respuesta4",
|
||||
"p5": "Sí",
|
||||
"p6": "respuesta 6"
|
||||
}
|
||||
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- respuestas de cuestionario formulario alumno
|
||||
|
||||
|
||||
{
|
||||
"p1": [
|
||||
"Dependencia de la UNAM",
|
||||
"Asesoría académica",
|
||||
"Oportunidad de desarrollo de tesis"
|
||||
],
|
||||
"p12_A_1": "Deficiente",
|
||||
"p12_A_2": "Deficiente",
|
||||
"p12_A_3": "Deficiente",
|
||||
"p12_A_4": "Deficiente",
|
||||
"p12_B_1": "Básico",
|
||||
"p12_B_2": "Básico",
|
||||
"p12_B_3": "Básico",
|
||||
"p12_B_4": "Básico",
|
||||
"p12_C_1": "Intermedio",
|
||||
"p12_C_2": "Intermedio",
|
||||
"p12_C_3": "Intermedio",
|
||||
"p12_C_4": "Intermedio",
|
||||
"p10_1": "si",
|
||||
"p10_2": "si",
|
||||
"p10_3": "si",
|
||||
"p11_1": "Nunca",
|
||||
"p11_2": "Rara vez",
|
||||
"p11_3": "Algunas veces",
|
||||
"p11_4": "Siempre",
|
||||
"p17_1": "si",
|
||||
"p17_2": "no",
|
||||
"p17_3": "si",
|
||||
"p3_1": "si",
|
||||
"p3_2": "si",
|
||||
"p3_3": "si",
|
||||
"p3_4": "si",
|
||||
"p12_D_1": "Destacado",
|
||||
"p12_D_2": "Destacado",
|
||||
"p12_D_3": "Destacado",
|
||||
"p12_D_4": "Destacado",
|
||||
"p12_D_5": "Destacado",
|
||||
"p2": "Deficiente",
|
||||
"p4": "No",
|
||||
"p5": "respuesta5",
|
||||
"p6": "Sí",
|
||||
"p7": "Sí",
|
||||
"p8": "respuesta8",
|
||||
"p9": "Sí",
|
||||
"p13": "Responsable directo del programa",
|
||||
"p14": "Se te otorgó de acuerdo a lo establecido",
|
||||
"p15": "Sí",
|
||||
"p16": "respuesta 16",
|
||||
"p18": "respuesta18"
|
||||
}
|
||||
|
||||
|
||||
-->
|
||||
|
||||
*/
|
||||
@@ -1,5 +1,5 @@
|
||||
const helperPath = '../../helper';
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
//const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
@@ -23,13 +23,13 @@ const cartaTermino = async (body, file) => {
|
||||
if (res.cartaAceptacion)
|
||||
throw new Error('Ya se subio la Carta de Aceptación.');
|
||||
switch (res.idStatus) {
|
||||
case 7:
|
||||
/* case 7:
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
`Carta_Aceptacion.pdf`,
|
||||
'application/pdf',
|
||||
res.carpeta
|
||||
);
|
||||
); */
|
||||
case 1:
|
||||
throw new Error(
|
||||
'Esta linea de la API solo puede ser usada cuando es estatus del Servicio Social sea 7.'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const helperPath = '../../helper';
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
//const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
@@ -23,13 +23,13 @@ const cartaTermino = async (body, file) => {
|
||||
if (res.cartaTermino) throw new Error('Ya se subio la Carta de Termino.');
|
||||
switch (res.idStatus) {
|
||||
case 4:
|
||||
case 8:
|
||||
/* case 8:
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
`Carta_Termino.pdf`,
|
||||
'application/pdf',
|
||||
res.carpeta
|
||||
);
|
||||
); */
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const helperPath = '../../helper';
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
//const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
@@ -23,13 +23,13 @@ const informeGlobal = async (body, file) => {
|
||||
if (res.informeGlobal) throw new Error('Ya se subio el Informe Global.');
|
||||
switch (res.idStatus) {
|
||||
case 4:
|
||||
case 9:
|
||||
/* case 9:
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
`Informe_Global.pdf`,
|
||||
'application/pdf',
|
||||
res.carpeta
|
||||
);
|
||||
); */
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Op } = require('sequelize');
|
||||
const helperPath = '../../helper';
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
//const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
@@ -79,7 +79,7 @@ const nuevo = async (body, file) => {
|
||||
.then((servicio) => {
|
||||
let carpeta = '';
|
||||
|
||||
drive
|
||||
/* drive
|
||||
.mkDir(numeroCuenta)
|
||||
.then((res) => {
|
||||
carpeta = res;
|
||||
@@ -95,7 +95,7 @@ const nuevo = async (body, file) => {
|
||||
{ carpeta, cartaAceptacion: res },
|
||||
{ where: { idServicio: servicio.idServicio } }
|
||||
)
|
||||
);
|
||||
); */
|
||||
return { message: `Se Pre-Registro correctamente a este alumno.` };
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const helperPath = '../../helper';
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
//const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
@@ -13,6 +13,8 @@ const update = async (body, files) => {
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then(async (res) => {
|
||||
if (!res) throw new Error('Este Servicio Social no existe en la db.');
|
||||
|
||||
/*
|
||||
try {
|
||||
if (files['cartaAceptacion'][0].filename)
|
||||
dataUpdate.cartaAceptacion = await drive.uploadFile(
|
||||
@@ -40,6 +42,9 @@ const update = async (body, files) => {
|
||||
res.carpeta
|
||||
);
|
||||
} catch (err) {}
|
||||
*/
|
||||
|
||||
|
||||
if (body.correo) dataUpdate.correo = validar.validarCorreo(body.correo);
|
||||
if (body.fechaInicio)
|
||||
dataUpdate.fechaInicio = validar.validarFecha(
|
||||
|
||||
Reference in New Issue
Block a user