Overview
The Response Options API manages the answer choices associated with questions in the question bank. Response options are used primarily for multiple choice and true/false questions, where each option has text, a correct/incorrect flag, and an optional display order.
Endpoints
List All Response Options
Retrieve all response options in the system.
Response
Indicates if the request was successful
Response message: “Opciones de respuesta listadas con éxito”
Array of response option objects Show Response Option Object
Unique identifier for the response option
ID of the question this option belongs to (foreign key to preguntas table)
The text content of the answer option
Flag indicating if this is the correct answer (0 = incorrect, 1 = correct, default: 0)
Display order for the option (nullable, useful for controlling option sequence)
Timestamp when the option was created
Timestamp when the option was last updated
Example Request
curl -X GET https://api.example.com/api/response_option \
-H "Accept: application/json"
Example Response
{
"success" : true ,
"message" : "Opciones de respuesta listadas con éxito" ,
"data" : [
{
"id" : 1 ,
"preguntas_id" : 5 ,
"texto" : "$variable" ,
"es_correcta" : 1 ,
"orden" : 1 ,
"created_at" : "2026-03-05T10:30:00.000000Z" ,
"updated_at" : "2026-03-05T10:30:00.000000Z"
},
{
"id" : 2 ,
"preguntas_id" : 5 ,
"texto" : "var variable" ,
"es_correcta" : 0 ,
"orden" : 2 ,
"created_at" : "2026-03-05T10:30:00.000000Z" ,
"updated_at" : "2026-03-05T10:30:00.000000Z"
},
{
"id" : 3 ,
"preguntas_id" : 5 ,
"texto" : "variable:" ,
"es_correcta" : 0 ,
"orden" : 3 ,
"created_at" : "2026-03-05T10:30:00.000000Z" ,
"updated_at" : "2026-03-05T10:30:00.000000Z"
},
{
"id" : 4 ,
"preguntas_id" : 5 ,
"texto" : "#variable" ,
"es_correcta" : 0 ,
"orden" : 4 ,
"created_at" : "2026-03-05T10:30:00.000000Z" ,
"updated_at" : "2026-03-05T10:30:00.000000Z"
}
]
}
Create Response Option
Create a new response option for a question.
POST /api/response_option
Request Body
ID of the question this option belongs to
The text content of the answer option
Flag indicating if this is the correct answer (0 = incorrect, 1 = correct)
Display order for the option (optional, useful for sequencing)
Response
Indicates if the option was created successfully
Response message: “Opción de respuesta creada con éxito”
The created response option object with all fields including timestamps
Example Request
curl -X POST https://api.example.com/api/response_option \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"preguntas_id": 25,
"texto": "El operador punto (.)",
"es_correcta": 1,
"orden": 1
}'
Example Response
{
"success" : true ,
"message" : "Opción de respuesta creada con éxito" ,
"data" : {
"id" : 87 ,
"preguntas_id" : 25 ,
"texto" : "El operador punto (.)" ,
"es_correcta" : 1 ,
"orden" : 1 ,
"created_at" : "2026-03-05T14:25:00.000000Z" ,
"updated_at" : "2026-03-05T14:25:00.000000Z"
}
}
Get Response Option
Retrieve a specific response option by ID.
GET /api/response_option/{id}
Path Parameters
The unique identifier of the response option
Response
Indicates if the request was successful
Response message: “Opción de respuesta obtenida con éxito”
The response option object with all fields
Example Request
curl -X GET https://api.example.com/api/response_option/87 \
-H "Accept: application/json"
Example Response
{
"success" : true ,
"message" : "Opción de respuesta obtenida con éxito" ,
"data" : {
"id" : 87 ,
"preguntas_id" : 25 ,
"texto" : "El operador punto (.)" ,
"es_correcta" : 1 ,
"orden" : 1 ,
"created_at" : "2026-03-05T14:25:00.000000Z" ,
"updated_at" : "2026-03-05T14:25:00.000000Z"
}
}
Update Response Option
Update an existing response option.
PUT /api/response_option/{id}
Path Parameters
The unique identifier of the response option to update
Request Body
ID of the question this option belongs to
The text content of the answer option
Correct answer flag (0 or 1)
Response
Indicates if the update was successful
Response message: “Opción de respuesta actualizada con éxito”
The updated response option object
Example Request
curl -X PUT https://api.example.com/api/response_option/87 \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"texto": "El operador punto (.) para concatenación",
"orden": 1
}'
Example Response
{
"success" : true ,
"message" : "Opción de respuesta actualizada con éxito" ,
"data" : {
"id" : 87 ,
"preguntas_id" : 25 ,
"texto" : "El operador punto (.) para concatenación" ,
"es_correcta" : 1 ,
"orden" : 1 ,
"created_at" : "2026-03-05T14:25:00.000000Z" ,
"updated_at" : "2026-03-05T15:18:00.000000Z"
}
}
Delete Response Option
Delete a response option from the system.
DELETE /api/response_option/{id}
Path Parameters
The unique identifier of the response option to delete
Response
Indicates if the deletion was successful
Response message: “Opción de respuesta eliminada con éxito”
Returns null after successful deletion
Example Request
curl -X DELETE https://api.example.com/api/response_option/87 \
-H "Accept: application/json"
Example Response
{
"success" : true ,
"message" : "Opción de respuesta eliminada con éxito" ,
"data" : null
}
Foreign Key Relationships
Question Relationship
Field : preguntas_id
References : preguntas.id
On Delete : CASCADE (deleting a question will delete all its response options)
Important Notes
Route Name
Note that the API route is /api/response_option (singular), not /api/response_options (plural).
Usage Guidelines
Each question can have multiple response options
For multiple choice questions, typically 4-5 options are created
For true/false questions, exactly 2 options should be created
Only one option should have es_correcta set to 1 for single-answer questions
Multiple options can be correct for multi-select questions
The orden field allows control over how options are displayed to users
Response options use timestamps (created_at, updated_at) for audit tracking
Best Practices
Ordering : Use the orden field to control the sequence of display
Validation : Ensure at least one option is marked as correct for each question
Text Length : Keep option text concise and clear
Cascading Deletes : Be aware that deleting a question will automatically delete all its response options
Example: Creating a Complete Multiple Choice Question
Here’s a workflow for creating a multiple choice question with options:
# Step 1: Create the question
curl -X POST https://api.example.com/api/questions \
-H "Content-Type: application/json" \
-d '{
"tema_id": 8,
"tipo": "opcion_multiple",
"enunciado": "¿Cuál es la forma correcta de declarar una variable en PHP?",
"puntaje": 1.00,
"nivel_dificultad": 1
}'
# Response: { "data": { "id": 50, ... } }
# Step 2: Create response options
curl -X POST https://api.example.com/api/response_option \
-H "Content-Type: application/json" \
-d '{"preguntas_id": 50, "texto": "$variable", "es_correcta": 1, "orden": 1}'
curl -X POST https://api.example.com/api/response_option \
-H "Content-Type: application/json" \
-d '{"preguntas_id": 50, "texto": "var variable", "es_correcta": 0, "orden": 2}'
curl -X POST https://api.example.com/api/response_option \
-H "Content-Type: application/json" \
-d '{"preguntas_id": 50, "texto": "variable:", "es_correcta": 0, "orden": 3}'
curl -X POST https://api.example.com/api/response_option \
-H "Content-Type: application/json" \
-d '{"preguntas_id": 50, "texto": "#variable", "es_correcta": 0, "orden": 4}'