CSC/ECE 517 Fall 2024 - E2484. Reimplement participants controller.rb

From Expertiza_Wiki
Revision as of 18:53, 11 November 2024 by Crjiang (talk | contribs) (→‎Patterns)
Jump to navigation Jump to search

About Expertiza

Expertiza is an open source project based on Ruby on Rails framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.

Introduction

This project aims to reimplement the participants_controller.rb and participants_helper.rb in the new Expertiza system. The participants_controller.rb manages participants within assignments, and this reimplementation focuses on streamlining its methods, eliminating redundancy, and enhancing code readability and maintainability.

Requirements

  • Implement participants_controller.rb Methods: Fully implement each controller method with the same functionality as the current controller.
  • Import from participants_helper.rb : Integrate relevant helper methods to streamline functionality and remove redundancy.
  • API Creation: Expose API endpoints for all necessary methods to enable seamless access and integration from the frontend. Ensure that each endpoint follows best practices for RESTful API design, including proper error handling and secure data access.
  • Testing with rswag: Create test cases for all methods, focusing on edge cases, and generate rswag documentation.
  • Swagger UI Video Documentation: Record a video walkthrough of API endpoints in Swagger UI, showcasing each method’s functionality.
  • Existing Issues

    Reimplement participants_controller.rb while addressing the following:

  • Refactor code to comply with the Open-Closed Principle.
  • Introduce dependency injection where necessary.
  • Reduce excessive conditional statements.
  • Include sufficient code tests to verify functionality.
  • Enhance comments to better explain each method's functionality, purpose, and rationale for keeping or modifying particular aspects of the code.
  • Provide a more detailed explanation of design choices and refactoring steps.
  • Design

    Patterns

    Facade: The participants_controller.rb uses the Facade Design Pattern to streamline interactions with the Expertiza backend, abstracting away complex logic and data handling tasks into a simplified API layer. A lot of calls to various services, objects, and features are abstracted, providing a unified, cohesive interface. By centralizing these calls, the controller can reduce dependencies on specific backend structures, making it easier for the front end to perform actions with minimal knowledge of what is going on in the backend, enhancing the maintainability and scalability of our codebase.

    SOLD Principles

    Open and Closed Principle: "Software entities should be open for extension, but closed for modification."
    Currently the code directly checks the type of curr_object to determine whether it’s an Assignment or Course, which can make it challenging to extend or modify. We plan on implementing polymorphism which could allow each class (e.g., Assignment, Course) to handle participant-related logic through inheritance or composition.

    API Calls

     #  Method Endpoint Description
    1 index GET /participants Return a list of participants
    2 show GET /participant/:id Return a specified participant
    3 inherit GET /participants/inherit Copy all participants from a course to an assignment
    4 bequeath GET /participants/bequeath Copy all participants from an assignment to a course
    5 create POST /participant Create a participant
    5 update_authorization PATCH /participant/:id/authorization Update the permissions of a participant
    6 update_handle PATCH /participant/:id/handle Update the handle of a participant
    7 destroy DELETE /participant/:id Destroy a specified participant

    Testing Plan

    Team

    Mentor

    • Jay Patel <jhpatel9@ncsu.edu>

    Students

    • Pierce Whelan <pwwhelan@ncsu.edu>
    • Calvin Jiang <crjiang@ncsu.edu>
    • Hechun Zhang <hzhang56@ncsu.edu>

    Relevant Links

    Pull Request [1]
    GitHub Repository [2]
    participants_controller.rb in Old Expertiza [3]