Skip to content

[FEATURE]: View full quiz history with Show More / Show Less#645

Closed
Ashvin-KS wants to merge 2 commits intoAOSSIE-Org:mainfrom
Ashvin-KS:feat/full-quiz-history-show-more
Closed

[FEATURE]: View full quiz history with Show More / Show Less#645
Ashvin-KS wants to merge 2 commits intoAOSSIE-Org:mainfrom
Ashvin-KS:feat/full-quiz-history-show-more

Conversation

@Ashvin-KS
Copy link
Copy Markdown
Contributor

@Ashvin-KS Ashvin-KS commented Mar 29, 2026

Addressed Issues:
Implements issue #641 by allowing users to store all generated quizzes in history and view them with a Show More / Show Less toggle.

Fixes #641

Screenshots/Recordings:
Not attached from CLI environment.

Additional Notes:
This PR updates Quiz Dashboard history behavior while preserving existing localStorage compatibility.

Key Improvements:

  • Removed the hard cap that truncated stored history to only the latest 5 quizzes
  • Kept backward compatibility by continuing to use the existing localStorage key
  • Added robust parsing safeguards for malformed localStorage data
  • Added Show More / Show Less toggle on Quiz Dashboard (default view: latest 5 quizzes)
  • Preserved existing behavior for opening a selected quiz and clearing history

AI Usage Disclosure:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.
  • AI models/tools used: GitHub Copilot (GPT-5.3-Codex)

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • I have filled this PR template completely and carefully, and I understand that my PR may be closed without review otherwise.

Validation:

  • npm --prefix eduaid_web run build (successful)
  • Existing project lint warnings are unchanged and unrelated to this feature

Summary by CodeRabbit

Release Notes

  • New Features

    • Added "Show More/Show Less" toggle button to easily expand and collapse the quiz history list, allowing users to view all quizzes or just the 5 most recent ones for optimal interface readability.
  • Bug Fixes

    • Improved quiz history reliability with enhanced error handling and automatic recovery mechanisms for corrupted or invalid stored data.
    • Cleared quiz history now properly resets the list view to collapsed state.

Copilot AI review requested due to automatic review settings March 29, 2026 12:13
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 29, 2026

Warning

Rate limit exceeded

@Ashvin-KS has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 40 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 13 minutes and 40 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: 110c132f-c725-44d9-8855-ecbd8b662b20

📥 Commits

Reviewing files that changed from the base of the PR and between e2b18ee and b02803c.

📒 Files selected for processing (3)
  • eduaid_web/src/pages/Previous.jsx
  • eduaid_web/src/pages/Text_Input.jsx
  • eduaid_web/src/utils/quizHistoryStorage.js
📝 Walkthrough

Walkthrough

The changes implement functionality to display all stored quizzes with a "Show More/Show Less" toggle, replacing the previous 5-quiz limit. A new helper function safely retrieves quiz history from local storage, removing the automatic truncation logic.

Changes

Cohort / File(s) Summary
Quiz Display Toggle
eduaid_web/src/pages/Previous.jsx
Added showAllQuizzes state and quizzesToDisplay computed value to conditionally render all quizzes or only the most recent 5. Introduced DEFAULT_VISIBLE_QUIZZES constant, enhanced getQuizzesFromLocalStorage with defensive error handling and empty array fallback, and added a conditional "Show More/Show Less" button. Updated handleClearQuizzes to reset toggle state.
Quiz History Storage
eduaid_web/src/pages/Text_Input.jsx
Extracted quiz history retrieval logic into new getQuizHistoryFromLocalStorage() helper with safe JSON parsing and array validation. Refactored sendToBackend to use the helper and removed the enforced max-5 quiz limit that previously shifted oldest entries.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A burrow of quizzes, once hidden away,
Now blossoms with "Show More"—hip, hip, hooray!
Five became many, defensive and tight,
Safe parsing shines bright through the storage's dark night!
No truncation, just joy—all the quizzes in sight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main feature: Show More/Show Less toggle for quiz history. It directly aligns with the primary change in the changeset.
Linked Issues check ✅ Passed All coding requirements from issue #641 are met: storing all quizzes (Text_Input.jsx), adding Show More/Show Less toggle (Previous.jsx), handling malformed data safely, maintaining backward compatibility, and preserving existing behavior.
Out of Scope Changes check ✅ Passed All changes are focused on implementing the Show More/Show Less feature and supporting full quiz history storage. No unrelated modifications were introduced outside the scope of issue #641.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements issue #641 by persisting the full quiz generation history (instead of truncating to 5) while keeping the existing localStorage key and adding a “Show More / Show Less” toggle on the Quiz Dashboard.

