cuestionario temporal
This commit is contained in:
@@ -2,6 +2,117 @@ const validar = require('../../helper/validar');
|
||||
const CuestionarioAlumno = require('../../db/tablas/CuestionarioAlumno');
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const nuevo = async (body) => {};
|
||||
const nuevo = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
|
||||
let sexo = '';
|
||||
let edad = '';
|
||||
let servicioMedico = '';
|
||||
let pUno = '';
|
||||
let pDos = '';
|
||||
let pTres = '';
|
||||
let pCuatro = '';
|
||||
let pCinco = '';
|
||||
let pSeis = '';
|
||||
let pSiete = '';
|
||||
let pOcho = '';
|
||||
let pNueve = '';
|
||||
let pDiez = '';
|
||||
let pOnce = '';
|
||||
let pDoce = '';
|
||||
let pTrece = '';
|
||||
let pCatorce = '';
|
||||
let pQuince = '';
|
||||
let pDieciseis = '';
|
||||
let pDiecisiete = '';
|
||||
let pDieciocho = '';
|
||||
let pDiecinueve = '';
|
||||
let pVeinte = '';
|
||||
let pVeintiuno = '';
|
||||
let pVeintidos = '';
|
||||
let pVeintitres = '';
|
||||
let pVeinticuatro = '';
|
||||
let pVeinticinco = '';
|
||||
let pVeintiseis = '';
|
||||
let pVeintisiete = '';
|
||||
let pVeintiocho = '';
|
||||
let pVeintinueve = '';
|
||||
let pTreinta = '';
|
||||
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then((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'
|
||||
);
|
||||
switch (res.idStatus) {
|
||||
case 4:
|
||||
return CuestionarioAlumno.create({
|
||||
sexo,
|
||||
edad,
|
||||
servicioMedico,
|
||||
pUno,
|
||||
pDos,
|
||||
pTres,
|
||||
pCuatro,
|
||||
pCinco,
|
||||
pSeis,
|
||||
pSiete,
|
||||
pOcho,
|
||||
pNueve,
|
||||
pDiez,
|
||||
pOnce,
|
||||
pDoce,
|
||||
pTrece,
|
||||
pCatorce,
|
||||
pQuince,
|
||||
pDieciseis,
|
||||
pDiecisiete,
|
||||
pDieciocho,
|
||||
pDiecinueve,
|
||||
pVeinte,
|
||||
pVeintiuno,
|
||||
pVeintidos,
|
||||
pVeintitres,
|
||||
pVeinticuatro,
|
||||
pVeinticinco,
|
||||
pVeintiseis,
|
||||
pVeintisiete,
|
||||
pVeintiocho,
|
||||
pVeintinueve,
|
||||
pTreinta,
|
||||
});
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
throw new Error(
|
||||
'Aun no se puede contestar el cuestionario este Servicio Social.'
|
||||
);
|
||||
case 5:
|
||||
case 6:
|
||||
throw new Error(
|
||||
'Este Servicio Social ya paso la fase de contestar el cuestionario.'
|
||||
);
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
throw new Error(
|
||||
'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corriga lo necesario.'
|
||||
);
|
||||
case 10:
|
||||
throw new Error('Este Servicio Social esta cancelado.');
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.update(
|
||||
{ idCuestionarioAlumno: res.idCuestionarioAlumno },
|
||||
{ where: { idServicio } }
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return { message: 'Se guardo tus respuestas correctamente.' };
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = nuevo;
|
||||
|
||||
@@ -2,6 +2,66 @@ const validar = require('../../helper/validar');
|
||||
const CuestionarioPrograma = require('../../db/tablas/CuestionarioPrograma');
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
const nuevo = async (body) => {};
|
||||
const nuevo = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let actividadUno = '';
|
||||
let actividadDos = '';
|
||||
let actividadTres = '';
|
||||
let actividadCuatro = '';
|
||||
let actividadCinco = '';
|
||||
let retroalimentacion = '';
|
||||
let pSeis = '';
|
||||
let pSiete = '';
|
||||
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No existe este Servicio Social.');
|
||||
if (res.idCuestionarioPrograma)
|
||||
throw new Error(
|
||||
'Este Servicio Social ya cuenta con cuestionario de programa'
|
||||
);
|
||||
switch (res.idStatus) {
|
||||
case 4:
|
||||
return CuestionarioPrograma.create({
|
||||
actividadUno,
|
||||
actividadDos,
|
||||
actividadTres,
|
||||
actividadCuatro,
|
||||
actividadCinco,
|
||||
retroalimentacion,
|
||||
pSeis,
|
||||
pSiete,
|
||||
});
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
throw new Error(
|
||||
'Aun no se puede contestar el cuestionario este Servicio Social.'
|
||||
);
|
||||
case 5:
|
||||
case 6:
|
||||
throw new Error(
|
||||
'Este Servicio Social ya paso la fase de contestar el cuestionario.'
|
||||
);
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
throw new Error(
|
||||
'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corriga lo necesario.'
|
||||
);
|
||||
case 10:
|
||||
throw new Error('Este Servicio Social esta cancelado.');
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
return Servicio.update(
|
||||
{ idCuestionarioPrograma: res.idCuestionarioPrograma },
|
||||
{ where: { idServicio } }
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return { message: 'Se guardo tus respuestas correctamente.' };
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = nuevo;
|
||||
|
||||
@@ -10,9 +10,7 @@ const cartaTermino = async (body, file) => {
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Este servicio no existe.');
|
||||
|
||||
if (res.cartaTermino) throw new Error('Ya se subio la carta de termino.');
|
||||
|
||||
switch (res.idStatus) {
|
||||
case 4:
|
||||
case 8:
|
||||
|
||||
@@ -10,9 +10,7 @@ const informeGlobal = async (body, file) => {
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Este servicio no existe.');
|
||||
|
||||
if (res.informeGlobal) throw new Error('Ya se subio el informe global.');
|
||||
|
||||
switch (res.idStatus) {
|
||||
case 4:
|
||||
case 9:
|
||||
|
||||
@@ -9,7 +9,7 @@ const registro = async (body) => {
|
||||
let idServicio = validar.validarId(body.idServicio);
|
||||
let password = '';
|
||||
let correo = {};
|
||||
let idUsuario = null;
|
||||
let idUsuario;
|
||||
|
||||
return Servicio.findOne({
|
||||
where: { idServicio },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
const route = '/cuestionario_alumno';
|
||||
const nuevo = require('../controller/CuestionarioAlumno');
|
||||
const nuevo = require('../controller/CuestionarioAlumno/nuevo');
|
||||
|
||||
app.post(`${route}`, (req, res) => {
|
||||
return nuevo(req.body)
|
||||
@@ -9,7 +9,7 @@ app.post(`${route}`, (req, res) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json(err);
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
const route = '/cuestionario_programa';
|
||||
const nuevo = require('../controller/CuestionarioPrograma');
|
||||
const nuevo = require('../controller/CuestionarioPrograma/nuevo');
|
||||
|
||||
app.post(`${route}`, (req, res) => {
|
||||
return nuevo(req.body)
|
||||
@@ -9,7 +9,7 @@ app.post(`${route}`, (req, res) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json(err);
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ app.use(require('./Status'));
|
||||
app.use(require('./Usuario'));
|
||||
app.use(require('./Servicio'));
|
||||
app.use(require('./Programa'));
|
||||
// app.use(require('./CuestionarioAlumno'))
|
||||
// app.use(require('./CuestionarioPrograma'))
|
||||
app.use(require('./CuestionarioAlumno'))
|
||||
app.use(require('./CuestionarioPrograma'))
|
||||
|
||||
module.exports = app;
|
||||
|
||||
Reference in New Issue
Block a user