diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..f6fde72 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,16 @@ +{ + "name": "Servicio Social API", + "dockerFile": "../Dockerfile", + "appPort": [3000], + "postCreateCommand": "npm install", + "extensions": [ + "dbaeumer.vscode-eslint", + "ms-azuretools.vscode-docker", + "esbenp.prettier-vscode" + ], + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + "remoteUser": "node" + } + \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4c27012..87f0f45 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules/ cred.json server/uploads/* +#.devcontainer \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ffc0e26 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# Usa una imagen base de Node.js +FROM node:16 + +# Establece el directorio de trabajo dentro del contenedor +WORKDIR /usr/src/app + +# Copia los archivos de package.json y package-lock.json (si existe) +COPY package*.json ./ + +# Instala las dependencias +RUN npm install + +# Copia el código fuente de la aplicación +COPY . . + +# Expone el puerto que la app usará +EXPOSE 3000 + +# Comando por defecto para ejecutar la aplicación en desarrollo +CMD ["npm", "run", "dev"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..3456870 --- /dev/null +++ b/README.md @@ -0,0 +1,70 @@ + + + + +# Documentacion del sistema IRIS + + + + + + +Tipos de usuarios + + +| 1 | admin | +| 2 | responsable | +| 3 | alumno | +| 4 | casoEspecial + + + +cuando se registran los admin? +cuando se carga la base se sube al admin - COESI + + + + + + + +los responsables se suben por carga m asiva en un csv +En testeo se sube un responsable al instalar la db +existen responsables internos y externos + + + +programsa admin +- son los programas que tiene asignados un administrador +Ejemplo + +Acatlan contigo - + +las claves de programa las sube coesi, que previamente se registro en otro ssitema y se guarda en iris + + + + +el responsable registra a los alumnos + + + + + +status del servicio social + 'Pre-Registro', + 'Pre-Registro Validado', + 'Registro', + 'Pre-Termino', + 'Termino', + 'Liberación', + 'Carta Aceptación Rechazada', + 'Carta Termino Rechazada', + 'Informe Global Rechazado', + 'Cancelado', + 'Articulo 52', + 'Articulo 91', + 'Liberación Articulo 52', + 'Liberación Articulo 91', + + diff --git a/Servicios.postman_collection.json b/Servicios.postman_collection.json new file mode 100644 index 0000000..32b67f0 --- /dev/null +++ b/Servicios.postman_collection.json @@ -0,0 +1,502 @@ +{ + "info": { + "_postman_id": "5672f077-78c4-41d4-8877-6c8ccddbf3ef", + "name": "Servicios", + "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json", + "_exporter_id": "39860549" + }, + "item": [ + { + "name": "cuestionarios", + "item": [ + { + "name": "cuestionario_alumno", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"year\":\"2024\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{api}}/cuestionario_alumno?year=2024", + "host": [ + "{{api}}" + ], + "path": [ + "cuestionario_alumno" + ], + "query": [ + { + "key": "year", + "value": "2024" + } + ] + } + }, + "response": [] + }, + { + "name": "cuestionario_alumno", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"token\":\"asdfasdf\",\n \"idServicio\":3,\n \n \"p1\": \"Dependencia de la UNAM, Asesoría académica, Oportunidad de desarrollo de tesis\",\n\n \"p12_A_1\": \"Deficiente\",\n \"p12_A_2\": \"Deficiente\",\n \"p12_A_3\": \"Deficiente\",\n \"p12_A_4\": \"Deficiente\",\n \"p12_B_1\": \"Básico\",\n \"p12_B_2\": \"Básico\",\n \"p12_B_3\": \"Básico\",\n \"p12_B_4\": \"Básico\",\n \"p12_C_1\": \"Intermedio\",\n \"p12_C_2\": \"Intermedio\",\n \"p12_C_3\": \"Intermedio\",\n \"p12_C_4\": \"Intermedio\",\n \"p10_1\": \"si\",\n \"p10_2\": \"si\",\n \"p10_3\": \"si\",\n \"p11_1\": \"Nunca\",\n \"p11_2\": \"Rara vez\",\n \"p11_3\": \"Algunas veces\",\n \"p11_4\": \"Siempre\",\n \"p17_1\": \"si\",\n \"p17_2\": \"no\",\n \"p17_3\": \"si\",\n \"p3_1\": \"si\",\n \"p3_2\": \"si\",\n \"p3_3\": \"si\",\n \"p3_4\": \"si\",\n \"p12_D_1\": \"Destacado\",\n \"p12_D_2\": \"Destacado\",\n \"p12_D_3\": \"Destacado\",\n \"p12_D_4\": \"Destacado\",\n \"p12_D_5\": \"Destacado\",\n \"p2\": \"Deficiente\",\n \"p4\": \"No\",\n \"p5\": \"respuesta5\",\n \"p6\": \"Sí\",\n \"p7\": \"Sí\",\n \"p8\": \"respuesta8\",\n \"p9\": \"Sí\",\n \"p13\": \"Responsable directo del programa\",\n \"p14\": \"Se te otorgó de acuerdo a lo establecido\",\n \"p15\": \"Sí\",\n \"p16\": \"respuesta 16\",\n \"p18\": \"respuesta18\"\n\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "{{api}}/cuestionario_alumno" + }, + "response": [] + } + ] + }, + { + "name": "usuarios", + "item": [ + { + "name": "login", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n usuario:\"asdfasdf\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "{{api}}/usuario/login" + }, + "response": [] + }, + { + "name": "escolares", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/usuario/escolares" + }, + "response": [] + }, + { + "name": "responsable", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/usuario/responsable" + }, + "response": [] + }, + { + "name": "responsables", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/usuario/responsables" + }, + "response": [] + }, + { + "name": "new pass alumno", + "request": { + "method": "PUT", + "header": [], + "url": "{{api}}/usuario/new_password_alumno" + }, + "response": [] + }, + { + "name": "new pass respon", + "request": { + "method": "PUT", + "header": [], + "url": "{{api}}/usuario/new_password_responsable" + }, + "response": [] + }, + { + "name": "responsable update", + "request": { + "method": "PUT", + "header": [], + "url": "{{api}}/usuario/responsable/update" + }, + "response": [] + } + ] + }, + { + "name": "status", + "item": [ + { + "name": "status", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/status" + }, + "response": [] + } + ] + }, + { + "name": "servicio", + "item": [ + { + "name": "status Copy", + "request": { + "method": "POST", + "header": [], + "url": "{{api}}/servicio/nuevo" + }, + "response": [] + }, + { + "name": "status Copy 2", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/admin" + }, + "response": [] + }, + { + "name": "status Copy 3", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/alumno" + }, + "response": [] + }, + { + "name": "status Copy 4", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/gustavo_baz_prada" + }, + "response": [] + }, + { + "name": "status Copy 5", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/reporte" + }, + "response": [] + }, + { + "name": "status Copy 6", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/servicios_admin" + }, + "response": [] + }, + { + "name": "status Copy 7", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/servicios_responsable" + }, + "response": [] + }, + { + "name": "status Copy 8", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/cancelar" + }, + "response": [] + }, + { + "name": "status Copy 9", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/carta_aceptacion" + }, + "response": [] + }, + { + "name": "status Copy 10", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/carta_termino" + }, + "response": [] + }, + { + "name": "status Copy 11", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/informe_global" + }, + "response": [] + }, + { + "name": "status Copy 12", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/liberacion" + }, + "response": [] + }, + { + "name": "status Copy 13", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/registro" + }, + "response": [] + }, + { + "name": "status Copy 14", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/registro_validado" + }, + "response": [] + }, + { + "name": "status Copy 15", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/rechazar_aceptacion" + }, + "response": [] + }, + { + "name": "status Copy 16", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/rechazar_informe" + }, + "response": [] + }, + { + "name": "status Copy 17", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/rechazar_termino" + }, + "response": [] + }, + { + "name": "status Copy 18", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/servicio/update" + }, + "response": [] + } + ] + }, + { + "name": "Programa", + "item": [ + { + "name": "status Copy 2", + "request": { + "method": "POST", + "header": [], + "url": "{{api}}/programa/carga_masiva" + }, + "response": [] + }, + { + "name": "status Copy 3", + "request": { + "method": "POST", + "header": [], + "url": "{{api}}/programa/reasignar_programas" + }, + "response": [] + }, + { + "name": "status Copy 4", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/programa/programas_admin" + }, + "response": [] + }, + { + "name": "status Copy 5", + "request": { + "method": "POST", + "header": [], + "url": "{{api}}/programa/programas_responsable" + }, + "response": [] + } + ] + }, + { + "name": "cuestionario", + "item": [ + { + "name": "cuestonario programa", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/cuestionario_programa" + }, + "response": [] + }, + { + "name": "cuestonario programa Copy", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/cuestionario_programa" + }, + "response": [] + }, + { + "name": "cuestonario alumno", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/cuestionario_alumno" + }, + "response": [] + }, + { + "name": "cuestonario alumno", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/cuestionario_alumno" + }, + "response": [] + } + ] + }, + { + "name": "caso especial", + "item": [ + { + "name": "cuestonario alumno Copy", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/caso_especial/nuevo" + }, + "response": [] + }, + { + "name": "cuestonario alumno Copy 2", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/caso_especial" + }, + "response": [] + }, + { + "name": "cuestonario alumno Copy 3", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/caso_especial/servicios_especiales" + }, + "response": [] + }, + { + "name": "cuestonario alumno Copy 4", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/caso_especial/liberacion" + }, + "response": [] + }, + { + "name": "cuestonario alumno Copy 5", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}/caso_especial/update" + }, + "response": [] + } + ] + }, + { + "name": "New Request", + "request": { + "method": "GET", + "header": [], + "url": "{{api}}" + }, + "response": [] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "key": "api", + "value": "http://localhost:3072", + "type": "string" + }, + { + "key": "api", + "value": "https://venus.acatlan.unam.mx/ss-pruebas", + "type": "string", + "disabled": true + } + ] +} \ No newline at end of file diff --git a/escolares_internal_test.sql b/escolares_internal_test.sql new file mode 100644 index 0000000..97b82d7 --- /dev/null +++ b/escolares_internal_test.sql @@ -0,0 +1,107 @@ +CREATE DATABASE Universidad; +USE Universidad; + + +CREATE TABLE Alumnos ( cuenta INT PRIMARY KEY, nombre VARCHAR(255), carrera VARCHAR(255), creditos DECIMAL(5,2)); + +INSERT INTO Alumnos (cuenta, nombre, carrera, creditos) VALUES +(455229002, 'Sara Francisco Ortega Ramos', 'LIC. EN FILOSOFIA', 3.37), +(344254873, 'Ing. Liliana García', 'LIC. ENSEÑANZA DE ESPAÑOL(LENG. EXTRANJ)', 54.26), +(108304507, 'Modesto Samaniego', 'LIC. EN COMUNICACION', 45.52), +(103285757, 'Rosalia Gonzalo Granado', 'LIC. EN LENGUA Y LITERATURA HISPANICAS', 83.41), +(510877055, 'Guillermo Cazares Vásquez', 'LIC. EN LENGUA Y LITERATURA HISPANICAS', 84.5), +(220810204, 'Wendolin Madera', 'LIC. EN ARQUITECTURA', 64.16), +(662985844, 'César Mayorga Rico', 'LIC. EN LENGUA Y LITERATURA HISPANICAS', 49.36), +(320707048, 'Natalia Martha Patiño', 'LIC. EN ARQUITECTURA', 75.9), +(460281371, 'Micaela Araceli Amaya', 'LIC. EN SOCIOLOGIA', 82.13), +(558466371, 'Fidel Vela Valencia', 'LIC. EN DISEÑO GRAFICO', 46.29), +(730812014, 'Yeni Pedro Collado Barraza', 'LIC. EN ACTUARIA', 64.73), +(657270526, 'Miriam María Eugenia Ochoa', 'LIC. EN HISTORIA', 6.06), +(553042949, 'Patricia Cristal Feliciano', 'LIC. EN MATEMATICAS APLICADAS Y COMP.', 21.64), +(256120924, 'Olga Federico Abrego Espinoza', 'LIC. EN LENGUA Y LITERATURA HISPANICAS', 57.51), +(580095253, 'Jaqueline Candelaria', 'LIC. EN INGENIERIA CIVIL', 21.71), +(894433015, 'Agustín Galván Salgado', 'LIC. ENSEÑANZA DE ALEMÁN (LENG. EXTRANJS', 10.66), +(249880845, 'Lic. Felipe Madrigal', 'LIC. EN LENGUA Y LITERATURA HISPANICAS', 21.64), +(776013075, 'Dr. Jerónimo Arteaga', 'LIC. ENSEÑANZA DE ESPAÑOL(LENG. EXTRANJ)', 90.96), +(711114545, 'Hermelinda Rendón Esquivel', 'LIC. ENSEÑANZA DE ESPAÑOL(LENG. EXTRANJ)', 98.52), +(969046528, 'Norma Rubio', 'LIC. EN FILOSOFIA', 40.1), +(977597890, 'Perla Guzmán Mora', 'LIC. EN INGENIERIA CIVIL', 79.66), +(989320527, 'Soledad Abreu', 'LIC. EN DERECHO (SUA)', 0.46), +(557675592, 'Juan Carlos Tovar', 'LIC. EN DERECHO', 86.37), +(454578965, 'Reynaldo Elias Berríos', 'LIC. EN LENGUA Y LITERATURA HISPANICAS', 51.72), +(574884941, 'Clara Alberto Bahena', 'LIC. EN RELACIONES INTERNACIONALES (SUA)', 43.79), +(344273189, 'Noemí Abrego Beltrán', 'LIC. EN RELACIONES INTERNACIONALES (SUA)', 92.72), +(920455788, 'Ilse Mata', 'LIC. EN ACTUARIA', 85.39), +(843807025, 'Alfredo Homero Lomeli', 'LIC. EN ENSEÑANZA DE INGLES', 98.72), +(737482670, 'Sr(a). Natalia Ortega', 'LIC. EN PEDAGOGÍA', 27.62), +(947886427, 'Amalia Emiliano Sanabria González', 'LIC. EN RELACIONES INTERNACIONALES', 23.84), +(303428996, 'Camilo Fajardo Caldera', 'LIC. EN COMUNICACION', 28.69), +(504420847, 'Socorro Gonzalo Varela Escalante', 'LIC. ENSEÑANZA DE INGLÉS(LENG. EXTRANJE)', 76.77), +(916897575, 'Lic. Armando Vallejo', 'LIC. EN RELACIONES INTERNACIONALES (SUA)', 76.18), +(910548164, 'Ing. Dulce Serna', 'LIC. ENSEÑANZA DE ITALIANO(LENG. EXTRANJ', 99.85), +(287603576, 'Bernardo Juana Barrientos Anguiano', 'LIC. EN SOCIOLOGIA', 83.36), +(127855790, 'Lilia Wendolin Urbina Hernández', 'LIC. EN MATEMATICAS APLICADAS Y COMP.', 28.4), +(572039876, 'Soledad Benjamín Tello Aranda', 'LIC. EN DERECHO (SUA)', 6.27), +(177669679, 'María Luisa Rodarte Sotelo', 'LIC. ENSEÑANZA DE INGLÉS(LENG. EXTRANJE)', 17.71), +(750642431, 'Dr. Fabiola Montoya', 'LIC. ENSEÑANZA DE ALEMÁN (LENG. EXTRANJS', 87.34), +(181357215, 'Berta Bruno Cervantes', 'LIC. EN DISEÑO GRAFICO', 98.56), +(837171875, 'Sandra Miriam Arevalo', 'LIC. EN HISTORIA', 77.77), +(865516896, 'Federico Rafaél Ozuna', 'LIC. EN FILOSOFIA', 5.81), +(418259119, 'Ing. Alfredo Galván', 'LIC. ENSEÑANZA DE ITALIANO(LENG. EXTRANJ', 74.91), +(654945240, 'Alejandra Miguel Ángel Paz', 'LIC. EN DERECHO', 70.53), +(838906646, 'Juana Valentín', 'LIC. EN FILOSOFIA', 13.81), +(786618542, 'Vanesa Contreras', 'LIC. EN CIENCIAS POLITICAS Y ADMON PUB', 18.42), +(311809331, 'Cristobal Lucía Lozano Rico', 'LIC. EN MAT. APLICADAS Y COMPUTACION', 46.31), +(633338912, 'Zacarías Zúñiga Cervantes', 'LIC. ENSEÑANZA DE ALEMÁN (LENG. EXTRANJS', 16.59), +(430388364, 'Linda Gómez', 'LIC. ENSEÑANZA DE ITALIANO(LENG. EXTRANJ', 30.53), +(494179153, 'Emiliano Robledo Montes', 'LIC. EN COMUNICACION', 90.31), +(761549514, 'Julia Rosa Corrales Luevano', 'LIC. ENSEÑANZA DE ESPAÑOL(LENG. EXTRANJ)', 68.57), +(917797548, 'Elvia Camarillo', 'LIC. EN DISEÑO GRAFICO', 93.9), +(656519098, 'Asunción Valles Arguello', 'LIC. EN DERECHO (SUA)', 49.11), +(959317624, 'Abraham Merino Collado', 'LIC. EN LENGUA Y LITERATURA HISPANICAS', 74.86), +(529088942, 'Mtro. José Emilio Carrero', 'LIC. EN DERECHO', 25.26), +(410136542, 'Lic. Ivonne Crespo', 'LIC. EN CIENCIAS POLITICAS Y ADMON PUB', 41.01), +(955532842, 'Hermelinda Violeta Vela', 'LIC. ENSEÑANZA DE ITALIANO(LENG. EXTRANJ', 23.99), +(944109052, 'Leonardo Mónica Arenas Barreto', 'LIC. EN CIENCIAS POLITICAS Y ADMON PUB', 65.66), +(736137931, 'Mtro. Vanesa Santiago', 'LIC. EN MAT. APLICADAS Y COMPUTACION', 60.6), +(548504744, 'René Gutiérrez Ozuna', 'LIC. EN ECONOMIA', 51.1), +(230591766, 'Esparta Zamudio Rendón', 'LIC. ENSEÑANZA DE ESPAÑOL(LENG. EXTRANJ)', 96.7), +(365584469, 'Lic. Jacinto Baeza', 'LIC. EN ENSEÑANZA DE INGLES', 16.6), +(366378810, 'Benito Garica Gómez', 'LIC. EN DISEÑO GRAFICO', 50.21), +(130793203, 'Mercedes Dalia Melgar', 'LIC. EN DISEÑO GRAFICO', 79.79), +(118327168, 'Aurelio Juana Chávez', 'LIC. EN PEDAGOGÍA', 65.11), +(541469134, 'René Estévez Alvarez', 'LIC. EN ENSEÑANZA DE INGLES', 83.62), +(146702834, 'Verónica Hugo Montañez Montero', 'LIC. EN ACTUARIA', 82.31), +(391227832, 'Federico Escobar Gollum', 'LIC. EN MATEMATICAS APLICADAS Y COMP.', 53.46), +(620658001, 'Ing. Bernabé Flores', 'LIC. EN ENSEÑANZA DE INGLES', 77.52), +(434742427, 'Esmeralda Yeni Téllez Guerrero', 'LIC. ENSEÑANZA DE ALEMÁN (LENG. EXTRANJS', 92.49), +(789523713, 'Margarita Bahena Rodríquez', 'LIC. EN MAT. APLICADAS Y COMPUTACION', 32.86), +(388536523, 'Hilda Aparicio Ulloa', 'LIC. EN RELACIONES INTERNACIONALES (SUA)', 29.32), +(533652320, 'Lic. Luis Miguel Concepción', 'LIC. EN RELACIONES INTERNACIONALES (SUA)', 57.32), +(766082299, 'Tomás Córdova', 'LIC. ENSEÑANZA DE ALEMÁN (LENG. EXTRANJS', 73.03), +(386050318, 'Noelia Villarreal Colón', 'LIC. EN RELACIONES INTERNACIONALES (SUA)', 17.6), +(746187129, 'Sr(a). Jos Nava', 'LIC. EN ARQUITECTURA', 95.45), +(485991016, 'Lucía Aurora Casárez', 'LIC. EN ACTUARIA', 42.66), +(563067802, 'David Jorge Pizarro Camarillo', 'LIC. EN DERECHO (SUA)', 62.65), +(736767614, 'Ing. Adán Serna', 'LIC. EN HISTORIA', 88.74), +(809970519, 'Rosalia Amelia Zamora Molina', 'LIC. EN RELACIONES INTERNACIONALES', 74.47), +(895517249, 'Gloria Genaro Bustos', 'LIC. ENSEÑANZA DE INGLÉS(LENG. EXTRANJE)', 68.23), +(747147954, 'Nadia Becerra', 'LIC. EN ECONOMIA', 2.22), +(354535405, 'Roberto Zamora', 'LIC. EN COMUNICACION', 87.97), +(577656886, 'Hernán Robledo Guevara', 'LIC. ENSEÑANZA DE ESPAÑOL(LENG. EXTRANJ)', 66.64), +(187735537, 'Camila Gaytán Guerrero', 'LIC. EN DERECHO (SUA)', 6.46), +(399199599, 'José Luis Humberto Villalpando', 'LIC. EN DERECHO (SUA)', 6.83), +(143603799, 'Anabel Rodríquez', 'LIC. EN RELACIONES INTERNACIONALES', 34.91), +(966725974, 'Laura Gloria Maya', 'LIC. EN MATEMATICAS APLICADAS Y COMP.', 51.86), +(612650412, 'Elvira Villaseñor', 'LIC. EN MATEMATICAS APLICADAS Y COMP.', 51.44), +(931796380, 'Clemente Nayeli Robledo', 'LIC. EN CIENCIAS POLITICAS Y ADMON.PUBL.', 29.24), +(414281020, 'Arcelia Delgadillo', 'LIC. ENSEÑANZA DE INGLÉS(LENG. EXTRANJE)', 10.09), +(142787880, 'Inés Julio César Tijerina Roybal', 'LIC. EN ENSEÑANZA DE INGLES', 53.02), +(439856515, 'Bruno Guardado', 'LIC. EN PERIODISMO Y COMUNICACION COL.', 4.94), +(378161746, 'Lic. Porfirio García', 'LIC. EN LENGUA Y LITERATURA HISPANICAS', 50.44), +(216618195, 'Nayeli Raquel Serrato', 'LIC. ENSEÑANZA DE ITALIANO(LENG. EXTRANJ', 56.96), +(826483124, 'Dr. Gabino Carrera', 'LIC. EN SOCIOLOGIA', 74.9), +(936737436, 'Yeni Liliana Pedroza Girón', 'LIC. EN CIENCIAS POLITICAS Y ADMON.PUBL.', 48.61), +(350401488, 'Dalia Julia Trujillo', 'LIC. EN CIENCIAS POLITICAS Y ADMON PUB', 80.19), +(443993884, 'Abigail Caridad Cervántez Rojas', 'LIC. EN DISEÑO GRAFICO', 86.89), +(920680444, 'Barbara David Montoya', 'LIC. EN PERIODISMO Y COMUNICACION COL.', 81.56); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 0931f0a..5a08a42 100644 --- a/package-lock.json +++ b/package-lock.json @@ -90,9 +90,9 @@ "integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==" }, "node_modules/@types/node": { - "version": "14.18.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.4.tgz", - "integrity": "sha512-swe3lD4izOJWHuxvsZdDFRq6S9i6koJsXOnQKYekhSO5JTizMVirUFgY/bUsaOJQj8oSD4oxmRYPBM/0b6jpdw==" + "version": "14.18.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.7.tgz", + "integrity": "sha512-UpLEO1iBG7esNPusSAjoZhWFK5Mfd8QfwWhHRrg5io13POn/stsBgTCba9suQaFflNA4tc0+6AFM3R6BZNng6A==" }, "node_modules/abbrev": { "version": "1.1.1", @@ -1008,9 +1008,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.14.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.6.tgz", - "integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==", + "version": "1.14.7", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", + "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==", "funding": [ { "type": "individual", @@ -1205,11 +1205,11 @@ } }, "node_modules/google-p12-pem": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-3.1.2.tgz", - "integrity": "sha512-tjf3IQIt7tWCDsa0ofDQ1qqSCNzahXDxdAGJDbruWqu3eCg5CKLYKN+hi0s6lfvzYZ1GDVr+oDF9OOWlDSdf0A==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-3.1.3.tgz", + "integrity": "sha512-MC0jISvzymxePDVembypNefkAQp+DRP7dBE+zNUPaIjEspIlYg0++OrsNr248V9tPbz6iqtZ7rX1hxWA5B8qBQ==", "dependencies": { - "node-forge": "^0.10.0" + "node-forge": "^1.0.0" }, "bin": { "gp12-pem": "build/src/bin/gp12-pem.js" @@ -1269,9 +1269,9 @@ } }, "node_modules/graceful-fs": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", - "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", + "version": "4.2.9", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", + "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==", "dev": true }, "node_modules/gtoken": { @@ -1967,22 +1967,30 @@ "integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==" }, "node_modules/node-fetch": { - "version": "2.6.6", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.6.tgz", - "integrity": "sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==", + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", "dependencies": { "whatwg-url": "^5.0.0" }, "engines": { "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } } }, "node_modules/node-forge": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz", - "integrity": "sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.2.1.tgz", + "integrity": "sha512-Fcvtbb+zBcZXbTTVwqGA5W+MKBj56UjVRevvchv5XrcyXbmNdesfZL37nlcWOfpgHhgmxApw3tQbTr4CqNmX4w==", "engines": { - "node": ">= 6.0.0" + "node": ">= 6.13.0" } }, "node_modules/nodemailer": { @@ -2471,9 +2479,9 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, "node_modules/sequelize": { - "version": "6.12.4", - "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.12.4.tgz", - "integrity": "sha512-P2E8TzlV3VwdvPqTS58ctIpcAOytXdaylUUfxxnALjtMmF6I+kfNtrqTP7WQFaenOboAtXPCJReZ9MPy+Zy/Ig==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.13.0.tgz", + "integrity": "sha512-p0dXXGZSc0Ng7CdGwlKN4P6DTRD/w9Ar2CnmHamNVDnqEWh6pMVOp3xrlG5+IWhbwrqL3SjIYEYt3Xog1vXRDw==", "funding": [ { "type": "opencollective", @@ -3051,9 +3059,9 @@ "integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==" }, "@types/node": { - "version": "14.18.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.4.tgz", - "integrity": "sha512-swe3lD4izOJWHuxvsZdDFRq6S9i6koJsXOnQKYekhSO5JTizMVirUFgY/bUsaOJQj8oSD4oxmRYPBM/0b6jpdw==" + "version": "14.18.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.7.tgz", + "integrity": "sha512-UpLEO1iBG7esNPusSAjoZhWFK5Mfd8QfwWhHRrg5io13POn/stsBgTCba9suQaFflNA4tc0+6AFM3R6BZNng6A==" }, "abbrev": { "version": "1.1.1", @@ -3771,9 +3779,9 @@ } }, "follow-redirects": { - "version": "1.14.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.6.tgz", - "integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==" + "version": "1.14.7", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.7.tgz", + "integrity": "sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==" }, "forwarded": { "version": "0.2.0", @@ -3908,11 +3916,11 @@ } }, "google-p12-pem": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-3.1.2.tgz", - "integrity": "sha512-tjf3IQIt7tWCDsa0ofDQ1qqSCNzahXDxdAGJDbruWqu3eCg5CKLYKN+hi0s6lfvzYZ1GDVr+oDF9OOWlDSdf0A==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-3.1.3.tgz", + "integrity": "sha512-MC0jISvzymxePDVembypNefkAQp+DRP7dBE+zNUPaIjEspIlYg0++OrsNr248V9tPbz6iqtZ7rX1hxWA5B8qBQ==", "requires": { - "node-forge": "^0.10.0" + "node-forge": "^1.0.0" } }, "googleapis": { @@ -3957,9 +3965,9 @@ } }, "graceful-fs": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", - "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", + "version": "4.2.9", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz", + "integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==", "dev": true }, "gtoken": { @@ -4504,17 +4512,17 @@ "integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==" }, "node-fetch": { - "version": "2.6.6", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.6.tgz", - "integrity": "sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==", + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", "requires": { "whatwg-url": "^5.0.0" } }, "node-forge": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz", - "integrity": "sha512-PPmu8eEeG9saEUvI97fm4OYxXVB6bFvyNTyiUOBichBpFG8A1Ljw3bY62+5oOjDEMHRnd0Y7HQ+x7uzxOzC6JA==" + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.2.1.tgz", + "integrity": "sha512-Fcvtbb+zBcZXbTTVwqGA5W+MKBj56UjVRevvchv5XrcyXbmNdesfZL37nlcWOfpgHhgmxApw3tQbTr4CqNmX4w==" }, "nodemailer": { "version": "6.7.2", @@ -4888,9 +4896,9 @@ } }, "sequelize": { - "version": "6.12.4", - "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.12.4.tgz", - "integrity": "sha512-P2E8TzlV3VwdvPqTS58ctIpcAOytXdaylUUfxxnALjtMmF6I+kfNtrqTP7WQFaenOboAtXPCJReZ9MPy+Zy/Ig==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.13.0.tgz", + "integrity": "sha512-p0dXXGZSc0Ng7CdGwlKN4P6DTRD/w9Ar2CnmHamNVDnqEWh6pMVOp3xrlG5+IWhbwrqL3SjIYEYt3Xog1vXRDw==", "requires": { "@types/debug": "^4.1.7", "debug": "^4.3.3", diff --git a/server/app.js b/server/app.js index a2a0806..071a18a 100644 --- a/server/app.js +++ b/server/app.js @@ -17,7 +17,7 @@ app.use(bodyParser.json()); app.use(express.static('csv')); -app.get('/', (req, res) => res.send('API IRIS')); +app.get('/', (req, res) => res.send('API IRIS updated 30 jan')); app.use(require('./routes/index')); diff --git a/server/config/sequelize.conf.js b/server/config/sequelize.conf.js index 3502aaf..ba66ef2 100644 --- a/server/config/sequelize.conf.js +++ b/server/config/sequelize.conf.js @@ -10,9 +10,9 @@ const sequelize = new Sequelize( dialect: process.env.TYPEDB, logging: false, dialectOptions: { - useUTC: false, + timezone: "America/Mexico_City", // También en dialectOptions }, - timezone: '-05:00', + timezone: '-06:00', } ); diff --git a/server/controller/CasoEspecial/casoEspecial.js b/server/controller/CasoEspecial/casoEspecial.js index 897e516..cc72ed8 100644 --- a/server/controller/CasoEspecial/casoEspecial.js +++ b/server/controller/CasoEspecial/casoEspecial.js @@ -15,16 +15,31 @@ const admin = async (body) => { return CasoEspecial.findOne({ where: { idCasoEspecial }, include: [ - { model: Usuario, include: [{ model: TipoUsuario }] }, + { + model: Usuario, + include: [{ model: TipoUsuario }], + attributes: ['idUsuario', 'usuario', 'nombre'], + }, { model: Carrera }, { model: Status }, ], + attributes: [ + 'idCasoEspecial', + 'creditos', + 'correo', + 'telefono', + 'institucion', + 'dependencia', + 'motivo', + 'direccion', + 'fechaInicio', + 'fechaFin', + 'fechaNacimiento', + 'archivoZip', + 'createdAt', + ], }).then((res) => { if (!res) throw new Error('No existe este Caso Especial.'); - delete res.dataValues.Usuario.dataValues.password; - delete res.dataValues.idUsuario; - delete res.dataValues.idCarrera; - delete res.dataValues.idStatus; return res; }); }; diff --git a/server/controller/CasoEspecial/nuevo.js b/server/controller/CasoEspecial/nuevo.js index 8a30e51..10d3948 100644 --- a/server/controller/CasoEspecial/nuevo.js +++ b/server/controller/CasoEspecial/nuevo.js @@ -49,7 +49,7 @@ const nuevo = async (body, file) => { let carpeta = ''; return Usuario.findOne({ - where: { idUsuario }, + where: { idUsuario }, }) .then((res) => { if (!res) throw new Error('Este alumno no existe en la db.'); diff --git a/server/controller/CasoEspecial/serviciosEspeciales.js b/server/controller/CasoEspecial/serviciosEspeciales.js index 2ce5d06..b70c730 100644 --- a/server/controller/CasoEspecial/serviciosEspeciales.js +++ b/server/controller/CasoEspecial/serviciosEspeciales.js @@ -35,19 +35,16 @@ const serviciosEspeciales = async (body) => { { nombre: { [Op.like]: `%${nombre}%` } }, ], }, + attributes: ['idUsuario', 'usuario', 'nombre'], }, { model: Carrera }, { model: Status, where }, ], + attributes: ['idCasoEspecial', 'fechaInicio', 'fechaFin', 'createdAt'], order: [['updatedAt', 'DESC']], limit: 25, offset: 25 * (pagina - 1), - }).then((res) => { - for (let i = 0; i < res.rows.length; i++) { - // delete res.rows[i].dataValues.idUsuario - } - return { count: res.count, serviciosEspeciales: res.rows }; - }); + }).then((res) => ({ count: res.count, serviciosEspeciales: res.rows })); }; module.exports = serviciosEspeciales; diff --git a/server/controller/CuestionarioAlumno/get.js b/server/controller/CuestionarioAlumno/get.js index db7646d..b6d6aa7 100644 --- a/server/controller/CuestionarioAlumno/get.js +++ b/server/controller/CuestionarioAlumno/get.js @@ -10,7 +10,9 @@ const Programa = require(`${dbPath}/Programa`); const Servicio = require(`${dbPath}/Servicio`); const Usuario = require(`${dbPath}/Usuario`); -const get = async (body) => { +const CuestionarioAlumno2 = require(`${dbPath}/CuestionarioAlumno2`); + +const getOld = async (body) => { const year = validarNumero(body.year, 'año', true, 4); const path = `server/uploads/${year}_cuestionario_alumno.csv`; const data = []; @@ -79,4 +81,68 @@ const get = async (body) => { .then((res) => path); }; +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 + +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); + + 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; diff --git a/server/controller/CuestionarioAlumno/nuevo.js b/server/controller/CuestionarioAlumno/nuevo.js index db3e05e..489ed8d 100644 --- a/server/controller/CuestionarioAlumno/nuevo.js +++ b/server/controller/CuestionarioAlumno/nuevo.js @@ -3,7 +3,11 @@ const dbPath = '../../db/tablas'; const CuestionarioAlumno = require(`${dbPath}/CuestionarioAlumno`); const Servicio = require(`${dbPath}/Servicio`); -const nuevo = async (body) => { + +const CuestionarioAlumno2 = require(`${dbPath}/CuestionarioAlumno2`); + + +const nuevoOld = async (body) => { const idServicio = validar.validarNumeroEntero( body.idServicio, 'id servicio' @@ -161,4 +165,121 @@ const nuevo = async (body) => { })); }; + + +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.idCuestionarioAlumno2) + 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 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("datos a registrar en la tabla cuestionarioAlumno2", { ...body} ); + + let respuestasRegistradas = await CuestionarioAlumno2.create({ ...body }); + console.log('despues de registrar cuestionario', respuestasRegistradas); + + + + + console.log('agregar el id a la tabla servicio, esta validado en el front'); + + let resX = await Servicio.update( + { idCuestionarioAlumno2: respuestasRegistradas.idCuestionarioAlumno2}, + { where: { idServicio } } + ) + + console.log('despues de registrar el id en la tabla servicio', resX); + + + + return respuestasRegistradas; + }) + + + .then((res) => validar.validarPreTermino(idServicio)) + + + .then((res) => ({ + message: `Se guardaron tus respuestas correctamente. ${res}`, + })); +}; + + module.exports = nuevo; diff --git a/server/controller/CuestionarioPrograma/get.js b/server/controller/CuestionarioPrograma/get.js index 25a9338..bd9fa1d 100644 --- a/server/controller/CuestionarioPrograma/get.js +++ b/server/controller/CuestionarioPrograma/get.js @@ -6,12 +6,17 @@ const helper = require(`${helperPath}/helper`); const { validarNumero } = require(`${helperPath}/validar`); const dbPath = '../../db/tablas'; const Carrera = require(`${dbPath}/Carrera`); -const CuestionarioPrograma = require(`${dbPath}/CuestionarioPrograma`); const Servicio = require(`${dbPath}/Servicio`); const Programa = require(`${dbPath}/Programa`); const Usuario = require(`${dbPath}/Usuario`); -const get = async (body) => { + +const CuestionarioPrograma2 = require(`${dbPath}/CuestionarioPrograma2`); + + + +const CuestionarioPrograma = require(`${dbPath}/CuestionarioPrograma`); +const getOld = async (body) => { const year = validarNumero(body.year, 'año', true, 4); const path = `server/uploads/${year}_cuestionario_programa.csv`; const data = []; @@ -56,4 +61,78 @@ const get = async (body) => { .then((res) => path); }; + + + + +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'){ + + temp = CuestionarioPrograma.findAll({ + where: { + 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); + + 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); + } + + + module.exports = get; diff --git a/server/controller/CuestionarioPrograma/nuevo.js b/server/controller/CuestionarioPrograma/nuevo.js index c42c9a8..5e38ba9 100644 --- a/server/controller/CuestionarioPrograma/nuevo.js +++ b/server/controller/CuestionarioPrograma/nuevo.js @@ -3,7 +3,12 @@ const dbPath = '../../db/tablas'; const CuestionarioPrograma = require(`${dbPath}/CuestionarioPrograma`); const Servicio = require(`${dbPath}/Servicio`); -const nuevo = async (body) => { + +const CuestionarioPrograma2 = require(`${dbPath}/CuestionarioPrograma2`); + + + +const nuevoOld = async (body) => { const idServicio = validar.validarNumeroEntero( body.idServicio, 'id servicio' @@ -76,4 +81,128 @@ const nuevo = async (body) => { })); }; + + +const nuevo = async (body) => { + // console.log(body); + + let idServicio = body.idServicio; + body = validar.validarCuestionarioPrograma2(body); + + /* + 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.idCuestionarioPrograma2) + throw new Error( + 'Este Servicio Social ya cuenta con cuestionario de programa' + ); + + console.log('el servicio social si existe', res); + // 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 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); + */ + + + + // falta verificar que tenga solo un cuestionario + + + + 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 + + + console.log("registrar id en servicio en cuestionario 2"); + + let x = await Servicio.update( + { idCuestionarioPrograma2: respuestasRegistradas.idCuestionarioPrograma2 }, + { where: { idServicio } } + ) + + console.log(x); + + + + + + + return respuestasRegistradas; + }) + + .then((res) => validar.validarPreTermino(idServicio)) + + + .then((res) => ({ + message: `Se guardaron tus respuestas correctamente. ${res}`, + })); +}; + + + + module.exports = nuevo; diff --git a/server/controller/Servicio/admin.js b/server/controller/Servicio/admin.js index 7660940..380be7f 100644 --- a/server/controller/Servicio/admin.js +++ b/server/controller/Servicio/admin.js @@ -13,20 +13,55 @@ const admin = async (body) => { return Servicio.findOne({ where: { idServicio }, include: [ - { model: Usuario, include: [{ model: TipoUsuario }] }, + { + model: Usuario, + include: [{ model: TipoUsuario }], + attributes: ['idUsuario', 'usuario', 'nombre'], + }, { model: Carrera }, { model: Status }, - { model: Programa, include: [{ model: Usuario }] }, + { + model: Programa, + include: [ + { + model: Usuario, + attributes: ['idUsuario', 'usuario', 'nombre'], + }, + ], + attributes: [ + 'idPrograma', + 'institucion', + 'dependencia', + 'programa', + 'clavePrograma', + 'acatlan', + ], + }, + ], + attributes: [ + 'idServicio', + 'creditos', + 'correo', + 'telefono', + 'direccion', + 'fechaInicio', + 'fechaFin', + 'fechaLiberacion', + 'fechaNacimiento', + 'cartaAceptacion', + 'cartaTermino', + 'informeGlobal', + 'programaInterno', + 'profesor', + 'vistoBuenoAcatlan', + 'createdAt', + 'idCuestionarioAlumno', + 'idCuestionarioAlumno2', + 'idCuestionarioPrograma', + 'idCuestionarioPrograma2' ], }).then((res) => { if (!res) throw new Error('No existe este servicio social.'); - delete res.dataValues.Usuario.dataValues.password; - delete res.dataValues.Programa.dataValues.idUsuario; - delete res.dataValues.Programa.dataValues.Usuario.dataValues.password; - delete res.dataValues.idUsuario; - delete res.dataValues.idCarrera; - delete res.dataValues.idStatus; - delete res.dataValues.idPrograma; return res; }); }; diff --git a/server/controller/Servicio/alumno.js b/server/controller/Servicio/alumno.js index 03e9292..e4f1a23 100644 --- a/server/controller/Servicio/alumno.js +++ b/server/controller/Servicio/alumno.js @@ -17,22 +17,41 @@ const alumno = async (body) => { throw new Error('No es un usuario de tipo alumno.'); return Servicio.findOne({ where: { idUsuario, idStatus: { [Op.not]: 10 } }, - include: [{ model: Carrera }, { model: Status }, { model: Programa }], + include: [ + { model: Carrera }, + { model: Status }, + { + model: Programa, + attributes: [ + 'idPrograma', + 'institucion', + 'dependencia', + 'programa', + 'clavePrograma', + ], + }, + ], + attributes: [ + 'idServicio', + 'creditos', + 'correo', + 'telefono', + 'direccion', + 'fechaInicio', + 'fechaFin', + 'fechaLiberacion', + 'fechaNacimiento', + 'informeGlobal', + 'programaInterno', + 'profesor', + 'createdAt', + 'idCuestionarioAlumno', + 'idCuestionarioAlumno2' + ], }); }) .then((res) => { if (!res) throw new Error('No existe este servicio social.'); - delete res.dataValues.idUsuario; - delete res.dataValues.idCarrera; - delete res.dataValues.idStatus; - delete res.dataValues.idPrograma; - delete res.dataValues.updatedAt; - delete res.dataValues.carpeta; - delete res.dataValues.cartaAceptacion; - delete res.dataValues.cartaTermino; - delete res.dataValues.vistoBuenoAcatlan; - delete res.dataValues.idCuestionarioPrograma; - delete res.dataValues.Programa.idUsuario; return res; }); }; diff --git a/server/controller/Servicio/cartaTermino.js b/server/controller/Servicio/cartaTermino.js index 6153f0c..5df792f 100644 --- a/server/controller/Servicio/cartaTermino.js +++ b/server/controller/Servicio/cartaTermino.js @@ -24,12 +24,14 @@ const cartaTermino = async (body, file) => { switch (res.idStatus) { case 4: case 8: - return drive.uploadFile( + return drive.uploadFile( path, `Carta_Termino.pdf`, 'application/pdf', res.carpeta - ); + ); + //return "carta de termino" + case 1: case 2: case 3: diff --git a/server/controller/Servicio/informeGlobal.js b/server/controller/Servicio/informeGlobal.js index 7d7d158..32eb772 100644 --- a/server/controller/Servicio/informeGlobal.js +++ b/server/controller/Servicio/informeGlobal.js @@ -24,12 +24,13 @@ const informeGlobal = async (body, file) => { switch (res.idStatus) { case 4: case 9: - return drive.uploadFile( + return drive.uploadFile( path, `Informe_Global.pdf`, 'application/pdf', res.carpeta - ); + ); + // return "informe global" case 1: case 2: case 3: diff --git a/server/controller/Servicio/nuevo.js b/server/controller/Servicio/nuevo.js index 7a9520e..c2b5f34 100644 --- a/server/controller/Servicio/nuevo.js +++ b/server/controller/Servicio/nuevo.js @@ -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.` }; }); }; diff --git a/server/controller/Servicio/registro.js b/server/controller/Servicio/registro.js index 11f5d16..82b4b6f 100644 --- a/server/controller/Servicio/registro.js +++ b/server/controller/Servicio/registro.js @@ -12,7 +12,9 @@ const registro = async (body) => { body.idServicio, 'id servicio' ); - const password = encriptar.generarPassword(); + const password = encriptar.generarPassword(); // esta genera la contraseña + if (process.env.MODE == "pruebas") password = 'qwertyui' + // const password = pass //encriptar.encriptar(pass) let correo = {}; let idUsuario; @@ -57,7 +59,7 @@ const registro = async (body) => { .then((res) => Servicio.update({ idStatus: 2 }, { where: { idServicio } })) .then((res) => ({ message: - 'Se cambio de estatus correctamente y se envio un correo al alumno con sus credenciales.', + 'Se cambio de estatus correctamente y se envio un correo al alumno con sus credenciales.' })); }; diff --git a/server/controller/Servicio/registroValidado.js b/server/controller/Servicio/registroValidado.js index 0dcadfb..93d7bde 100644 --- a/server/controller/Servicio/registroValidado.js +++ b/server/controller/Servicio/registroValidado.js @@ -78,13 +78,19 @@ const registroValidado = async (body) => { gmail(correoResponsable.subject, emailResponsable, correoResponsable.msj) ) .then((res) => - Servicio.update( + { + + let tempStatus = 3 + if (process.env.MODE == "pruebas") tempStatus = 4 + + return Servicio.update( // Producción - { idStatus: 3, direccion, telefono, fechaNacimiento }, + // { idStatus: 3, direccion, telefono, fechaNacimiento }, // Pruebas - // { idStatus: 4, direccion, telefono, fechaNacimiento }, + { idStatus: tempStatus, direccion, telefono, fechaNacimiento }, { where: { idServicio } } ) + } ) .then((res) => ({ message: 'Haz terminado el registro de tu Servicio Social correctamente.', diff --git a/server/controller/Servicio/serviciosAdmin.js b/server/controller/Servicio/serviciosAdmin.js index e459b6c..7aab32a 100644 --- a/server/controller/Servicio/serviciosAdmin.js +++ b/server/controller/Servicio/serviciosAdmin.js @@ -36,33 +36,16 @@ const serviciosAdmin = async (body) => { { nombre: { [Op.like]: `%${nombre}%` } }, ], }, + attributes: ['idUsuario', 'usuario', 'nombre'], }, { model: Carrera }, { model: Status, where }, ], + attributes: ['idServicio', 'fechaInicio', 'fechaFin', 'createdAt'], order: [['updatedAt', 'DESC']], limit: 25, offset: 25 * (pagina - 1), - }).then((res) => { - let data = []; - - for (let i = 0; i < res.rows.length; i++) { - data.push({ - idServicio: res.rows[i].idServicio, - fechaInicio: moment(res.rows[i].fechaInicio).format(), - fechaFin: moment(res.rows[i].fechaFin).format(), - createdAt: moment(res.rows[i].createdAt).format(), - Usuario: { - idUsuario: res.rows[i].Usuario.idUsuario, - usuario: res.rows[i].Usuario.usuario, - nombre: res.rows[i].Usuario.nombre, - }, - Carrera: res.rows[i].Carrera, - Status: res.rows[i].Status, - }); - } - return { count: res.count, serviciosAdmin: data }; - }); + }).then((res) => ({ count: res.count, serviciosAdmin: res.rows })); }; module.exports = serviciosAdmin; diff --git a/server/controller/Servicio/serviciosResponsable.js b/server/controller/Servicio/serviciosResponsable.js index f15afac..ff70814 100644 --- a/server/controller/Servicio/serviciosResponsable.js +++ b/server/controller/Servicio/serviciosResponsable.js @@ -36,7 +36,7 @@ const serviciosResponsable = async (body) => { throw new Error('No es un usuario tipo responsable.'); return Servicio.findAndCountAll({ include: [ - { model: Programa, where: { idUsuario } }, + { model: Programa, where: { idUsuario }, attributes: [] }, { model: Usuario, where: { @@ -45,36 +45,26 @@ const serviciosResponsable = async (body) => { { nombre: { [Op.like]: `%${nombre}%` } }, ], }, + attributes: ['idUsuario', 'usuario', 'nombre'], }, { model: Carrera }, { model: Status, where }, ], + attributes: [ + 'idServicio', + 'fechaInicio', + 'fechaFin', + 'cartaTermino', + 'createdAt', + 'idCuestionarioPrograma', + 'idCuestionarioPrograma2' + ], order: [['updatedAt', 'DESC']], limit: 25, offset: 25 * (pagina - 1), }); }) - .then((res) => { - let data = []; - - for (let i = 0; i < res.rows.length; i++) { - data.push({ - idServicio: res.rows[i].idServicio, - fechaInicio: moment(res.rows[i].fechaInicio).format(), - fechaFin: moment(res.rows[i].fechaFin).format(), - cartaTermino: res.rows[i].cartaTermino, - idCuestionarioPrograma: res.rows[i].idCuestionarioPrograma, - Usuario: { - idUsuario: res.rows[i].Usuario.idUsuario, - usuario: res.rows[i].Usuario.usuario, - nombre: res.rows[i].Usuario.nombre, - }, - Carrera: res.rows[i].Carrera, - Status: res.rows[i].Status, - }); - } - return { count: res.count, serviciosResponsable: data }; - }); + .then((res) => ({ count: res.count, serviciosResponsable: res.rows })); }; module.exports = serviciosResponsable; diff --git a/server/controller/Servicio/update.js b/server/controller/Servicio/update.js index 4043ecb..cbac17f 100644 --- a/server/controller/Servicio/update.js +++ b/server/controller/Servicio/update.js @@ -79,6 +79,11 @@ const update = async (body, files) => { ); return Servicio.update(dataUpdate, { where: { idServicio } }); }) + .then(async (res) => { + if (dataUpdate.cartaTermino || dataUpdate.informeGlobal) + return validar.validarPreTermino(idServicio); + return false; + }) .then((res) => ({ message: 'Se guardo correctamente los cambios de este servicio.', })); diff --git a/server/controller/Usuario/escolares.js b/server/controller/Usuario/escolares.js index 1326a47..f3dc8e4 100644 --- a/server/controller/Usuario/escolares.js +++ b/server/controller/Usuario/escolares.js @@ -36,11 +36,32 @@ const escolares = async (body) => { const numeroCuenta = validarNumeroCuenta(body.numeroCuenta); let alumno; - return axios({ - method: 'post', - url: `${process.env.ESCOLARES}${numeroCuenta}`, - data: `${process.env.ESCOLARES_PASS}`, - }) + + let promise; + + if(process.env.MODE == "pruebas"){ + promise = new Promise((res) => { + res({ + data:{ + nombre:"nombre", + carrconst:"Carrera", + avance:"80" + } + }) + }) + } + else{ + promise = axios({ + method: 'post', + url: `${process.env.ESCOLARES}${numeroCuenta}`, + data: `${process.env.ESCOLARES_PASS}`, + }) + + } + + return promise + + .then((res) => { if (!res.data.nombre || !res.data.carrconst || !res.data.avance) throw new Error( diff --git a/server/controller/Usuario/login.js b/server/controller/Usuario/login.js index b6314ef..d0c8682 100644 --- a/server/controller/Usuario/login.js +++ b/server/controller/Usuario/login.js @@ -1,5 +1,6 @@ -const validar = require('../../helper/validar'); const { crearToken } = require('../../middleware/autentificacion'); +// const validarPath = '../../db/tablas'; +const validar = require('../../helper/validar'); const { comparar } = require('../../helper/encriptar'); const dbPath = '../../db/tablas'; const Usuario = require(`${dbPath}/Usuario`); @@ -21,20 +22,26 @@ const login = async (body) => { return Usuario.findOne({ where: { usuario }, - include: [{ model: TipoUsuario }], - }).then((res) => { - if (!res) throw new Error('No existe este usuario.'); - if (!res.activo) throw new Error('Este usuario no esta activo.'); - if (comparar(password, res.password)) { - delete res.dataValues.password; - delete res.dataValues.activo; - return { - Usuario: res, - token: crearToken(res.idUsuario), - }; - } - throw new Error('La contraseña es incorrecta'); - }); + attributes: ['idUsuario', 'activo', 'password'], + }) + .then((res) => { + if (!res) throw new Error('No existe este usuario.'); + if (!res.activo) throw new Error('Este usuario no esta activo.'); + if (!comparar(password, res.password)) + throw new Error('La contraseña es incorrecta'); + return Usuario.findOne({ + where: { idUsuario: res.idUsuario }, + include: [{ model: TipoUsuario }], + attributes: ['idUsuario', 'usuario', 'nombre'], + }); + }) + .then((res) => ({ + Usuario: res, + token: crearToken({ + idUsuario: res.idUsuario, + idTipoUsuario: res.TipoUsuario.idTipoUsuario, + }), + })); }; module.exports = login; diff --git a/server/controller/Usuario/responsable.js b/server/controller/Usuario/responsable.js index a35c7dc..4427dca 100644 --- a/server/controller/Usuario/responsable.js +++ b/server/controller/Usuario/responsable.js @@ -6,10 +6,7 @@ const responsable = async (body) => { return Usuario.findOne({ where: { idUsuario }, - }).then((res) => { - delete res.dataValues.password; - delete res.dataValues.idTipoUsuario; - return res; + attributes: ['idUsuario', 'usuario', 'nombre', 'activo'], }); }; diff --git a/server/controller/Usuario/responsables.js b/server/controller/Usuario/responsables.js index b3478bd..a068f5f 100644 --- a/server/controller/Usuario/responsables.js +++ b/server/controller/Usuario/responsables.js @@ -26,15 +26,10 @@ const responsables = async (body) => { { idTipoUsuario: 2 }, ], }, + attributes: ['idUsuario', 'usuario', 'nombre', 'activo'], limit: 25, offset: 25 * (pagina - 1), - }).then((res) => { - for (let i = 0; i < res.rows.length; i++) { - delete res.rows[i].dataValues.password; - delete res.rows[i].dataValues.idTipoUsuario; - } - return { count: res.count, responsables: res.rows }; - }); + }).then((res) => ({ count: res.count, responsables: res.rows })); }; module.exports = responsables; diff --git a/server/db/data-fake.js b/server/db/data-fake.js index ea5fe92..9e70a58 100644 --- a/server/db/data-fake.js +++ b/server/db/data-fake.js @@ -3,11 +3,64 @@ const encriptar = require('../helper/encriptar'); const Usuario = require('./tablas/Usuario'); const Programa = require('./tablas/Programa'); -const correosExt = ['lemuel@acatlan.unam.mx']; -const correosInt = ['cidwa1@pcpuma.acatlan.unam.mx']; -const nombresExt = ['Lemuel Rosas']; -const nombresInt = ['Lemuel Márquez']; +const correosExt = ['eithan.castillo@acatlan.unam.mx']; +const correosInt = ['316092940@pcpuma.acatlan.unam.mx']; +const nombresExt = ['responsable exterior']; +const nombresInt = ['responsable interno']; +const correosAdmin = ['unam.alternativo@gmail.com'] +const nombresAdmin = ['admin1'] + + +const correosEspecial = ['eithan.dev@gmail.com'] +const nombresEspecial = ['Especial1'] + + + + + + + + + + +// create los admin son los encargados de cada programa +const createAdmin = async () => { + console.log('\nPaso 1) Instalando Responsables Externos falsos.'.bold.blue); + for (let i = 0; i < correosAdmin.length; i++) { + await Usuario.create({ + usuario: correosAdmin[i], + idTipoUsuario: 1, + nombre: nombresAdmin[i], + password: encriptar.encriptar('qwertyui'), + activo: true, + }) + + + } +}; + + + + +const createEspecial = async () => { + console.log('\nPaso 1) Instalando Responsables Externos falsos.'.bold.blue); + for (let i = 0; i < correosEspecial.length; i++) { + await Usuario.create({ + usuario: correosEspecial[i], + idTipoUsuario: 4, + nombre: nombresEspecial[i], + password: encriptar.encriptar('qwertyui'), + activo: true, + }) + } +}; + + + + + + const dataResponsableExt = async () => { console.log('\nPaso 1) Instalando Responsables Externos falsos.'.bold.blue); for (let i = 0; i < correosExt.length; i++) { @@ -33,7 +86,9 @@ const dataResponsableExt = async () => { } }); } -}; +}; + + const dataResponsableInt = async () => { console.log('\nPaso 1) Instalando Responsables Internos falsos.'.bold.blue); @@ -62,9 +117,17 @@ const dataResponsableInt = async () => { } }; + + + + + const exec = async () => { await dataResponsableExt(); await dataResponsableInt(); + await createAdmin(); + await createEspecial(); + console.log( '\nSe ha instalado exitosamente la informacion falsa.\n'.underline.bold .green diff --git a/server/db/install.js b/server/db/install.js index 6c9ef67..439798e 100644 --- a/server/db/install.js +++ b/server/db/install.js @@ -10,6 +10,8 @@ const CasoEspecial = require('./tablas/CasoEspecial'); const Status = require('./tablas/Status'); const TipoUsuario = require('./tablas/TipoUsuario'); const Usuario = require('./tablas/Usuario'); +const CuestionarioAlumno2 = require('./tablas/CuestionarioAlumno2'); +const CuestionarioPrograma2 = require('./tablas/CuestionarioPrograma2'); const drop = async () => { console.log('\nPaso 1) Desinstalando la db.'.bold.blue); @@ -44,8 +46,25 @@ const drop = async () => { await TipoUsuario.drop(); console.log('La tabla TipoUsuario se desinstalo correctamente.'.magenta); + + + +/* await CuestionarioPrograma2.drop(); + console.log( + 'La tabla CuestionarioPrograma se desinstalo correctamente.'.magenta + ); + + await CuestionarioAlumno2.drop(); + console.log( + 'La tabla CuestionarioAlumno se desinstalo correctamente.'.magenta + ); */ + + }; + + + const sync = async () => { console.log('\nPaso 2) Instalando la db.'.bold.blue); @@ -77,6 +96,16 @@ const sync = async () => { await CasoEspecial.sync(); console.log('La tabla CasoEspecial se instalo correctamente.'.magenta); + + + /* await CuestionarioAlumno2.sync(); + console.log('La tabla CuestionarioAlumno se instalo correctamente.'.magenta); + + await CuestionarioPrograma2.sync(); + console.log( + 'La tabla CuestionarioPrograma se instalo correctamente.'.magenta + ); */ + }; const dataTipoUsuario = async () => { @@ -125,7 +154,7 @@ const dataAdmin = async () => { }); }; -const dataResponsableCasoEspecial = async () => { +/* const dataResponsableCasoEspecial = async () => { console.log( '\nPaso 6) Instalando responsable de casos especiales.'.bold.blue ); @@ -136,7 +165,7 @@ const dataResponsableCasoEspecial = async () => { idTipoUsuario: 4, activo: true, }); -}; +}; */ const exe = async () => { await drop(); @@ -144,7 +173,7 @@ const exe = async () => { await dataTipoUsuario(); await dataStatus(); await dataAdmin(); - await dataResponsableCasoEspecial(); + //await dataResponsableCasoEspecial(); console.log( '\nSe ha instalado exitosamente la base de datos.\n'.underline.bold.green ); diff --git a/server/db/tablas/CuestionarioAlumno2.js b/server/db/tablas/CuestionarioAlumno2.js new file mode 100644 index 0000000..d290083 --- /dev/null +++ b/server/db/tablas/CuestionarioAlumno2.js @@ -0,0 +1,222 @@ + +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); + +class CuestionarioAlumno2 extends Model {} + +CuestionarioAlumno2.init( + { + idCuestionarioAlumno2: { + type: DataTypes.INTEGER, + primaryKey: true, + autoIncrement: true, + }, + + + + p1: { + type: DataTypes.STRING(100), + allowNull: true, + }, + p2: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p4: { + type: DataTypes.STRING(5), + allowNull: true, + }, + p5: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p6: { + type: DataTypes.STRING(5), + allowNull: true, + }, + p7: { + type: DataTypes.STRING(5), + allowNull: true, + }, + p8: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p9: { + type: DataTypes.STRING(5), + allowNull: true, + }, + + // p3_*: se definen como string (el JSON trae si/no) + p3_1: { + type: DataTypes.STRING(5), + allowNull: true, + }, + p3_2: { + type: DataTypes.STRING(5), + allowNull: true, + }, + p3_3: { + type: DataTypes.STRING(5), + allowNull: true, + }, + p3_4: { + type: DataTypes.STRING(5), + allowNull: true, + }, + + // p10_* y p11_* + p10_1: { + type: DataTypes.STRING(5), + allowNull: true, + }, + p10_2: { + type: DataTypes.STRING(5), + allowNull: true, + }, + p10_3: { + type: DataTypes.STRING(5), + allowNull: true, + }, + p11_1: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p11_2: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p11_3: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p11_4: { + type: DataTypes.STRING(20), + allowNull: true, + }, + + // p12_A_*, p12_B_*, p12_C_*, p12_D_* + // Ajusta el tamaño de la cadena según requieras + p12_A_1: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_A_2: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_A_3: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_A_4: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_B_1: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_B_2: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_B_3: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_B_4: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_C_1: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_C_2: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_C_3: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_C_4: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_D_1: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_D_2: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_D_3: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_D_4: { + type: DataTypes.STRING(20), + allowNull: true, + }, + p12_D_5: { + type: DataTypes.STRING(20), + allowNull: true, + }, + + // p13, p14, p15, p16... + p13: { + type: DataTypes.STRING(100), + allowNull: true, + }, + p14: { + type: DataTypes.STRING(100), + allowNull: true, + }, + p15: { + type: DataTypes.STRING(5), + allowNull: true, + }, + p16: { + type: DataTypes.STRING(50), + allowNull: true, + }, + + // p17_* + p17_1: { + type: DataTypes.STRING(5), + allowNull: true, + }, + p17_2: { + type: DataTypes.STRING(5), + allowNull: true, + }, + p17_3: { + type: DataTypes.STRING(5), + allowNull: true, + }, + + // p18 + p18: { + type: DataTypes.STRING(50), + allowNull: true, + }, + + + + }, + { + sequelize, + modelName: 'CuestionarioAlumno2', + tableName: 'cuestionario_alumno_2', + timestamps: true, + createdAt: true, + updatedAt: false, + } +); + + + +module.exports = CuestionarioAlumno2; diff --git a/server/db/tablas/CuestionarioPrograma2.js b/server/db/tablas/CuestionarioPrograma2.js new file mode 100644 index 0000000..bbfeccc --- /dev/null +++ b/server/db/tablas/CuestionarioPrograma2.js @@ -0,0 +1,144 @@ +const { DataTypes, Model } = require('sequelize'); +const sequelize = require('../../config/sequelize.conf'); + + + +class CuestionarioPrograma2 extends Model {} + +CuestionarioPrograma2.init( + { + idCuestionarioPrograma2: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + autoIncrement: true, + }, + + + + // Sección p3_A_* + p3_A_1: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p3_A_2: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p3_A_3: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p3_A_4: { + type: DataTypes.STRING(50), + allowNull: true, + }, + + // Sección p3_B_* + p3_B_1: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p3_B_2: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p3_B_3: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p3_B_4: { + type: DataTypes.STRING(50), + allowNull: true, + }, + + // Sección p3_C_* + p3_C_1: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p3_C_2: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p3_C_3: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p3_C_4: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p3_C_5: { + type: DataTypes.STRING(50), + allowNull: true, + }, + + // Sección p3_D_* + p3_D_1: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p3_D_2: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p3_D_3: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p3_D_4: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p3_D_5: { + type: DataTypes.STRING(50), + allowNull: true, + }, + + // Sección p3_E_* + p3_E_1: { + type: DataTypes.STRING(50), + allowNull: true, + }, + + // p1, p2, p4, p5, p6 + p1: { + type: DataTypes.STRING(100), + allowNull: true, + }, + p2: { + type: DataTypes.STRING(50), + allowNull: true, + }, + p4: { + type: DataTypes.STRING(100), + allowNull: true, + }, + p5: { + type: DataTypes.STRING(5), + allowNull: true, + }, + p6: { + type: DataTypes.STRING(100), + allowNull: true, + }, + }, + { + sequelize, + modelName: 'CuestionarioPrograma2', + tableName: 'cuestionario_programa_2', + timestamps: true, + createdAt: true, + updatedAt: false, + } +); + + + + + + + +module.exports = CuestionarioPrograma2; diff --git a/server/db/tablas/Servicio.js b/server/db/tablas/Servicio.js index 4f147c7..12f6852 100644 --- a/server/db/tablas/Servicio.js +++ b/server/db/tablas/Servicio.js @@ -7,6 +7,9 @@ const Status = require('./Status'); const CuestionarioAlumno = require('./CuestionarioAlumno'); const CuestionarioPrograma = require('./CuestionarioPrograma'); +const CuestionarioAlumno2 = require('./CuestionarioAlumno2'); +const CuestionarioPrograma2 = require('./CuestionarioPrograma2'); + class Servicio extends Model {} Servicio.init( { @@ -146,4 +149,26 @@ Servicio.belongsTo(CuestionarioPrograma, { }, }); + + + +Servicio.belongsTo(CuestionarioAlumno2, { + foreignKey: { + name: 'idCuestionarioAlumno2', + type: DataTypes.INTEGER, + allowNull: true, + defaultValue: null, + }, +}); + +Servicio.belongsTo(CuestionarioPrograma2, { + foreignKey: { + name: 'idCuestionarioPrograma2', + type: DataTypes.INTEGER, + allowNull: true, + defaultValue: null, + }, +}); + + module.exports = Servicio; diff --git a/server/helper/drive.js b/server/helper/drive.js index d6c9de0..3025574 100644 --- a/server/helper/drive.js +++ b/server/helper/drive.js @@ -1,37 +1,70 @@ require('../config/config'); const fs = require('fs'); const { google } = require('googleapis'); -const drive = google.drive('v3'); -const credenciales = JSON.parse(fs.readFileSync('./cred.json', 'utf8')); -const jwtClient = new google.auth.JWT( - credenciales.client_email, - null, - credenciales.private_key, - ['https://www.googleapis.com/auth/drive'] -); +// const drive = google.drive('v3'); +// const credenciales = JSON.parse(fs.readFileSync('./cred.json', 'utf8')); +// const jwtClient = new google.auth.JWT( +// credenciales.client_email, +// null, +// credenciales.private_key, +// ['https://www.googleapis.com/auth/drive'] +// ); + +/* const loadCredentials = () => { + try { + const credenciales = JSON.parse(fs.readFileSync('./cred.json', 'utf8')); + return google.auth.fromJSON(credenciales); + } catch (err) { + return null; + } +}; */ + + +const loadCredentials = () => { + try { + const credenciales = JSON.parse(fs.readFileSync('./cred.json', 'utf8')); + credenciales.private_key = credenciales.private_key.replace(/\\n/g, '\n'); // Asegurar formato correcto + return new google.auth.JWT( + credenciales.client_email, + null, + credenciales.private_key, + ['https://www.googleapis.com/auth/drive'] + ); + } catch (err) { + console.error('❌ Error cargando credenciales:', err); + return null; + } +}; + + const list = (pageToken) => { - return new Promise((resolve, reject) => { - jwtClient.authorize((err, tokens) => { - if (err) reject('Error de autorización: ' + err); - drive.files.list( - { - auth: jwtClient, - corpora: 'user', - supportsTeamDrives: true, - includeTeamDriveItems: true, - spaces: 'drive', - pageSize: 1000, - pageToken, - // fields: '*', - orderBy: 'name', - }, - (err, resp) => { - if (err) reject('Ha habido un error en la petición: ' + err); - resolve(resp.data); - } - ); - }); + return new Promise(async (resolve, reject) => { + // jwtClient.authorize((err, tokens) => { + // if (err) reject('Error de autorización: ' + err); + const authClient = await loadCredentials(); + const drive = google.drive({ version: 'v3', auth: authClient }); + + drive.files.list( + { + // auth: jwtClient, + corpora: 'user', + supportsTeamDrives: true, + includeTeamDriveItems: true, + spaces: 'drive', + pageSize: 1000, + pageToken, + // fields: '*', + orderBy: 'name', + }, + (err, resp) => { + console.log(resp); + + if (err) reject('Ha habido un error en la petición: ' + err); + resolve(resp.data); + } + ); + // }); }); }; @@ -39,26 +72,29 @@ const list = (pageToken) => { const deleteFile = (fileId) => { if (fileId === process.env.CARPETA) throw new Error('No se puede eliminar este archivo/carpeta.'); - return new Promise((resolve, reject) => { - jwtClient.authorize(async (err, tokens) => { - if (err) reject(err); - drive.files.delete( - { - fileId, - auth: jwtClient, - }, - (err, resp) => { - if (err) reject(err); - resolve(resp); - } - ); - }); + return new Promise(async (resolve, reject) => { + // jwtClient.authorize(async (err, tokens) => { + // if (err) reject(err); + const authClient = await loadCredentials(); + const drive = google.drive({ version: 'v3', auth: authClient }); + + drive.files.delete( + { + fileId, + // auth: jwtClient, + }, + (err, resp) => { + if (err) reject(err); + resolve(resp); + } + ); + // }); }); }; // SUBIR ARCHIVO const uploadFile = (path, name, mimeType, parent) => { - return new Promise((resolve, reject) => { + return new Promise(async (resolve, reject) => { const requestBody = { name, parents: [parent], @@ -68,64 +104,78 @@ const uploadFile = (path, name, mimeType, parent) => { body: fs.createReadStream(`${path}`), }; - jwtClient.authorize(function (err, tokens) { - if (err) reject('Error de autorización: ' + err); - drive.files.create( - { - media, - requestBody, - fields: 'id', - auth: jwtClient, - }, - (err, file) => { - if (err) reject(err); - fs.unlinkSync(path); - resolve(file.data.id); - } - ); - }); + // jwtClient.authorize(function (err, tokens) { + // if (err) reject('Error de autorización: ' + err); + const authClient = await loadCredentials(); + const drive = google.drive({ version: 'v3', auth: authClient }); + + drive.files.create( + { + media, + requestBody, + fields: 'id', + // auth: jwtClient, + }, + (err, file) => { + if (err) reject(err); + fs.unlinkSync(path); + resolve(file.data.id); + } + ); + // }); }); }; // CREAR CARPETA const mkDir = (name) => { - return new Promise((resolve, reject) => { + return new Promise(async (resolve, reject) => { + const authClient = await loadCredentials(); + const drive = google.drive({ version: 'v3', auth: authClient }); const requestBody = { name, mimeType: 'application/vnd.google-apps.folder', parents: [process.env.CARPETA], }; - jwtClient.authorize((err, tokens) => { - if (err) reject('Error de autorización: ' + err); - drive.files.create( - { - fields: 'id', - auth: jwtClient, - requestBody, - }, - (err, res) => { - if (err) reject(err); - resolve(res.data.id); - } - ); - }); + // jwtClient.authorize((err, tokens) => { + // if (err) reject('Error de autorización: ' + err); + drive.files.create( + { + fields: 'id', + // auth: jwtClient, + requestBody, + }, + (err, res) => { + console.log(err); + console.log("variable res "); + + console.log(res); + + + if (err) reject(err); + resolve(res.data.id); + } + ); + // }); }); }; // Update File const update = (fileId, addParents, removeParents) => { - return new Promise((resolve, reject) => { - jwtClient.authorize((err, tokens) => { - if (err) reject('Error de autorización: ' + err); - drive.files.update( - { auth: jwtClient, fileId, addParents, removeParents }, - (err, resp) => { - if (err) reject('Ha habido un error en la petición: ' + err); - resolve(resp.data); - } - ); - }); + return new Promise(async (resolve, reject) => { + // jwtClient.authorize((err, tokens) => { + // if (err) reject('Error de autorización: ' + err); + const authClient = await loadCredentials(); + const drive = google.drive({ version: 'v3', auth: authClient }); + + drive.files.update( + { auth: jwtClient, fileId, addParents, removeParents }, + (err, resp) => { + if (err) reject('Ha habido un error en la petición: ' + err); + resolve(resp.data); + } + ); + // }); }); }; diff --git a/server/helper/gmail.js b/server/helper/gmail.js index 464a4a1..cb60784 100644 --- a/server/helper/gmail.js +++ b/server/helper/gmail.js @@ -6,12 +6,18 @@ const send = require('gmail-send')({ }); const gmail = (subject, to, text) => { + return new Promise((resolve, reject) => { send({ subject, to, text }, (error, result, fullResult) => { if (error) reject(error); resolve(result); }); }); + + + // return "envio de correo" + + }; module.exports = gmail; diff --git a/server/helper/helper.js b/server/helper/helper.js index f269aa5..db06bfe 100644 --- a/server/helper/helper.js +++ b/server/helper/helper.js @@ -3,6 +3,9 @@ const moment = require('moment'); const crearDDMMAAAA = (date) => { const fechaMoment = moment(date); + + // const fechaMoment = moment(new Date(date).toISOString()); + let ddmmaaaa = ''; if (fechaMoment.isValid()) diff --git a/server/helper/validar.js b/server/helper/validar.js index 77ebfe4..f1431c5 100644 --- a/server/helper/validar.js +++ b/server/helper/validar.js @@ -171,15 +171,28 @@ const validarObjetoVacio = (obj) => { }; const validarPreTermino = (idServicio) => { + + // obtener los id cuestionarios by idServicio de la tabla cuestionario + // budcar el id cuestionario de alumno en las tablas de alumnos - depende de la version + // buscar el id cuestionario de programa en las tablas de programas - depende de la version + + // validar el if + + console.log("este es el id en la busqieda", idServicio); + + return Servicio.findOne({ where: { idServicio } }) .then((res) => { + + console.log("validando pre termino", res); + + if ( - res.idCuestionarioPrograma && - res.idCuestionarioAlumno && + (res.idCuestionarioPrograma || res.idCuestionarioPrograma2) && + (res.idCuestionarioAlumno || res.idCuestionarioAlumno2) && res.cartaTermino && res.informeGlobal - ) - return Servicio.update({ idStatus: 5 }, { where: { idServicio } }); + ) return Servicio.update({ idStatus: 5 }, { where: { idServicio } }); return false; }) .then((res) => @@ -189,6 +202,159 @@ const validarPreTermino = (idServicio) => { ); }; + + + + +const validarCuestionarioAlumno2old = (body) => { + console.log("Validando cuestionario alumno 2"); + + // Excluir p2 de la validación de campos nulos + const camposExcluidos = [ + // 'p2' + ]; + + // Verificar si algún campo es nulo o indefinido (excepto p2) + for (const [key, value] of Object.entries(body)) { + if (!camposExcluidos.includes(key) && (value === null || value === undefined || value === '')) { + throw new Error(`El campo ${key} no puede estar vacío.`); + } + } + + console.log("Validación exitosa. Todos los campos son válidos."); + return body; +}; + +const validarCuestionarioAlumno2 = (body) => { + console.log("Validando cuestionario alumno 2"); + + // Definir las claves que se consideran opcionales (las preguntas condicionales en el front) + const optionalKeys = ['p5', 'p8', 'p16', 'p18']; + + // Si p1 viene como array, concatenarla en una cadena separada por comas. + if (Array.isArray(body.p1)) { + body.p1 = body.p1.join(', '); + } + + // Verificar que cada campo obligatorio (no opcional) no esté vacío. + for (const [key, value] of Object.entries(body)) { + if (!optionalKeys.includes(key) && (value === null || value === undefined || value === '')) { + throw new Error(`El campo ${key} no puede estar vacío.`); + } + } + + // Lista de claves obligatorias esperadas (según la función formatearRespuestas en el front) + const expectedKeys = [ + // Preguntas individuales obligatorias: + "p1", "p2", "p4", "p6", "p7", "p9", "p13", "p14", "p15", + // Las condicionales se consideran opcionales: p5, p8, p16 y p18 + + // Tablas: + // Tabla 130 (numeroPregunta 3) + "p3_1", "p3_2", "p3_3", "p3_4", + // Tabla 104 (numeroPregunta 10) + "p10_1", "p10_2", "p10_3", + // Tabla 105 (numeroPregunta 11) + "p11_1", "p11_2", "p11_3", "p11_4", + // Tabla 106 (numeroPregunta 17) + "p17_1", "p17_2", "p17_3", + // Tabla 101 (numeroPregunta 12, sub "A. Habilidades personales") + "p12_A_1", "p12_A_2", "p12_A_3", "p12_A_4", + // Tabla 102 (numeroPregunta 12, sub "B. Habilidades profesionales") + "p12_B_1", "p12_B_2", "p12_B_3", "p12_B_4", + // Tabla 103 (numeroPregunta 12, sub "C. Habilidades sociales") + "p12_C_1", "p12_C_2", "p12_C_3", "p12_C_4", "p12_C_5", + // Tabla 1042 (numeroPregunta 12, sub "D. Conocimientos") + "p12_D_1", "p12_D_2", "p12_D_3", "p12_D_4", "p12_D_5" + ]; + + for (const key of expectedKeys) { + if (!(key in body)) { + throw new Error(`Falta la respuesta para la pregunta ${key}.`); + } + } + + console.log("Validación exitosa. Todos los campos son válidos."); + return body; +}; + + + + + +const validarCuestionarioPrograma2old = (body) => { + console.log("Validando cuestionario programa 2"); + + // Excluir p2 de la validación de campos nulos + const camposExcluidos = [ + // 'p2' + ]; + + // Verificar si algún campo es nulo o indefinido (excepto p2) + for (const [key, value] of Object.entries(body)) { + if (!camposExcluidos.includes(key) && (value === null || value === undefined || value === '')) { + throw new Error(`El campo ${key} no puede estar vacío.`); + } + } + + console.log("Validación exitosa. Todos los campos son válidos."); + return body; + }; + + + const validarCuestionarioPrograma2 = (body) => { + console.log("Validando cuestionario programa 2"); + + // Definir las claves condicionales (opcionales). En este caso, la pregunta 6 (porqueNoContrataria) es condicional. + const camposOpcionales = ["p6"]; + + // Si la respuesta de p1 viene como array, concatenarla en una cadena + if (Array.isArray(body.p1)) { + body.p1 = body.p1.join(', '); + } + + // Verificar que cada campo obligatorio (no opcional) no esté vacío + for (const [key, value] of Object.entries(body)) { + if (!camposOpcionales.includes(key) && (value === null || value === undefined || value === '')) { + throw new Error(`El campo ${key} no puede estar vacío.`); + } + } + + // Lista de claves obligatorias esperadas (según el formateo que se usa en el front) + const expectedKeys = [ + // Preguntas individuales obligatorias: + "p1", "p2", "p4", "p5", + // Las condicionales, como "p6", son opcionales + + // Tablas: + // Tabla 301 (sub "A. Habilidades personales") + "p3_A_1", "p3_A_2", "p3_A_3", "p3_A_4", + // Tabla 302 (sub "B. Habilidades profesionales") + "p3_B_1", "p3_B_2", "p3_B_3", "p3_B_4", + // Tabla 303 (sub "C. Habilidades sociales") + "p3_C_1", "p3_C_2", "p3_C_3", "p3_C_4", "p3_C_5", + // Tabla 304 (sub "D. Conocimientos") + "p3_D_1", "p3_D_2", "p3_D_3", "p3_D_4", "p3_D_5" + ]; + + // Verificar que existan todas las claves obligatorias + for (const key of expectedKeys) { + if (!(key in body)) { + throw new Error(`Falta la respuesta para la pregunta ${key}.`); + } + } + + console.log("Validación exitosa. Todos los campos son válidos."); + return body; + }; + + module.exports = { validarCuestionarioPrograma2 }; + + + + + + module.exports = { yaExiste, noValido, @@ -203,4 +369,8 @@ module.exports = { validarNumero, validarObjetoVacio, validarPreTermino, + + validarCuestionarioAlumno2, + validarCuestionarioPrograma2 + }; diff --git a/server/middleware/autentificacion.js b/server/middleware/autentificacion.js index bc99d03..f0f5572 100644 --- a/server/middleware/autentificacion.js +++ b/server/middleware/autentificacion.js @@ -2,11 +2,13 @@ require('../config/config'); const jwt = require('jsonwebtoken'); const verificaToken = (req, res, next) => { + let token = req.headers.token; + if (!token) return res.status(400).json({ - message: 'No se envio el token.', + message: 'No se envio el token. v2', }); jwt.verify(token, process.env.KEY, (err, decoded) => { if (err) { @@ -23,6 +25,10 @@ const verificaToken = (req, res, next) => { req.decoded = decoded; next(); }); + + + + // next() // solo esta linea si se estan haciendo pruebas }; const crearToken = (info) => { diff --git a/server/routes/CasoEspecial.js b/server/routes/CasoEspecial.js index b393b7b..679e1a4 100644 --- a/server/routes/CasoEspecial.js +++ b/server/routes/CasoEspecial.js @@ -15,7 +15,7 @@ const update = require(`${controllerPath}/update`); // POST app.post( `${route}/nuevo`, - // verificaToken, + verificaToken, upload.single('archivos'), (req, res) => { return nuevo(JSON.parse(req.body.alumno), req.file.filename) diff --git a/server/routes/CuestionarioAlumno.js b/server/routes/CuestionarioAlumno.js index 764bb4a..e43a080 100644 --- a/server/routes/CuestionarioAlumno.js +++ b/server/routes/CuestionarioAlumno.js @@ -1,13 +1,18 @@ const express = require('express'); const app = express(); -const { verificaToken } = require('../middleware/autentificacion'); +// const { verificaToken } = require('../middleware/autentificacion'); const route = '/cuestionario_alumno'; const controllerPath = '../controller/CuestionarioAlumno'; + const get = require(`${controllerPath}/get`); const nuevo = require(`${controllerPath}/nuevo`); // POST -app.post(`${route}`, verificaToken, (req, res) => { +app.post(`${route}`, + // verificaToken, + (req, res) => { + console.log("cuestionario Alumnos antes de la funcion"); + return nuevo(req.body) .then((data) => { res.status(200).json(data); @@ -18,7 +23,10 @@ app.post(`${route}`, verificaToken, (req, res) => { }); // GET -app.get(`${route}`, verificaToken, (req, res) => { +app.get(`${route}`, + // verificaToken, + + (req, res) => { return get(req.query) .then((data) => { res.download(data); diff --git a/server/routes/CuestionarioPrograma.js b/server/routes/CuestionarioPrograma.js index 7183d54..4387ac4 100644 --- a/server/routes/CuestionarioPrograma.js +++ b/server/routes/CuestionarioPrograma.js @@ -3,11 +3,14 @@ const app = express(); const { verificaToken } = require('../middleware/autentificacion'); const route = '/cuestionario_programa'; const controllerPath = '../controller/CuestionarioPrograma'; + const get = require(`${controllerPath}/get`); const nuevo = require(`${controllerPath}/nuevo`); // POST -app.post(`${route}`, verificaToken, (req, res) => { +app.post(`${route}`, + verificaToken, + (req, res) => { return nuevo(req.body) .then((data) => { res.status(200).json(data); @@ -18,7 +21,9 @@ app.post(`${route}`, verificaToken, (req, res) => { }); // GET -app.get(`${route}`, verificaToken, (req, res) => { +app.get(`${route}`, + verificaToken, + (req, res) => { return get(req.query) .then((data) => { res.download(data); diff --git a/server/routes/Programa.js b/server/routes/Programa.js index fbce79a..adca5c3 100644 --- a/server/routes/Programa.js +++ b/server/routes/Programa.js @@ -13,7 +13,7 @@ const reasignarProgramas = require(`${controllerPath}/reasignarProgramas`); // POST app.post( `${route}/carga_masiva`, - // verificaToken, + verificaToken, upload.single('csv'), (req, res) => { if (req.file) { diff --git a/server/routes/Servicio.js b/server/routes/Servicio.js index 217155b..eed2d99 100644 --- a/server/routes/Servicio.js +++ b/server/routes/Servicio.js @@ -28,7 +28,7 @@ const gustavoBazPrada = require(`${controllerPath}/gustavoBazPrada`); // POST app.post( `${route}/nuevo`, - // verificaToken, + verificaToken, upload.single('cartaAceptacion'), (req, res) => { return nuevo(JSON.parse(req.body.alumno), req.file.filename) @@ -116,7 +116,7 @@ app.put(`${route}/cancelar`, verificaToken, (req, res) => { app.put( `${route}/carta_aceptacion`, - // verificaToken, + verificaToken, upload.single('cartaAceptacion'), (req, res) => { return cartaAceptacion(JSON.parse(req.body.data), req.file.filename) @@ -132,7 +132,7 @@ app.put( app.put( `${route}/carta_termino`, - // verificaToken, + verificaToken, upload.single('cartaTermino'), (req, res) => { return cartaTermino(JSON.parse(req.body.data), req.file.filename) @@ -148,7 +148,7 @@ app.put( app.put( `${route}/informe_global`, - // verificaToken, + verificaToken, upload.single('informeGlobal'), (req, res) => { return informeGlobal(JSON.parse(req.body.data), req.file.filename) @@ -185,6 +185,8 @@ app.put(`${route}/registro`, verificaToken, (req, res) => { app.put(`${route}/registro_validado`, verificaToken, (req, res) => { return registroValidado(req.body) .then((data) => { + console.log('golasdf'); + res.status(200).json(data); }) .catch((err) => { diff --git a/server/routes/Status.js b/server/routes/Status.js index b09bd3b..f7f4910 100644 --- a/server/routes/Status.js +++ b/server/routes/Status.js @@ -5,6 +5,8 @@ const route = '/status'; const get = require('../controller/Status/get'); app.get(`${route}`, verificaToken, (req, res) => { + console.log("status"); + return get() .then((data) => { res.status(200).json(data); diff --git a/test.js b/test.js new file mode 100644 index 0000000..f3a5cfc --- /dev/null +++ b/test.js @@ -0,0 +1,22 @@ +const { google } = require('googleapis'); +const fs = require('fs'); + +const credenciales = JSON.parse(fs.readFileSync('./cred.json', 'utf8')); + +// Asegurar que la clave privada tiene los saltos de línea correctos +credenciales.private_key = credenciales.private_key.replace(/\\n/g, '\n'); + +const jwtClient = new google.auth.JWT( + credenciales.client_email, + null, + credenciales.private_key, + ['https://www.googleapis.com/auth/drive'] +); + +jwtClient.authorize((err, tokens) => { + if (err) { + console.error('❌ Error de autenticación:', err); + } else { + console.log('✅ Autenticación exitosa:', tokens); + } +}); diff --git a/test2.js b/test2.js new file mode 100644 index 0000000..1ae04c6 --- /dev/null +++ b/test2.js @@ -0,0 +1,28 @@ +const { google } = require('googleapis'); +const fs = require('fs'); + +const credenciales = JSON.parse(fs.readFileSync('./cred.json', 'utf8')); +credenciales.private_key = credenciales.private_key.replace(/\\n/g, '\n'); + +const jwtClient = new google.auth.JWT( + credenciales.client_email, + null, + credenciales.private_key, + ['https://www.googleapis.com/auth/drive'] +); + +const drive = google.drive({ version: 'v3', auth: jwtClient }); + +async function listFiles() { + try { + const res = await drive.files.list({ + pageSize: 10, + fields: 'files(id, name)', + }); + console.log('✅ Archivos en Drive:', res.data.files); + } catch (error) { + console.error('❌ Error al listar archivos:', error); + } +} + +listFiles(); diff --git a/test3.js b/test3.js new file mode 100644 index 0000000..41f457c --- /dev/null +++ b/test3.js @@ -0,0 +1,35 @@ +const { google } = require('googleapis'); +const fs = require('fs'); + +const credenciales = JSON.parse(fs.readFileSync('./cred.json', 'utf8')); +credenciales.private_key = credenciales.private_key.replace(/\\n/g, '\n'); + +const jwtClient = new google.auth.JWT( + credenciales.client_email, + null, + credenciales.private_key, + ['https://www.googleapis.com/auth/drive'] +); + +const drive = google.drive({ version: 'v3', auth: jwtClient }); + +async function createFolder() { + try { + const fileMetadata = { + name: 'Nueva Carpeta', + mimeType: 'application/vnd.google-apps.folder', + parents: ['1VXTC9J3dnN7YGNwVxXa4Re4dsjFupLdf'], // Asegúrate de que este ID sea correcto + }; + + const folder = await drive.files.create({ + resource: fileMetadata, + fields: 'id', + }); + + console.log('✅ Carpeta creada con ID:', folder.data.id); + } catch (error) { + console.error('❌ Error al crear carpeta:', error); + } +} + +createFolder(); diff --git a/testing.sql b/testing.sql new file mode 100644 index 0000000..765b7c8 --- /dev/null +++ b/testing.sql @@ -0,0 +1,473 @@ +-- MariaDB dump 10.17 Distrib 10.4.10-MariaDB, for Win64 (AMD64) +-- +-- Host: 132.248.180.82 Database: Iris_Produccion +-- ------------------------------------------------------ +-- Server version 10.6.7-MariaDB + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `carrera` +-- + +drop database servicio_test; +create database servicio_test; +use servicio_test; + + +DROP TABLE IF EXISTS `carrera`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `carrera` ( + `idCarrera` int(11) NOT NULL AUTO_INCREMENT, + `carrera` varchar(50) NOT NULL, + PRIMARY KEY (`idCarrera`), + UNIQUE KEY `idCarrera` (`idCarrera`) +) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `carrera` +-- + +LOCK TABLES `carrera` WRITE; +/*!40000 ALTER TABLE `carrera` DISABLE KEYS */; +INSERT INTO `carrera` VALUES (1,'LIC. EN DERECHO'),(2,'LIC. EN ACTUARIA'),(3,'LIC. EN MATEMATICAS APLICADAS Y COMP.'),(4,'LIC. EN COMUNICACION'),(5,'LIC. EN ECONOMIA'),(6,'LIC. EN PERIODISMO Y COMUNICACION COL.'),(7,'LIC. EN RELACIONES INTERNACIONALES'),(8,'LIC. EN FILOSOFIA'),(9,'LIC. EN HISTORIA'),(10,'LIC. EN LENGUA Y LITERATURA HISPANICAS'),(11,'LIC. EN SOCIOLOGIA'),(12,'LIC. EN CIENCIAS POLITICAS Y ADMON PUB'),(13,'LIC. EN INGENIERIA CIVIL'),(14,'LIC. EN ENSEÑANZA DE INGLES'),(15,'LIC. EN DISEÑO GRAFICO'),(16,'LIC. EN PEDAGOGÍA'),(17,'LIC. EN DERECHO (SUA)'),(18,'LIC. ENSEÑANZA DE ESPAÑOL(LENG. EXTRANJ)'),(19,'LIC. ENSEÑANZA DE ITALIANO(LENG. EXTRANJ'),(20,'LIC. EN ARQUITECTURA'),(21,'LIC. EN RELACIONES INTERNACIONALES (SUA)'),(22,'LIC. ENSEÑANZA DE INGLÉS(LENG. EXTRANJE)'),(23,'LIC. ENSEÑANZA DE ALEMÁN (LENG. EXTRANJS'),(24,'LIC. EN MAT. APLICADAS Y COMPUTACION'),(25,'LIC. EN CIENCIAS POLITICAS Y ADMON.PUBL.'),(26,'LIC. ENSEÑANZA DE FRANCÉS(LENG. EXTRANJ)'); +/*!40000 ALTER TABLE `carrera` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `caso_especial` +-- + +DROP TABLE IF EXISTS `caso_especial`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `caso_especial` ( + `idCasoEspecial` int(11) NOT NULL AUTO_INCREMENT, + `creditos` varchar(3) NOT NULL, + `correo` varchar(60) NOT NULL, + `telefono` varchar(15) NOT NULL, + `institucion` varchar(200) DEFAULT NULL, + `dependencia` varchar(200) DEFAULT NULL, + `motivo` varchar(1) DEFAULT NULL, + `direccion` varchar(200) NOT NULL, + `fechaInicio` datetime NOT NULL, + `fechaFin` datetime NOT NULL, + `fechaNacimiento` datetime NOT NULL, + `carpeta` varchar(60) NOT NULL, + `archivoZip` varchar(60) NOT NULL, + `createdAt` datetime NOT NULL, + `updatedAt` datetime NOT NULL, + `idUsuario` int(11) NOT NULL, + `idCarrera` int(11) NOT NULL, + `idStatus` int(11) NOT NULL DEFAULT 1, + PRIMARY KEY (`idCasoEspecial`), + UNIQUE KEY `idCasoEspecial` (`idCasoEspecial`), + KEY `idUsuario` (`idUsuario`), + KEY `idCarrera` (`idCarrera`), + KEY `idStatus` (`idStatus`), + CONSTRAINT `caso_especial_ibfk_1` FOREIGN KEY (`idUsuario`) REFERENCES `usuario` (`idUsuario`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `caso_especial_ibfk_2` FOREIGN KEY (`idCarrera`) REFERENCES `carrera` (`idCarrera`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `caso_especial_ibfk_3` FOREIGN KEY (`idStatus`) REFERENCES `status` (`idStatus`) ON DELETE NO ACTION ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=392 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `caso_especial` +-- + +LOCK TABLES `caso_especial` WRITE; +/*!40000 ALTER TABLE `caso_especial` DISABLE KEYS */; +/*!40000 ALTER TABLE `caso_especial` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `cuestionario_alumno` +-- + +DROP TABLE IF EXISTS `cuestionario_alumno`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `cuestionario_alumno` ( + `idCuestionarioAlumno` int(11) NOT NULL AUTO_INCREMENT, + `sexo` varchar(1) NOT NULL, + `edad` varchar(2) NOT NULL, + `servicioMedico` varchar(100) NOT NULL, + `p1` tinyint(1) NOT NULL, + `p2` tinyint(1) NOT NULL, + `p3` varchar(150) NOT NULL, + `p4` tinyint(1) NOT NULL, + `p5` varchar(7) NOT NULL, + `p6` tinyint(1) NOT NULL, + `p7` tinyint(1) NOT NULL, + `p8` varchar(5) NOT NULL, + `p9` tinyint(1) NOT NULL, + `p10` tinyint(1) NOT NULL, + `p11` tinyint(1) NOT NULL, + `p12` tinyint(1) NOT NULL, + `p13` tinyint(1) NOT NULL, + `p14` varchar(7) NOT NULL, + `p15` varchar(7) NOT NULL, + `p16` varchar(2) NOT NULL, + `p17` varchar(5) NOT NULL, + `p18` tinyint(1) NOT NULL, + `p19` tinyint(1) NOT NULL, + `p20` tinyint(1) NOT NULL, + `p21` varchar(9) NOT NULL, + `p22` varchar(23) NOT NULL, + `p23` varchar(8) NOT NULL, + `p24` varchar(8) NOT NULL, + `p25` tinyint(1) NOT NULL, + `p26` tinyint(1) NOT NULL, + `p27` varchar(400) NOT NULL, + `p28` varchar(1) NOT NULL, + `p29` varchar(1) NOT NULL, + `p30` varchar(400) NOT NULL, + `createdAt` datetime NOT NULL, + PRIMARY KEY (`idCuestionarioAlumno`), + UNIQUE KEY `idCuestionarioAlumno` (`idCuestionarioAlumno`) +) ENGINE=InnoDB AUTO_INCREMENT=13564 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `cuestionario_alumno` +-- + +LOCK TABLES `cuestionario_alumno` WRITE; +/*!40000 ALTER TABLE `cuestionario_alumno` DISABLE KEYS */; + + +/*!40000 ALTER TABLE `cuestionario_alumno` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `cuestionario_programa` +-- + +DROP TABLE IF EXISTS `cuestionario_programa`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `cuestionario_programa` ( + `idCuestionarioPrograma` int(11) NOT NULL AUTO_INCREMENT, + `actividad1` varchar(400) NOT NULL, + `actividad2` varchar(400) NOT NULL, + `actividad3` varchar(400) NOT NULL, + `actividad4` varchar(400) NOT NULL, + `actividad5` varchar(400) NOT NULL, + `retroalimentacion` varchar(9) NOT NULL, + `p6` varchar(800) DEFAULT NULL, + `p7` varchar(800) NOT NULL, + `createdAt` datetime NOT NULL, + PRIMARY KEY (`idCuestionarioPrograma`), + UNIQUE KEY `idCuestionarioPrograma` (`idCuestionarioPrograma`) +) ENGINE=InnoDB AUTO_INCREMENT=13582 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `cuestionario_programa` +-- + +LOCK TABLES `cuestionario_programa` WRITE; +/*!40000 ALTER TABLE `cuestionario_programa` DISABLE KEYS */; +/*!40000 ALTER TABLE `cuestionario_programa` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `programa` +-- + +DROP TABLE IF EXISTS `programa`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `programa` ( + `idPrograma` int(11) NOT NULL AUTO_INCREMENT, + `institucion` varchar(120) NOT NULL, + `dependencia` varchar(120) NOT NULL, + `programa` varchar(280) NOT NULL, + `clavePrograma` varchar(20) NOT NULL, + `acatlan` tinyint(1) NOT NULL DEFAULT 0, + `activo` tinyint(1) NOT NULL DEFAULT 1, + `idUsuario` int(11) NOT NULL, + PRIMARY KEY (`idPrograma`), + UNIQUE KEY `idPrograma` (`idPrograma`), + KEY `idUsuario` (`idUsuario`), + CONSTRAINT `programa_ibfk_1` FOREIGN KEY (`idUsuario`) REFERENCES `usuario` (`idUsuario`) ON DELETE NO ACTION ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=11518 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `programa` +-- + +LOCK TABLES `programa` WRITE; +/*!40000 ALTER TABLE `programa` DISABLE KEYS */; +/*!40000 ALTER TABLE `programa` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `servicio` +-- + +DROP TABLE IF EXISTS `servicio`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `servicio` ( + `idServicio` int(11) NOT NULL AUTO_INCREMENT, + `creditos` varchar(3) NOT NULL, + `correo` varchar(60) NOT NULL, + `telefono` varchar(15) DEFAULT NULL, + `direccion` varchar(200) DEFAULT NULL, + `fechaInicio` datetime NOT NULL, + `fechaFin` datetime NOT NULL, + `fechaNacimiento` datetime DEFAULT NULL, + `carpeta` varchar(60) NOT NULL, + `cartaAceptacion` varchar(60) NOT NULL, + `cartaTermino` varchar(60) DEFAULT NULL, + `informeGlobal` varchar(60) DEFAULT NULL, + `programaInterno` varchar(250) DEFAULT NULL, + `profesor` varchar(50) DEFAULT NULL, + `vistoBuenoAcatlan` tinyint(1) DEFAULT NULL, + `createdAt` datetime NOT NULL, + `updatedAt` datetime NOT NULL, + `idUsuario` int(11) NOT NULL, + `idCarrera` int(11) NOT NULL, + `idStatus` int(11) NOT NULL DEFAULT 1, + `idPrograma` int(11) NOT NULL, + `idCuestionarioAlumno` int(11) DEFAULT NULL, + `idCuestionarioPrograma` int(11) DEFAULT NULL, + `fechaLiberacion` datetime DEFAULT NULL, + PRIMARY KEY (`idServicio`), + UNIQUE KEY `idServicio` (`idServicio`), + KEY `idUsuario` (`idUsuario`), + KEY `idCarrera` (`idCarrera`), + KEY `idStatus` (`idStatus`), + KEY `idPrograma` (`idPrograma`), + KEY `idCuestionarioAlumno` (`idCuestionarioAlumno`), + KEY `idCuestionarioPrograma` (`idCuestionarioPrograma`), + CONSTRAINT `servicio_ibfk_1` FOREIGN KEY (`idUsuario`) REFERENCES `usuario` (`idUsuario`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `servicio_ibfk_2` FOREIGN KEY (`idCarrera`) REFERENCES `carrera` (`idCarrera`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `servicio_ibfk_3` FOREIGN KEY (`idStatus`) REFERENCES `status` (`idStatus`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `servicio_ibfk_4` FOREIGN KEY (`idPrograma`) REFERENCES `programa` (`idPrograma`) ON DELETE NO ACTION ON UPDATE CASCADE, + CONSTRAINT `servicio_ibfk_5` FOREIGN KEY (`idCuestionarioAlumno`) REFERENCES `cuestionario_alumno` (`idCuestionarioAlumno`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `servicio_ibfk_6` FOREIGN KEY (`idCuestionarioPrograma`) REFERENCES `cuestionario_programa` (`idCuestionarioPrograma`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=17310 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `servicio` +-- + +LOCK TABLES `servicio` WRITE; +/*!40000 ALTER TABLE `servicio` DISABLE KEYS */; +/*!40000 ALTER TABLE `servicio` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `status` +-- + +DROP TABLE IF EXISTS `status`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `status` ( + `idStatus` int(11) NOT NULL AUTO_INCREMENT, + `status` varchar(30) NOT NULL, + PRIMARY KEY (`idStatus`), + UNIQUE KEY `idStatus` (`idStatus`) +) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `status` +-- + +LOCK TABLES `status` WRITE; +/*!40000 ALTER TABLE `status` DISABLE KEYS */; +INSERT INTO `status` VALUES (1,'Pre-Registro'),(2,'Pre-Registro Validado'),(3,'Registro'),(4,'Pre-Termino'),(5,'Termino'),(6,'Liberación'),(7,'Carta Aceptación Rechazada'),(8,'Carta Termino Rechazada'),(9,'Informe Global Rechazado'),(10,'Cancelado'),(11,'Articulo 52'),(12,'Articulo 91'),(13,'Liberación Articulo 52'),(14,'Liberación Articulo 91'); +/*!40000 ALTER TABLE `status` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `tipo_usuario` +-- + +DROP TABLE IF EXISTS `tipo_usuario`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `tipo_usuario` ( + `idTipoUsuario` int(11) NOT NULL AUTO_INCREMENT, + `tipoUsuario` varchar(15) NOT NULL, + PRIMARY KEY (`idTipoUsuario`), + UNIQUE KEY `idTipoUsuario` (`idTipoUsuario`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `tipo_usuario` +-- + +LOCK TABLES `tipo_usuario` WRITE; +/*!40000 ALTER TABLE `tipo_usuario` DISABLE KEYS */; +INSERT INTO `tipo_usuario` VALUES (1,'admin'),(2,'responsable'),(3,'alumno'),(4,'casoEspecial'); +/*!40000 ALTER TABLE `tipo_usuario` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `usuario` +-- + +DROP TABLE IF EXISTS `usuario`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `usuario` ( + `idUsuario` int(11) NOT NULL AUTO_INCREMENT, + `usuario` varchar(100) NOT NULL, + `password` varchar(60) DEFAULT NULL, + `nombre` varchar(70) DEFAULT NULL, + `activo` tinyint(1) NOT NULL, + `idTipoUsuario` int(11) NOT NULL, + PRIMARY KEY (`idUsuario`), + UNIQUE KEY `idUsuario` (`idUsuario`), + UNIQUE KEY `usuario` (`usuario`), + KEY `idTipoUsuario` (`idTipoUsuario`), + CONSTRAINT `usuario_ibfk_1` FOREIGN KEY (`idTipoUsuario`) REFERENCES `tipo_usuario` (`idTipoUsuario`) ON DELETE NO ACTION ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=19930 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `usuario` +-- + +LOCK TABLES `usuario` WRITE; +/*!40000 ALTER TABLE `usuario` DISABLE KEYS */; + + +INSERT INTO `usuario` VALUES (1,'ejemplo1','$2b$10$lpasLiiPi/OTCL84PK8n4./Y7EVqPjC306JS4jJOB2i7JkUJoExsO','COESI',1,1) + +/*!40000 ALTER TABLE `usuario` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping routines for database 'Iris_Produccion' +-- +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2025-01-12 23:25:49 + + + + + + +DROP TABLE IF EXISTS `cuestionario_alumno_2`; + +CREATE TABLE + `cuestionario_alumno_2` ( + `idCuestionarioAlumno2` INT PRIMARY KEY NOT NULL AUTO_INCREMENT, + `createdAt` DATETIME, + `p12_A_1` VARCHAR(20), + `p12_A_2` VARCHAR(20), + `p12_A_3` VARCHAR(20), + `p12_A_4` VARCHAR(20), + `p12_B_1` VARCHAR(20), + `p12_B_2` VARCHAR(20), + `p12_B_3` VARCHAR(20), + `p12_B_4` VARCHAR(20), + `p12_C_1` VARCHAR(20), + `p12_C_2` VARCHAR(20), + `p12_C_3` VARCHAR(20), + `p12_C_4` VARCHAR(20), + `p10_1` VARCHAR(20), + `p10_2` VARCHAR(20), + `p10_3` VARCHAR(20), + `p11_1` VARCHAR(20), + `p11_2` VARCHAR(20), + `p11_3` VARCHAR(20), + `p11_4` VARCHAR(20), + `p17_1` VARCHAR(20), + `p17_2` VARCHAR(20), + `p17_3` VARCHAR(20), + `p3_1` VARCHAR(50), + `p3_2` VARCHAR(50), + `p3_3` VARCHAR(50), + `p3_4` VARCHAR(50), + `p12_D_1` VARCHAR(50), + `p12_D_2` VARCHAR(50), + `p12_D_3` VARCHAR(50), + `p12_D_4` VARCHAR(50), + `p12_D_5` VARCHAR(50), + `p1` TEXT, + `p2` VARCHAR(50), + `p4` VARCHAR(50), + `p5` VARCHAR(50), + `p6` VARCHAR(50), + `p7` VARCHAR(50), + `p8` VARCHAR(50), + `p9` VARCHAR(50), + `p13` VARCHAR(50), + `p14` VARCHAR(50), + `p15` VARCHAR(50), + `p16` VARCHAR(50), + `p18` VARCHAR(50) + ); + +DROP TABLE IF EXISTS `cuestionario_programa_2`; + +CREATE TABLE + `cuestionario_programa_2` ( + `idCuestionarioPrograma2` INT PRIMARY KEY NOT NULL AUTO_INCREMENT, + `createdAt` DATETIME, + `p3_A_1` VARCHAR(50), + `p3_A_2` VARCHAR(50), + `p3_A_3` VARCHAR(50), + `p3_A_4` VARCHAR(50), + `p3_B_1` VARCHAR(50), + `p3_B_2` VARCHAR(50), + `p3_B_3` VARCHAR(50), + `p3_B_4` VARCHAR(50), + `p3_C_1` VARCHAR(50), + `p3_C_2` VARCHAR(50), + `p3_C_3` VARCHAR(50), + `p3_C_4` VARCHAR(50), + `p3_C_5` VARCHAR(50), + `p3_D_1` VARCHAR(50), + `p3_D_2` VARCHAR(50), + `p3_D_3` VARCHAR(50), + `p3_D_4` VARCHAR(50), + `p3_D_5` VARCHAR(50), + `p3_E_1` VARCHAR(50), + `p1` VARCHAR(50), + `p2` VARCHAR(50), + `p4` VARCHAR(50), + `p5` VARCHAR(50), + `p6` VARCHAR(50), + `p7` VARCHAR(50) + ); + + +ALTER TABLE servicio ADD COLUMN idCuestionarioAlumno2 INT; +ALTER TABLE servicio ADD COLUMN idCuestionarioPrograma2 INT; + +ALTER TABLE `servicio` ADD FOREIGN KEY (`idCuestionarioAlumno2`) REFERENCES `cuestionario_alumno_2` (`idCuestionarioAlumno2`); +ALTER TABLE `servicio` ADD FOREIGN KEY (`idCuestionarioPrograma2`) REFERENCES `cuestionario_programa_2` (`idCuestionarioPrograma2`); + + + diff --git a/update.sql b/update.sql new file mode 100644 index 0000000..f2f11e8 --- /dev/null +++ b/update.sql @@ -0,0 +1,95 @@ + +DROP TABLE IF EXISTS `cuestionario_alumno_2`; + +CREATE TABLE + `cuestionario_alumno_2` ( + `idCuestionarioAlumno2` INT PRIMARY KEY NOT NULL AUTO_INCREMENT, + `createdAt` DATETIME, + `p12_A_1` VARCHAR(20), + `p12_A_2` VARCHAR(20), + `p12_A_3` VARCHAR(20), + `p12_A_4` VARCHAR(20), + `p12_B_1` VARCHAR(20), + `p12_B_2` VARCHAR(20), + `p12_B_3` VARCHAR(20), + `p12_B_4` VARCHAR(20), + `p12_C_1` VARCHAR(20), + `p12_C_2` VARCHAR(20), + `p12_C_3` VARCHAR(20), + `p12_C_4` VARCHAR(20), + `p10_1` VARCHAR(20), + `p10_2` VARCHAR(20), + `p10_3` VARCHAR(20), + `p11_1` VARCHAR(20), + `p11_2` VARCHAR(20), + `p11_3` VARCHAR(20), + `p11_4` VARCHAR(20), + `p17_1` VARCHAR(20), + `p17_2` VARCHAR(20), + `p17_3` VARCHAR(20), + `p3_1` VARCHAR(50), + `p3_2` VARCHAR(50), + `p3_3` VARCHAR(50), + `p3_4` VARCHAR(50), + `p12_D_1` VARCHAR(50), + `p12_D_2` VARCHAR(50), + `p12_D_3` VARCHAR(50), + `p12_D_4` VARCHAR(50), + `p12_D_5` VARCHAR(50), + `p1` TEXT, + `p2` VARCHAR(50), + `p4` VARCHAR(50), + `p5` VARCHAR(50), + `p6` VARCHAR(50), + `p7` VARCHAR(50), + `p8` VARCHAR(50), + `p9` VARCHAR(50), + `p13` VARCHAR(50), + `p14` VARCHAR(50), + `p15` VARCHAR(50), + `p16` VARCHAR(50), + `p18` VARCHAR(50) + ); + +DROP TABLE IF EXISTS `cuestionario_programa_2`; + +CREATE TABLE + `cuestionario_programa_2` ( + `idCuestionarioPrograma2` INT PRIMARY KEY NOT NULL AUTO_INCREMENT, + `createdAt` DATETIME, + `p3_A_1` VARCHAR(50), + `p3_A_2` VARCHAR(50), + `p3_A_3` VARCHAR(50), + `p3_A_4` VARCHAR(50), + `p3_B_1` VARCHAR(50), + `p3_B_2` VARCHAR(50), + `p3_B_3` VARCHAR(50), + `p3_B_4` VARCHAR(50), + `p3_C_1` VARCHAR(50), + `p3_C_2` VARCHAR(50), + `p3_C_3` VARCHAR(50), + `p3_C_4` VARCHAR(50), + `p3_C_5` VARCHAR(50), + `p3_D_1` VARCHAR(50), + `p3_D_2` VARCHAR(50), + `p3_D_3` VARCHAR(50), + `p3_D_4` VARCHAR(50), + `p3_D_5` VARCHAR(50), + `p3_E_1` VARCHAR(50), + `p1` VARCHAR(50), + `p2` VARCHAR(50), + `p4` VARCHAR(50), + `p5` VARCHAR(50), + `p6` VARCHAR(50), + `p7` VARCHAR(50) + ); + + + +ALTER TABLE servicio ADD COLUMN idCuestionarioAlumno2 INT; +ALTER TABLE servicio ADD COLUMN idCuestionarioPrograma2 INT; + +ALTER TABLE `servicio` ADD FOREIGN KEY (`idCuestionarioAlumno2`) REFERENCES `cuestionario_alumno_2` (`idCuestionarioAlumno2`); +ALTER TABLE `servicio` ADD FOREIGN KEY (`idCuestionarioPrograma2`) REFERENCES `cuestionario_programa_2` (`idCuestionarioPrograma2`); + +