The Indicators module lets Corpen management define measurable KPIs, execute live SQL queries against the database to calculate current values, download PDF performance reports, and run multiple-choice assessment quizzes for staff. KPIs are grouped by organizational area and each indicator stores the calculation formula alongside its target (meta) and measurement frequency. The quiz system is publicly accessible so that external participants or staff without an account can complete an assessment.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/corpentunida-org/corpen/llms.txt
Use this file to discover all available pages before exploring further.
Routes Overview
Public quiz routes (no authentication required)
| Method | URL | Name | Controller method |
|---|---|---|---|
GET | /indicators/quiz | indicators.quiz.inicio | QuizController@quizinicio |
GET | /indicators/quiz/{prueba}/preguntas | indicators.quiz.preguntas | QuizController@generarpreguntas |
POST | /indicators/validarcorreo | indicators.validar.correo | QuizController@validar |
POST | /indicators/quiz/store | indicators.quiz.store | QuizController@storeQuiz |
Authenticated routes
Indicators Sub-resource
Controller:App\Http\Controllers\Indicators\IndicadoresControllerModel:
App\Models\Indicators\IndIndicadoresRoute resource prefix:
indicators/indicador → named indicators.indicadores.*
Indicator fields
consulta_bd field holds a raw SQL SELECT statement. The index page executes it live via DB::select() and attaches the result as $ind->indicador_calculado on each indicator object. If a query throws an exception, the user is redirected back with the error message.
Indicator index
GET /indicators/indicador (named indicators.indicadores.index) loads only the indicators accessible to the authenticated user based on their assigned roles:
Defining an Indicator and Generating a Report
Create the indicator
Navigate to Fill in the name, calculation formula, goal, frequency, responsible employee, area, and the SQL query. Then submit to
GET /indicators/indicador/create. The form loads available areas from gdo_area and employee names from gdo_empleados (IDs ≥ 11):POST /indicators/indicador.Verify the calculated value
Return to
GET /indicators/indicador (the index). The controller runs each indicator’s consulta_bd query and sets $ind->indicador_calculado to the first column of the first row returned. Verify that the live value appears correctly.Example SQL stored in consulta_bd:Edit if needed
Use
GET /indicators/indicador/{id}/edit to update the formula, goal, or SQL query. Submit via PUT /indicators/indicador/{id}.Download the PDF report
Send a
POST request to /indicators/generar/informe (requires auth). The controller:- Runs
dataIndicadores()to compute all live values for the user’s areas. - Renders the
indicators.informepdfBlade view as a PDF usingbarryvdh/laravel-dompdfon A4 portrait paper. - Saves the file to S3 at
corpentunida/indicators/InformeTIC_{timestamp}.pdf. - Creates an
IndRegistroInformesrecord logging the file path, user, and download timestamp. - Triggers a browser file download as
informe_indicadores.pdfvia$pdf->download().
Quiz Sub-resource
Controller:App\Http\Controllers\Indicators\QuizControllerModels:
IndQuiz, IndPreguntas, IndRespuestas, IndUsuariosRoute resource prefix:
indicators/quizes → named indicators.quizes.*
Public quiz flow
Start the quiz
Any user — authenticated or not — can access
GET /indicators/quiz to view the quiz entry screen. No login is required.Validate email
Before showing questions, the client-side form calls Response:
POST /indicators/validarcorreo to confirm:- The email exists in
gdo_cargo.correo_corporativo(i.e. the person is a staff member). - The user has not already completed this specific quiz (
pruebaID).
Load questions
Navigate to
GET /indicators/quiz/{prueba}/preguntas. The controller verifies the quiz is active (estado = 1) and then builds a question set:- 5 questions drawn randomly from
ind_preguntasfor the given quiz ID (excluding the two special question IDs 1 and 2). - The 2 fixed special questions (IDs 1 and 2) are always appended.
- Each question gets 1 correct answer and up to 3 incorrect answers, shuffled.
Submit answers
Post the completed quiz to Score is calculated as correct answers out of The user is shown the
POST /indicators/quiz/store:total_questions - 2 (special questions are excluded from scoring). An IndUsuarios record is created:indicators.quiz.resultadoquiz view with a per-question breakdown.Admin quiz dashboard
GET /indicators/quizes (requires auth) shows all quiz submissions with aggregated stats. The controller computes:
| Metric | Source |
|---|---|
| Users scoring > 3 | IndUsuarios where CAST(SUBSTRING_INDEX(puntaje, '/', 1) AS UNSIGNED) > 3 |
| Total employees | GdoEmpleado where id > 11 |
| Score distribution (1–5) | Parsed from IndUsuarios.puntaje |
| Question 5 ratings (TIC Corpen) | Index [5] of each user’s respuestas JSON |
| Question 6 ratings (TIC Software) | Index [6] of each user’s respuestas JSON (supports 'n/a') |
$datacharts array passed to the quiz admin view.
Report History
Every successful call toPOST /indicators/generar/informe creates a row in ind_registro_informes:
The quiz start page (
GET /indicators/quiz) and all quiz submission routes (GET /indicators/quiz/{prueba}/preguntas, POST /indicators/validarcorreo, POST /indicators/quiz/store) are intentionally outside the auth middleware. This allows external participants — members, applicants, or trainees — to complete assessments without needing a Corpen platform account. Only the quiz management CRUD (GET /indicators/quizes and its resource routes) and the indicator CRUD and report download require authentication.