Reviews are the core feedback mechanism in UniSierra Eats. Logged-in students can rate any cafeteria product from 1 to 5 stars and leave a written comment. The average of all active reviews for a product is computed live and displayed wherever that product appears — in the catalog, search results, and the product detail page.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/JuseAR27/Unisierra-eats/llms.txt
Use this file to discover all available pages before exploring further.
Data Model
Reviews are stored in theResenas table:
| Field | Type | Constraints | Description |
|---|---|---|---|
id | INTEGER | PRIMARY KEY | Auto-incremented review identifier |
usuario_id | INTEGER | FOREIGN KEY -> Usuarios.id | The student who wrote the review |
producto_id | INTEGER | FOREIGN KEY -> Productos.id_producto | The product being reviewed |
calificacion | INTEGER | CHECK (1 to 5) | Star rating from 1 (lowest) to 5 (highest) |
comentario | TEXT | Written review body | |
fecha | DATETIME | DEFAULT CURRENT_TIMESTAMP | Timestamp of submission |
estado | TEXT | DEFAULT 'activa' | Review visibility state |
Review States
| State | Meaning |
|---|---|
activa | Visible to all users on the product detail page |
reportada | Flagged by a student; hidden from public view, pending admin review |
API Endpoints
Submit a Review
POST /api/resenas
Creates a new review. The student must be logged in — the frontend reads usuario_id directly from the localStorage session.
Request body:
200 OK):
Edit a Review
PUT /api/resenas/:id
Updates the star rating and comment of an existing review. Only the fields calificacion and comentario are accepted.
Delete a Review
DELETE /api/resenas/:id
Permanently removes a review. No confirmation is performed server-side; the frontend presents a confirmation modal before calling this endpoint.
Flag a Review
PUT /api/resenas/:id/reportar
Sets the review’s estado to 'reportada'. Reported reviews are immediately hidden from the product detail page and queued for admin review via GET /api/admin/resenas-reportadas. The request is sent with method: 'PUT' and no request body.
Fetch Reviews for a Product
GET /api/resenas/producto/:producto_id
Returns all active reviews for a specific product, ordered newest first. Each row includes the reviewer’s display name joined from the Usuarios table.
Fetch Reviews by User
GET /api/resenas/usuario/:usuario_id
Returns all active reviews written by a specific student, ordered newest first. Each row includes the product name and image joined from the Productos table — used to render the profile page’s “Mis Reseñas” tab.
Submitting a Review
Browse to a Product
Navigate to the product catalog or search results and click any product card to open
detalle_producto.html?id=<id_producto>.Click 'Escribir Reseña'
On the product detail page, click the Escribir Reseña button. If you are not logged in, an alert prompts you to sign in first. Authenticated users are redirected to
escribir_resena.html?id=<id_producto>.Select a Star Rating
Click one of the five interactive star icons to set your rating. The label below the stars updates to confirm your selection, e.g. “3 estrellas”.
Write Your Comment
Enter your review text in the comment field. The comment field is required — the form will not submit without it.
Fetch Code — Submitting a Review
The following code frommanejarEscrituraResena() in app.js shows how the review form posts to the API:
Star Rating Display
ThegenerarEstrellas() helper in app.js renders a row of Font Awesome icons for any numeric rating. It supports full, half, and empty stars:
Rating Distribution Bars
The product detail page shows a 5-row progress bar breakdown of ratings. The bars are computed entirely in the frontend after fetching reviews from/api/resenas/producto/:producto_id:
- Each row corresponds to a star level (5 down to 1).
- The filled width is
(count for that star / total reviews) × 100%. - A smooth CSS transition (
0.8s ease-out) animates the bars on load.
Students can only view, edit, and delete their own reviews. The profile page at
perfil.html fetches reviews via GET /api/resenas/usuario/:usuario_id using the ID stored in the session, so only that user’s reviews are ever loaded. Editing and deleting controls appear exclusively on the profile page, not on public product pages.