AOSSIE-Org / AOSSIE-Org/EduAid

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

Đang mở
#566 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
JavaScript
Star
171
Fork
425
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.