Skip to content

Improve Output UI: Add empty state and navigation link#651

Open
Lavish-Dadhich20 wants to merge 5 commits into
AOSSIE-Org:mainfrom
Lavish-Dadhich20:main
Open

Improve Output UI: Add empty state and navigation link#651
Lavish-Dadhich20 wants to merge 5 commits into
AOSSIE-Org:mainfrom
Lavish-Dadhich20:main

Conversation

@Lavish-Dadhich20
Copy link
Copy Markdown

@Lavish-Dadhich20 Lavish-Dadhich20 commented Mar 30, 2026

Addressed Issues:

Fixes #N/A


Screenshots/Recordings:

Before:

  • When no quiz data was available, only a static message was shown.

After:

  • Added improved empty state UI.
  • Added a navigation link to redirect users to the input page.
  • Better user experience when no quiz is present.

Additional Notes:

Changes made:

  • Added proper empty state handling when qaPairs is empty.
  • Added a "Go to input page" link using React Router.
  • Improved error handling for Google Form generation.
  • Added safe parsing for localStorage to prevent crashes.

These improvements enhance usability and make the UI more user-friendly.


AI Usage Disclosure:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have reviewed, understood, and tested the changes locally.

Tools used:

  • ChatGPT (for guidance)

Checklist

  • My PR addresses a single improvement
  • My code follows the project's style
  • Documentation updated (not required)
  • Tests added (not required)
  • No new warnings or errors introduced
  • I have read the contribution guidelines
  • I will address review comments if any

Summary by CodeRabbit

  • New Features

    • Added loading state and "No quiz available" messaging during data prep; simplified per-question display and edit UI
  • Bug Fixes

    • Better handling of malformed stored quiz data to prevent crashes
    • Save now preserves original answers/options when edits are empty; shuffle is disabled while editing
    • Improved user-facing error alerts for form generation failures
  • Refactor

    • Removed PDF generation and streamlined quiz output rendering

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 30, 2026

Warning

Rate limit exceeded

@Lavish-Dadhich20 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 11 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 3 minutes and 11 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f3c638b4-4526-4b6b-8b16-32e906979ec5

📥 Commits

Reviewing files that changed from the base of the PR and between fdbb832 and 1c42808.

📒 Files selected for processing (1)
  • eduaid_web/src/pages/Output.jsx
📝 Walkthrough

Walkthrough

Single-file UI/data-flow rewrite in Output.jsx: added loading and empty-state early returns, safer localStorage parsing, stricter nested-data checks when building quiz pairs, removed PDF generation, changed save/edit/shuffle logic, and simplified Google Form handling and question rendering.

Changes

Cohort / File(s) Summary
Output Component
eduaid_web/src/pages/Output.jsx
Major rewrite of quiz output UI and flow: added loading state and early returns for loading/empty data; wrapped JSON.parse(localStorage.getItem("qaPairs")) in try/catch with fallback; stricter nested-structure checks and === for question-type branching; updated edit/save to preserve original values when edits are empty and to exit edit mode via handleCancelEdit(); guard shuffle while editing; simplified JSX (removed card layout and detailed option rendering); removed PDF generation state, worker, dropdown and related UI; simplified Google Form generation error handling and link opening.

Sequence Diagram(s)

sequenceDiagram
  participant User as "User (clicks/Gestures)"
  participant UI as "Output.jsx (UI/controller)"
  participant LS as "localStorage"
  participant API as "Google Forms API"
  participant Browser as "Browser (open link)"

  User->>UI: Open Output page
  UI->>LS: read `qaPairs` (JSON)
  alt parse success
    LS-->>UI: parsed data
  else parse failure
    LS-->>UI: invalid -> return {}
  end
  UI->>UI: build combinedQaPairs (strict checks for nested fields)
  alt qaPairs empty
    UI-->>User: render empty-state
  else not empty
    UI-->>User: render questions (minimal view)
  end

  User->>UI: "Generate Google Form"
  UI->>API: call form generation
  alt API returns link string or { form_link }
    API-->>UI: form link
    UI->>Browser: open link (noopener,noreferrer)
  else API error
    API-->>UI: error
    UI-->>User: alert with error message
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰
I hopped through JSON, careful and spry,
Caught broken bits before they could cry,
Loading lights blink, questions trimmed neat,
Forms open windows — click, skip, repeat,
A tiny rabbit cheers: the output is sweet! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main UI improvements: adding an empty state display and navigation link when no quiz data is present, which are the primary user-facing changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
eduaid_web/src/pages/Output.jsx (1)

