AOSSIE-Org / AOSSIE-Org/EduAid
[BUG]: Missing answers for Boolean questions in Output.jsx causes "undefined" in PDF export
- Lingua principale
- JavaScript
- Stelle
- 171
- Fork
- 425
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
### Bug Description
## Problem:
While reviewing PR #468 , CodeRabbit AI flagged an architectural discrepancy in how the web app handles Boolean questions compared to the browser extension
Right now, /get_boolq returns an array of questions, but it doesn’t include the corresponding answers. In the browser extension, we explicitly make a secondary call to /get_boolean_answer and populate the answers that way. The web app, however, never makes that second call. Output.jsx parses the questions into state, but qaPair.answer is never actually set.
Because of that, when exporting a PDF with answers enabled, pdfWorker.js tries to read qaPair.answer and ends up rendering Answer: undefined.
## Expected Behavior:
The PDF worker should receive the correctly fetched "True" or "False" answer strings and render them accurately in the exported document.
## Actual Behavior:
The answers are never fetched from the backend which passes undefined to the PDF worker.
## Proposed Solution:
I'd like to get the maintainers' feedback on the best architectural approach to fix this:
Frontend Fix: Replicate the extension's behavior by updating the useEffect in Output.jsx to fetch answers from the /get_boolean_answer endpoint before setting the final qaPairs state.
Backend Fix: Update the backend generator logic so that /get_boolq returns the answers alongside the questions in its initial payload, eliminating the need for a secondary API call.
**Note:** This seems conceptually related to the backend data structure issues recently patched in #454 for /get_boolq_hard. It highlights a broader need to standardize how Boolean questions and their answers are packaged and delivered across all endpoints.
### Steps to Reproduce
1. Navigate to the EduAid web app Input page.
2. Select the Boolean question type.
3. Paste any valid source text.
4. Click Generate.
5. On the Output page, click the Generate PDF dropdown and select either Questions with Answers or Answers Only.
6. Open the downloaded PDF.
7. Notice that under each question, it renders as Answer X: undefined.
### Logs and Screenshots
### Environment Details
_No response_
### Impact
High - Major feature is broken
### Code of Conduct
- [x] I have joined the [Discord server](https://discord.gg/hjUhu33uAn) and will post updates there
- [x] I have searched existing issues to avoid duplicates
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.