Skip to main content

Dynamic Forums (1, 2, 4, 6)

curl https://proyecto-ingenieria-software-6ccv.onrender.com/respuestas_foro1

GET /respuestas_foro

Retrieve all responses for a specific forum with user information. Implementation: main.py:232-256
foro_id
integer
required
Forum identifier: 1, 2, 4, or 6

Response Schema

responses
array
Array of forum response objects

User Join Behavior

The endpoint attempts to JOIN with the usuarios table:
SELECT r.*, u.nombre, u.apellidos
FROM {foro_nombre} r
LEFT JOIN usuarios u ON r.email = u.email
ORDER BY r.fecha DESC
If the JOIN fails (e.g., usuarios table doesn’t exist), the endpoint falls back to returning only forum response data without nombre and apellidos fields.

Example Response

[
  {
    "email": "[email protected]",
    "r1": "The derivative represents the rate of change",
    "r2": "f'(x) = 2x",
    "r3": "Local maximum at x = 3",
    "r4": "Concave up on (0, infinity)",
    "r5": "Area equals 12 square units",
    "r6": "Fundamental theorem connects derivatives and integrals",
    "fecha": "2026-03-05T14:32:18",
    "nombre": "Maria",
    "apellidos": "Garcia"
  },
  {
    "email": "[email protected]",
    "r1": "Instantaneous rate of change at a point",
    "r2": "2x",
    "r3": "x=3",
    "r4": "Positive second derivative",
    "r5": "12",
    "r6": "Connection between differentiation and integration",
    "fecha": "2026-03-05T13:15:42",
    "nombre": "Juan",
    "apellidos": "Martinez"
  }
]

GET /verificar_foro/

Check if a student has already participated in a forum. Implementation: main.py:258-271
foro_id
integer
required
Forum identifier: 1, 2, 4, or 6
email
string
required
Student email address to check

Response

participo
boolean
true if student has submitted a response, false otherwise
Example Response:
{
  "participo": true
}
{
  "participo": false
}

Forum 3 - Table Responses

curl https://proyecto-ingenieria-software-6ccv.onrender.com/respuestas_en_foro_3

GET /respuestas_en_foro_3

Retrieve all Forum 3 responses with table data. Implementation: main.py:307-316

Response Schema

responses
array
Array of Forum 3 response objects

Example Response

[
  {
    "email": "[email protected]",
    "r1": "Answer 1",
    "r2": "Answer 2",
    "r3": "Answer 3",
    "r4": "Answer 4",
    "r5": "Answer 5",
    "t6_r1_c1": "f(x)",
    "t6_r1_c2": "x^2",
    "t6_r1_c3": "2x",
    "t6_r2_c1": "g(x)",
    "t6_r2_c2": "sin(x)",
    "t6_r2_c3": "cos(x)",
    "t6_r3_c1": "h(x)",
    "t6_r3_c2": "e^x",
    "t6_r3_c3": "e^x",
    "r7": "Answer 7",
    "r8": "Answer 8",
    "fecha": "2026-03-05T14:20:33",
    "nombre": "Carlos",
    "apellidos": "Rodriguez"
  }
]

GET /verificar_en_foro_3/

Check if a student has participated in Forum 3. Implementation: main.py:318-329
email
string
required
Student email address

Response

{
  "participo": true
}

Forum 5 - Image Responses

curl https://proyecto-ingenieria-software-6ccv.onrender.com/respuestas_en_foro_5

GET /respuestas_en_foro_5

Retrieve all Forum 5 responses with base64-encoded images. Implementation: main.py:592-644

Response Schema

responses
array
Array of Forum 5 response objects

Image Encoding Process

The endpoint converts binary image data (BYTEA) to base64-encoded data URLs (main.py:607-637):
  1. Fetch binary data from PostgreSQL (memoryview or bytes)
  2. Convert to bytes if needed: bytes(valor)
  3. Encode to base64: base64.b64encode(valor).decode('utf-8')
  4. Create data URL: data:image/jpeg;base64,{encoded}
  5. Remove binary field and add _url field
If image encoding fails, all image URLs are set to null. The endpoint handles errors gracefully to prevent response failures.

Example Response

[
  {
    "id": 42,
    "email": "[email protected]",
    "r2": "The limit approaches infinity",
    "r4": "Continuous on all real numbers",
    "r5": "Differentiable except at x=0",
    "r6": "Graph shows vertical asymptote",
    "imagen_pregunta_3_url": "data:image/jpeg;base64,/9j/4AAQSkZJRg...",
    "imagen_1_url": "data:image/jpeg;base64,iVBORw0KGgoAAAANSUhE...",
    "imagen_2_url": "data:image/jpeg;base64,R0lGODlhAQABAIAA...",
    "imagen_3_url": null,
    "nombre": "Ana",
    "apellidos": "Lopez"
  }
]

Using Image URLs

The data URLs can be used directly in HTML img tags:
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRg..." alt="Student sketch" />

GET /verificar_en_foro_5/

Check if a student has participated in Forum 5. Implementation: main.py:578-589
email
string
required
Student email address

Response

{
  "participo": true
}

Error Handling

HTTP Status Codes

404
Not Found
Forum ID not found in configuration (dynamic forums)
500
Internal Server Error
Database connection or query error

Graceful Degradation

All endpoints implement fallback behavior:
  1. JOIN failures: Return data without user names
  2. Image encoding errors: Set image URLs to null
  3. Database errors: Return empty arrays or {"participo": false}

Sorting

All response endpoints sort by submission timestamp in descending order:
ORDER BY r.fecha DESC  -- Most recent first

Next Steps

Submit Responses

Learn how to submit forum responses

Forums Overview

View forum configuration and routing

Build docs developers (and LLMs) love