martin-markovic / learn-connect

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

Implement rest of quiz CRUD functionality #24

Closed martin-markovic closed 1 month ago

martin-markovic commented 1 month ago

Summary

This pull request enhances the quiz management capabilities by integrating update and delete functionalities. It includes refactoring the deleteQuiz function, removing redundant code, implementing ID validation, and refining state management in quizSlice.js and Quizzes.jsx.

Changes

  1. Controller Updates

    • Refactored deleteQuiz to await the deleteOne method and respond with the deleted quiz ID in quizController.js.
  2. Service Cleanup

    • Removed the redundant editQuiz function and export in quizService.js.
  3. Redux and State Management

    • Removed redundant state properties and editQuiz thunk in quizSlice.js.
    • Implemented ID validation and response handling for updateQuiz thunk in quizSlice.js.
    • Implemented ID validation and response handling for deleteQuiz thunk in quizSlice.js.
    • Refactored extra reducers to match the semantic origin of thunks in quizSlice.js.
    • Removed redundant extra reducer cases for editQuiz thunk in quizSlice.js.
  4. Component Integration

    • Refactored quizFormData, localQuizzes, and quizQuery state management in Quizzes.jsx.
    • Integrated dispatching of updateQuiz and deleteQuiz actions to matching handlers in Quizzes.jsx.
    • Integrated edit handlers for managing quiz editing state in Quizzes.jsx.
    • Implemented conditional quiz rendering based on the isEditing state and the length of localQuizzes in Quizzes.jsx.

Testing

Additional Information