Skip to content

Bug: "forEach" error for "all type" questions due to missing "output" key in qaPairs #221

@ts-31

Description

@ts-31

Description:
When generating "all type" questions, the application throws a TypeError:
TypeError: Cannot read properties of undefined (reading 'forEach')

Steps to Reproduce:

Generate questions using the "all type" option.
Observe that the code attempts to iterate over qaPairsFromStorage["output"] using .forEach().
Expected Behavior:
For "all type" questions, the application should merge question data from the keys "output_boolq", "output_mcq", and "output_shortq" rather than expecting a non-existent "output" key.

Actual Behavior:
The code falls into a branch that calls .forEach() on qaPairsFromStorage["output"], which is undefined when the question type is "all type".

Proposed Fix:
Update the useEffect hook that reads qaPairs from localStorage to explicitly check for and merge data from the correct keys (i.e., "output_boolq", "output_mcq", and "output_shortq") when "all type" is selected.

Please let me know if you need further clarification.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions