martin-markovic / learn-connect

Multi-feature platform designed to enhance the online learning experience.
MIT License
0 stars 0 forks source link

Enhance Quiz Management with User and Classroom Separation #26

Closed martin-markovic closed 1 month ago

martin-markovic commented 1 month ago

Summary

This pull request refactors the quiz management functionality to separate user and classroom quizzes, implements new components for handling and rendering quizzes, and integrates classroom-specific validation and state management.

Changes

  1. State Management

    • Separated initialState into user and class quizzes in quizSlice.js.
    • Refactored getQuizzes thunk into getUserQuizzes to fetch user quizzes and updated state handling.
    • Implemented getClassQuizzes thunk for fetching class quizzes and added corresponding state handling cases.
    • Refactored function names to match changes in quizService.js.
  2. Component Updates

    • Moved state management from Quizzes.jsx to a new component UserQuizList.jsx.
    • Implemented ClassQuizList.jsx to handle client-side logic, state management, and quiz rendering.
    • Integrated UserQuizList.jsx and ClassQuizList.jsx into Quizzes.jsx.
  3. Schema and Model Enhancements

    • Defined a classroom schema with required fields and created a Classroom model.
    • Separated scoreSchema into a new module and added a new classroom field to quizSchema.
    • Implemented quizScoreSchema and integrated it into userSchema, including a classroom reference in the Classroom model.
    • Integrated input validation, user and classroom ID matching into the createQuiz function.
  4. API and Backend Enhancements

    • Implemented a new function getQuizzesByClassroom to fetch quizzes based on user and quiz ID, and classroom enrollment.
    • Integrated getQuizzesByClassroom into a new API endpoint in quizRoutes.js.
  5. Component and State Integration

    • Implemented Classroom.jsx to manage and render classroom quizzes.
    • Integrated redux state handling, input field validation, and new HTML input elements to reflect classroom schema addition in QuizForm.jsx.
    • Integrated the Classroom component into Dashboard.jsx.

Testing

Additional Information