Quiz Data Fetching and Submission Logic Implementation#224
Merged
phertyameen merged 6 commits intoMindBlockLabs:mainfrom Jan 29, 2026
Merged
Conversation
- Replaced local state management with a custom hook `useQuiz` for better state handling. - Updated quiz page to utilize Redux for state management, including question fetching and answer submission. - Enhanced error and loading states for improved user experience. - Added API integration for fetching daily quests and submitting answers. - Refactored quiz logic to streamline question navigation and answer selection.
…r handling in auth and quiz components - Removed eslint-disable comments from various files for cleaner code. - Updated error handling in `CheckEmail`, `ForgotPassword`, and `ResetPassword` components to use a generic catch variable. - Adjusted import paths in quiz-related files for consistency. - Enhanced type definitions in quiz API response handling.
Member
|
Please checkout CONTRIBUTING.md for build test to fix build/cicd errors. |
Contributor
Author
|
ok, will resolve now |
- Updated the submission result display to show whether the answer was correct or incorrect, along with points earned. - Added a note regarding the backend's limitation in returning the correct option, emphasizing the highlighting of the selected answer only.
phertyameen
approved these changes
Jan 29, 2026
Member
phertyameen
left a comment
There was a problem hiding this comment.
Nice file structure overall. You should have highlighted that some backend endpoints were missing for testing (Please do that when contributing to projects. It helps alot). I will add some missing expected dtos the merge the pr.
Contributor
Author
|
ok. thanks for the reviews, and the comments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Implemented centralized quiz data-fetching and submission logic using Redux thunks and a custom
useQuizhook. This centralizes all API calls, state management, and provides a clean interface for UI components.Closes #158
Changes Made
New Files Created
frontend/lib/api/quizApi.tsfetchDailyQuest(),fetchPuzzles(),submitAnswer()frontend/hooks/useQuiz.tsquestions,currentQuestion,currentQuestionIndexselectedAnswerId,isLoading,isSubmitting,errorselectAnswer(),submitAnswer(),goToNextQuestion()Modified Files
frontend/lib/features/quiz/quizSlice.tsQuestioninterface to match backendPuzzleResponseDtoselectedAnswerId,isSubmitting,submissionResult,correctAnswersCountfetchQuestionsthunk to accept{ type: 'daily-quest' } | { type: 'category', categoryId: string, difficulty?: string }quizApisubmitAnswerThunkfor POST/puzzles/submitfrontend/app/quiz/page.tsxuseQuizhookstep,selectedId,isSubmitted,score,isFinished)MOCK_QUIZ)API Endpoints Used
GET /puzzles/daily-quest- Fetch daily quest puzzlesGET /puzzles?categoryId=X&difficulty=Y- Fetch puzzles by category and difficultyPOST /puzzles/submit- Submit answer and get validation resultData Flow
Key Features
isCorrectandpointsEarned- used for UI feedbackState Management
isCorrectandpointsEarnedAuthentication
localStorage.getItem('accessToken')subfield) for answer submissionTesting Checklist
/puzzles/daily-quest/puzzles?categoryId=X&difficulty=Y(via hook configuration)Notes
correctAnswerinPuzzleResponseDtofor security reasonsisCorrectfield)questionStartTimeto calculatetimeSpentfor each submission