138-171: ⚠️ Potential issue | 🟠 Major

Potential duplicate questions when output_mcq exists alongside output.

When questionType is "get_shortq" or "get_problems" and both output_mcq and output keys exist in storage:

  1. Lines 138-151 push items from output as MCQ (because output_mcq is truthy)
  2. Lines 160-171 also push items from output as Short (because questionType !== "get_mcq")

This results in the same questions being added twice with different question_type values.

🔧 Suggested fix: Make conditions mutually exclusive
       if (
-        (qaPairsFromStorage["output_mcq"] || questionType === "get_mcq") &&
+        questionType === "get_mcq" &&
         qaPairsFromStorage["output"]
       ) {
         qaPairsFromStorage["output"].forEach((qaPair) => {

Alternatively, refactor the entire block to ensure each output entry is only processed once based on questionType.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@eduaid_web/src/pages/Output.jsx` around lines 138 - 171, The combinedQaPairs
population logic currently processes qaPairsFromStorage["output"] twice when
output_mcq exists and questionType is not get_mcq; update the conditional flow
around combinedQaPairs.push so each output entry is handled only once: make the
MCQ branch use an exclusive check (e.g., require questionType === "get_mcq" or
otherwise ensure output_mcq handling is mutually exclusive) and convert the
following blocks into else/else-if branches so that when the MCQ branch runs the
Short/Boolean branches are skipped; locate and modify the block manipulating
combinedQaPairs and reading qaPairsFromStorage["output"] /
qaPairsFromStorage["output_mcq"] to enforce a single-path processing per entry.
🧹 Nitpick comments (1)
eduaid_web/src/pages/Output.jsx (1)

20-31: Consider using a React ref instead of getElementById.

Using document.getElementById bypasses React's DOM management. A useRef hook would be more idiomatic and safer for accessing the dropdown element.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@eduaid_web/src/pages/Output.jsx` around lines 20 - 31, Replace the direct DOM
lookup in the useEffect by creating a React ref (e.g., pdfDropdownRef via
useRef) and attaching it to the dropdown element instead of the id
"pdfDropdown"; update handleClickOutside to use pdfDropdownRef.current (check
for null) and event.target.closest checks as before, and keep the existing event
listener registration and cleanup in the useEffect so you remove the listener on
unmount.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@eduaid_web/src/pages/Output.jsx`:
- Around line 197-199: Remove the accidental inline comment that will render to
users inside the Link element: update the JSX in Output.jsx where the Link
to="/input" (the Link component) currently contains the text "Go to input page
// test change" so that only the intended visible text remains (e.g., "Go to
input page"); ensure no stray "// test change" string remains inside the Link
children or any JSX node.
- Line 176: The useEffect in Output.jsx currently has an empty dependency array
but reads the questionType state, so it can become stale; update the effect's
dependency array to include questionType (i.e., change the useEffect that
currently ends with "}, []);" to "}, [questionType]);") so the effect re-runs
whenever questionType changes and ensures state-driven behavior is correct.

---

Outside diff comments:
In `@eduaid_web/src/pages/Output.jsx`:
- Around line 138-171: The combinedQaPairs population logic currently processes
qaPairsFromStorage["output"] twice when output_mcq exists and questionType is
not get_mcq; update the conditional flow around combinedQaPairs.push so each
output entry is handled only once: make the MCQ branch use an exclusive check
(e.g., require questionType === "get_mcq" or otherwise ensure output_mcq
handling is mutually exclusive) and convert the following blocks into
else/else-if branches so that when the MCQ branch runs the Short/Boolean
branches are skipped; locate and modify the block manipulating combinedQaPairs
and reading qaPairsFromStorage["output"] / qaPairsFromStorage["output_mcq"] to
enforce a single-path processing per entry.

---

Nitpick comments:
In `@eduaid_web/src/pages/Output.jsx`:
- Around line 20-31: Replace the direct DOM lookup in the useEffect by creating
a React ref (e.g., pdfDropdownRef via useRef) and attaching it to the dropdown
element instead of the id "pdfDropdown"; update handleClickOutside to use
pdfDropdownRef.current (check for null) and event.target.closest checks as
before, and keep the existing event listener registration and cleanup in the
useEffect so you remove the listener on unmount.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7882cd85-7a50-4bab-a736-35928d451d72

📥 Commits

Reviewing files that changed from the base of the PR and between 2038116 and 501384b.

⛔ Files ignored due to path filters (1)
  • eduaid_web/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • eduaid_web/src/pages/Output.jsx

Comment thread eduaid_web/src/pages/Output.jsx Outdated
Comment thread eduaid_web/src/pages/Output.jsx Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@eduaid_web/src/pages/Output.jsx`:
- Around line 266-273: The save flow for question-only edits is overwriting
boolean rows with empty answer/options because handleSaveQuestion writes
editedAnswer/editedOptions even when the editor doesn't expose them; change
handleSaveQuestion to only update fields that have been edited (e.g., if
editedAnswer or editedOptions are null/undefined/not-modified, keep the original
item's answer and options) or explicitly preserve the existing item's
answer/options from the items array when applying the updated question (use the
original item at index to copy answer/options for mixed/boolean rows); ensure
editedQuestion is the only field changed when the UI only shows the textarea,
and avoid writing answer: "" or options: [] back into the saved object.
- Around line 113-167: The current if/else-if chain around qaPairsFromStorage
(symbols: combinedQaPairs, qaPairsFromStorage, output_boolq, output_mcq,
output_shortq, questionType) causes early exit when output_boolq exists and
drops other sections; change the logic so each output_* section is processed
independently (use separate if blocks or iterate each key rather than mutually
exclusive else-if) and append MCQ items (map qaPairsFromStorage["output_mcq"] or
qaPairsFromStorage["output"] when questionType is "get_mcq" to question_type
"MCQ"), Boolean items (from output_boolq to question_type "Boolean"), and short
answer items (output_shortq or generic output to question_type "Short") into
combinedQaPairs, preserving options/answer/context fields and existing field
fallbacks (question, question_statement, Question, Answer) so mixed quizzes
include all question types.
- Around line 222-227: The shuffle button is icon-only and needs an accessible
name: update the button element that uses onClick={handleShuffleQuestions} and
contains the FiShuffle icon to include an accessible label (e.g., add
aria-label="Shuffle questions" or aria-labelledby pointing to a visible label,
or a title attribute) so assistive technologies can announce it; ensure the
label text clearly describes the action (e.g., "Shuffle questions") and keep it
in the same button element.
- Around line 196-205: The success path in generateGoogleForm expects an object
but apiClient.post("/generate_gform", { qa_pairs: qaPairs, question_type:
questionType }) actually returns the responder URL string; change the success
handling to treat the returned value as a string (open the returned URL directly
rather than result.form_link) and optionally validate it (e.g., ensure it's a
non-empty string) before calling window.open to avoid opening blank tabs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7e8467a2-2c5b-4984-bed0-ac14271b27b0

📥 Commits

Reviewing files that changed from the base of the PR and between 501384b and e9d6547.

📒 Files selected for processing (1)
  • eduaid_web/src/pages/Output.jsx

Comment thread eduaid_web/src/pages/Output.jsx Outdated
Comment thread eduaid_web/src/pages/Output.jsx
Comment thread eduaid_web/src/pages/Output.jsx Outdated
Comment thread eduaid_web/src/pages/Output.jsx Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (4)
eduaid_web/src/pages/Output.jsx (4)

197-207: Empty and loading states lack styling.

The PR objective mentions "improved empty state UI," but these early returns render unstyled <div> elements. Consider adding consistent styling (e.g., centered layout, appropriate spacing, themed colors) to match the rest of the application's UI.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@eduaid_web/src/pages/Output.jsx` around lines 197 - 207, The loading and
empty states in the Output component render plain unstyled divs; update the
early returns that check loading and !qaPairs.length to use the app's consistent
UI styles — wrap them in the same container component or CSS classes used by
this page (e.g., a centered flex container, spacing/padding, and themed text
color), replace the bare text with a styled heading/paragraph and a styled Link
button to "/input", and ensure you apply any existing classes/components used
elsewhere in Output.jsx so the Loading and empty-state markup matches the rest
of the UI.

46-53: shuffledOptionsMap is computed but never used.

This memoized value computes shuffled options for each question but is not referenced anywhere in the render. If options display was intentionally removed, delete this code to avoid unnecessary computation on every qaPairs change.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@eduaid_web/src/pages/Output.jsx` around lines 46 - 53, The memoized variable
shuffledOptionsMap (created via useMemo using qaPairs and shuffleArray) is never
used; either remove this useMemo block entirely to avoid wasted computation, or
wire shuffledOptionsMap into the component where question options are rendered
(replace direct qaPair.options/qaPair.answer usage with
shuffledOptionsMap[index] in the render or pass it down to the child that
renders options). Locate the useMemo that defines shuffledOptionsMap and
implement one of these two fixes accordingly.

1-21: Remove dead code from removed PDF feature.

logoPNG (line 3) is imported but never used in the component. pdfDropdownRef (line 20) and its associated click-outside handler (lines 22-35) reference a dropdown element that no longer exists in the JSX after PDF functionality was removed.

♻️ Proposed cleanup
-import React, { useState, useEffect, useMemo, useRef } from "react";
+import React, { useState, useEffect, useMemo } from "react";
 import "../index.css";
-import logoPNG from "../assets/aossie_logo_transparent.png";
 import { Link } from "react-router-dom";
 import apiClient from "../utils/apiClient";
 import { FiShuffle, FiEdit2, FiCheck, FiX } from "react-icons/fi";

And remove lines 20-35 (the pdfDropdownRef declaration and its useEffect).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@eduaid_web/src/pages/Output.jsx` around lines 1 - 21, Remove dead PDF-related
code: delete the unused import symbol logoPNG from the top import list, remove
the pdfDropdownRef declaration (useRef) and remove the associated click-outside
useEffect that references pdfDropdownRef and the dropdown element; search for
any remaining references to pdfDropdownRef or a PDF dropdown click handler in
the Output component (e.g., the useEffect that adds/removes the mousedown
listener) and remove them so there are no dangling references.

90-94: handleOptionChange is defined but never called.

This handler updates editedOptions, but the edit UI only renders a textarea for the question—no input fields call this function. Either remove this dead code or restore the options editing UI.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@eduaid_web/src/pages/Output.jsx` around lines 90 - 94, The handler
handleOptionChange and the editedOptions state are unused; either remove them
and any related unused state/vars (editedOptions, setEditedOptions,
handleOptionChange) or restore the options editing UI so the function is
actually invoked. If restoring, render input fields (or textareas) for each
option within the edit mode (e.g., map over current question.options) and call
handleOptionChange(index, newValue) from their onChange, and ensure
editedOptions is initialized from the question options and persisted on save; if
removing, also clean up any imports/props tied to option editing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@eduaid_web/src/pages/Output.jsx`:
- Around line 228-245: The icon-only edit/save/cancel buttons (buttons that call
handleEditQuestion, handleSaveQuestion, handleCancelEdit and render FiEdit2,
FiCheck, FiX) lack accessible names; add clear accessible labels by giving each
button an aria-label (e.g., aria-label="Edit question", "Save changes", "Cancel
edit") or include visually-hidden text inside the button so screen readers can
announce them, ensuring the labels match the action and remain localized if
needed.
- Around line 148-172: The boolean questions are being added twice because after
the Boolean branch (when questionType === "get_boolq") the Short branch still
runs; update the Short-questions condition to exclude boolean type (e.g., change
the check used before iterating data.output in the Short block so it only runs
when questionType !== "get_mcq" && questionType !== "get_boolq") so that when
questionType === "get_boolq" only the Boolean branch (the first
data.output.forEach that sets question_type: "Boolean") executes and no
duplicate pushes to combined occur.
- Around line 220-250: The current question rendering only shows qa.question and
ignores other fields; update the qaPairs.map rendering (and its edit mode
handling around editingIndex, editedQuestion, handleEditQuestion,
handleSaveQuestion, handleCancelEdit) to display question type (e.g., qa.type),
context (qa.context), and for MCQs render the options list (use
shuffledOptionsMap when showing shuffled order) with the correct answer
highlighted or labeled; in edit mode expose and bind inputs for answers/options
and the question type so options and the correct answer can be edited and saved
via handleSaveQuestion; remove or repurpose the unused shuffledOptionsMap if you
decide not to use shuffling to avoid dead code.

---

Nitpick comments:
In `@eduaid_web/src/pages/Output.jsx`:
- Around line 197-207: The loading and empty states in the Output component
render plain unstyled divs; update the early returns that check loading and
!qaPairs.length to use the app's consistent UI styles — wrap them in the same
container component or CSS classes used by this page (e.g., a centered flex
container, spacing/padding, and themed text color), replace the bare text with a
styled heading/paragraph and a styled Link button to "/input", and ensure you
apply any existing classes/components used elsewhere in Output.jsx so the
Loading and empty-state markup matches the rest of the UI.
- Around line 46-53: The memoized variable shuffledOptionsMap (created via
useMemo using qaPairs and shuffleArray) is never used; either remove this
useMemo block entirely to avoid wasted computation, or wire shuffledOptionsMap
into the component where question options are rendered (replace direct
qaPair.options/qaPair.answer usage with shuffledOptionsMap[index] in the render
or pass it down to the child that renders options). Locate the useMemo that
defines shuffledOptionsMap and implement one of these two fixes accordingly.
- Around line 1-21: Remove dead PDF-related code: delete the unused import
symbol logoPNG from the top import list, remove the pdfDropdownRef declaration
(useRef) and remove the associated click-outside useEffect that references
pdfDropdownRef and the dropdown element; search for any remaining references to
pdfDropdownRef or a PDF dropdown click handler in the Output component (e.g.,
the useEffect that adds/removes the mousedown listener) and remove them so there
are no dangling references.
- Around line 90-94: The handler handleOptionChange and the editedOptions state
are unused; either remove them and any related unused state/vars (editedOptions,
setEditedOptions, handleOptionChange) or restore the options editing UI so the
function is actually invoked. If restoring, render input fields (or textareas)
for each option within the edit mode (e.g., map over current question.options)
and call handleOptionChange(index, newValue) from their onChange, and ensure
editedOptions is initialized from the question options and persisted on save; if
removing, also clean up any imports/props tied to option editing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2c9a0715-b528-43fc-a9b2-ca86054bd7bf

📥 Commits

Reviewing files that changed from the base of the PR and between e9d6547 and fdbb832.

📒 Files selected for processing (1)
  • eduaid_web/src/pages/Output.jsx

Comment thread eduaid_web/src/pages/Output.jsx Outdated
Comment on lines +220 to +250
{qaPairs.map((qa, i) => {
const isEditing = editingIndex === i;

{/* Action Buttons - Responsive layout */}
<div className="flex flex-col sm:flex-row items-center justify-center gap-4 sm:gap-6 mx-4 sm:mx-auto pb-4 sm:pb-6">
<button
className="bg-[#518E8E] items-center flex gap-1 w-full sm:w-auto font-semibold text-white px-4 sm:px-6 py-3 sm:py-2 rounded-xl text-sm sm:text-base hover:bg-[#3a6b6b] active:scale-95 active:bg-[#2f5555] transition-all justify-center"
onClick={generateGoogleForm}
>
Generate Google form
</button>

<div className="relative w-full sm:w-auto">
<button
className="bg-[#518E8E] items-center flex gap-1 w-full sm:w-auto font-semibold text-white px-4 sm:px-6 py-3 sm:py-2 rounded-xl text-sm sm:text-base hover:bg-[#3a6b6b] active:scale-95 active:bg-[#2f5555] transition-all justify-center"
onClick={() => document.getElementById('pdfDropdown').classList.toggle('hidden')}
>
Generate PDF
</button>

<div
id="pdfDropdown"
className="hidden absolute bottom-full mb-1 left-0 sm:left-auto right-0 sm:right-auto bg-[#02000F] shadow-md text-white rounded-lg shadow-lg z-50 w-full sm:w-48"
>
<button
className="block w-full text-left px-4 py-2 hover:bg-gray-500 active:bg-gray-600 active:scale-95 text-sm sm:text-base"
onClick={() => generatePDF('questions')}
>
Questions Only
return (
<div key={i}>
{!isEditing ? (
<>
<p>{qa.question}</p>
<button onClick={() => handleEditQuestion(i)}>
<FiEdit2 />
</button>
<button
className="block w-full text-left px-4 py-2 hover:bg-gray-500 active:bg-gray-600 active:scale-95 text-sm sm:text-base"
onClick={() => generatePDF('questions_answers')}
>
Questions with Answers
</>
) : (
<>
<textarea
value={editedQuestion}
onChange={(e) =>
setEditedQuestion(e.target.value)
}
/>
<button onClick={() => handleSaveQuestion(i)}>
<FiCheck />
</button>
<button
className="block w-full text-left px-4 py-2 hover:bg-gray-500 active:bg-gray-600 active:scale-95 text-sm sm:text-base"
onClick={() => generatePDF('answers')}
>
Answers Only
<button onClick={handleCancelEdit}>
<FiX />
</button>
</div>
</div>
</>
)}
</div>
</div>
</div>
);
})}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if there's a separate detailed view or if this is intentional simplification
rg -n "options|answer" eduaid_web/src/pages/Output.jsx -B2 -A2

Repository: AOSSIE-Org/EduAid

Length of output: 1399


🏁 Script executed:

#!/bin/bash
# Check if shuffledOptionsMap is actually used anywhere in the file
rg -n "shuffledOptionsMap" eduaid_web/src/pages/Output.jsx

Repository: AOSSIE-Org/EduAid

Length of output: 108


🏁 Script executed:

#!/bin/bash
# Look at the complete render structure to see if answers/options are displayed elsewhere
sed -n '200,300p' eduaid_web/src/pages/Output.jsx | cat -n

Repository: AOSSIE-Org/EduAid

Length of output: 1846


🏁 Script executed:

#!/bin/bash
# Check the component's imports and overall structure
head -50 eduaid_web/src/pages/Output.jsx | cat -n

Repository: AOSSIE-Org/EduAid

Length of output: 2079


🏁 Script executed:

#!/bin/bash
# Check total file length
wc -l eduaid_web/src/pages/Output.jsx

Repository: AOSSIE-Org/EduAid

Length of output: 96


🏁 Script executed:

#!/bin/bash
# Search for any references to question_type or context in the display/render
rg -n "question_type|context" eduaid_web/src/pages/Output.jsx | grep -v "const\|=\|localStorage"

Repository: AOSSIE-Org/EduAid

Length of output: 440


Questions render without answers, options, type indicators, or context.

The UI only displays qa.question. Several data fields present in the data structures are never rendered:

  • MCQ options and correct answers
  • Question type indicators (MCQ, Boolean, Short) — problematic given mixed question types are supported
  • Context information

The edit mode exacerbates this by only exposing question text editing despite maintaining state for answers and options. Additionally, shuffledOptionsMap is computed but never used (dead code).

For a quiz output page where users need to review and refine generated questions, this is a significant UX regression.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@eduaid_web/src/pages/Output.jsx` around lines 220 - 250, The current question
rendering only shows qa.question and ignores other fields; update the
qaPairs.map rendering (and its edit mode handling around editingIndex,
editedQuestion, handleEditQuestion, handleSaveQuestion, handleCancelEdit) to
display question type (e.g., qa.type), context (qa.context), and for MCQs render
the options list (use shuffledOptionsMap when showing shuffled order) with the
correct answer highlighted or labeled; in edit mode expose and bind inputs for
answers/options and the question type so options and the correct answer can be
edited and saved via handleSaveQuestion; remove or repurpose the unused
shuffledOptionsMap if you decide not to use shuffling to avoid dead code.

Comment thread eduaid_web/src/pages/Output.jsx Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant