CSC/ECE 517 Fall 2024 - E2450. Refactor assignments controller.rb
About Controller
The `AssignmentsController` handles actions related to managing assignments.Key functionalities include initializing a new assignment in the `new` action and creating assignments through the `create` action, with validations to prevent duplicate names and directory paths. If creation succeeds, it redirects appropriately; otherwise, it renders the form with errors. This controller ensures smooth assignment management by enforcing proper validations and access control throughout the process.
Functionality of assignments_controller
The `AssignmentsController` handles the management of assignments by providing actions for creating and initializing them while ensuring access control. It uses `before_action` callbacks to enforce authorization, ensuring only permitted users can interact with assignment-related features. The `new` action initializes a blank assignment object for form rendering, facilitating the creation of new assignments. Additionally, the `create` action is responsible for processing form submissions, validating input, and saving the assignment if it meets the criteria. This controller ensures that all assignment operations are secure, properly initialized, and follow the required business logic.
Problem Statement
The `assignments_controller` presents difficulties due to its large size, intricate structure, and absence of comments, making it challenging for developers to grasp its functionality. To address these issues, a thorough refactor is advised, breaking down lengthy methods into smaller, more manageable sections. This strategy would modularize complex logic, assigning specific tasks to individual parts within the controller’s responsibilities. Furthermore, the refactor should aim to remove redundant code by consolidating repetitive sections into reusable functions or utilities, enhancing code quality and reducing the risk of errors. By restructuring the controller and improving its documentation, developers can better understand its operations, making maintenance, debugging, and future updates more straightforward.
Tasks
1. Refactor create method
2. Refactor edit method
3. Refactor update method
4. Refactor delete method: New models for subclasses will be implemented to streamline organization and simplify management.
5. Reposition methods
6. Enhance Comments
7. Expand Test Coverage
Phase 1
- Clarify and Refactor exist_assignment variable.
- Clarify aq Parameter Naming in list_unassigned_rubrics & remove_existing_questionnaire.
- Fixing the Github required checks.
- Refactor Variable Naming for Clarity.
- Review path Method Location.
- Refactor Authorization Checks.
- Simplify Array Usage in Create Method.
- Refactor Method Names with 'Check'.
- Refactor query_participants_and_alert Method.
Test Cases
- To do
Implementation
Clarify and Refactor exist_assignment variable.
What
Todo.
Why
Todo
How
Todo
Clarify aq Parameter Naming in list_unassigned_rubrics & remove_existing_questionnaire
Original Code
- Todo
Updated Code
- Todo
Fixing the Github required checks
Original Code
- Todo
Updated Code
- Todo
Refactor Variable Naming for Clarity
Original Code
- Todo.
Updated Code
Todo
Review path Method Location
Original Code
- Todo
Updated Code
Todo
Refactor Authorization Checks
Original Code
- Todo.
Updated Code
- Todo.
Simplify Array Usage in Create Method
Original Code
- Todo.
Updated Code
- Todo.
Refactor Method Names with 'Check'
Original Code
- Todo.
Updated Code
- Todo.
Refactor query_participants_and_alert Method
Original Code
- Todo.
Updated Code
- Todo.
Team
Mentor
- Ameya Vaichalkar
Members
- Avleen Mehal
- Daksh Pratap Singh
- Abhinav Sharma