Spaces:
Running
Replace the hardcoded datasets with data from planesOracle - COMG.csv. Build these constants:
Browse filesprogramasData: [{ id, nombre }]
id = slug of <SWVPLAN_NIVEL>-<SWVPLAN_CARRERA>
nombre = SWVPLAN_CARRERA
planesData: { [progId]: [{ id, nombre }] }
id = slug of <SWVPLAN_CARRERA><SWVPLAN_TIPO_PLAN>
nombre = <SWVPLAN_CARRERA><SWVPLAN_TIPO_PLAN>
materiasData: { [progId]: { [planId]: [ { clave, nombre, creditos, prerrequisitos[], anual, escritura, semestreSugerido, departamento, curso, programas:[progId], prioridad_base:5 } ] } }
clave = SUBJ_CON_CRSE (combined subject+course, e.g., COM-12345)
nombre = NOMBRE
creditos = SWVPLAN_CREDITOS
prerrequisitos[] = from PREREQUISITOS (split by , ; |)
anual = ANUAL
escritura = ESCRITURA
semestreSugerido = SWVPLAN_SEMESTRE
departamento = SWVPLAN_SUBJ
curso = NOMBRE
programas = [progId]
Keep the existing UI and element IDs unchanged.
|
@@ -1,71 +1,101 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
};
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
{
|
| 26 |
-
clave: 'ECO-10101',
|
| 27 |
-
nombre: 'Microeconomía I',
|
| 28 |
-
prerrequisitos: [],
|
| 29 |
-
escritura: '',
|
| 30 |
-
anual: '',
|
| 31 |
-
creditos: 6,
|
| 32 |
-
semestreSugerido: 1,
|
| 33 |
-
departamento: 'ECO',
|
| 34 |
-
curso: '10101',
|
| 35 |
-
programas: ['lic_eco']
|
| 36 |
-
},
|
| 37 |
-
{
|
| 38 |
-
clave: 'ECO-10201',
|
| 39 |
-
nombre: 'Macroeconomía I',
|
| 40 |
-
prerrequisitos: ['ECO-10101'],
|
| 41 |
-
escritura: 'ECO-10202',
|
| 42 |
-
anual: 'Primavera',
|
| 43 |
-
creditos: 6,
|
| 44 |
-
semestreSugerido: 2,
|
| 45 |
-
departamento: 'ECO',
|
| 46 |
-
curso: '10201',
|
| 47 |
-
programas: ['lic_eco']
|
| 48 |
-
},
|
| 49 |
-
{
|
| 50 |
-
clave: 'ECO-20101',
|
| 51 |
-
nombre: 'Econometría I',
|
| 52 |
-
prerrequisitos: ['ECO-10101', 'ECO-10201'],
|
| 53 |
-
escritura: '',
|
| 54 |
-
anual: '',
|
| 55 |
-
creditos: 8,
|
| 56 |
-
semestreSugerido: 3,
|
| 57 |
-
departamento: 'ECO',
|
| 58 |
-
curso: '20101',
|
| 59 |
-
programas: ['lic_eco']
|
| 60 |
}
|
| 61 |
-
|
| 62 |
-
plan2022: [
|
| 63 |
-
{ clave: 'ECO111', nombre: 'Microeconomía Básica', prerrequisitos: [], prioridad_base: 5, intercambio: false, anual: "N", creditos: 6, programas: ['lic_eco'] }
|
| 64 |
-
]
|
| 65 |
-
},
|
| 66 |
-
// Más datos...
|
| 67 |
-
};
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
// Variables globales
|
| 70 |
let selectedProgram = null;
|
| 71 |
let selectedPlan = null;
|
|
@@ -73,6 +103,8 @@ let materias = [];
|
|
| 73 |
let semestres = [];
|
| 74 |
let materiasCursadas = [];
|
| 75 |
|
|
|
|
|
|
|
| 76 |
// DOM Elements
|
| 77 |
const programaSelect = document.getElementById('programa');
|
| 78 |
const planSelect = document.getElementById('plan');
|
|
@@ -86,11 +118,13 @@ const maxMateriasInput = document.getElementById('maxMaterias');
|
|
| 86 |
const maxCreditosInput = document.getElementById('maxCreditos');
|
| 87 |
const maxMateriasValue = document.getElementById('maxMateriasValue');
|
| 88 |
const maxCreditosValue = document.getElementById('maxCreditosValue');
|
| 89 |
-
|
| 90 |
// Event Listeners
|
| 91 |
document.addEventListener('DOMContentLoaded', () => {
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
| 94 |
});
|
| 95 |
function setupEventListeners() {
|
| 96 |
// Botón volver al inicio
|
|
|
|
| 1 |
+
|
| 2 |
+
// Variables para almacenar los datos procesados
|
| 3 |
+
let programasData = [];
|
| 4 |
+
let planesData = {};
|
| 5 |
+
let materiasData = {};
|
| 6 |
+
|
| 7 |
+
// Función para procesar el CSV
|
| 8 |
+
async function cargarDatos() {
|
| 9 |
+
try {
|
| 10 |
+
const response = await fetch('planesOracle-COMG.csv');
|
| 11 |
+
const csvData = await response.text();
|
| 12 |
+
const lines = csvData.split('\n');
|
| 13 |
+
const headers = lines[0].split(',').map(h => h.trim());
|
| 14 |
+
|
| 15 |
+
// Procesar cada línea del CSV
|
| 16 |
+
const rawData = [];
|
| 17 |
+
for (let i = 1; i < lines.length; i++) {
|
| 18 |
+
const values = lines[i].split(',');
|
| 19 |
+
if (values.length === headers.length) {
|
| 20 |
+
const entry = {};
|
| 21 |
+
headers.forEach((header, index) => {
|
| 22 |
+
entry[header] = values[index] ? values[index].trim() : '';
|
| 23 |
+
});
|
| 24 |
+
rawData.push(entry);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
// Generar programasData
|
| 29 |
+
const programasUnicos = {};
|
| 30 |
+
rawData.forEach(row => {
|
| 31 |
+
const id = `${row.SWVPLAN_NIVEL}-${row.SWVPLAN_CARRERA}`.toLowerCase().replace(/\s+/g, '_');
|
| 32 |
+
programasUnicos[id] = {
|
| 33 |
+
id,
|
| 34 |
+
nombre: row.SWVPLAN_CARRERA
|
| 35 |
+
};
|
| 36 |
+
});
|
| 37 |
+
programasData = Object.values(programasUnicos);
|
| 38 |
+
|
| 39 |
+
// Generar planesData y materiasData
|
| 40 |
+
rawData.forEach(row => {
|
| 41 |
+
const progId = `${row.SWVPLAN_NIVEL}-${row.SWVPLAN_CARRERA}`.toLowerCase().replace(/\s+/g, '_');
|
| 42 |
+
const planId = `${row.SWVPLAN_CARRERA}${row.SWVPLAN_TIPO_PLAN}`.toLowerCase().replace(/\s+/g, '_');
|
| 43 |
+
|
| 44 |
+
// Agregar a planesData
|
| 45 |
+
if (!planesData[progId]) {
|
| 46 |
+
planesData[progId] = [];
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
if (!planesData[progId].some(p => p.id === planId)) {
|
| 50 |
+
planesData[progId].push({
|
| 51 |
+
id: planId,
|
| 52 |
+
nombre: `${row.SWVPLAN_CARRERA} ${row.SWVPLAN_TIPO_PLAN}`
|
| 53 |
+
});
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
// Agregar a materiasData
|
| 57 |
+
if (!materiasData[progId]) {
|
| 58 |
+
materiasData[progId] = {};
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
if (!materiasData[progId][planId]) {
|
| 62 |
+
materiasData[progId][planId] = [];
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
// Procesar prerrequisitos
|
| 66 |
+
let prerrequisitos = [];
|
| 67 |
+
if (row.PREREQUISITOS) {
|
| 68 |
+
prerrequisitos = row.PREREQUISITOS.split(/[,;|]/)
|
| 69 |
+
.map(p => p.trim())
|
| 70 |
+
.filter(p => p.length > 0);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
// Crear objeto materia
|
| 74 |
+
const materia = {
|
| 75 |
+
clave: `${row.SWVPLAN_SUBJ}-${row.SWVPLAN_CRSE}`,
|
| 76 |
+
nombre: row.NOMBRE,
|
| 77 |
+
creditos: parseInt(row.SWVPLAN_CREDITOS) || 0,
|
| 78 |
+
prerrequisitos,
|
| 79 |
+
anual: row.ANUAL || '',
|
| 80 |
+
escritura: row.ESCRITURA || '',
|
| 81 |
+
semestreSugerido: parseInt(row.SWVPLAN_SEMESTRE) || 1,
|
| 82 |
+
departamento: row.SWVPLAN_SUBJ,
|
| 83 |
+
curso: row.SWVPLAN_CRSE,
|
| 84 |
+
programas: [progId],
|
| 85 |
+
prioridad_base: 5
|
| 86 |
+
};
|
| 87 |
+
|
| 88 |
+
// Verificar si la materia ya existe para evitar duplicados
|
| 89 |
+
if (!materiasData[progId][planId].some(m => m.clave === materia.clave)) {
|
| 90 |
+
materiasData[progId][planId].push(materia);
|
| 91 |
+
}
|
| 92 |
+
});
|
| 93 |
+
|
| 94 |
+
console.log('Datos cargados:', { programasData, planesData, materiasData });
|
| 95 |
+
} catch (error) {
|
| 96 |
+
console.error('Error al cargar datos:', error);
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
// Variables globales
|
| 100 |
let selectedProgram = null;
|
| 101 |
let selectedPlan = null;
|
|
|
|
| 103 |
let semestres = [];
|
| 104 |
let materiasCursadas = [];
|
| 105 |
|
| 106 |
+
// Cargar datos al iniciar
|
| 107 |
+
cargarDatos();
|
| 108 |
// DOM Elements
|
| 109 |
const programaSelect = document.getElementById('programa');
|
| 110 |
const planSelect = document.getElementById('plan');
|
|
|
|
| 118 |
const maxCreditosInput = document.getElementById('maxCreditos');
|
| 119 |
const maxMateriasValue = document.getElementById('maxMateriasValue');
|
| 120 |
const maxCreditosValue = document.getElementById('maxCreditosValue');
|
|
|
|
| 121 |
// Event Listeners
|
| 122 |
document.addEventListener('DOMContentLoaded', () => {
|
| 123 |
+
// Esperar un momento para asegurar que los datos se carguen
|
| 124 |
+
setTimeout(() => {
|
| 125 |
+
cargarProgramas();
|
| 126 |
+
setupEventListeners();
|
| 127 |
+
}, 500);
|
| 128 |
});
|
| 129 |
function setupEventListeners() {
|
| 130 |
// Botón volver al inicio
|