monitor, asistencia, asistentes

This commit is contained in:
Lemuel Marquez
2021-07-21 09:07:59 -05:00
parent 62758847ae
commit 666a29cc72
10 changed files with 60 additions and 23 deletions
@@ -1,16 +1,10 @@
const moment = require('moment');
const { Op } = require('sequelize');
const helperPath = '../../helper';
const helper = require(`${helperPath}/helper`);
const encriptar = require(`${helperPath}/encriptar`);
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const CarreraHorario = require(`${dbPath}/CarreraHorario`);
const Grupo = require(`${dbPath}/Grupo`);
const Horario = require(`${dbPath}/Horario`);
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
const get = async (body) => {
const monitor = async (body) => {
return CarreraHorario.findAll({
include: [{ model: Horario }, { model: Carrera }],
order: ['idHorario'],
@@ -28,4 +22,4 @@ const get = async (body) => {
});
};
module.exports = get;
module.exports = monitor;
@@ -0,0 +1,24 @@
const helperPath = '../../helper';
const validar = require(`${helperPath}/validar`);
const dbPath = '../../db/tablas';
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
const asistencia = async (body) => {
const idPrimerSemestre = validar.validarId(body.idPrimerSemestre);
return PrimerSemestre.findOne({ where: { idPrimerSemestre } })
.then((res) => {
if (!res) throw new Error('No existe este alumno.');
if (res.asistio)
throw new Error('Ya fue registrada la asistencia de este alumno.');
return PrimerSemestre.update(
{ asistio: true },
{ where: { idPrimerSemestre } }
);
})
.then((res) => ({
message: 'Se registro correctamente la asistencia de este alumno.',
}));
};
module.exports = asistencia;
@@ -0,0 +1,17 @@
const helperPath = '../../helper';
const validar = require(`${helperPath}/validar`);
const dbPath = '../../db/tablas';
const Carrera = require(`${dbPath}/Carrera`);
const Grupo = require(`${dbPath}/Grupo`);
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
const asistentes = async (body) => {
const idHorario = validar.validarId(body.idHorario);
return PrimerSemestre.findAll({
where: { idHorario },
include: [{ model: Grupo, include: [{ model: Carrera }] }],
});
};
module.exports = asistentes;
+3 -3
View File
@@ -1,5 +1,5 @@
const { convertArrayToCSV } = require('convert-array-to-csv');
const moment = require('moment');
const { convertArrayToCSV } = require('convert-array-to-csv');
const helperPath = '../../helper';
const helper = require(`${helperPath}/helper`);
const encriptar = require(`${helperPath}/encriptar`);
@@ -9,7 +9,7 @@ const Grupo = require(`${dbPath}/Grupo`);
const Horario = require(`${dbPath}/Horario`);
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
const get = async (body) => {
const csv = async (body) => {
const path = `server/uploads/primer_semestre.csv`;
const data = [];
@@ -54,4 +54,4 @@ const get = async (body) => {
.then((res) => path);
};
module.exports = get;
module.exports = csv;
@@ -9,7 +9,7 @@ const Horario = require(`${dbPath}/Horario`);
const Grupo = require(`${dbPath}/Grupo`);
const PrimerSemestre = require(`${dbPath}/PrimerSemestre`);
const get = async (body) => {
const registrar = async (body) => {
const idCarrera = validar.validarId(body.idCarrera);
const idGrupo = validar.validarId(body.idGrupo);
const idHorario = validar.validarId(body.idHorario);
@@ -82,4 +82,4 @@ const get = async (body) => {
}));
};
module.exports = get;
module.exports = registrar;