Overview
The Questions API manages the question bank used for creating assessments and evaluations. Questions can be of different types (multiple choice, true/false, short answer, calculation) and are associated with specific topics. Each question has configurable difficulty levels, point values, and optional explanations.
Endpoints
List All Questions
Retrieve all questions in the question bank.
Response
Indicates if the request was successful
Response message: “Preguntas listadas con éxito”
Array of question objects Unique identifier for the question
ID of the topic this question belongs to (foreign key to topics table)
ID of the instructor who created this question (foreign key to users table, nullable)
Type of question. Possible values: opcion_multiple, verdadero_falso, respuesta_corta, calculo
The question statement or prompt
URL to an image associated with the question (max 500 characters, nullable)
Point value for this question (decimal with 5 digits, 2 decimal places, default: 1.00)
Difficulty level of the question (default: 1)
Explanation or rationale for the correct answer (nullable)
Status flag indicating if question is active (0 = inactive, 1 = active, default: 1)
Timestamp when the question was created
Timestamp when the question was last updated
Example Request
curl -X GET https://api.example.com/api/questions \
-H "Accept: application/json"
Example Response
{
"success" : true ,
"message" : "Preguntas listadas con éxito" ,
"data" : [
{
"id" : 1 ,
"tema_id" : 8 ,
"docente_id" : 12 ,
"tipo" : "opcion_multiple" ,
"enunciado" : "¿Cuál es la forma correcta de declarar una variable en PHP?" ,
"imagen_url" : null ,
"puntaje" : "1.00" ,
"nivel_dificultad" : 1 ,
"explicacion" : "En PHP, las variables se declaran con el símbolo $ seguido del nombre de la variable" ,
"activo" : 1 ,
"created_at" : "2026-03-05T10:30:00.000000Z" ,
"updated_at" : "2026-03-05T10:30:00.000000Z"
},
{
"id" : 2 ,
"tema_id" : 8 ,
"docente_id" : 12 ,
"tipo" : "verdadero_falso" ,
"enunciado" : "PHP es un lenguaje de programación compilado" ,
"imagen_url" : null ,
"puntaje" : "0.50" ,
"nivel_dificultad" : 1 ,
"explicacion" : "Falso. PHP es un lenguaje interpretado, no compilado" ,
"activo" : 1 ,
"created_at" : "2026-03-05T10:35:00.000000Z" ,
"updated_at" : "2026-03-05T10:35:00.000000Z"
}
]
}
Create Question
Create a new question in the question bank.
Request Body
ID of the topic this question belongs to
ID of the instructor creating this question (optional)
Type of question. Must be one of: opcion_multiple, verdadero_falso, respuesta_corta, calculo
The question statement or prompt
URL to an image for the question (maximum 500 characters, optional)
Point value for this question (format: 999.99)
Difficulty level (typically 1-5, where 1 is easiest)
Explanation for the correct answer (optional)
Active status (0 = inactive, 1 = active)
Response
Indicates if the question was created successfully
Response message: “Pregunta creada con éxito”
The created question object with all fields including timestamps
Example Request
curl -X POST https://api.example.com/api/questions \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"tema_id": 8,
"docente_id": 12,
"tipo": "opcion_multiple",
"enunciado": "¿Qué operador se utiliza para concatenar cadenas en PHP?",
"imagen_url": null,
"puntaje": 1.50,
"nivel_dificultad": 2,
"explicacion": "El operador punto (.) se utiliza para concatenar strings en PHP",
"activo": 1
}'
Example Response
{
"success" : true ,
"message" : "Pregunta creada con éxito" ,
"data" : {
"id" : 25 ,
"tema_id" : 8 ,
"docente_id" : 12 ,
"tipo" : "opcion_multiple" ,
"enunciado" : "¿Qué operador se utiliza para concatenar cadenas en PHP?" ,
"imagen_url" : null ,
"puntaje" : "1.50" ,
"nivel_dificultad" : 2 ,
"explicacion" : "El operador punto (.) se utiliza para concatenar strings en PHP" ,
"activo" : 1 ,
"created_at" : "2026-03-05T14:22:00.000000Z" ,
"updated_at" : "2026-03-05T14:22:00.000000Z"
}
}
Get Question
Retrieve a specific question by ID.
Path Parameters
The unique identifier of the question
Response
Indicates if the request was successful
Response message: “Pregunta obtenida con éxito”
The question object with all fields
Example Request
curl -X GET https://api.example.com/api/questions/25 \
-H "Accept: application/json"
Example Response
{
"success" : true ,
"message" : "Pregunta obtenida con éxito" ,
"data" : {
"id" : 25 ,
"tema_id" : 8 ,
"docente_id" : 12 ,
"tipo" : "opcion_multiple" ,
"enunciado" : "¿Qué operador se utiliza para concatenar cadenas en PHP?" ,
"imagen_url" : null ,
"puntaje" : "1.50" ,
"nivel_dificultad" : 2 ,
"explicacion" : "El operador punto (.) se utiliza para concatenar strings en PHP" ,
"activo" : 1 ,
"created_at" : "2026-03-05T14:22:00.000000Z" ,
"updated_at" : "2026-03-05T14:22:00.000000Z"
}
}
Update Question
Update an existing question.
Path Parameters
The unique identifier of the question to update
Request Body
ID of the topic this question belongs to
Type of question: opcion_multiple, verdadero_falso, respuesta_corta, or calculo
URL to an associated image (maximum 500 characters)
Point value (format: 999.99)
Explanation for the correct answer
Response
Indicates if the update was successful
Response message: “Pregunta actualizada con éxito”
The updated question object
Example Request
curl -X PUT https://api.example.com/api/questions/25 \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"puntaje": 2.00,
"nivel_dificultad": 3,
"explicacion": "El operador punto (.) se utiliza para concatenar strings en PHP. Ejemplo: $nombre . $apellido"
}'
Example Response
{
"success" : true ,
"message" : "Pregunta actualizada con éxito" ,
"data" : {
"id" : 25 ,
"tema_id" : 8 ,
"docente_id" : 12 ,
"tipo" : "opcion_multiple" ,
"enunciado" : "¿Qué operador se utiliza para concatenar cadenas en PHP?" ,
"imagen_url" : null ,
"puntaje" : "2.00" ,
"nivel_dificultad" : 3 ,
"explicacion" : "El operador punto (.) se utiliza para concatenar strings en PHP. Ejemplo: $nombre . $apellido" ,
"activo" : 1 ,
"created_at" : "2026-03-05T14:22:00.000000Z" ,
"updated_at" : "2026-03-05T15:10:00.000000Z"
}
}
Delete Question
Delete a question from the question bank.
DELETE /api/questions/{id}
Path Parameters
The unique identifier of the question to delete
Response
Indicates if the deletion was successful
Response message: “Pregunta eliminada con éxito”
Returns null after successful deletion
Example Request
curl -X DELETE https://api.example.com/api/questions/25 \
-H "Accept: application/json"
Example Response
{
"success" : true ,
"message" : "Pregunta eliminada con éxito" ,
"data" : null
}
Foreign Key Relationships
Topic Relationship
Field : tema_id
References : topics.id
On Delete : CASCADE (deleting a topic will delete all associated questions)
Instructor Relationship
Field : docente_id
References : users.id
On Delete : SET NULL (deleting a user will set the field to null, preserving the question)
Question Types
The tipo field supports four question types:
opcion_multiple : Multiple choice questions with several answer options
verdadero_falso : True/false questions
respuesta_corta : Short answer questions requiring text input
calculo : Calculation questions requiring numeric answers
Notes
Questions use timestamps (created_at, updated_at) for audit tracking
The puntaje field allows decimal values for flexible grading (e.g., 1.50, 2.00)
Difficulty levels typically range from 1 (easiest) to 5 (hardest)
Questions can be soft-deleted by setting activo to 0
The imagen_url field allows adding visual elements to questions
Each question must be associated with a valid topic via tema_id
The explicacion field is useful for providing feedback after answering