Endpoint
Description
Marks an employee background evaluation as complete and finalized. This endpoint should only be called after all required data sections have been completed and all mandatory documents have been uploaded. Upon successful finalization, the evaluation is recorded in the finalized evaluations table with a timestamp.Authentication
This endpoint requires session-based authentication via theisLoggedIn middleware. Users must be authenticated before accessing this endpoint.
Request Parameters
The encrypted evaluation ID obtained from the Create Evaluation or View Evaluation endpoints. This value is encrypted using
ncrypt-js with the key "key_cecc".Prerequisites
Before finalizing an evaluation, ensure all requirements are met based on evaluation type:Permanencia (tipo_eval = 1)
Data Sections (6 required)
- Personal information completed
- Family information completed
- Academic background completed
- Work history completed
- Economic data completed
- References completed
Required Documents (5 required)
- Birth certificate (Acta de Nacimiento)
- Official identification (INE)
- Proof of address (Comprobante de Domicilio)
- Education certificates (Comprobante de Estudios)
- Proof of income (Comprobante de Ingresos)
Nuevo Ingreso (tipo_eval = 2)
Data Sections (6 required)
- Personal information completed
- Family information completed
- Academic background completed
- Work history completed
- Economic data completed
- References completed
Required Documents (7 required)
- Birth certificate (Acta de Nacimiento)
- Official identification (INE)
- Proof of address (Comprobante de Domicilio)
- Education certificates (Comprobante de Estudios)
- Military service card (Cartilla Militar)
- Proof of income (Comprobante de Ingresos)
- Letter of motivation (Motivo de Ingreso)
- Credit bureau report (Buró de Crédito)
How It Works
Decrypt evaluation ID
The encrypted evaluation ID is decrypted using
ncrypt-js with the key "key_cecc" to obtain the actual evalID.Get current timestamp
The system retrieves the current date and time using the
GetDate() helper function.Record finalization
A new record is inserted into the
tbl_dgo_evalfinalizadas table containing:evalID- The evaluation identifierfinalizadoFecha- The finalization timestamp
Response
This endpoint performs a redirect rather than returning JSON data.Success Response
Status Code:302 Found
Redirect URL: /auth/profile
Flash Message: “Evaluación Finalizada”
Error Response
Status Code:302 Found
Redirect URL: Previous page (using res.redirect("back"))
Flash Message: “Algo salio mal !”
Errors are also logged to the console for debugging purposes.
Database Operations
Query Used
Example Request
Example Usage Flow
Complete evaluation
Employee or administrator completes all required data sections and uploads all mandatory documents.
Verify completion
The View Evaluation endpoint shows
ListoRevision: true, indicating the evaluation is ready for finalization.Data Packet Structure
Important Notes
Post-FinalizationOnce an evaluation is finalized:
- A record is created in
tbl_dgo_evalfinalizadaswith the finalization timestamp - The evaluation remains accessible for viewing but should not be modified
- The finalization date serves as an audit trail
Error Scenarios
Invalid Encrypted Data
Invalid Encrypted Data
Cause: The
encryptedData parameter cannot be decrypted using the key "key_cecc".Result: Error logged to console, user redirected back with error message.Solution: Ensure the encrypted data is obtained from a valid evaluation creation/view response.Database Connection Error
Database Connection Error
Cause: Unable to connect to the database or execute the insert query.Result: Error logged to console, user redirected back with error message.Solution: Check database connectivity and table structure.
Invalid Evaluation ID
Invalid Evaluation ID
Cause: The decrypted evaluation ID does not exist in the system.Result: Database insert may fail or succeed with invalid reference.Solution: Verify the evaluation exists before attempting finalization.
Session Expired
Session Expired
Cause: User session is not active or has expired.Result: User is redirected to
/auth/signin by the isLoggedIn middleware.Solution: User must authenticate again before finalizing.Related Endpoints
- Create Evaluation - Create or resume an evaluation
- View Evaluation - Retrieve evaluation data and check completion status
Security Considerations
Session-Based Authentication: Requires active user session
Encrypted Identifiers: Uses encrypted evaluation IDs to prevent tampering
Audit Trail: Records finalization timestamp for compliance tracking