AOSSIE-Org / AOSSIE-Org/EduAid

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

Offen
#566 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
JavaScript
Sterne
171
Forks
425
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

### 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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.