AOSSIE-Org / AOSSIE-Org/EduAid

[BUG]: Missing answers for Boolean questions in Output.jsx causes "undefined" in PDF export

未关闭
#471 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
JavaScript
星标
171
派生
425
PR 合并指标
30 天内没有已合并 PR

描述

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

Image

Image

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

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。