Changes:

  • Remove the “keep only last 5 quizzes” cap when writing quiz history to localStorage.
  • Add safer parsing/cleanup for malformed quiz history stored under last5Quizzes.
  • Add a Show More / Show Less toggle to default the dashboard view to the latest 5 quizzes while allowing access to all history.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
eduaid_web/src/pages/Text_Input.jsx Stops truncating stored history; adds parsing helper for last5Quizzes and appends new quiz entries.
eduaid_web/src/pages/Previous.jsx Adds robust history parsing, computes a default “latest 5” view, and introduces a Show More / Show Less toggle plus state reset on clear.
Comments suppressed due to low confidence (1)

eduaid_web/src/pages/Previous.jsx:44

  • handleQuizClick writes quiz.qaPair into qaPairs without validating it. If quiz.qaPair is missing/undefined (e.g., corrupted localStorage array entries), this can result in qaPairs being set to the string "undefined", and Output.jsx later does an unguarded JSON.parse(localStorage.getItem("qaPairs")) which will throw. Add a guard/fallback (and/or remove the bad history entry) and wrap the setItem/parse path in try/catch so navigation to /output can't be triggered with invalid JSON.
  const handleQuizClick = (quiz) => {
    localStorage.setItem("qaPairs", JSON.stringify(quiz.qaPair));
    navigate('/output'); 
  };

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread eduaid_web/src/pages/Previous.jsx Outdated
}
};

const [quizzes, setQuizzes] = React.useState(getQuizzesFromLocalStorage());
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

React.useState(getQuizzesFromLocalStorage()) eagerly reads/parses localStorage on every render because the function is being invoked. Use a lazy initializer (useState(() => getQuizzesFromLocalStorage()) or pass the function directly) so parsing only happens on the initial render.

Suggested change
const [quizzes, setQuizzes] = React.useState(getQuizzesFromLocalStorage());
const [quizzes, setQuizzes] = React.useState(getQuizzesFromLocalStorage);

Copilot uses AI. Check for mistakes.
Comment thread eduaid_web/src/pages/Previous.jsx Outdated
Comment on lines 14 to 32
const getQuizzesFromLocalStorage = () => {
const quizzes = localStorage.getItem("last5Quizzes");
return quizzes ? JSON.parse(quizzes) : [];
if (!quizzes) {
return [];
}

try {
const parsedQuizzes = JSON.parse(quizzes);
if (Array.isArray(parsedQuizzes)) {
return parsedQuizzes;
}

localStorage.removeItem("last5Quizzes");
return [];
} catch {
localStorage.removeItem("last5Quizzes");
return [];
}
};
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

The robust localStorage parsing logic here duplicates the same pattern introduced in Text_Input.jsx. To avoid the two implementations drifting over time, consider extracting a shared helper (e.g., utils/quizHistoryStorage.js) and a shared key constant for "last5Quizzes" so all reads/writes go through one codepath.

Copilot uses AI. Check for mistakes.
Comment thread eduaid_web/src/pages/Text_Input.jsx Outdated
Comment on lines 142 to 146
const quizHistory = getQuizHistoryFromLocalStorage();
quizHistory.push(quizDetails);
localStorage.setItem("last5Quizzes", JSON.stringify(quizHistory));

navigate("/output");
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

