AOSSIE-Org / AOSSIE-Org/EduAid

[BUG]: Fix /generate_gform response shape to return form_link for web and extension UIs

Abierto
#566 2 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
JavaScript
Estrellas
171
Forks
425
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### Feature and its Use Cases

## Summary

While testing the Google Forms integration, I found that the `/generate_gform` backend endpoint and the frontend consumers (web app + browser extension) currently **disagree on the response shape**.

- The backend returns a **bare JSON string** containing `result["responderUri"]`.
- The frontends expect a **JSON object** with a `form_link` field.

As a result, clicking **“Generate Google form”** in the web app Output page or in the extension’s Question/SidePanel views does not open a usable Google Form URL.

---

## Why This Could Be Improved

Today:

- **Backend** (`backend/server.py`):
- Returns `jsonify(result["responderUri"])` (a raw string).
- Also calls `webbrowser.open_new_tab(...)` on the server.

- **Frontends** (`eduaid_web/src/pages/Output.jsx`, `extension/src/pages/question/Question.jsx`, `SidePanel.jsx`):
- Assume the response is an object and read `result.form_link`.
- `result.form_link` is therefore `undefined`, so `window.open(formUrl, "_blank")` opens `about:blank` or does nothing observable.

This mismatch:

- **Breaks a flagship feature**: “Dynamic Google Form Integration”.
- Creates inconsistent API contracts between backend and frontend.
- Makes it harder for new contributors to trust the behavior of the `/generate_gform` endpoint.

---

## Proposed Direction (Open for Discussion)

A minimal, backwards-compatible direction:

1. **Standardize the backend response shape**

- Change `/generate_gform` to return a JSON object:

```python
responder_url = result.get("responderUri")
edit_url = f"https://docs.google.com/forms/d/{result['formId']}/edit"

return jsonify({
"form_link": responder_url,
"edit_link": edit_url
}), 200

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.