CSC/ECE 517 Spring 2024 - E2415. Reimplement responses controller.rb (Design Document)

From Expertiza_Wiki
Jump to navigation Jump to search

CSC/ECE 517 Spring 2024 - E2415: Reimplementation of responses_controller.rb (Design Document)

1.Expertiza

The Expertiza project, an open-source endeavor rooted in Ruby on Rails, embarks on continuous improvement to adapt and integrate modern software engineering practices. The Responses Controller is engineered to assist reviewers in submitting structured data that is specifically aligned with an assignment's rubrics, ensuring the provision of relevant questions for each round within the correct due date period. It enables a reviewer to evaluate and score the rubric questions pertinent to the assignment's topics. Furthermore, it ensures the delivery of appropriate questions for each assignment round, allowing reviewers to create and modify scores and comments for each of the rubric questions associated with the assignment. After reviewers submit their scored questions and comments, the Responses Controller dispatches an email notification to the instructor and the reviewed team's members.

2.Problem Statement

The ResponseController in Expertiza, a legacy system with conventions predating Rails standards, is overly complex, encompassing functionalities beyond basic CRUD operations and needing adherence to modern Rails naming and design principles. Key issues include the direct implementation of functionalities like sorting reviews and checking reviewer roles within the controller, suggesting a shift towards polymorphism and a more structured approach to code organization. Furthermore, the controller's handling of email notifications and feedback mechanisms is inconsistent, indicating the necessity for a dedicated helper to streamline communication processes. The reimplementation effort must focus on simplifying the controller, adhering to Rails conventions, and improving code readability and maintainability by appropriately distributing responsibilities.

3.Design Goal

The redesign of the `responses_controller.rb` is guided by several key objectives to improve the code quality, system behavior, and developer interaction. The goals include:

  • Maintainability and Scalability: Ensuring the code is easy to understand, modify, and extend. The reimplementation should simplify future updates and feature additions.
  • Adherence to Rails Best Practices: Following Rails conventions for naming, structure, and coding practices to ensure code consistency and reliability.
  • DRY Principle: "Don't Repeat Yourself" - removing redundant code and logic to create a more efficient and error-resistant codebase.
  • Single Responsibility Principle: Restructuring the controller and associated models so that each class and method has one purpose and one purpose only, leading to easier testing and management.
  • Improved Testing and Coverage: Enhancing test suites to cover more scenarios and edge cases, increasing confidence in the application's stability and performance.
  • Performance Optimization: Identifying and optimizing slow or inefficient areas in the code to ensure the application runs smoothly.
  • Clean Up Dead Methods: Audit the codebase for any unused ("dead") methods within the current controller and remove them to declutter the code.
  • Reduced Controller Complexity: We already have streamline the `ResponseController` to focus primarily on CRUD operations and extract non-essential logic to appropriate models or helpers, now we aim to implement the rest operations.

By meeting these design goals, the project aims to produce a `responses_controller.rb` that is robust, efficient, and a pleasure to work with, both for the current development team and for those who will maintain the system in the future.


4. Implementation

4.1 Model

Methods within the model were refactored or introduced, including:

  • 4.1.1 set_content
  • 4.1.2 validate_params
  • 4.1.3 serialize_response

4.2 Controller

Controller methods for CRUD operations were enhanced, comprising:

  • 4.2.1 Create
  • 4.2.2 Show
  • 4.2.3 Update
  • 4.2.4 Delete
  • 4.2.5 Questionnaire_from_response_map
  • 4.2.6 Questionnaire_from_response
  • 4.2.7 Create_answers
  • 4.2.8 Show_calibration_results_for_student
  • 4.2.9 Init_answers
  • 4.2.10 Save

5. Files Modified/Added

List of primary files modified or created includes:

  • responses_controller.rb
  • response_helper.rb
  • response.rb


6. Test Plan

The Model and Controller functions will be tested throughoughly.

1. Rspec unit tests will be used to test each function of the refactored and reimplemented functions to verify the expected responses are received for given inputs.

Unit tests will be written for the following model functions:
* set_content
* validate_params
* serialize_response
Unit tests will also be written for the controller functions:
* Create
* Show
* Update
* Delete
* Questionnaire_from_response_map
* Questionnaire_from_response
* Create_answers
* Show_calibration_results_for_student
* Init_answers
* Save

2. The Swagger UI will be utilized to make the controller functions accessible VIA API calls. This will allow for testing of the input and outputs of the API calls to the methods, and will function as integration tests.


7. Team

7.1 Mentor
  • Ameya Vaichalkar
7.2 Members
  • Jeff Riehle
  • Maday Moya
  • Jacob Leavitt

8. Links

Swagger Video Link:

Pull request: https://github.com/expertiza/reimplementation-back-end/pull/92

Model Tests Video:

Controller Tests Video:

References