Now that history is unbounded, localStorage.setItem("last5Quizzes", ...) is more likely to hit browser storage limits and throw (QuotaExceededError), which will prevent navigation to /output and only log Error:. Consider handling quota failures explicitly (e.g., catch around setItem, optionally trimming oldest entries or skipping history write) so quiz generation still succeeds even if history can't be persisted.

Copilot uses AI. Check for mistakes.
Comment thread eduaid_web/src/pages/Text_Input.jsx Outdated
Comment on lines +102 to +120
const getQuizHistoryFromLocalStorage = () => {
const storedQuizzes = localStorage.getItem("last5Quizzes");
if (!storedQuizzes) {
return [];
}

try {
const parsedQuizzes = JSON.parse(storedQuizzes);
if (Array.isArray(parsedQuizzes)) {
return parsedQuizzes;
}

localStorage.removeItem("last5Quizzes");
return [];
} catch {
localStorage.removeItem("last5Quizzes");
return [];
}
};
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

The localStorage parsing/cleanup helper introduced here is effectively duplicated in Previous.jsx. Extracting it into a shared utility and reusing it for both reading history (dashboard) and appending history (quiz generation) will reduce maintenance risk and keep parsing/cleanup behavior consistent.

Copilot uses AI. Check for mistakes.
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: 1

🧹 Nitpick comments (2)
eduaid_web/src/pages/Previous.jsx (1)

97-111: Consider adding unique IDs to quizzes for stable React keys.

Using index as a key works here but could cause subtle rendering issues when toggling between Show More/Show Less, as the indices change for the same quiz items. A more robust solution would be to generate a unique ID (e.g., Date.now() or crypto.randomUUID()) when creating each quiz in Text_Input.jsx.

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

In `@eduaid_web/src/pages/Previous.jsx` around lines 97 - 111, The list uses index
as a React key in quizzesToDisplay.map (key={index}), which is unstable when
items reorder; update quiz objects to include a unique id when created (e.g.,
set id via crypto.randomUUID() or Date.now() in the quiz creation logic in
Text_Input.jsx) and change the list to use that id as the key (and ensure
handleQuizClick(quiz) continues to receive the quiz object with id). Locate quiz
creation in Text_Input.jsx, add a stable id field to each quiz, and replace
key={index} with key={quiz.id} in Previous.jsx.
eduaid_web/src/pages/Text_Input.jsx (1)

102-120: Defensive parsing looks good; consider extracting to a shared utility.

The safeguards for malformed localStorage data are well-implemented. However, this function is nearly identical to getQuizzesFromLocalStorage in Previous.jsx (lines 14-32). Consider extracting this into a shared utility (e.g., src/utils/quizStorage.js) to avoid duplication.

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

