feat(academic): allow subjects to be associated with multiple careers (v3.8.21)
This commit is contained in:
@@ -11,6 +11,15 @@ El formato está basado en [Keep a Changelog](https://keepachangelog.com/es-ES/1
|
|||||||
- **Sincronización Continua Moodle (Fase 6):** Automatización de workers persistentes en background para el procesamiento continuo de la cola de Web Services Moodle 4.1.
|
- **Sincronización Continua Moodle (Fase 6):** Automatización de workers persistentes en background para el procesamiento continuo de la cola de Web Services Moodle 4.1.
|
||||||
- **Pruebas de Carga y Hardening (Fase 6):** Pruebas de estrés de concurrencia y validación final de producción.
|
- **Pruebas de Carga y Hardening (Fase 6):** Pruebas de estrés de concurrencia y validación final de producción.
|
||||||
|
|
||||||
|
## [3.8.21] - 2026-10-26
|
||||||
|
### Added & Improved
|
||||||
|
- **Gestión de Asignaturas: Asociación a Múltiples Carreras (`admin/subjects_list`)**:
|
||||||
|
- Reemplazado el selector simple de carrera por un componente de selección múltiple interactivo y responsivo tanto en la creación (`modalAddSubject`) como en la edición (`modalEditSubject`).
|
||||||
|
- Incorporado buscador rápido de carreras, botones de acción masiva ("Todas" / "Ninguna"), badges de código y contador dinámico de carreras seleccionadas.
|
||||||
|
- Sincronización completa en Frontend BFF (`handleSubjectAdd`, `handleSubjectEdit`) enviando arrays de `career_ids` y preservando `career_id` principal por compatibilidad relacional.
|
||||||
|
- Sincronización robusta en Backend FastAPI (`POST /subjects` y `PUT /subjects/{id}`), actualizando la relación Many-to-Many `Subject.careers` (tabla `subject_careers`).
|
||||||
|
- Suite de pruebas ampliada con `test_subject_multiple_careers_create_and_update` (80 tests 100% pasando).
|
||||||
|
|
||||||
## [3.8.20] - 2026-10-26
|
## [3.8.20] - 2026-10-26
|
||||||
### Fixed & Improved
|
### Fixed & Improved
|
||||||
- **Gestión de Comisiones: Visualización de Asignatura y Carreras Heredadas**:
|
- **Gestión de Comisiones: Visualización de Asignatura y Carreras Heredadas**:
|
||||||
|
|||||||
@@ -9,17 +9,18 @@ Memoria del proyecto entre sesiones para la rama `dev`.
|
|||||||
- Libro de Calificaciones (*Gradebook*) con actas de regularidad inmutables.
|
- Libro de Calificaciones (*Gradebook*) con actas de regularidad inmutables.
|
||||||
- Autenticación híbrida (Google OAuth 2.0, Moodle SSO, Local) y Modo Impersonación.
|
- Autenticación híbrida (Google OAuth 2.0, Moodle SSO, Local) y Modo Impersonación.
|
||||||
- Reinicialización segura del sistema con contraseña de Administrador.
|
- Reinicialización segura del sistema con contraseña de Administrador.
|
||||||
- **Sprint Activo: Corrección de Comisiones (Asignatura y Carreras Heredadas), Scoping de Roles y Libro de Calificaciones — v3.8.20**:
|
- **Sprint Activo: Asociación de Asignaturas a Múltiples Carreras y Enriquecimiento Académico — v3.8.21**:
|
||||||
- **Asignatura y Carreras en Comisiones**: Corregido el mapeo en `admin/commissions_list` para que la columna "Asignatura" muestre destacadamente el nombre de la materia/asignatura real (`comm.subject.name or comm.subject_name`), junto con su código y las carreras que hereda la comisión.
|
- **Asociación Multicarrera de Asignaturas (`admin/subjects_list`)**:
|
||||||
- **Selector de Asignaturas en Modales de Alta y Edición**: `modalAddCommission` y `modalEditCommission` ahora cargan la lista de materias activas con sus planes y carreras asociadas, junto con un banner interactivo que previsualiza las carreras heredadas y enlace directo al catálogo de materias.
|
- Reemplazado el selector simple de carrera por un componente interactivo de selección múltiple con buscador en tiempo real, botones masivos "Todas"/"Ninguna", badges de código y contador dinámico ("X seleccionadas").
|
||||||
- **Enriquecimiento de Backend**: `Commission.to_dict()` expone `subject_name` y `subject_code`, y `GET /commissions` devuelve `subjects`, `careers` y `academic_terms` para evitar llamadas redundantes y asegurar dropdowns siempre poblados.
|
- Sincronización en modales `modalAddSubject` y `modalEditSubject` vía JavaScript nativo pre-poblando checkboxes a partir de `data-career-ids`.
|
||||||
- **Scoping por Roles (Docente / Alumno / Bedelía)**:
|
- Adaptado el Frontend BFF (`admin.js`) para capturar arrays o valores únicos de `career_ids` y despacharlos al backend.
|
||||||
- Docentes: Filtrado estricto en materias (`my_subjects`), reservas (`/schedule/list_reservations`) y aulas virtuales (`/classrooms/list_classrooms?view_mode=virtual`) para ver únicamente lo asignado a su usuario.
|
- Sincronización robusta en Backend FastAPI (`POST /subjects` y `PUT /subjects/{id}`), actualizando `subject.careers` (Many-to-Many `subject_careers`) y manteniendo `career_id` principal como fallback relacional.
|
||||||
- Libro de Calificaciones: Habilitada la programación de evaluaciones (Parciales, TPs, Finales) mediante modal `#addMilestoneModal`, eliminación de hitos si el acta no está sellada, autocalculado de notas en vivo y guardado debounced.
|
- **Comisiones, Roles y Calificaciones (Consolidado de v3.8.20)**:
|
||||||
- Alumnos: Visualización de materias inscritas y notas en `my_grades.html`.
|
- Nombre de materia y badges de carreras heredadas en `admin/commissions_list`.
|
||||||
- Eliminados fallbacks con datos mock/relleno en toda la plataforma.
|
- Scoping estricto para Docentes y Alumnos (cero fallbacks mock).
|
||||||
- **QA & Seguridad**: 79 tests aprobados en `pytest` (100%), 0 vulnerabilidades en auditoría de seguridad (Bandit, pip-audit, njsscan, npm audit).
|
- Gestión de hitos y actas en Gradebook.
|
||||||
- **Versión Consolidada**: `v3.8.20`.
|
- **QA & Seguridad**: 80 tests aprobados en `pytest` (100%), 0 vulnerabilidades en auditoría de seguridad (Bandit, pip-audit, njsscan, npm audit).
|
||||||
|
- **Versión Consolidada**: `v3.8.21`.
|
||||||
|
|
||||||
## Decisiones (y por qué)
|
## Decisiones (y por qué)
|
||||||
- **Flujo Secuencial de Bedelía (9 Pasos)**: Estandarizar la carga operativa en: 1) Sede -> 2) Aula -> 3) Ciclo Lectivo -> 4) Carrera -> 5) Materia (vinculada a Carrera) -> 6) Comisión (asociada a Materia, Carrera y Ciclo) -> 7) Profesores -> 8) Alumnos -> 9) Reserva de Espacio. Esto asegura consistencia e integridad relacional.
|
- **Flujo Secuencial de Bedelía (9 Pasos)**: Estandarizar la carga operativa en: 1) Sede -> 2) Aula -> 3) Ciclo Lectivo -> 4) Carrera -> 5) Materia (vinculada a Carrera) -> 6) Comisión (asociada a Materia, Carrera y Ciclo) -> 7) Profesores -> 8) Alumnos -> 9) Reserva de Espacio. Esto asegura consistencia e integridad relacional.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from typing import Any
|
|||||||
from database import db, get_db, engine, SessionLocal, session
|
from database import db, get_db, engine, SessionLocal, session
|
||||||
from config.config import Config
|
from config.config import Config
|
||||||
|
|
||||||
__version__ = "3.8.20"
|
__version__ = "3.8.21"
|
||||||
|
|
||||||
class DummyContext:
|
class DummyContext:
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
|
|||||||
@@ -311,10 +311,6 @@ async def update_subject(
|
|||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if 'career_id' in data:
|
|
||||||
c_id = data['career_id']
|
|
||||||
subject.career_id = int(c_id) if c_id else None
|
|
||||||
|
|
||||||
if 'career_ids' in data:
|
if 'career_ids' in data:
|
||||||
career_ids = data.get('career_ids')
|
career_ids = data.get('career_ids')
|
||||||
if isinstance(career_ids, str):
|
if isinstance(career_ids, str):
|
||||||
@@ -326,14 +322,20 @@ async def update_subject(
|
|||||||
if c_id_list:
|
if c_id_list:
|
||||||
c_objs = Career.query.filter(Career.id.in_(c_id_list)).all()
|
c_objs = Career.query.filter(Career.id.in_(c_id_list)).all()
|
||||||
subject.careers = c_objs
|
subject.careers = c_objs
|
||||||
if c_objs and not subject.career_id:
|
if not subject.career_id or subject.career_id not in c_id_list:
|
||||||
subject.career_id = c_objs[0].id
|
subject.career_id = c_objs[0].id if c_objs else None
|
||||||
else:
|
else:
|
||||||
subject.careers = []
|
subject.careers = []
|
||||||
elif 'career_id' in data and subject.career_id:
|
subject.career_id = None
|
||||||
|
elif 'career_id' in data:
|
||||||
|
c_id = data['career_id']
|
||||||
|
subject.career_id = int(c_id) if c_id else None
|
||||||
|
if subject.career_id:
|
||||||
c_obj = Career.query.get(subject.career_id)
|
c_obj = Career.query.get(subject.career_id)
|
||||||
if c_obj and c_obj not in subject.careers:
|
if c_obj:
|
||||||
subject.careers = [c_obj]
|
subject.careers = [c_obj]
|
||||||
|
else:
|
||||||
|
subject.careers = []
|
||||||
|
|
||||||
if 'description' in data:
|
if 'description' in data:
|
||||||
subject.description = (data['description'] or '').strip()
|
subject.description = (data['description'] or '').strip()
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="edu-space-admin",
|
name="edu-space-admin",
|
||||||
version="3.8.20",
|
version="3.8.21",
|
||||||
description="Administrative interface for Edu-Space Classroom Management System (FastAPI ASGI Core)",
|
description="Administrative interface for Edu-Space Classroom Management System (FastAPI ASGI Core)",
|
||||||
author="Edu-Space Development Team",
|
author="Edu-Space Development Team",
|
||||||
author_email="admin@edu-space.com",
|
author_email="admin@edu-space.com",
|
||||||
|
|||||||
@@ -228,3 +228,59 @@ def test_system_reset_success_preserves_users(client, auth_headers):
|
|||||||
assert len(reset_logs) == 1
|
assert len(reset_logs) == 1
|
||||||
assert reset_logs[0].user_email == 'admin_abm@unicaba.edu.ar'
|
assert reset_logs[0].user_email == 'admin_abm@unicaba.edu.ar'
|
||||||
|
|
||||||
|
|
||||||
|
def test_subject_multiple_careers_create_and_update(client, auth_headers):
|
||||||
|
from app.models.career import Career
|
||||||
|
|
||||||
|
# 1. Crear carreras
|
||||||
|
c1 = Career(name='Licenciatura en Ciencia de Datos', code='DATOS')
|
||||||
|
c2 = Career(name='Tecnicatura en Videojuegos', code='VJ')
|
||||||
|
c3 = Career(name='Tecnicatura en Desarrollo Digital', code='TEC-DIG')
|
||||||
|
db.session.add_all([c1, c2, c3])
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
# 2. Crear una materia con múltiples carreras asociadas (c1 y c2)
|
||||||
|
payload_create = {
|
||||||
|
'code': 'SUBJ-MULTI-1',
|
||||||
|
'name': 'Programación Interactiva Avanzada',
|
||||||
|
'credits': 4,
|
||||||
|
'career_ids': [c1.id, c2.id],
|
||||||
|
'department': 'Tecnología',
|
||||||
|
'description': 'Materia compartida entre Datos y Videojuegos'
|
||||||
|
}
|
||||||
|
res_create = client.post('/api/v1/subjects', headers=auth_headers, json=payload_create)
|
||||||
|
assert res_create.status_code == 201
|
||||||
|
data_create = res_create.get_json()
|
||||||
|
assert data_create['status'] == 'success'
|
||||||
|
subj_data = data_create['subject']
|
||||||
|
assert subj_data['code'] == 'SUBJ-MULTI-1'
|
||||||
|
assert len(subj_data['careers']) == 2
|
||||||
|
career_names = [c['name'] for c in subj_data['careers']]
|
||||||
|
assert 'Licenciatura en Ciencia de Datos' in career_names
|
||||||
|
assert 'Tecnicatura en Videojuegos' in career_names
|
||||||
|
|
||||||
|
subj_id = subj_data['id']
|
||||||
|
|
||||||
|
# 3. Actualizar la materia para asociarla a c2 y c3
|
||||||
|
payload_update = {
|
||||||
|
'career_ids': [c2.id, c3.id],
|
||||||
|
'description': 'Actualizada a Videojuegos y Desarrollo Digital'
|
||||||
|
}
|
||||||
|
res_update = client.put(f'/api/v1/subjects/{subj_id}', headers=auth_headers, json=payload_update)
|
||||||
|
assert res_update.status_code == 200
|
||||||
|
data_update = res_update.get_json()
|
||||||
|
subj_updated = data_update['subject']
|
||||||
|
assert len(subj_updated['careers']) == 2
|
||||||
|
updated_career_names = [c['name'] for c in subj_updated['careers']]
|
||||||
|
assert 'Tecnicatura en Videojuegos' in updated_career_names
|
||||||
|
assert 'Tecnicatura en Desarrollo Digital' in updated_career_names
|
||||||
|
assert 'Licenciatura en Ciencia de Datos' not in updated_career_names
|
||||||
|
|
||||||
|
# 4. Verificar que GET /subjects lista la materia con sus carreras
|
||||||
|
res_get = client.get('/api/v1/subjects', headers=auth_headers)
|
||||||
|
assert res_get.status_code == 200
|
||||||
|
all_subjects = res_get.get_json()['subjects']
|
||||||
|
found = next((s for s in all_subjects if s['id'] == subj_id), None)
|
||||||
|
assert found is not None
|
||||||
|
assert len(found['careers']) == 2
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "frontend",
|
"name": "frontend",
|
||||||
"version": "3.8.20",
|
"version": "3.8.21",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
+3
-3
@@ -86,9 +86,9 @@ const env = nunjucks.configure(path.join(__dirname, '../views'), {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Versiones institucionales del sistema
|
// Versiones institucionales del sistema
|
||||||
const APP_VERSION = '3.8.20';
|
const APP_VERSION = '3.8.21';
|
||||||
const FRONTEND_VERSION = '3.8.20';
|
const FRONTEND_VERSION = '3.8.21';
|
||||||
const BACKEND_VERSION = '3.8.20';
|
const BACKEND_VERSION = '3.8.21';
|
||||||
|
|
||||||
env.addGlobal('app_version', APP_VERSION);
|
env.addGlobal('app_version', APP_VERSION);
|
||||||
env.addGlobal('frontend_version', FRONTEND_VERSION);
|
env.addGlobal('frontend_version', FRONTEND_VERSION);
|
||||||
|
|||||||
@@ -962,14 +962,24 @@ const handleSubjectsList = async (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubjectAdd = async (req, res) => {
|
const handleSubjectAdd = async (req, res) => {
|
||||||
const { code, name, department, credits, career_id, description, is_active } = req.body;
|
const { code, name, department, credits, description, is_active } = req.body;
|
||||||
|
let careerIds = [];
|
||||||
|
if (Array.isArray(req.body.career_ids)) {
|
||||||
|
careerIds = req.body.career_ids.map(id => parseInt(id, 10)).filter(id => !isNaN(id));
|
||||||
|
} else if (req.body.career_ids) {
|
||||||
|
careerIds = [parseInt(req.body.career_ids, 10)].filter(id => !isNaN(id));
|
||||||
|
} else if (req.body.career_id) {
|
||||||
|
careerIds = [parseInt(req.body.career_id, 10)].filter(id => !isNaN(id));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await req.apiClient.post('/subjects', {
|
await req.apiClient.post('/subjects', {
|
||||||
code,
|
code,
|
||||||
name,
|
name,
|
||||||
department,
|
department,
|
||||||
credits: parseInt(credits, 10) || 4,
|
credits: parseInt(credits, 10) || 4,
|
||||||
career_id: career_id ? parseInt(career_id, 10) : null,
|
career_id: careerIds.length > 0 ? careerIds[0] : null,
|
||||||
|
career_ids: careerIds,
|
||||||
description,
|
description,
|
||||||
is_active: is_active === 'on' || is_active === 'true' || is_active === true
|
is_active: is_active === 'on' || is_active === 'true' || is_active === true
|
||||||
});
|
});
|
||||||
@@ -983,14 +993,24 @@ const handleSubjectAdd = async (req, res) => {
|
|||||||
|
|
||||||
const handleSubjectEdit = async (req, res) => {
|
const handleSubjectEdit = async (req, res) => {
|
||||||
const id = req.params.id || req.body.id;
|
const id = req.params.id || req.body.id;
|
||||||
const { code, name, department, credits, career_id, description, is_active } = req.body;
|
const { code, name, department, credits, description, is_active } = req.body;
|
||||||
|
let careerIds = [];
|
||||||
|
if (Array.isArray(req.body.career_ids)) {
|
||||||
|
careerIds = req.body.career_ids.map(cid => parseInt(cid, 10)).filter(cid => !isNaN(cid));
|
||||||
|
} else if (req.body.career_ids) {
|
||||||
|
careerIds = [parseInt(req.body.career_ids, 10)].filter(cid => !isNaN(cid));
|
||||||
|
} else if (req.body.career_id) {
|
||||||
|
careerIds = [parseInt(req.body.career_id, 10)].filter(cid => !isNaN(cid));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await req.apiClient.put(`/subjects/${id}`, {
|
await req.apiClient.put(`/subjects/${id}`, {
|
||||||
code,
|
code,
|
||||||
name,
|
name,
|
||||||
department,
|
department,
|
||||||
credits: parseInt(credits, 10) || 4,
|
credits: parseInt(credits, 10) || 4,
|
||||||
career_id: career_id ? parseInt(career_id, 10) : null,
|
career_id: careerIds.length > 0 ? careerIds[0] : null,
|
||||||
|
career_ids: careerIds,
|
||||||
description,
|
description,
|
||||||
is_active: is_active === 'on' || is_active === 'true' || is_active === true
|
is_active: is_active === 'on' || is_active === 'true' || is_active === true
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -190,6 +190,7 @@
|
|||||||
data-name="{{ s.name }}"
|
data-name="{{ s.name }}"
|
||||||
data-credits="{{ s.credits }}"
|
data-credits="{{ s.credits }}"
|
||||||
data-career-id="{{ s.career_id or '' }}"
|
data-career-id="{{ s.career_id or '' }}"
|
||||||
|
data-career-ids="{% if s.careers %}{% for c in s.careers %}{{ c.id }}{% if not loop.last %},{% endif %}{% endfor %}{% elif s.career_id %}{{ s.career_id }}{% endif %}"
|
||||||
data-department="{{ s.department or '' }}"
|
data-department="{{ s.department or '' }}"
|
||||||
data-description="{{ s.description or '' }}"
|
data-description="{{ s.description or '' }}"
|
||||||
data-active="{{ 'true' if s.is_active else 'false' }}"
|
data-active="{{ 'true' if s.is_active else 'false' }}"
|
||||||
@@ -291,13 +292,33 @@
|
|||||||
<input type="text" name="name" class="form-control form-control-sm" placeholder="ej. Álgebra Lineal" required>
|
<input type="text" name="name" class="form-control form-control-sm" placeholder="ej. Álgebra Lineal" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label small fw-semibold">Carrera Vinculada</label>
|
<div class="d-flex justify-content-between align-items-center mb-1">
|
||||||
<select name="career_id" class="form-select form-select-sm">
|
<label class="form-label small fw-semibold mb-0">
|
||||||
<option value="">Sin carrera específica (General)</option>
|
<i class="bi bi-mortarboard text-primary me-1"></i>Carreras Vinculadas
|
||||||
|
</label>
|
||||||
|
<span class="badge bg-secondary-subtle text-secondary border rounded-pill" id="addSubjectCareerCount">0 seleccionadas</span>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-2 gap-2">
|
||||||
|
<input type="text" class="form-control form-control-sm career-filter-input" placeholder="Filtrar carreras..." data-target="addSubjectCareerList">
|
||||||
|
<div class="btn-group btn-group-sm flex-shrink-0">
|
||||||
|
<button type="button" class="btn btn-outline-secondary select-all-careers" data-target="addSubjectCareerList" title="Seleccionar todas las visibles">Todas</button>
|
||||||
|
<button type="button" class="btn btn-outline-secondary deselect-all-careers" data-target="addSubjectCareerList" title="Deseleccionar todas">Ninguna</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="border rounded p-2 bg-body-tertiary" style="max-height: 170px; overflow-y: auto;" id="addSubjectCareerList">
|
||||||
{% for c in careers %}
|
{% for c in careers %}
|
||||||
<option value="{{ c.id }}">{{ c.name }}</option>
|
<div class="form-check career-item py-1 px-2 mb-1 rounded">
|
||||||
|
<input class="form-check-input career-checkbox" type="checkbox" name="career_ids" value="{{ c.id }}" id="add_career_{{ c.id }}">
|
||||||
|
<label class="form-check-label small d-flex justify-content-between align-items-center w-100 cursor-pointer" for="add_career_{{ c.id }}">
|
||||||
|
<span class="career-label-text fw-medium">{{ c.name }}</span>
|
||||||
|
<span class="badge bg-secondary-subtle text-secondary font-monospace ms-2">{{ c.code or ('ID ' + c.id) }}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<p class="text-muted small mb-0 p-2 text-center">No hay carreras registradas.</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</div>
|
||||||
|
<small class="text-muted d-block mt-1">Podés seleccionar una o más carreras para asociar esta asignatura a múltiples planes de estudio.</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label small fw-semibold">Departamento / Área</label>
|
<label class="form-label small fw-semibold">Departamento / Área</label>
|
||||||
@@ -345,13 +366,33 @@
|
|||||||
<input type="text" name="name" id="editSubjectName" class="form-control form-control-sm" required>
|
<input type="text" name="name" id="editSubjectName" class="form-control form-control-sm" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label small fw-semibold">Carrera Vinculada</label>
|
<div class="d-flex justify-content-between align-items-center mb-1">
|
||||||
<select name="career_id" id="editSubjectCareer" class="form-select form-select-sm">
|
<label class="form-label small fw-semibold mb-0">
|
||||||
<option value="">Sin carrera específica (General)</option>
|
<i class="bi bi-mortarboard text-primary me-1"></i>Carreras Vinculadas
|
||||||
|
</label>
|
||||||
|
<span class="badge bg-secondary-subtle text-secondary border rounded-pill" id="editSubjectCareerCount">0 seleccionadas</span>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-2 gap-2">
|
||||||
|
<input type="text" class="form-control form-control-sm career-filter-input" placeholder="Filtrar carreras..." data-target="editSubjectCareerList">
|
||||||
|
<div class="btn-group btn-group-sm flex-shrink-0">
|
||||||
|
<button type="button" class="btn btn-outline-secondary select-all-careers" data-target="editSubjectCareerList" title="Seleccionar todas las visibles">Todas</button>
|
||||||
|
<button type="button" class="btn btn-outline-secondary deselect-all-careers" data-target="editSubjectCareerList" title="Deseleccionar todas">Ninguna</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="border rounded p-2 bg-body-tertiary" style="max-height: 170px; overflow-y: auto;" id="editSubjectCareerList">
|
||||||
{% for c in careers %}
|
{% for c in careers %}
|
||||||
<option value="{{ c.id }}">{{ c.name }}</option>
|
<div class="form-check career-item py-1 px-2 mb-1 rounded">
|
||||||
|
<input class="form-check-input career-checkbox" type="checkbox" name="career_ids" value="{{ c.id }}" id="edit_career_{{ c.id }}">
|
||||||
|
<label class="form-check-label small d-flex justify-content-between align-items-center w-100 cursor-pointer" for="edit_career_{{ c.id }}">
|
||||||
|
<span class="career-label-text fw-medium">{{ c.name }}</span>
|
||||||
|
<span class="badge bg-secondary-subtle text-secondary font-monospace ms-2">{{ c.code or ('ID ' + c.id) }}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<p class="text-muted small mb-0 p-2 text-center">No hay carreras registradas.</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</div>
|
||||||
|
<small class="text-muted d-block mt-1">Podés seleccionar una o más carreras para asociar esta asignatura a múltiples planes de estudio.</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label small fw-semibold">Departamento / Área</label>
|
<label class="form-label small fw-semibold">Departamento / Área</label>
|
||||||
@@ -405,6 +446,93 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
function updateCareerCount(containerId, countBadgeId) {
|
||||||
|
var container = document.getElementById(containerId);
|
||||||
|
var badge = document.getElementById(countBadgeId);
|
||||||
|
if (!container || !badge) return;
|
||||||
|
var checked = container.querySelectorAll('.career-checkbox:checked').length;
|
||||||
|
badge.textContent = checked + (checked === 1 ? ' seleccionada' : ' seleccionadas');
|
||||||
|
if (checked > 0) {
|
||||||
|
badge.className = 'badge bg-primary text-white rounded-pill';
|
||||||
|
} else {
|
||||||
|
badge.className = 'badge bg-secondary-subtle text-secondary border rounded-pill';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dynamic career filter within modals
|
||||||
|
document.querySelectorAll('.career-filter-input').forEach(function(input) {
|
||||||
|
input.addEventListener('input', function() {
|
||||||
|
var term = this.value.toLowerCase().trim();
|
||||||
|
var targetId = this.getAttribute('data-target');
|
||||||
|
var container = document.getElementById(targetId);
|
||||||
|
if (container) {
|
||||||
|
container.querySelectorAll('.career-item').forEach(function(item) {
|
||||||
|
var text = item.textContent.toLowerCase();
|
||||||
|
item.style.display = text.includes(term) ? '' : 'none';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Select all / Deselect all
|
||||||
|
document.querySelectorAll('.select-all-careers').forEach(function(btn) {
|
||||||
|
btn.addEventListener('click', function() {
|
||||||
|
var targetId = this.getAttribute('data-target');
|
||||||
|
var container = document.getElementById(targetId);
|
||||||
|
if (container) {
|
||||||
|
container.querySelectorAll('.career-checkbox').forEach(function(cb) {
|
||||||
|
var item = cb.closest('.career-item');
|
||||||
|
if (!item || item.style.display !== 'none') {
|
||||||
|
cb.checked = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var countId = targetId === 'addSubjectCareerList' ? 'addSubjectCareerCount' : 'editSubjectCareerCount';
|
||||||
|
updateCareerCount(targetId, countId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelectorAll('.deselect-all-careers').forEach(function(btn) {
|
||||||
|
btn.addEventListener('click', function() {
|
||||||
|
var targetId = this.getAttribute('data-target');
|
||||||
|
var container = document.getElementById(targetId);
|
||||||
|
if (container) {
|
||||||
|
container.querySelectorAll('.career-checkbox').forEach(function(cb) {
|
||||||
|
cb.checked = false;
|
||||||
|
});
|
||||||
|
var countId = targetId === 'addSubjectCareerList' ? 'addSubjectCareerCount' : 'editSubjectCareerCount';
|
||||||
|
updateCareerCount(targetId, countId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Individual checkbox changes
|
||||||
|
document.querySelectorAll('.career-checkbox').forEach(function(cb) {
|
||||||
|
cb.addEventListener('change', function() {
|
||||||
|
var container = this.closest('[id$="CareerList"]');
|
||||||
|
if (container) {
|
||||||
|
var countId = container.id === 'addSubjectCareerList' ? 'addSubjectCareerCount' : 'editSubjectCareerCount';
|
||||||
|
updateCareerCount(container.id, countId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Reset Add Modal on open
|
||||||
|
var modalAdd = document.getElementById('modalAddSubject');
|
||||||
|
if (modalAdd) {
|
||||||
|
modalAdd.addEventListener('show.bs.modal', function() {
|
||||||
|
var filterInput = modalAdd.querySelector('.career-filter-input');
|
||||||
|
if (filterInput) filterInput.value = '';
|
||||||
|
modalAdd.querySelectorAll('.career-item').forEach(function(item) {
|
||||||
|
item.style.display = '';
|
||||||
|
});
|
||||||
|
modalAdd.querySelectorAll('.career-checkbox').forEach(function(cb) {
|
||||||
|
cb.checked = false;
|
||||||
|
});
|
||||||
|
updateCareerCount('addSubjectCareerList', 'addSubjectCareerCount');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Populate Edit Subject Modal
|
// Populate Edit Subject Modal
|
||||||
var modalEdit = document.getElementById('modalEditSubject');
|
var modalEdit = document.getElementById('modalEditSubject');
|
||||||
if (modalEdit) {
|
if (modalEdit) {
|
||||||
@@ -415,10 +543,25 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
document.getElementById('editSubjectCode').value = btn.getAttribute('data-code') || '';
|
document.getElementById('editSubjectCode').value = btn.getAttribute('data-code') || '';
|
||||||
document.getElementById('editSubjectName').value = btn.getAttribute('data-name') || '';
|
document.getElementById('editSubjectName').value = btn.getAttribute('data-name') || '';
|
||||||
document.getElementById('editSubjectCredits').value = btn.getAttribute('data-credits') || '4';
|
document.getElementById('editSubjectCredits').value = btn.getAttribute('data-credits') || '4';
|
||||||
document.getElementById('editSubjectCareer').value = btn.getAttribute('data-career-id') || '';
|
|
||||||
document.getElementById('editSubjectDept').value = btn.getAttribute('data-department') || '';
|
document.getElementById('editSubjectDept').value = btn.getAttribute('data-department') || '';
|
||||||
document.getElementById('editSubjectDesc').value = btn.getAttribute('data-description') || '';
|
document.getElementById('editSubjectDesc').value = btn.getAttribute('data-description') || '';
|
||||||
document.getElementById('editSubjectActive').checked = (btn.getAttribute('data-active') === 'true');
|
document.getElementById('editSubjectActive').checked = (btn.getAttribute('data-active') === 'true');
|
||||||
|
|
||||||
|
// Reset search filter
|
||||||
|
var filterInput = modalEdit.querySelector('.career-filter-input');
|
||||||
|
if (filterInput) filterInput.value = '';
|
||||||
|
modalEdit.querySelectorAll('.career-item').forEach(function(item) {
|
||||||
|
item.style.display = '';
|
||||||
|
});
|
||||||
|
|
||||||
|
// Populate careers checkboxes
|
||||||
|
var careerIdsStr = btn.getAttribute('data-career-ids') || btn.getAttribute('data-career-id') || '';
|
||||||
|
var selectedIds = careerIdsStr ? careerIdsStr.split(',').map(function(s) { return s.trim(); }).filter(Boolean) : [];
|
||||||
|
|
||||||
|
modalEdit.querySelectorAll('#editSubjectCareerList .career-checkbox').forEach(function(cb) {
|
||||||
|
cb.checked = selectedIds.includes(cb.value);
|
||||||
|
});
|
||||||
|
updateCareerCount('editSubjectCareerList', 'editSubjectCareerCount');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user