CSC/ECE 517 Fall 2023 - E2370. Reimplement join team requests controller

From Expertiza_Wiki
Revision as of 01:24, 31 October 2023 by Mayyapp (talk | contribs)
Jump to navigation Jump to search

Expertiza

Expertiza is a Ruby on Rails based open source project. Instructors have the ability to add new projects, assignments, etc., as well as edit existing ones. Later on, they can view student submissions and grade them. Students can also use Expertiza to organize into teams to work on different projects and assignments and submit their work. They can also review other students' submissions.

Problem Statement

The controller join_team_requests_controller.rb contains functions to create, list, update, delete, and decline requests to join teams. This is a fairly straightforward controller with basic functionalities which is easily tested using Postman. The objective of this project was to change the operation of this controller to suit our API.

New Files

  1. app/controllers/join_team_requests_controller.rb
  2. app/models/join_team_requests.rb
  3. spec/requests/api/v1/join_team_requests_spec.rb

File Changes

#app/models/participant.rb
Original code

class Participant < ApplicationRecord
  belongs_to :user
  belongs_to :assignment, foreign_key: 'assignment_id', inverse_of: false

Modified code

class Participant < ApplicationRecord
  belongs_to :user
  belongs_to :assignment, foreign_key: 'assignment_id', inverse_of: false
  has_many   :join_team_requests, dependent: :destroy

#config/routes.rb
Original code

Rails.application.routes.draw do

  mount Rswag::Api::Engine => 'api-docs'
  mount Rswag::Ui::Engine => 'api-docs'
  # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
          post '/sign_up_student', to: 'signed_up_teams#sign_up_student'
        end
      end

Modified code

Rails.application.routes.draw do

  mount Rswag::Api::Engine => 'api-docs'
  mount Rswag::Ui::Engine => 'api-docs'
  # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
          post '/sign_up_student', to: 'signed_up_teams#sign_up_student'
        end
      end

      resources :join_team_requests do
        collection do
          post 'decline/:id', to:'join_team_requests#decline'
          post 'accept/:id', to:'join_team_requests#accept'
        end
      end

Testing

We have thoroughly tested our code using Postman and the controller works flawlessly.
Following is a link to the Swagger test file -
https://github.com/manoj-ayyappan/csc517_program3_E2370/blob/main/swagger/v1/swagger.yaml


Modifications

- Created new methods for the Join Team Requests Controller to support CRUD functionality.
- Added an accept and decline method.
- Modified the status to use constants such as 'PENDING', 'ACCEPTED', and 'DECLINED' instead of 'P', 'D', 'A'.

Results

We've successfully reimplemented the Join Teams Request Controller, achieving a more comprehensive feature set by introducing new methods for CRUD functionality, facilitating the acceptance and rejection of join requests, and adopting meaningful status constants like 'PENDING,' 'ACCEPTED,' and 'DECLINED' in place of less intuitive single-character codes. These improvements not only expand the controller's capabilities but also enhance its readability and maintainability,

Team

Mentor
Renji Joseph Sabu <rsabu@ncsu.edu>

Students
Manoj Ayyappan <mayyapp@ncsu.edu>
Pradeep Patil <papatil@ncsu.edu>
Maya Patel <mdpatel2@ncsu.edu>

Pull Request

Changes for this project are under Expertiza Pull Request https://github.com/expertiza/reimplementation-back-end/pull/50