File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,15 +83,30 @@ export function calcularValoracionComportamiento(valor) {
8383export function abreviarNivel ( nivel ) {
8484 if ( ! nivel || typeof nivel !== "string" ) return "" ;
8585
86- const partes = nivel . split ( " " ) ;
87- if ( partes . length < 2 ) return "" ;
86+ // Normalizar: quitar acentos, pasar a minúsculas y colapsar espacios
87+ const norm = nivel
88+ . normalize ( 'NFD' )
89+ . replace ( / [ \u0300 - \u036f ] / g, '' )
90+ . toLowerCase ( )
91+ . trim ( )
92+ . replace ( / \s + / g, ' ' ) ;
93+
94+ // Extraer grado (número al inicio o primer dígito que aparezca)
95+ let grado = "" ;
96+ const inicioNum = norm . match ( / ^ ( \d + ) / ) ;
97+ if ( inicioNum ) {
98+ grado = inicioNum [ 1 ] ;
99+ } else {
100+ const anyDigit = norm . match ( / ( \d ) / ) ;
101+ if ( anyDigit ) grado = anyDigit [ 1 ] ;
102+ }
88103
89- const grado = partes [ 0 ] [ 0 ] ; // Ej. "1ro" => "1"
104+ if ( ! grado ) return "" ;
90105
91- if ( nivel . includes ( "Bachillerato" ) ) return `${ grado } BCH` ;
92- if ( nivel . includes ( "Básico Elemental" ) ) return `${ grado } BE` ;
93- if ( nivel . includes ( "Básico Medio" ) ) return `${ grado } BM` ;
94- if ( nivel . includes ( "Básico Superior" ) ) return `${ grado } BS` ;
106+ if ( norm . includes ( 'bachiller' ) ) return `${ grado } BCH` ;
107+ if ( norm . includes ( 'basico elemental' ) || norm . includes ( 'basicoelemental' ) ) return `${ grado } BE` ;
108+ if ( norm . includes ( 'basico medio' ) || norm . includes ( 'basicomedio' ) ) return `${ grado } BM` ;
109+ if ( norm . includes ( 'basico superior' ) || norm . includes ( 'basicosuperior' ) ) return `${ grado } BS` ;
95110
96- return "" ; // Por defecto si no matchea nada
111+ return "" ;
97112}
You can’t perform that action at this time.
0 commit comments