Implement educational platform access control by evaluating credentials, account status, maintenance mode, and role permissions in strict priority order.
In an educational platform, deciding whether a user can access a resource requires distinguishing between authentication and account status (who is the user and what state is their account in?), operational availability (is the platform in maintenance mode?), and role-based authorization (does their role have permission for that resource?). Evaluating these gates in strict priority order avoids leaking information or granting unauthorized access. (Note: this is an educational simulation of decision rules, not a production security system).
Implement the solve(input) function, which receives a JSON object with six properties:
credencialesValidas: boolean.
cuentaActiva: boolean.
cuentaBloqueada: boolean.
rol: exactly "ESTUDIANTE", "INSTRUCTOR", or "ADMIN".
recurso: exactly "CURSOS", "EVALUACIONES", "GESTION_CONTENIDO", or "ADMINISTRACION".
modoMantenimiento: boolean.
Apply the following rules in strict priority order:
If credencialesValidas is false → status "CREDENCIALES_INVALIDAS" (access denied).
If cuentaActiva is false → status "CUENTA_INACTIVA" (access denied).
If cuentaBloqueada is true → status "CUENTA_BLOQUEADA" (access denied).
If modoMantenimiento is true and rol is not "ADMIN" → status "MANTENIMIENTO" (access denied).
Role permission matrix:
"ESTUDIANTE": can access only "CURSOS" and "EVALUACIONES".
"INSTRUCTOR": can access "CURSOS", "EVALUACIONES", and "GESTION_CONTENIDO".
"ADMIN": can access all resources, including "ADMINISTRACION". During maintenance mode, "ADMIN" retains normal permissions, but can never bypass checks 1, 2, and 3.
If the role has permission for the resource → status "ACCESO_AUTORIZADO" (accesoPermitido: true); otherwise → "PERMISO_DENEGADO" (accesoPermitido: false).
Return a JSON object with those exact five properties:
accesoPermitido: boolean.
estado: string with one of the six status values above.
rol: the original role received.
recurso: the original resource received.
puedeAdministrar: boolean true only if rol === "ADMIN" and accesoPermitido is true (must be false on any rejection).
Rules and constraints
Use explicit conditionals (if, else if, else) and favor early returns for rejections.
Do not solve everything with a single boolean expression, ternary operators (? :), permission maps, arrays, classes, or helper functions.