In `@eduaid_web/src/pages/Text_Input.jsx` around lines 102 - 120, Duplicate
localStorage parsing logic exists in getQuizHistoryFromLocalStorage and
getQuizzesFromLocalStorage; extract this logic into a shared utility function
(e.g., export function safeParseQuizzes or getQuizzesFromLocalStorage in a new
module) that performs the getItem, JSON.parse, Array.isArray check, and removal
on error, then import and use that function from Text_Input.jsx and Previous.jsx
to remove duplication and centralize error handling.
🤖 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/Text_Input.jsx`:
- Around line 142-144: The current web code appends quizzes unbounded to
quizHistory (getQuizHistoryFromLocalStorage / quizHistory /
localStorage.setItem("last5Quizzes"...)), risking localStorage quota issues and
diverging from the extension which trims to 5; change the logic to enforce a
clear cap (e.g., MAX_QUIZZES = 100, or match extension’s MAX_QUIZZES) after
pushing quizDetails by trimming older entries (shift/pop) so both web and
extension share the same behavior, rename the storage key from "last5Quizzes" to
"quizHistory", and add a migration step in getQuizHistoryFromLocalStorage that
reads "last5Quizzes" if present, converts it to the new key, and preserves/trims
entries to the cap before saving.

---

Nitpick comments:
In `@eduaid_web/src/pages/Previous.jsx`:
- Around line 97-111: The list uses index as a React key in quizzesToDisplay.map
(key={index}), which is unstable when items reorder; update quiz objects to
include a unique id when created (e.g., set id via crypto.randomUUID() or
Date.now() in the quiz creation logic in Text_Input.jsx) and change the list to
use that id as the key (and ensure handleQuizClick(quiz) continues to receive
the quiz object with id). Locate quiz creation in Text_Input.jsx, add a stable
id field to each quiz, and replace key={index} with key={quiz.id} in
Previous.jsx.

In `@eduaid_web/src/pages/Text_Input.jsx`:
- Around line 102-120: Duplicate localStorage parsing logic exists in
getQuizHistoryFromLocalStorage and getQuizzesFromLocalStorage; extract this
logic into a shared utility function (e.g., export function safeParseQuizzes or
getQuizzesFromLocalStorage in a new module) that performs the getItem,
JSON.parse, Array.isArray check, and removal on error, then import and use that
function from Text_Input.jsx and Previous.jsx to remove duplication and
centralize error handling.
🪄 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: ea884d8b-dbc7-4ebd-bca0-c169b42c1b55

📥 Commits

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

📒 Files selected for processing (2)
  • eduaid_web/src/pages/Previous.jsx
  • eduaid_web/src/pages/Text_Input.jsx

Comment thread eduaid_web/src/pages/Text_Input.jsx Outdated
Comment on lines +142 to +144
const quizHistory = getQuizHistoryFromLocalStorage();
quizHistory.push(quizDetails);
localStorage.setItem("last5Quizzes", JSON.stringify(quizHistory));
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 | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify the extension still has the 5-quiz cap logic
rg -n "last5Quizzes" --glob "extension/**/*.jsx" -A 3 -B 1

Repository: AOSSIE-Org/EduAid

Length of output: 1668


Unbounded quiz history may hit localStorage quota; web/extension now diverge.

Two concerns with removing the cap:

  1. localStorage limits: With no upper bound, users who generate many quizzes over time could eventually exceed the ~5MB localStorage quota, causing silent failures. Consider adding a reasonable cap (e.g., 50-100 quizzes) or implementing a cleanup strategy.

  2. Web/extension inconsistency: The extension (extension/src/pages/text_input/TextInput.jsx:159-164) still enforces the 5-quiz limit via .shift(). If users switch between web and extension, they'll experience different behaviors and potentially lose history sync.

Additionally, the localStorage key "last5Quizzes" is now misleading since the web version stores all quizzes. Consider renaming to "quizHistory" (with a migration path for existing users).

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

In `@eduaid_web/src/pages/Text_Input.jsx` around lines 142 - 144, The current web
code appends quizzes unbounded to quizHistory (getQuizHistoryFromLocalStorage /
quizHistory / localStorage.setItem("last5Quizzes"...)), risking localStorage
quota issues and diverging from the extension which trims to 5; change the logic
to enforce a clear cap (e.g., MAX_QUIZZES = 100, or match extension’s
MAX_QUIZZES) after pushing quizDetails by trimming older entries (shift/pop) so
both web and extension share the same behavior, rename the storage key from
"last5Quizzes" to "quizHistory", and add a migration step in
getQuizHistoryFromLocalStorage that reads "last5Quizzes" if present, converts it
to the new key, and preserves/trims entries to the cap before saving.

@Ashvin-KS
Copy link
Copy Markdown
Contributor Author

Added a follow-up commit to address review feedback:

  • Refactored quiz history read/write/clear logic into a shared utility:
    • eduaid_web/src/utils/quizHistoryStorage.js
  • Updated Previous page to use lazy state initialization for history loading.
  • Added quota-safe persistence fallback for history writes so quiz generation can continue even when localStorage is near capacity.
  • Reused shared storage logic in both Text_Input and Previous to avoid drift.

Build validation:

  • npm --prefix eduaid_web run build (successful)
  • Existing lint warnings are unchanged and unrelated to this PR.

@Ashvin-KS Ashvin-KS closed this Mar 30, 2026
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.

[FEATURE]: Ability to view all the past quizess instead of just recent 5

2 participants