Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2574b2bf86 | |||
| 0d0cc8f53d | |||
| 1c821addfb | |||
| 0c48921a9b | |||
| 3ba883ef5d | |||
| b2ce341ef1 | |||
| cfd2202dfe | |||
| 573471a33d | |||
| f7763a62e4 | |||
| 4deb3e9093 | |||
| 5aef8dac66 | |||
| 8a24c4368b | |||
| 7bef28e60f | |||
| f89b7e05db | |||
| 7e29a5e5b4 | |||
| f6dc38c00f | |||
| 38afeb084a | |||
| 76092c627f | |||
| 87c311c0c8 | |||
| c547f25a0a | |||
| 8cc4c7d34f | |||
| ab21808ec8 | |||
| 3a3c279080 | |||
| f1d041e891 | |||
| d181790277 | |||
| 493fd83e0e | |||
| 27988f9235 | |||
| 329332ad97 | |||
| 73b88b5fde | |||
| 67a23bcef0 | |||
| 3b18b3a8c2 | |||
| bc146595a9 |
@@ -1,25 +0,0 @@
|
||||
# Base image
|
||||
FROM node:16-alpine
|
||||
|
||||
# Install build tools and Python
|
||||
RUN apk add --no-cache python3 make g++ && \
|
||||
python3 -m ensurepip && \
|
||||
pip3 install --no-cache --upgrade pip
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json and package-lock.json
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . .
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 3000
|
||||
|
||||
# Command to run the application
|
||||
CMD ["npm", "run", "dev"]
|
||||
@@ -1,18 +1,16 @@
|
||||
{
|
||||
"name": "Node.js API Dev Container",
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile",
|
||||
"context": ".."
|
||||
},
|
||||
"forwardPorts": [3000],
|
||||
"settings": {
|
||||
"terminal.integrated.defaultProfile.linux": "bash"
|
||||
},
|
||||
"name": "Servicio Social API",
|
||||
"dockerFile": "../Dockerfile",
|
||||
"appPort": [3000],
|
||||
"postCreateCommand": "npm install",
|
||||
"extensions": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"ms-azuretools.vscode-docker",
|
||||
"esbenp.prettier-vscode"
|
||||
],
|
||||
"postCreateCommand": "npm install",
|
||||
"settings": {
|
||||
"terminal.integrated.shell.linux": "/bin/bash"
|
||||
},
|
||||
"remoteUser": "node"
|
||||
}
|
||||
|
||||
@@ -3,3 +3,4 @@ node_modules/
|
||||
cred.json
|
||||
server/uploads/*
|
||||
|
||||
#.devcontainer
|
||||
+20
@@ -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"]
|
||||
@@ -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',
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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);
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
-- 1) Insertar un par de servicios
|
||||
--INSERT INTO servicio VALUES ('094123123123','ferelena27@gmail.com','5538836200','Calle D #43 Colonia Modelo, Naucalpan de Juárez, Edo Mex.','2020-01-28 00:00:00','2020-07-28 00:00:00','1996-06-27 00:00:00','1zAAbHd2Gn8E7JougyynxHVLFJCHYM4U7','1ygjJyezG88X6qd-wV3i7PMDfW7yDGAbJ','1qzgUwhXqCRXPiYd0w8TADWB2Ja-0Geqy','1i-mmx-hlOVcdYHxoNM8ym96pwL2YQKxP','servicio y asesoría de cómputo','Lic. Araceli Pérez Palma',1,'2020-03-04 19:25:19','2021-04-26 19:21:57',2990,1,6,28,872,835,'2021-04-26 19:21:56');
|
||||
--INSERT INTO servicio VALUES ('091234123123','ferelena27@gmail.com','5538836200','Calle D #43 Colonia Modelo, Naucalpan de Juárez, Edo Mex.','2020-01-28 00:00:00','2020-07-28 00:00:00','1996-06-27 00:00:00','1zAAbHd2Gn8E7JougyynxHVLFJCHYM4U7','1ygjJyezG88X6qd-wV3i7PMDfW7yDGAbJ','1qzgUwhXqCRXPiYd0w8TADWB2Ja-0Geqy','1i-mmx-hlOVcdYHxoNM8ym96pwL2YQKxP','servicio y asesoría de cómputo','Lic. Araceli Pérez Palma',1,'2020-03-04 19:25:19','2021-04-26 19:21:57',2990,1,6,28,872,835,'2021-04-26 19:21:56');
|
||||
|
||||
-- 2) Insertar cuestionarios, cada uno asociado a un servicio
|
||||
INSERT INTO Cuestionario (
|
||||
idServicio, version, titulo, `desc`, dirigidoA, createdAt
|
||||
) VALUES
|
||||
(1, 'v1.0', 'Cuestionario Inicial', 'Descripción breve', 'Alumnos', NOW()),
|
||||
(2, 'v2.0', 'Cuestionario Avanzado', 'Otro cuestionario', 'Programas', '2025-01-23 10:25:00');
|
||||
|
||||
-- 3) Insertar en cuestionario_alumno_2
|
||||
INSERT INTO cuestionario_alumno_2 (
|
||||
idCuestionario,
|
||||
createdAt,
|
||||
p12_A_1,
|
||||
p12_A_2,
|
||||
p12_A_3,
|
||||
p12_A_4,
|
||||
p12_B_1,
|
||||
p12_B_2
|
||||
) VALUES
|
||||
(1, NOW(), 'respuesta1', 'respuesta2', 'respuesta3', 'respuesta4', 'respuesta5', 'respuesta6'),
|
||||
(1, '2025-01-23 11:00:00', 'respA', 'respB', 'respC', 'respD', 'respE', 'respF');
|
||||
|
||||
-- 4) Insertar en cuestionario_programa_2
|
||||
INSERT INTO cuestionario_programa_2 (
|
||||
idCuestionario,
|
||||
createdAt,
|
||||
p3_A_1,
|
||||
p3_A_2,
|
||||
p3_A_3,
|
||||
p3_A_4,
|
||||
p3_B_1
|
||||
) VALUES
|
||||
(2, NOW(), 'respuesta1', 'respuesta2', 'respuesta3', 'respuesta4', 'respuesta5'),
|
||||
(2, '2025-01-23 12:15:00', 'respX', 'respY', 'respZ', 'respW', 'respQ');
|
||||
Generated
+2124
-1204
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@
|
||||
"mariadb": "^2.5.1",
|
||||
"moment": "^2.29.1",
|
||||
"multer": "^1.4.2",
|
||||
"nodemailer": "^6.10.1",
|
||||
"sequelize": "^6.3.5",
|
||||
"validator": "^13.1.17"
|
||||
},
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -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'));
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
require('./config');
|
||||
const { Sequelize } = require('sequelize');
|
||||
|
||||
|
||||
|
||||
const sequelize = new Sequelize(
|
||||
process.env.DB,
|
||||
process.env.USERDB,
|
||||
@@ -12,21 +10,10 @@ 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',
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
|
||||
await sequelize.authenticate();
|
||||
console.log('Conexión exitosa con la Base de Datos');
|
||||
} catch (error) {
|
||||
console.error('No se pudo conectar a la BD:', error);
|
||||
}
|
||||
})();
|
||||
|
||||
module.exports = sequelize;
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const helperPath = '../../helper';
|
||||
// const drive = require(`${helperPath}/drive`);
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
@@ -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.');
|
||||
@@ -63,14 +63,14 @@ const nuevo = async (body, file) => {
|
||||
where: { idUsuario },
|
||||
});
|
||||
})
|
||||
/* .then(async (res) => {
|
||||
.then(async (res) => {
|
||||
if (res) throw new Error('Este alumno ya tienen un Caso Especial.');
|
||||
return drive.folder(numeroCuenta);
|
||||
})
|
||||
.then((res) => {
|
||||
carpeta = res;
|
||||
return drive.uploadFile(path, `archivos.zip`, 'application/zip', carpeta);
|
||||
}) */
|
||||
})
|
||||
.then((res) =>
|
||||
CasoEspecial.create({
|
||||
idUsuario,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
const { convertArrayToCSV } = require('convert-array-to-csv');
|
||||
const { Op } = require('sequelize');
|
||||
const helperPath = '../../helper';
|
||||
const helper = require(`${helperPath}/helper`);
|
||||
const { validarNumero } = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const CuestionarioAlumno2 = require(`${dbPath}/CuestionarioAlumno2`);
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
|
||||
|
||||
const get = async (body) => {
|
||||
const year = validarNumero(body.year, 'año', true, 4);
|
||||
const path = `server/uploads/${year}_cuestionario_alumno.csv`;
|
||||
const data = [];
|
||||
|
||||
console.log(year);
|
||||
|
||||
|
||||
/*
|
||||
return Servicio.findAll({
|
||||
include: [
|
||||
{
|
||||
model: CuestionarioAlumno2,
|
||||
where: { idCuestionarioAlumno: { [Op.not]: null } },
|
||||
},
|
||||
{ model: Programa, where: { clavePrograma: { [Op.like]: `${year}%` } } },
|
||||
{ model: Usuario },
|
||||
{ model: Carrera },
|
||||
],
|
||||
order: [['createdAt']],
|
||||
})
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* return CuestionarioAlumno2.findAll({
|
||||
where: {
|
||||
idCuestionarioAlumno2: {
|
||||
[Op.not]: null,
|
||||
},
|
||||
},
|
||||
// order: [['createdAt', 'ASC']], // Descomentar si se requiere ordenamiento
|
||||
})
|
||||
.then(async (res) => {
|
||||
|
||||
console.log("segunda parte",res);
|
||||
|
||||
for (let i = 0; i < res.length; i++)
|
||||
data.push({ ...res})
|
||||
|
||||
|
||||
data.push({
|
||||
idServicio: res[i].idServicio,
|
||||
clavePrograma: res[i].Programa.clavePrograma,
|
||||
usuario: res[i].Usuario.usuario,
|
||||
nombre: res[i].Usuario.nombre,
|
||||
carrera: res[i].Carrera.carrera,
|
||||
idCuestionarioAlumno: res[i].CuestionarioAlumno.idCuestionarioAlumno,
|
||||
sexo: res[i].CuestionarioAlumno.sexo,
|
||||
edad: res[i].CuestionarioAlumno.edad,
|
||||
servicioMedico: res[i].CuestionarioAlumno.servicioMedico,
|
||||
p1: res[i].CuestionarioAlumno.p1,
|
||||
p2: res[i].CuestionarioAlumno.p2,
|
||||
p3: res[i].CuestionarioAlumno.p3,
|
||||
p4: res[i].CuestionarioAlumno.p4,
|
||||
p5: res[i].CuestionarioAlumno.p5,
|
||||
p6: res[i].CuestionarioAlumno.p6,
|
||||
p7: res[i].CuestionarioAlumno.p7,
|
||||
p8: res[i].CuestionarioAlumno.p8,
|
||||
p9: res[i].CuestionarioAlumno.p9,
|
||||
p10: res[i].CuestionarioAlumno.p10,
|
||||
p11: res[i].CuestionarioAlumno.p11,
|
||||
p12: res[i].CuestionarioAlumno.p12,
|
||||
p13: res[i].CuestionarioAlumno.p13,
|
||||
p14: res[i].CuestionarioAlumno.p14,
|
||||
p15: res[i].CuestionarioAlumno.p15,
|
||||
p16: res[i].CuestionarioAlumno.p16,
|
||||
p17: res[i].CuestionarioAlumno.p17,
|
||||
p18: res[i].CuestionarioAlumno.p18,
|
||||
p19: res[i].CuestionarioAlumno.p19,
|
||||
p20: res[i].CuestionarioAlumno.p20,
|
||||
p21: res[i].CuestionarioAlumno.p21,
|
||||
p22: res[i].CuestionarioAlumno.p22,
|
||||
p23: res[i].CuestionarioAlumno.p23,
|
||||
p24: res[i].CuestionarioAlumno.p24,
|
||||
p25: res[i].CuestionarioAlumno.p25,
|
||||
p26: res[i].CuestionarioAlumno.p26,
|
||||
p27: res[i].CuestionarioAlumno.p27,
|
||||
p28: res[i].CuestionarioAlumno.p28,
|
||||
p29: res[i].CuestionarioAlumno.p29,
|
||||
p30: res[i].CuestionarioAlumno.p30,
|
||||
createdAt: res[i].CuestionarioAlumno.createdAt,
|
||||
});
|
||||
await helper.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => path);
|
||||
}; */
|
||||
|
||||
|
||||
|
||||
return CuestionarioAlumno2.findAll({
|
||||
where: {
|
||||
idCuestionarioAlumno2: {
|
||||
[Op.not]: null,
|
||||
},
|
||||
},
|
||||
})
|
||||
.then(async (res) => {
|
||||
console.log("segunda parte", res);
|
||||
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
data.push(res[i].get({ plain: true }));
|
||||
}
|
||||
|
||||
// Alternativa manual si necesitas campos específicos
|
||||
/* for (let i = 0; i < res.length; i++) {
|
||||
const row = res[i].get({ plain: true });
|
||||
data.push({
|
||||
idCuestionarioAlumno2: row.idCuestionarioAlumno2,
|
||||
p1: row.p1,
|
||||
p2: row.p2,
|
||||
p3: row.p3,
|
||||
p4: row.p4,
|
||||
p5: row.p5,
|
||||
// Agrega los demás campos según sea necesario
|
||||
});
|
||||
} */
|
||||
|
||||
await helper.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = get;
|
||||
@@ -1,246 +0,0 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const CuestionarioAlumno = require(`${dbPath}/CuestionarioAlumno`);
|
||||
const CuestionarioAlumno2 = require(`${dbPath}/CuestionarioAlumno2`);
|
||||
|
||||
const Cuestionario = require(`${dbPath}/Cuestionario`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
const nuevo = async (body) => {
|
||||
// console.log(body);
|
||||
|
||||
let idServicio = body.idServicio;
|
||||
/*
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
); */
|
||||
|
||||
|
||||
body = validar.validarCuestionarioAlumno2(body);
|
||||
|
||||
|
||||
// pasar preguntas de array a string
|
||||
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then(async (res) => {
|
||||
if (!res) throw new Error('No existe este Servicio Social.');
|
||||
/*
|
||||
if (res.idCuestionarioAlumno)
|
||||
throw new Error(
|
||||
'Este Servicio Social ya cuenta con cuestionario de alumno'
|
||||
);
|
||||
*/
|
||||
|
||||
console.log('el servicio social si existe');
|
||||
// console.log(res);
|
||||
|
||||
/**
|
||||
* existe el servicio social?
|
||||
* tiene cuestionario alumno en la tabla cuestionario? select * from cuestionario where idServicio = 1
|
||||
* si no existe, entonces se puede crear el cuestionario
|
||||
* creamos el cuestionario y guardamos las respuestas
|
||||
*/
|
||||
|
||||
const messageByStatus = {
|
||||
1: 'Aun no se puede contestar el cuestionario este Servicio Social.',
|
||||
2: 'Aun no se puede contestar el cuestionario este Servicio Social.',
|
||||
3: 'Aun no se puede contestar el cuestionario este Servicio Social.',
|
||||
5: 'Este Servicio Social ya paso la fase de contestar el cuestionario.',
|
||||
6: 'Este Servicio Social ya paso la fase de contestar el cuestionario.',
|
||||
7: 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corrija lo necesario.',
|
||||
8: 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corrija lo necesario.',
|
||||
9: 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corrija lo necesario.',
|
||||
10: 'Este Servicio Social fue cancelado.',
|
||||
};
|
||||
|
||||
// if (res.idStatus === 4) return CuestionarioAlumno2.create({ ...body });
|
||||
console.log('antes de create ques2');
|
||||
|
||||
// if (res.idStatus) return CuestionarioAlumno2.create({ ...body });
|
||||
|
||||
// si idStatus está en el objeto, arrojamos el mensaje
|
||||
|
||||
/* if (messageByStatus.hasOwnProperty(res.idStatus))
|
||||
throw new Error(messageByStatus[res.idStatus]); */
|
||||
|
||||
// throw new Error('Id status no valido.'); // si no coincide con nada, error por defecto
|
||||
|
||||
// Cuestionario.findOne({});
|
||||
|
||||
let dataCuestionario = await Cuestionario.findOne({
|
||||
where: { idServicio, dirigidoA: 'estudiantes' },
|
||||
});
|
||||
console.log('data cuestionario', dataCuestionario);
|
||||
|
||||
if (dataCuestionario) {
|
||||
throw new Error('Ya existe un cuestionario para este servicio social');
|
||||
}
|
||||
|
||||
|
||||
let 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, idCuestionario: cuestionarioRegistro.idCuestionario } );
|
||||
|
||||
let respuestasRegistradas = await CuestionarioAlumno2.create({ ...body, idCuestionario: cuestionarioRegistro.idCuestionario });
|
||||
console.log('despues de registrar cuestionario', respuestasRegistradas);
|
||||
|
||||
|
||||
console.log('cuestionario registrado', cuestionarioRegistro);
|
||||
|
||||
return cuestionarioRegistro;
|
||||
})
|
||||
|
||||
.then((res) => ({
|
||||
message: `Se guardaron tus respuestas correctamente. ${res}`,
|
||||
}));
|
||||
};
|
||||
|
||||
const convertirSTR = () => {
|
||||
for (let i = 0; i < body.p3.length; i++) {
|
||||
p3 += body.p3[i];
|
||||
if (i < body.p3.length - 1) p3 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p5.length; i++) {
|
||||
p5 += body.p5[i];
|
||||
if (i < body.p5.length - 1) p5 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p8.length; i++) {
|
||||
p8 += body.p8[i];
|
||||
if (i < body.p8.length - 1) p8 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p14.length; i++) {
|
||||
p14 += body.p14[i];
|
||||
if (i < body.p14.length - 1) p14 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p15.length; i++) {
|
||||
p15 += body.p15[i];
|
||||
if (i < body.p15.length - 1) p15 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p17.length; i++) {
|
||||
p17 += body.p17[i];
|
||||
if (i < body.p17.length - 1) p17 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p21.length; i++) {
|
||||
p21 += body.p21[i];
|
||||
if (i < body.p21.length - 1) p21 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p22.length; i++) {
|
||||
p22 += body.p22[i];
|
||||
if (i < body.p22.length - 1) p22 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p23.length; i++) {
|
||||
p23 += body.p23[i];
|
||||
if (i < body.p23.length - 1) p23 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p24.length; i++) {
|
||||
p24 += body.p24[i];
|
||||
if (i < body.p24.length - 1) p24 += ',';
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = nuevo;
|
||||
|
||||
/*
|
||||
|
||||
<!-- respuestas de cuestionario formulario2
|
||||
todas las preguntas se guardan correctamente
|
||||
{
|
||||
"p3_A_1": "Deficiente",
|
||||
"p3_A_2": "Deficiente",
|
||||
"p3_A_3": "Deficiente",
|
||||
"p3_A_4": "Deficiente",
|
||||
"p3_B_1": "Básico",
|
||||
"p3_B_2": "Básico",
|
||||
"p3_B_3": "Básico",
|
||||
"p3_B_4": "Básico",
|
||||
"p3_C_1": "Intermedio",
|
||||
"p3_C_2": "Intermedio",
|
||||
"p3_C_3": "Intermedio",
|
||||
"p3_C_4": "Intermedio",
|
||||
"p3_C_5": "Intermedio",
|
||||
"p3_D_1": "Destacado",
|
||||
"p3_D_2": "Destacado",
|
||||
"p3_D_3": "Destacado",
|
||||
"p3_D_4": "Destacado",
|
||||
"p3_D_5": "Destacado",
|
||||
"p3_E_1": "Deficiente",
|
||||
"p1": "respuesta1",
|
||||
"p2": "Excelente",
|
||||
"p4": "respuesta4",
|
||||
"p5": "Sí",
|
||||
"p6": "respuesta 6"
|
||||
}
|
||||
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- respuestas de cuestionario formulario alumno
|
||||
|
||||
|
||||
{
|
||||
"p1": [
|
||||
"Dependencia de la UNAM",
|
||||
"Asesoría académica",
|
||||
"Oportunidad de desarrollo de tesis"
|
||||
],
|
||||
"p12_A_1": "Deficiente",
|
||||
"p12_A_2": "Deficiente",
|
||||
"p12_A_3": "Deficiente",
|
||||
"p12_A_4": "Deficiente",
|
||||
"p12_B_1": "Básico",
|
||||
"p12_B_2": "Básico",
|
||||
"p12_B_3": "Básico",
|
||||
"p12_B_4": "Básico",
|
||||
"p12_C_1": "Intermedio",
|
||||
"p12_C_2": "Intermedio",
|
||||
"p12_C_3": "Intermedio",
|
||||
"p12_C_4": "Intermedio",
|
||||
"p10_1": "si",
|
||||
"p10_2": "si",
|
||||
"p10_3": "si",
|
||||
"p11_1": "Nunca",
|
||||
"p11_2": "Rara vez",
|
||||
"p11_3": "Algunas veces",
|
||||
"p11_4": "Siempre",
|
||||
"p17_1": "si",
|
||||
"p17_2": "no",
|
||||
"p17_3": "si",
|
||||
"p3_1": "si",
|
||||
"p3_2": "si",
|
||||
"p3_3": "si",
|
||||
"p3_4": "si",
|
||||
"p12_D_1": "Destacado",
|
||||
"p12_D_2": "Destacado",
|
||||
"p12_D_3": "Destacado",
|
||||
"p12_D_4": "Destacado",
|
||||
"p12_D_5": "Destacado",
|
||||
"p2": "Deficiente",
|
||||
"p4": "No",
|
||||
"p5": "respuesta5",
|
||||
"p6": "Sí",
|
||||
"p7": "Sí",
|
||||
"p8": "respuesta8",
|
||||
"p9": "Sí",
|
||||
"p13": "Responsable directo del programa",
|
||||
"p14": "Se te otorgó de acuerdo a lo establecido",
|
||||
"p15": "Sí",
|
||||
"p16": "respuesta 16",
|
||||
"p18": "respuesta18"
|
||||
}
|
||||
|
||||
|
||||
-->
|
||||
|
||||
*/
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const { convertArrayToCSV } = require('convert-array-to-csv');
|
||||
const { Op } = require('sequelize');
|
||||
const helperPath = '../../helper';
|
||||
const helper = require(`${helperPath}/helper`);
|
||||
const { validarNumero } = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const CuestionarioPrograma2 = require(`${dbPath}/CuestionarioPrograma`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
const Programa = require(`${dbPath}/Programa`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const get = async (body) => {
|
||||
const year = validarNumero(body.year, 'año', true, 4);
|
||||
const path = `server/uploads/${year}_cuestionario_programa.csv`;
|
||||
const data = [];
|
||||
|
||||
|
||||
|
||||
return CuestionarioPrograma2.findAll({
|
||||
where: {
|
||||
idCuestionarioPrograma2: {
|
||||
[Op.not]: null,
|
||||
},
|
||||
},
|
||||
})
|
||||
.then(async (res) => {
|
||||
console.log("segunda parte", res);
|
||||
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
data.push(res[i].get({ plain: true }));
|
||||
}
|
||||
|
||||
// Alternativa manual si necesitas campos específicos
|
||||
/* for (let i = 0; i < res.length; i++) {
|
||||
const row = res[i].get({ plain: true });
|
||||
data.push({
|
||||
idCuestionarioPrograma2: row.idCuestionarioPrograma2,
|
||||
p1: row.p1,
|
||||
p2: row.p2,
|
||||
p3: row.p3,
|
||||
p4: row.p4,
|
||||
p5: row.p5,
|
||||
// Agrega los demás campos según sea necesario
|
||||
});
|
||||
} */
|
||||
|
||||
await helper.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* return Servicio.findAll({
|
||||
include: [
|
||||
{
|
||||
model: CuestionarioPrograma,
|
||||
where: { idCuestionarioPrograma: { [Op.not]: null } },
|
||||
},
|
||||
{ model: Programa, where: { clavePrograma: { [Op.like]: `${year}-%` } } },
|
||||
{ model: Usuario },
|
||||
{ model: Carrera },
|
||||
],
|
||||
order: [['createdAt']],
|
||||
})
|
||||
.then(async (res) => {
|
||||
for (let i = 0; i < res.length; i++)
|
||||
data.push({
|
||||
idServicio: res[i].idServicio,
|
||||
clavePrograma: res[i].Programa.clavePrograma,
|
||||
usuario: res[i].Usuario.usuario,
|
||||
nombre: res[i].Usuario.nombre,
|
||||
carrera: res[i].Carrera.carrera,
|
||||
idCuestionarioPrograma:
|
||||
res[i].CuestionarioPrograma.idCuestionarioPrograma,
|
||||
actividad1: res[i].CuestionarioPrograma.actividad1,
|
||||
actividad2: res[i].CuestionarioPrograma.actividad2,
|
||||
actividad3: res[i].CuestionarioPrograma.actividad3,
|
||||
actividad4: res[i].CuestionarioPrograma.actividad4,
|
||||
actividad5: res[i].CuestionarioPrograma.actividad5,
|
||||
retroalimentacion: res[i].CuestionarioPrograma.retroalimentacion,
|
||||
p6: res[i].CuestionarioPrograma.p6,
|
||||
p7: res[i].CuestionarioPrograma.p7,
|
||||
createdAt: res[i].CuestionarioPrograma.createdAt,
|
||||
});
|
||||
await helper.eliminarArchivo(path).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
})
|
||||
.then((res) => path);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
module.exports = get;
|
||||
@@ -1,249 +0,0 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const CuestionarioAlumno = require(`${dbPath}/CuestionarioAlumno`);
|
||||
const CuestionarioPrograma2 = require(`${dbPath}/CuestionarioPrograma2`);
|
||||
|
||||
const Cuestionario = require(`${dbPath}/Cuestionario`);
|
||||
const Servicio = require(`${dbPath}/Servicio`);
|
||||
|
||||
const nuevo = async (body) => {
|
||||
// console.log(body);
|
||||
|
||||
let idServicio = body.idServicio;
|
||||
/*
|
||||
const idServicio = validar.validarNumeroEntero(
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
); */
|
||||
|
||||
// pasar preguntas de array a string
|
||||
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then(async (res) => {
|
||||
if (!res) throw new Error('No existe este Servicio Social.');
|
||||
/* if (res.idCuestionarioAlumno)
|
||||
throw new Error(
|
||||
'Este Servicio Social ya cuenta con cuestionario de programa'
|
||||
); */
|
||||
|
||||
console.log('el servicio social si existe');
|
||||
// console.log(res);
|
||||
|
||||
/**
|
||||
* existe el servicio social?
|
||||
* tiene cuestionario alumno en la tabla cuestionario? select * from cuestionario where idServicio = 1
|
||||
* si no existe, entonces se puede crear el cuestionario
|
||||
* creamos el cuestionario y guardamos las respuestas
|
||||
*/
|
||||
|
||||
const messageByStatus = {
|
||||
1: 'Aun no se puede contestar el cuestionario este Servicio Social.',
|
||||
2: 'Aun no se puede contestar el cuestionario este Servicio Social.',
|
||||
3: 'Aun no se puede contestar el cuestionario este Servicio Social.',
|
||||
5: 'Este Servicio Social ya paso la fase de contestar el cuestionario.',
|
||||
6: 'Este Servicio Social ya paso la fase de contestar el cuestionario.',
|
||||
7: 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corrija lo necesario.',
|
||||
8: 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corrija lo necesario.',
|
||||
9: 'Este Servicio Social se encuentra rechazado. No se puede avanzar hasta que se corrija lo necesario.',
|
||||
10: 'Este Servicio Social fue cancelado.',
|
||||
};
|
||||
|
||||
// if (res.idStatus === 4) return CuestionarioPrograma2.create({ ...body });
|
||||
console.log('antes de create ques2');
|
||||
|
||||
// if (res.idStatus) return CuestionarioPrograma2.create({ ...body });
|
||||
// si idStatus está en el objeto, arrojamos el mensaje
|
||||
/* if (messageByStatus.hasOwnProperty(res.idStatus))
|
||||
throw new Error(messageByStatus[res.idStatus]); */
|
||||
// throw new Error('Id status no valido.'); // si no coincide con nada, error por defecto
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let dataCuestionario = await Cuestionario.findOne({
|
||||
where: { idServicio, dirigidoA: 'programas' },
|
||||
});
|
||||
console.log('data cuestionario', dataCuestionario);
|
||||
|
||||
if (dataCuestionario) {
|
||||
throw new Error('Ya existe un cuestionario para este servicio social');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
let 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);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let respuestasRegistradas = await CuestionarioPrograma2.create({
|
||||
...body,
|
||||
idCuestionario: cuestionarioRegistro.idCuestionario
|
||||
});
|
||||
|
||||
console.log('despues de registrar cuestionario', respuestasRegistradas);
|
||||
|
||||
// si el cuestionario ya existe solo hay que actualizar el id de cuestionarioprograma o alumno
|
||||
|
||||
|
||||
return cuestionarioRegistro;
|
||||
})
|
||||
|
||||
.then((res) => ({
|
||||
message: `Se guardaron tus respuestas correctamente. ${res}`,
|
||||
}));
|
||||
};
|
||||
|
||||
const convertirSTR = () => {
|
||||
for (let i = 0; i < body.p3.length; i++) {
|
||||
p3 += body.p3[i];
|
||||
if (i < body.p3.length - 1) p3 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p5.length; i++) {
|
||||
p5 += body.p5[i];
|
||||
if (i < body.p5.length - 1) p5 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p8.length; i++) {
|
||||
p8 += body.p8[i];
|
||||
if (i < body.p8.length - 1) p8 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p14.length; i++) {
|
||||
p14 += body.p14[i];
|
||||
if (i < body.p14.length - 1) p14 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p15.length; i++) {
|
||||
p15 += body.p15[i];
|
||||
if (i < body.p15.length - 1) p15 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p17.length; i++) {
|
||||
p17 += body.p17[i];
|
||||
if (i < body.p17.length - 1) p17 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p21.length; i++) {
|
||||
p21 += body.p21[i];
|
||||
if (i < body.p21.length - 1) p21 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p22.length; i++) {
|
||||
p22 += body.p22[i];
|
||||
if (i < body.p22.length - 1) p22 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p23.length; i++) {
|
||||
p23 += body.p23[i];
|
||||
if (i < body.p23.length - 1) p23 += ',';
|
||||
}
|
||||
for (let i = 0; i < body.p24.length; i++) {
|
||||
p24 += body.p24[i];
|
||||
if (i < body.p24.length - 1) p24 += ',';
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = nuevo;
|
||||
|
||||
/*
|
||||
|
||||
<!-- respuestas de cuestionario formulario2
|
||||
todas las preguntas se guardan correctamente
|
||||
{
|
||||
"p3_A_1": "Deficiente",
|
||||
"p3_A_2": "Deficiente",
|
||||
"p3_A_3": "Deficiente",
|
||||
"p3_A_4": "Deficiente",
|
||||
"p3_B_1": "Básico",
|
||||
"p3_B_2": "Básico",
|
||||
"p3_B_3": "Básico",
|
||||
"p3_B_4": "Básico",
|
||||
"p3_C_1": "Intermedio",
|
||||
"p3_C_2": "Intermedio",
|
||||
"p3_C_3": "Intermedio",
|
||||
"p3_C_4": "Intermedio",
|
||||
"p3_C_5": "Intermedio",
|
||||
"p3_D_1": "Destacado",
|
||||
"p3_D_2": "Destacado",
|
||||
"p3_D_3": "Destacado",
|
||||
"p3_D_4": "Destacado",
|
||||
"p3_D_5": "Destacado",
|
||||
"p3_E_1": "Deficiente",
|
||||
"p1": "respuesta1",
|
||||
"p2": "Excelente",
|
||||
"p4": "respuesta4",
|
||||
"p5": "Sí",
|
||||
"p6": "respuesta 6"
|
||||
}
|
||||
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- respuestas de cuestionario formulario alumno
|
||||
|
||||
|
||||
{
|
||||
"p1": [
|
||||
"Dependencia de la UNAM",
|
||||
"Asesoría académica",
|
||||
"Oportunidad de desarrollo de tesis"
|
||||
],
|
||||
"p12_A_1": "Deficiente",
|
||||
"p12_A_2": "Deficiente",
|
||||
"p12_A_3": "Deficiente",
|
||||
"p12_A_4": "Deficiente",
|
||||
"p12_B_1": "Básico",
|
||||
"p12_B_2": "Básico",
|
||||
"p12_B_3": "Básico",
|
||||
"p12_B_4": "Básico",
|
||||
"p12_C_1": "Intermedio",
|
||||
"p12_C_2": "Intermedio",
|
||||
"p12_C_3": "Intermedio",
|
||||
"p12_C_4": "Intermedio",
|
||||
"p10_1": "si",
|
||||
"p10_2": "si",
|
||||
"p10_3": "si",
|
||||
"p11_1": "Nunca",
|
||||
"p11_2": "Rara vez",
|
||||
"p11_3": "Algunas veces",
|
||||
"p11_4": "Siempre",
|
||||
"p17_1": "si",
|
||||
"p17_2": "no",
|
||||
"p17_3": "si",
|
||||
"p3_1": "si",
|
||||
"p3_2": "si",
|
||||
"p3_3": "si",
|
||||
"p3_4": "si",
|
||||
"p12_D_1": "Destacado",
|
||||
"p12_D_2": "Destacado",
|
||||
"p12_D_3": "Destacado",
|
||||
"p12_D_4": "Destacado",
|
||||
"p12_D_5": "Destacado",
|
||||
"p2": "Deficiente",
|
||||
"p4": "No",
|
||||
"p5": "respuesta5",
|
||||
"p6": "Sí",
|
||||
"p7": "Sí",
|
||||
"p8": "respuesta8",
|
||||
"p9": "Sí",
|
||||
"p13": "Responsable directo del programa",
|
||||
"p14": "Se te otorgó de acuerdo a lo establecido",
|
||||
"p15": "Sí",
|
||||
"p16": "respuesta 16",
|
||||
"p18": "respuesta18"
|
||||
}
|
||||
|
||||
|
||||
-->
|
||||
|
||||
*/
|
||||
@@ -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;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const helperPath = '../../helper';
|
||||
//const drive = require(`${helperPath}/drive`);
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
@@ -23,13 +23,13 @@ const cartaTermino = async (body, file) => {
|
||||
if (res.cartaAceptacion)
|
||||
throw new Error('Ya se subio la Carta de Aceptación.');
|
||||
switch (res.idStatus) {
|
||||
/* case 7:
|
||||
case 7:
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
`Carta_Aceptacion.pdf`,
|
||||
'application/pdf',
|
||||
res.carpeta
|
||||
); */
|
||||
);
|
||||
case 1:
|
||||
throw new Error(
|
||||
'Esta linea de la API solo puede ser usada cuando es estatus del Servicio Social sea 7.'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const helperPath = '../../helper';
|
||||
//const drive = require(`${helperPath}/drive`);
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
@@ -23,13 +23,15 @@ const cartaTermino = async (body, file) => {
|
||||
if (res.cartaTermino) throw new Error('Ya se subio la Carta de Termino.');
|
||||
switch (res.idStatus) {
|
||||
case 4:
|
||||
/* case 8:
|
||||
return drive.uploadFile(
|
||||
case 8:
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
`Carta_Termino.pdf`,
|
||||
'application/pdf',
|
||||
res.carpeta
|
||||
); */
|
||||
);
|
||||
//return "carta de termino"
|
||||
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const helperPath = '../../helper';
|
||||
//const drive = require(`${helperPath}/drive`);
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
@@ -23,13 +23,14 @@ const informeGlobal = async (body, file) => {
|
||||
if (res.informeGlobal) throw new Error('Ya se subio el Informe Global.');
|
||||
switch (res.idStatus) {
|
||||
case 4:
|
||||
/* case 9:
|
||||
return drive.uploadFile(
|
||||
case 9:
|
||||
return drive.uploadFile(
|
||||
path,
|
||||
`Informe_Global.pdf`,
|
||||
'application/pdf',
|
||||
res.carpeta
|
||||
); */
|
||||
);
|
||||
// return "informe global"
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { Op } = require('sequelize');
|
||||
const helperPath = '../../helper';
|
||||
//const drive = require(`${helperPath}/drive`);
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
@@ -79,7 +79,7 @@ const nuevo = async (body, file) => {
|
||||
.then((servicio) => {
|
||||
let carpeta = '';
|
||||
|
||||
/* drive
|
||||
drive
|
||||
.mkDir(numeroCuenta)
|
||||
.then((res) => {
|
||||
carpeta = res;
|
||||
@@ -95,7 +95,7 @@ const nuevo = async (body, file) => {
|
||||
{ carpeta, cartaAceptacion: res },
|
||||
{ where: { idServicio: servicio.idServicio } }
|
||||
)
|
||||
); */
|
||||
);
|
||||
return { message: `Se Pre-Registro correctamente a este alumno.` };
|
||||
});
|
||||
};
|
||||
|
||||
@@ -12,7 +12,9 @@ const registro = async (body) => {
|
||||
body.idServicio,
|
||||
'id servicio'
|
||||
);
|
||||
const password = encriptar.generarPassword();
|
||||
let 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.'
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
@@ -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.',
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const helperPath = '../../helper';
|
||||
//const drive = require(`${helperPath}/drive`);
|
||||
const drive = require(`${helperPath}/drive`);
|
||||
const validar = require(`${helperPath}/validar`);
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
|
||||
@@ -13,8 +13,6 @@ const update = async (body, files) => {
|
||||
return Servicio.findOne({ where: { idServicio } })
|
||||
.then(async (res) => {
|
||||
if (!res) throw new Error('Este Servicio Social no existe en la db.');
|
||||
|
||||
/*
|
||||
try {
|
||||
if (files['cartaAceptacion'][0].filename)
|
||||
dataUpdate.cartaAceptacion = await drive.uploadFile(
|
||||
@@ -42,9 +40,6 @@ const update = async (body, files) => {
|
||||
res.carpeta
|
||||
);
|
||||
} catch (err) {}
|
||||
*/
|
||||
|
||||
|
||||
if (body.correo) dataUpdate.correo = validar.validarCorreo(body.correo);
|
||||
if (body.fechaInicio)
|
||||
dataUpdate.fechaInicio = validar.validarFecha(
|
||||
@@ -84,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.',
|
||||
}));
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
const helperPath = '../../helper';
|
||||
const encriptar = require(`${helperPath}/encriptar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const newAdmin = async (body) => {
|
||||
const password = encriptar.generarPassword();
|
||||
|
||||
|
||||
await Usuario.create({
|
||||
usuario: body.usuario,
|
||||
password: encriptar.encriptar(password),
|
||||
nombre: body.nombre,
|
||||
activo: true,
|
||||
idTipoUsuario: body.idTipoUsuario,
|
||||
})
|
||||
return password;
|
||||
};
|
||||
|
||||
module.exports = newAdmin;
|
||||
@@ -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'],
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+68
-5
@@ -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
|
||||
|
||||
+32
-37
@@ -10,11 +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/CuestionarioAlumno');
|
||||
const CuestionarioPrograma2 = require('./tablas/CuestionarioPrograma');
|
||||
|
||||
const CuestionarioAlumno2 = require('./tablas/CuestionarioAlumno2');
|
||||
const CuestionarioPrograma2 = require('./tablas/CuestionarioPrograma2');
|
||||
|
||||
const drop = async () => {
|
||||
console.log('\nPaso 1) Desinstalando la db.'.bold.blue);
|
||||
@@ -38,20 +35,6 @@ const drop = async () => {
|
||||
'La tabla CuestionarioAlumno 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
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
await Programa.drop();
|
||||
console.log('La tabla Programa se desinstalo correctamente.'.magenta);
|
||||
|
||||
@@ -63,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);
|
||||
|
||||
@@ -88,21 +88,6 @@ const sync = async () => {
|
||||
'La tabla CuestionarioPrograma 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
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
await Carrera.sync();
|
||||
console.log('La tabla Carrera se instalo correctamente.'.magenta);
|
||||
|
||||
@@ -111,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 () => {
|
||||
@@ -159,7 +154,7 @@ const dataAdmin = async () => {
|
||||
});
|
||||
};
|
||||
|
||||
const dataResponsableCasoEspecial = async () => {
|
||||
/* const dataResponsableCasoEspecial = async () => {
|
||||
console.log(
|
||||
'\nPaso 6) Instalando responsable de casos especiales.'.bold.blue
|
||||
);
|
||||
@@ -170,7 +165,7 @@ const dataResponsableCasoEspecial = async () => {
|
||||
idTipoUsuario: 4,
|
||||
activo: true,
|
||||
});
|
||||
};
|
||||
}; */
|
||||
|
||||
const exe = async () => {
|
||||
await drop();
|
||||
@@ -178,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
|
||||
);
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
|
||||
const { DataTypes, Model } = require('sequelize');
|
||||
const sequelize = require('../../config/sequelize.conf');
|
||||
const Usuario = require('./Usuario');
|
||||
const Carrera = require('./Carrera');
|
||||
const Programa = require('./Programa');
|
||||
const Servicio = require('./Servicio');
|
||||
const CuestionarioAlumno2 = require('./CuestionarioAlumno2');
|
||||
const CuestionarioPrograma2 = require('./CuestionarioPrograma2');
|
||||
|
||||
class Cuestionario extends Model {}
|
||||
Cuestionario.init(
|
||||
{
|
||||
idCuestionario: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
|
||||
idServicio: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: Servicio,
|
||||
key: 'idServicio',
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
version: {
|
||||
type: DataTypes.STRING(50),
|
||||
allowNull: false,
|
||||
},
|
||||
titulo: {
|
||||
type: DataTypes.STRING(50),
|
||||
allowNull: false,
|
||||
},
|
||||
desc: {
|
||||
type: DataTypes.STRING(50),
|
||||
allowNull: false,
|
||||
},
|
||||
dirigidoA: {
|
||||
type: DataTypes.STRING(50),
|
||||
allowNull: false,
|
||||
},
|
||||
createdAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'Cuestionario',
|
||||
tableName: 'Cuestionario',
|
||||
timestamps: false,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
Cuestionario.belongsTo(Servicio, { foreignKey: 'idServicio' });
|
||||
Servicio.hasMany(Cuestionario, { foreignKey: 'idServicio' });
|
||||
|
||||
|
||||
|
||||
Cuestionario.belongsTo(CuestionarioAlumno2, { foreignKey: 'idCuestionarioAlumno2' });
|
||||
CuestionarioAlumno2.hasOne(Cuestionario, { foreignKey: 'idCuestionarioAlumno2' });
|
||||
|
||||
Cuestionario.belongsTo(CuestionarioPrograma2, { foreignKey: 'idCuestionarioPrograma2' });
|
||||
CuestionarioPrograma2.hasOne(Cuestionario, { foreignKey: 'idCuestionarioPrograma2' });
|
||||
|
||||
|
||||
module.exports = Cuestionario;
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
const { DataTypes, Model } = require('sequelize');
|
||||
const sequelize = require('../../config/sequelize.conf');
|
||||
const Servicio = require('./Servicio');
|
||||
|
||||
class Cuestionario extends Model {}
|
||||
|
||||
Cuestionario.init(
|
||||
{
|
||||
idCuestionario: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
idServicio: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: Servicio,
|
||||
key: 'idServicio',
|
||||
},
|
||||
},
|
||||
version: DataTypes.STRING(50),
|
||||
titulo: DataTypes.STRING(50),
|
||||
desc: DataTypes.STRING(50),
|
||||
dirigidoA: DataTypes.STRING(50),
|
||||
createdAt: DataTypes.DATE,
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'Cuestionario',
|
||||
tableName: 'Cuestionario',
|
||||
timestamps: false,
|
||||
}
|
||||
);
|
||||
|
||||
Cuestionario.belongsTo(Servicio, { foreignKey: 'idServicio' });
|
||||
Servicio.hasMany(Cuestionario, { foreignKey: 'idServicio' });
|
||||
|
||||
module.exports = Cuestionario;
|
||||
@@ -1,253 +1,4 @@
|
||||
|
||||
/*
|
||||
const { DataTypes, Model } = require('sequelize');
|
||||
const sequelize = require('../../config/sequelize.conf');
|
||||
|
||||
const Cuestionario = require('./Cuestionario');
|
||||
|
||||
|
||||
|
||||
class CuestionarioAlumno2 extends Model {}
|
||||
|
||||
CuestionarioAlumno2.init(
|
||||
{
|
||||
idCuestionarioAlumno2: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
|
||||
|
||||
|
||||
idCuestionario: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: 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, // Ajusta según tus necesidades
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
CuestionarioAlumno2.belongsTo(Cuestionario, { foreignKey: 'idCuestionario' });
|
||||
Cuestionario.hasMany(CuestionarioAlumno2, { foreignKey: 'idCuestionario' });
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = CuestionarioAlumno2;
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
const { DataTypes, Model } = require('sequelize');
|
||||
const sequelize = require('../../config/sequelize.conf');
|
||||
|
||||
@@ -260,16 +11,9 @@ CuestionarioAlumno2.init(
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
idCuestionario: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
p1: {
|
||||
type: DataTypes.STRING(100),
|
||||
allowNull: true,
|
||||
@@ -473,11 +217,6 @@ CuestionarioAlumno2.init(
|
||||
}
|
||||
);
|
||||
|
||||
// Importación después de la definición para evitar dependencias circulares
|
||||
const Cuestionario = require('./Cuestionario');
|
||||
|
||||
// Definir relaciones después de importar correctamente
|
||||
CuestionarioAlumno2.belongsTo(Cuestionario, { foreignKey: 'idCuestionario' });
|
||||
Cuestionario.hasMany(CuestionarioAlumno2, { foreignKey: 'idCuestionario' });
|
||||
|
||||
module.exports = CuestionarioAlumno2;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const { DataTypes, Model } = require('sequelize');
|
||||
const sequelize = require('../../config/sequelize.conf');
|
||||
|
||||
const Cuestionario = require('./Cuestionario');
|
||||
|
||||
|
||||
class CuestionarioPrograma2 extends Model {}
|
||||
@@ -17,12 +16,6 @@ CuestionarioPrograma2.init(
|
||||
},
|
||||
|
||||
|
||||
idCuestionario: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
},
|
||||
|
||||
|
||||
|
||||
// Sección p3_A_*
|
||||
p3_A_1: {
|
||||
@@ -143,9 +136,6 @@ CuestionarioPrograma2.init(
|
||||
);
|
||||
|
||||
|
||||
CuestionarioPrograma2.belongsTo(Cuestionario, { foreignKey: 'idCuestionario' });
|
||||
Cuestionario.hasMany(CuestionarioPrograma2, { foreignKey: 'idCuestionario' });
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+136
-86
@@ -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);
|
||||
}
|
||||
);
|
||||
// });
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
+20
-11
@@ -1,17 +1,26 @@
|
||||
require('../config/config');
|
||||
require('../config/config'); // mantiene tu carga de variables
|
||||
const nodemailer = require('nodemailer');
|
||||
|
||||
const send = require('gmail-send')({
|
||||
user: process.env.GMAIL,
|
||||
pass: process.env.GMAILPASSWORD,
|
||||
const transporter = nodemailer.createTransport({
|
||||
host: 'smtp.gmail.com', // o smtp‑relay.gmail.com (ver punto 2)
|
||||
port: 587,
|
||||
secure: false,
|
||||
requireTLS: true, // TLS STARTTLS
|
||||
auth: { user: process.env.USER_GMAIL, pass: process.env.PASS_GMAIL },
|
||||
pool: true, // <‑‑ activa reuse
|
||||
maxConnections: 1, // una sola conexión viva
|
||||
maxMessages: 100, // reabrir después de 100 envíos
|
||||
rateDelta: 2000, // ventana 1 s
|
||||
rateLimit: 1 // máx. 5 mensajes/seg
|
||||
});
|
||||
|
||||
const gmail = (subject, to, text) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
send({ subject, to, text }, (error, result, fullResult) => {
|
||||
if (error) reject(error);
|
||||
resolve(result);
|
||||
});
|
||||
const gmail = (subject, to, text) =>
|
||||
transporter.sendMail({
|
||||
from: process.env.USER_GMAIL,
|
||||
to,
|
||||
subject,
|
||||
text,
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = gmail;
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
+127
-9
@@ -171,18 +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) => {
|
||||
if (
|
||||
|
||||
// se tiene que validar buscando en la tabla de cuestionarios
|
||||
|
||||
//res.idCuestionarioPrograma &&
|
||||
//res.idCuestionarioAlumno &&
|
||||
console.log("validando pre termino", res);
|
||||
|
||||
|
||||
if (
|
||||
(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) =>
|
||||
@@ -194,7 +204,9 @@ const validarPreTermino = (idServicio) => {
|
||||
|
||||
|
||||
|
||||
const validarCuestionarioAlumno2 = (body) => {
|
||||
|
||||
|
||||
const validarCuestionarioAlumno2old = (body) => {
|
||||
console.log("Validando cuestionario alumno 2");
|
||||
|
||||
// Excluir p2 de la validación de campos nulos
|
||||
@@ -213,11 +225,64 @@ const validarCuestionarioAlumno2 = (body) => {
|
||||
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 validarCuestionarioPrograma2 = (body) => {
|
||||
|
||||
const validarCuestionarioPrograma2old = (body) => {
|
||||
console.log("Validando cuestionario programa 2");
|
||||
|
||||
// Excluir p2 de la validación de campos nulos
|
||||
@@ -237,6 +302,59 @@ const validarCuestionarioPrograma2 = (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,
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,57 +1,32 @@
|
||||
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 controllerPath2 = '../controller/CuestionarioAlumno2';
|
||||
const get = require(`${controllerPath2}/get`);
|
||||
const nuevo = require(`${controllerPath2}/nuevo`);
|
||||
|
||||
/* // POST
|
||||
app.post(`${route}`, verificaToken, (req, res) => {
|
||||
return nuevo(req.body)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
// GET
|
||||
app.get(`${route}`, verificaToken, (req, res) => {
|
||||
return get(req.query)
|
||||
.then((data) => {
|
||||
res.download(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
}); */
|
||||
|
||||
|
||||
|
||||
const get = require(`${controllerPath}/get`);
|
||||
const nuevo = require(`${controllerPath}/nuevo`);
|
||||
|
||||
// POST
|
||||
app.post(`${route}/v2`, (req, res) => {
|
||||
console.log(`${route}/v2`);
|
||||
|
||||
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);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
// GET
|
||||
app.get(`${route}/v2`, (req, res) => {
|
||||
console.log(`${route}/v2`);
|
||||
app.get(`${route}`,
|
||||
// verificaToken,
|
||||
|
||||
(req, res) => {
|
||||
return get(req.query)
|
||||
.then((data) => {
|
||||
res.download(data);
|
||||
@@ -61,8 +36,4 @@ app.get(`${route}/v2`, (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = app;
|
||||
|
||||
@@ -2,12 +2,15 @@ const express = require('express');
|
||||
const app = express();
|
||||
const { verificaToken } = require('../middleware/autentificacion');
|
||||
const route = '/cuestionario_programa';
|
||||
const controllerPath = '../controller/CuestionarioPrograma2';
|
||||
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,36 +21,9 @@ app.post(`${route}`, verificaToken, (req, res) => {
|
||||
});
|
||||
|
||||
// GET
|
||||
app.get(`${route}`, verificaToken, (req, res) => {
|
||||
return get(req.query)
|
||||
.then((data) => {
|
||||
res.download(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
app.post(`${route}/v2`, (req, res) => {
|
||||
console.log(`${route}/v2`);
|
||||
|
||||
return nuevo(req.body)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
// GET
|
||||
app.get(`${route}/v2`, (req, res) => {
|
||||
console.log(`${route}/v2`);
|
||||
|
||||
app.get(`${route}`,
|
||||
verificaToken,
|
||||
(req, res) => {
|
||||
return get(req.query)
|
||||
.then((data) => {
|
||||
res.download(data);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -5,6 +5,7 @@ const route = '/usuario';
|
||||
const controllerPath = '../controller/Usuario';
|
||||
const escolares = require(`${controllerPath}/escolares`);
|
||||
const login = require(`${controllerPath}/login`);
|
||||
const newAdmin = require(`${controllerPath}/newUser`);
|
||||
const newPasswordAlumno = require(`${controllerPath}/newPasswordAlumno`);
|
||||
const newPasswordResponsable = require(`${controllerPath}/newPasswordResponsable`);
|
||||
const responsable = require(`${controllerPath}/responsable`);
|
||||
@@ -22,6 +23,17 @@ app.post(`${route}/login`, (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
// POST
|
||||
app.post(`${route}/newAdmin`, (req, res) => {
|
||||
return newAdmin(req.body)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
// GET
|
||||
app.get(`${route}/escolares`, verificaToken, (req, res) => {
|
||||
return escolares(req.query)
|
||||
|
||||
@@ -4,7 +4,6 @@ const app = express();
|
||||
app.use(require('./CasoEspecial'));
|
||||
app.use(require('./CuestionarioAlumno'));
|
||||
app.use(require('./CuestionarioPrograma'));
|
||||
|
||||
app.use(require('./Programa'));
|
||||
app.use(require('./Servicio'));
|
||||
app.use(require('./Status'));
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
PORT=3000
|
||||
DB = servicio_test
|
||||
USERDB = root
|
||||
PASSWORDDB = mypass
|
||||
HOSTDB = host.docker.internal
|
||||
TYPEDB = mariadb
|
||||
|
||||
ESCOLARES = 127.0.0.1
|
||||
ESCOLARES_PASS = mypass
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
@@ -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();
|
||||
@@ -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();
|
||||
+97
-118
@@ -19,6 +19,11 @@
|
||||
-- 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 */;
|
||||
@@ -36,6 +41,7 @@ CREATE 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;
|
||||
|
||||
@@ -139,6 +145,8 @@ CREATE TABLE `cuestionario_alumno` (
|
||||
|
||||
LOCK TABLES `cuestionario_alumno` WRITE;
|
||||
/*!40000 ALTER TABLE `cuestionario_alumno` DISABLE KEYS */;
|
||||
|
||||
|
||||
/*!40000 ALTER TABLE `cuestionario_alumno` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
@@ -285,6 +293,7 @@ CREATE 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;
|
||||
|
||||
@@ -309,6 +318,7 @@ CREATE 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;
|
||||
|
||||
@@ -340,6 +350,10 @@ CREATE 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;
|
||||
|
||||
@@ -361,134 +375,99 @@ UNLOCK TABLES;
|
||||
|
||||
|
||||
|
||||
/* CREATE TABLE `servicio` (
|
||||
`idServicio` INT PRIMARY KEY
|
||||
); */
|
||||
|
||||
DROP TABLE IF EXISTS `Cuestionario`;
|
||||
CREATE TABLE `Cuestionario` (
|
||||
`idCuestionario` INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
|
||||
`idCuestionarioAlumno` INT, -- Agregado para relación con alumnos
|
||||
`idCuestionarioPrograma` INT, -- Agregado para relación con programas
|
||||
|
||||
`idCuestionarioAlumno1` INT, -- Agregado para relación con alumnos
|
||||
`idCuestionarioPrograma1` INT, -- Agregado para relación con programas
|
||||
|
||||
`idServicio` INT,
|
||||
`version` VARCHAR(50),
|
||||
`titulo` VARCHAR(50),
|
||||
`desc` VARCHAR(50),
|
||||
`dirigidoA` VARCHAR(50),
|
||||
`createdAt` DATETIME
|
||||
);
|
||||
|
||||
|
||||
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(50),
|
||||
`p12_A_2` VARCHAR(50),
|
||||
`p12_A_3` VARCHAR(50),
|
||||
`p12_A_4` VARCHAR(50),
|
||||
`p12_B_1` VARCHAR(50),
|
||||
`p12_B_2` VARCHAR(50),
|
||||
`p12_B_3` VARCHAR(50),
|
||||
`p12_B_4` VARCHAR(50),
|
||||
`p12_C_1` VARCHAR(50),
|
||||
`p12_C_2` VARCHAR(50),
|
||||
`p12_C_3` VARCHAR(50),
|
||||
`p12_C_4` VARCHAR(50),
|
||||
`p10_1` VARCHAR(50),
|
||||
`p10_2` VARCHAR(50),
|
||||
`p10_3` VARCHAR(50),
|
||||
`p11_1` VARCHAR(50),
|
||||
`p11_2` VARCHAR(50),
|
||||
`p11_3` VARCHAR(50),
|
||||
`p11_4` VARCHAR(50),
|
||||
`p17_1` VARCHAR(50),
|
||||
`p17_2` VARCHAR(50),
|
||||
`p17_3` VARCHAR(50),
|
||||
`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` VARCHAR(150),
|
||||
`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)
|
||||
);
|
||||
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)
|
||||
);
|
||||
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)
|
||||
);
|
||||
|
||||
|
||||
-- Relaciones corregidas
|
||||
ALTER TABLE `Cuestionario`
|
||||
ADD FOREIGN KEY (`idServicio`) REFERENCES `servicio` (`idServicio`);
|
||||
|
||||
ALTER TABLE `Cuestionario`
|
||||
ADD FOREIGN KEY (`idCuestionarioAlumno`) REFERENCES `cuestionario_alumno_2` (`idCuestionarioAlumno2`);
|
||||
|
||||
ALTER TABLE `Cuestionario`
|
||||
ADD FOREIGN KEY (`idCuestionarioPrograma`) REFERENCES `cuestionario_programa_2` (`idCuestionarioPrograma2`);
|
||||
|
||||
|
||||
|
||||
|
||||
ALTER TABLE `Cuestionario`
|
||||
ADD FOREIGN KEY (`idCuestionarioAlumno1`) REFERENCES `cuestionario_alumno` (`idCuestionarioAlumno`);
|
||||
|
||||
ALTER TABLE `Cuestionario`
|
||||
ADD FOREIGN KEY (`idCuestionarioPrograma1`) REFERENCES `cuestionario_programa` (`idCuestionarioPrograma`);
|
||||
|
||||
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`);
|
||||
|
||||
|
||||
|
||||
+47
-79
@@ -1,53 +1,32 @@
|
||||
/* CREATE TABLE `servicio` (
|
||||
`idServicio` INT PRIMARY KEY
|
||||
); */
|
||||
--DROP TABLE IF EXISTS `Cuestionario`;
|
||||
|
||||
CREATE TABLE
|
||||
`Cuestionario` (
|
||||
`idCuestionario` INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
`idServicio` INT,
|
||||
`version` VARCHAR(50),
|
||||
`titulo` VARCHAR(50),
|
||||
`desc` VARCHAR(50),
|
||||
`dirigidoA` VARCHAR(50),
|
||||
`createdAt` DATETIME
|
||||
);
|
||||
|
||||
--`idCuestionarioAlumno` INT, -- Agregado para relación con alumnos
|
||||
--`idCuestionarioPrograma` INT, -- Agregado para relación con programas
|
||||
-- `idCuestionarioAlumno1` INT, -- Agregado para relación con alumnos
|
||||
-- `idCuestionarioPrograma1` INT, -- Agregado para relación con programas
|
||||
|
||||
DROP TABLE IF EXISTS `cuestionario_alumno_2`;
|
||||
|
||||
CREATE TABLE
|
||||
`cuestionario_alumno_2` (
|
||||
`idCuestionarioAlumno2` INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
`idCuestionario` INT,
|
||||
`createdAt` DATETIME,
|
||||
`p12_A_1` VARCHAR(50),
|
||||
`p12_A_2` VARCHAR(50),
|
||||
`p12_A_3` VARCHAR(50),
|
||||
`p12_A_4` VARCHAR(50),
|
||||
`p12_B_1` VARCHAR(50),
|
||||
`p12_B_2` VARCHAR(50),
|
||||
`p12_B_3` VARCHAR(50),
|
||||
`p12_B_4` VARCHAR(50),
|
||||
`p12_C_1` VARCHAR(50),
|
||||
`p12_C_2` VARCHAR(50),
|
||||
`p12_C_3` VARCHAR(50),
|
||||
`p12_C_4` VARCHAR(50),
|
||||
`p10_1` VARCHAR(50),
|
||||
`p10_2` VARCHAR(50),
|
||||
`p10_3` VARCHAR(50),
|
||||
`p11_1` VARCHAR(50),
|
||||
`p11_2` VARCHAR(50),
|
||||
`p11_3` VARCHAR(50),
|
||||
`p11_4` VARCHAR(50),
|
||||
`p17_1` VARCHAR(50),
|
||||
`p17_2` VARCHAR(50),
|
||||
`p17_3` VARCHAR(50),
|
||||
`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),
|
||||
@@ -57,19 +36,19 @@ CREATE TABLE
|
||||
`p12_D_3` VARCHAR(50),
|
||||
`p12_D_4` VARCHAR(50),
|
||||
`p12_D_5` VARCHAR(50),
|
||||
`p1` VARCHAR(150),
|
||||
`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)
|
||||
`p1` TEXT,
|
||||
`p2` VARCHAR(200),
|
||||
`p4` VARCHAR(200),
|
||||
`p5` VARCHAR(200),
|
||||
`p6` VARCHAR(200),
|
||||
`p7` VARCHAR(200),
|
||||
`p8` VARCHAR(200),
|
||||
`p9` VARCHAR(200),
|
||||
`p13` VARCHAR(200),
|
||||
`p14` VARCHAR(200),
|
||||
`p15` VARCHAR(200),
|
||||
`p16` VARCHAR(200),
|
||||
`p18` VARCHAR(200)
|
||||
);
|
||||
|
||||
DROP TABLE IF EXISTS `cuestionario_programa_2`;
|
||||
@@ -77,7 +56,6 @@ DROP TABLE IF EXISTS `cuestionario_programa_2`;
|
||||
CREATE TABLE
|
||||
`cuestionario_programa_2` (
|
||||
`idCuestionarioPrograma2` INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
`idCuestionario` INT,
|
||||
`createdAt` DATETIME,
|
||||
`p3_A_1` VARCHAR(50),
|
||||
`p3_A_2` VARCHAR(50),
|
||||
@@ -98,30 +76,20 @@ CREATE TABLE
|
||||
`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)
|
||||
`p1` VARCHAR(200),
|
||||
`p2` VARCHAR(200),
|
||||
`p4` VARCHAR(200),
|
||||
`p5` VARCHAR(200),
|
||||
`p6` VARCHAR(200),
|
||||
`p7` VARCHAR(200)
|
||||
);
|
||||
|
||||
-- Relaciones corregidas
|
||||
ALTER TABLE `Cuestionario` ADD FOREIGN KEY (`idServicio`) REFERENCES `servicio` (`idServicio`);
|
||||
|
||||
ALTER TABLE cuestionario_alumno ADD COLUMN idCuestionario INT;
|
||||
ALTER TABLE cuestionario_programa ADD COLUMN idCuestionario INT;
|
||||
|
||||
ALTER TABLE `cuestionario_alumno` ADD FOREIGN KEY (`idCuestionario`) REFERENCES `Cuestionario` (`idCuestionario`);
|
||||
ALTER TABLE `cuestionario_alumno_2` ADD FOREIGN KEY (`idCuestionario`) REFERENCES `Cuestionario` (`idCuestionario`);
|
||||
ALTER TABLE `cuestionario_programa` ADD FOREIGN KEY (`idCuestionario`) REFERENCES `Cuestionario` (`idCuestionario`);
|
||||
ALTER TABLE `cuestionario_programa_2` ADD FOREIGN KEY (`idCuestionario`) REFERENCES `Cuestionario` (`idCuestionario`);
|
||||
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`);
|
||||
|
||||
|
||||
--ALTER TABLE `Cuestionario`
|
||||
--ADD FOREIGN KEY (`idCuestionarioAlumno`) REFERENCES `cuestionario_alumno_2` (`idCuestionarioAlumno2`);
|
||||
--ALTER TABLE `Cuestionario`
|
||||
--ADD FOREIGN KEY (`idCuestionarioPrograma`) REFERENCES `cuestionario_programa_2` (`idCuestionarioPrograma2`);
|
||||
--ALTER TABLE `Cuestionario`
|
||||
--ADD FOREIGN KEY (`idCuestionarioAlumno1`) REFERENCES `cuestionario_alumno` (`idCuestionarioAlumno`);
|
||||
--ALTER TABLE `Cuestionario`
|
||||
--ADD FOREIGN KEY (`idCuestionarioPrograma1`) REFERENCES `cuestionario_programa` (`idCuestionarioPrograma`);
|
||||
|
||||
Reference in New Issue
Block a user