CSC/ECE 517 Fall 2023 - E2370. Reimplement join team requests controller
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
- app/controllers/join_team_requests_controller.rb
- app/models/join_team_requests.rb
- 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.
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
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