<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nmadapa</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nmadapa"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Nmadapa"/>
	<updated>2026-07-01T22:32:48Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150780</id>
		<title>CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150780"/>
		<updated>2023-10-31T01:19:18Z</updated>

		<summary type="html">&lt;p&gt;Nmadapa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Project Overview'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
===1.1 Expertiza Background===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an online platform designed to facilitate peer review and submission of various types of academic work, including articles, codes, and websites. The application allows instructors to add assignments, grade them, and assign students to teams based on their topic preferences. The platform also enables students to provide feedback on each other's work through peer reviews, which can be helpful in improving the quality of their projects. Expertiza is backed by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
'''1.2 Problem Statement'''&lt;br /&gt;
&lt;br /&gt;
The teams_controller.rb file contains operations on teams like listing of teams of an assignment/course, updating a team, deleting teams of an assignment/course, copying teams between two assignments or courses among others. The model team.rb contains a lot of functions, with probable violations of single responsibility principle and this needs to be reimplemented with care. The files do not benefit from the complex names the functions are given.&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
&lt;br /&gt;
'''Emphasize on Single Responsibility Principle''' - There are a questionable amount of functions that are directed at copying teams and team members between parents (courses/assignments). There are a lot of class functions in the model, which could be bad design. While reimplementing, make sure that SRP is maintained. See if any code is repetitive, and can be cut down.&lt;br /&gt;
&lt;br /&gt;
'''Improve naming''' - Some functions have confusing names. For example, the function “bequeath_copy” can definitely be given a better name if the functionality needs to be reimplemented. The over-populated “copy” related functions in this controller decrease the readability of the code.&lt;br /&gt;
&lt;br /&gt;
'''Better comments''' - Bigger files and functions require better comments for readability.&lt;br /&gt;
&lt;br /&gt;
'''2. Class Diagram:'''&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Teams assignment class diagram.png]]&lt;br /&gt;
&lt;br /&gt;
'''3. Functionality&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
In this project, we aim to:&lt;br /&gt;
&lt;br /&gt;
- Interact with teams assignment database (Basic CRUD) &lt;br /&gt;
- Interactions with a particular team assignment&lt;br /&gt;
&lt;br /&gt;
'''4. Project Design'''&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''4.1. Model'''&lt;br /&gt;
&lt;br /&gt;
This model is used to manage teams and their assignments. Here is a brief description of its key features:&lt;br /&gt;
&lt;br /&gt;
Associations: It has various associations with other models, including users, join_team_requests, team_node, signed_up_teams, and bids.&lt;br /&gt;
&lt;br /&gt;
CSV Import and Export: It contains methods for importing team data from a CSV file and exporting team data to a CSV file. The import method creates or finds teams and associates users with them based on the CSV data.&lt;br /&gt;
&lt;br /&gt;
Team Creation and Management: It includes methods to create a new team and add or remove users from teams. It checks for existing team membership before adding a user to a team.&lt;br /&gt;
&lt;br /&gt;
Team Name Generation: There is a method to generate a unique team name, which can be prefixed with a provided string.&lt;br /&gt;
&lt;br /&gt;
Version History: The model uses the has_paper_trail gem, which helps in tracking changes to the model's records over time.&lt;br /&gt;
&lt;br /&gt;
Code snippet can be found here:&lt;br /&gt;
&lt;br /&gt;
class TeamsAssignment &amp;lt; ApplicationRecord&lt;br /&gt;
  require 'csv'  # Require the 'csv' library&lt;br /&gt;
  &lt;br /&gt;
  has_many :users, through: :teams_users&lt;br /&gt;
  has_many :join_team_requests, dependent: :destroy&lt;br /&gt;
  has_one :team_node, foreign_key: :node_object_id, dependent: :destroy&lt;br /&gt;
  has_many :signed_up_teams, dependent: :destroy&lt;br /&gt;
  has_many :bids, dependent: :destroy&lt;br /&gt;
  has_paper_trail&lt;br /&gt;
&lt;br /&gt;
  # Import teams from a CSV file&lt;br /&gt;
  def self.import_teams_from_csv(file)&lt;br /&gt;
    CSV.foreach(file.path, headers: true) do |row|&lt;br /&gt;
      team = self.find_or_create_by(name: row['name'])&lt;br /&gt;
      team.users &amp;lt;&amp;lt; User.find_by(name: row['user_name'])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.export_teams_to_csv(file)&lt;br /&gt;
    CSV.open(file.path, 'w') do |csv|&lt;br /&gt;
    csv &amp;lt;&amp;lt; ['name', 'user_name'] # Add relevant column names&lt;br /&gt;
&lt;br /&gt;
      all.each do |team|&lt;br /&gt;
        team.users.each do |user|&lt;br /&gt;
          csv &amp;lt;&amp;lt; [team.name, user.name]&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Method to create a new team&lt;br /&gt;
  def create_team(name)&lt;br /&gt;
    team = Team.create(name: name, parent_id: self.id)&lt;br /&gt;
    TeamNode.create(parent_id: self.id, node_object_id: team.id)&lt;br /&gt;
    team&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Method to add a user to a team&lt;br /&gt;
  def add_user_to_team(team, user)&lt;br /&gt;
    # Check if the user is already a member of the team&lt;br /&gt;
    return if team.users.include?(user)&lt;br /&gt;
&lt;br /&gt;
    TeamsUser.create(team_id: team.id, user_id: user.id)&lt;br /&gt;
    # Optionally, you can add this user to any related associations, like CourseParticipants or AssignmentParticipants&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Method to remove a user from a team&lt;br /&gt;
  def remove_user_from_team(team, user)&lt;br /&gt;
    team_user = TeamsUser.find_by(team_id: team.id, user_id: user.id)&lt;br /&gt;
    team_user&amp;amp;.destroy&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Generate the team name&lt;br /&gt;
  def self.generate_team_name(team_name_prefix = '')&lt;br /&gt;
    counter = 1&lt;br /&gt;
    loop do&lt;br /&gt;
      team_name = &amp;quot;#{team_name_prefix} Team_#{counter}&amp;quot;&lt;br /&gt;
      return team_name unless TeamsAssignment.find_by(name: team_name)&lt;br /&gt;
&lt;br /&gt;
      counter += 1&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
'''4.2. Schema''' &lt;br /&gt;
&lt;br /&gt;
create_table &amp;quot;teams_assignments&amp;quot;, id: :integer, force: :cascade, options: &amp;quot;ENGINE=InnoDB DEFAULT CHARSET=latin1&amp;quot; do |t|&lt;br /&gt;
      t.string &amp;quot;name&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;parent_id&amp;quot;&lt;br /&gt;
      t.string &amp;quot;type&amp;quot;&lt;br /&gt;
      t.text &amp;quot;comments_for_advertisement&amp;quot;&lt;br /&gt;
      t.boolean &amp;quot;advertise_for_partner&amp;quot;&lt;br /&gt;
      t.text &amp;quot;submitted_hyperlinks&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;directory_num&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;grade_for_submission&amp;quot;&lt;br /&gt;
      t.text &amp;quot;comment_for_submission&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;pair_programming_request&amp;quot;, limit: 1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
'''4.3. Teams controller'''&lt;br /&gt;
&lt;br /&gt;
Api::V1::TeamsAssignmentController, which is responsible for handling HTTP requests related to a model named TeamAssignment. Here is a brief description of its key features:&lt;br /&gt;
&lt;br /&gt;
Before Actions: The controller specifies before actions using the before_action method. It sets up the @team_assignment instance variable for specific controller actions (show, update, destroy, and copy). It also uses rescue_from to handle exceptions.&lt;br /&gt;
&lt;br /&gt;
Index Action: The index action handles a GET request to list all team assignments. It retrieves all team assignments from the database and renders them as JSON.&lt;br /&gt;
&lt;br /&gt;
Show Action: The show action handles a GET request to retrieve a specific team assignment by its ID. It renders the team assignment as JSON.&lt;br /&gt;
&lt;br /&gt;
Create Action: The create action handles a POST request to create a new team assignment. It creates a new TeamAssignment instance with parameters from the request and saves it. It returns a JSON response with the created team assignment or error messages.&lt;br /&gt;
&lt;br /&gt;
Update Action: The update action handles a PUT or PATCH request to update an existing team assignment. It finds the team assignment, updates it with parameters from the request, and returns a JSON response with the updated team assignment or error messages.&lt;br /&gt;
&lt;br /&gt;
Destroy Action: The destroy action handles a DELETE request to delete a specific team assignment by its ID. It removes the team assignment from the database and returns a JSON response indicating the success of the deletion.&lt;br /&gt;
&lt;br /&gt;
Copy Action: The copy action handles a custom action to create a copy of a team assignment. It calls a method copy_team_assignment on the team assignment and returns a JSON response indicating the success or failure of the copy operation.&lt;br /&gt;
&lt;br /&gt;
Private Methods: There are several private methods used to encapsulate common functionality. set_team_assignment finds and sets the @team_assignment instance variable, team_assignment_params permits trusted parameters for creating or updating team assignments, and team_assignment_not_found and parameter_missing handle specific error cases.&lt;br /&gt;
&lt;br /&gt;
This controller provides a RESTful API for managing team assignments, including listing, creating, updating, and deleting team assignments, as well as a custom copy operation. It also includes error handling for common scenarios.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&lt;br /&gt;
class Api::V1::TeamsAssignmentController &amp;lt; ApplicationController&lt;br /&gt;
    &lt;br /&gt;
  before_action :set_team_assignment, only: %i[ show update destroy copy ]&lt;br /&gt;
  rescue_from ActiveRecord::RecordNotFound, with: :team_assignment_not_found&lt;br /&gt;
  rescue_from ActionController::ParameterMissing, with: :parameter_missing&lt;br /&gt;
&lt;br /&gt;
  # GET /team_assignments&lt;br /&gt;
  # List all the team_assignments&lt;br /&gt;
  def index&lt;br /&gt;
    team_assignment = TeamAssignment.all&lt;br /&gt;
    render json: team_assignment, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /team_assignments/1&lt;br /&gt;
  # Get a team_assignment&lt;br /&gt;
  def show&lt;br /&gt;
    render json: @team_assignment, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /team_assignments&lt;br /&gt;
  # Create a team_assignment&lt;br /&gt;
  def create&lt;br /&gt;
    team_assignment = TeamAssignment.new(team_assignment_params)&lt;br /&gt;
    if team_assignment.save&lt;br /&gt;
      render json: team_assignment, status: :created&lt;br /&gt;
    else&lt;br /&gt;
      render json: team_assignment.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PATCH/PUT /team_assignments/1&lt;br /&gt;
  # Update a team_assignment&lt;br /&gt;
  def update&lt;br /&gt;
    if @team_assignment.update(team_assignment_params)&lt;br /&gt;
      render json: @team_assignment, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: @team_assignment.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /team_assignments/1&lt;br /&gt;
  # Delete a team_assignment&lt;br /&gt;
  def destroy&lt;br /&gt;
    @team_assignment.destroy&lt;br /&gt;
    render json: { message: &amp;quot;Team assignment with id #{params[:id]}, deleted&amp;quot; }, status: :no_content&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Creates a copy of the team_assignment&lt;br /&gt;
  def copy&lt;br /&gt;
    if @team_assignment.copy_team_assignment&lt;br /&gt;
      render json: { message: &amp;quot;The team assignment #{@team_assignment.name} has been successfully copied&amp;quot; }, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: { message: &amp;quot;The team assignment was not able to be copied&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
&lt;br /&gt;
  # Use callbacks to share common setup or constraints between actions.&lt;br /&gt;
  def set_team_assignment&lt;br /&gt;
    @team_assignment = TeamAssignment.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Only allow a list of trusted parameters through.&lt;br /&gt;
  def team_assignment_params&lt;br /&gt;
    params.require(:team_assignment).permit(&lt;br /&gt;
        :name, :parent_id, :type, :comments_for_advertisement, :advertise_for_partner, :submitted_hyperlinks,&lt;br /&gt;
        :directory_num, :comment_for_submission, :pair_programming_request&lt;br /&gt;
    )&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def team_assignment_not_found&lt;br /&gt;
    render json: { error: &amp;quot;Team assignment with id #{params[:id]} not found&amp;quot; }, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def parameter_missing&lt;br /&gt;
    render json: { error: &amp;quot;Parameter missing&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
  &lt;br /&gt;
'''4.4 Testing Plan'''&lt;br /&gt;
&lt;br /&gt;
4.4.1. Model tests:&lt;br /&gt;
&lt;br /&gt;
Factory used:&lt;br /&gt;
&lt;br /&gt;
  factory :teams_assignment do&lt;br /&gt;
    name { &amp;quot;Sample Team Assignment&amp;quot; }&lt;br /&gt;
    parent_id { 1 } # You can adjust this value as needed&lt;br /&gt;
    type { &amp;quot;Assignment&amp;quot; }&lt;br /&gt;
    comments_for_advertisement { &amp;quot;Sample comments for advertisement&amp;quot; }&lt;br /&gt;
    advertise_for_partner { true }&lt;br /&gt;
    submitted_hyperlinks { &amp;quot;Sample hyperlinks&amp;quot; }&lt;br /&gt;
    directory_num { 1 }&lt;br /&gt;
    grade_for_submission { 100 }&lt;br /&gt;
    comment_for_submission { &amp;quot;Sample comment for submission&amp;quot; }&lt;br /&gt;
    pair_programming_request { 1 }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
To run model tests:&lt;br /&gt;
&lt;br /&gt;
1. git clone&lt;br /&gt;
&lt;br /&gt;
2. cd reimplementation-back-end/&lt;br /&gt;
&lt;br /&gt;
3. bundle install&lt;br /&gt;
&lt;br /&gt;
4. bundle exec rspec spec/models/teams_assignment_spec.rb&lt;br /&gt;
&lt;br /&gt;
To run controller tests:&lt;br /&gt;
&lt;br /&gt;
1. git clone&lt;br /&gt;
&lt;br /&gt;
2. cd reimplementation-back-end/&lt;br /&gt;
&lt;br /&gt;
3. bundle install&lt;br /&gt;
&lt;br /&gt;
4. 4. bundle exec rspec spec/requests/api/v1/teams_assignment_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
'''References:'''&lt;br /&gt;
&lt;br /&gt;
Github repo link[https://github.com/nitinjoseph11/reimplementation-back-end]&lt;br /&gt;
&lt;br /&gt;
Rspec documentation[https://rspec.info/documentation/3.8/rspec-core/]&lt;br /&gt;
&lt;br /&gt;
'''Team members:'''&lt;br /&gt;
&lt;br /&gt;
1. Reuben Vandezande&lt;br /&gt;
&lt;br /&gt;
2. Nitin Joseph Madapally Abraham&lt;br /&gt;
&lt;br /&gt;
'''Mentor:'''&lt;br /&gt;
&lt;br /&gt;
Renji Joseph Sabu&lt;/div&gt;</summary>
		<author><name>Nmadapa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150779</id>
		<title>CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150779"/>
		<updated>2023-10-31T01:18:44Z</updated>

		<summary type="html">&lt;p&gt;Nmadapa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Project Overview'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
===1.1 Expertiza Background===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an online platform designed to facilitate peer review and submission of various types of academic work, including articles, codes, and websites. The application allows instructors to add assignments, grade them, and assign students to teams based on their topic preferences. The platform also enables students to provide feedback on each other's work through peer reviews, which can be helpful in improving the quality of their projects. Expertiza is backed by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
'''1.2 Problem Statement'''&lt;br /&gt;
&lt;br /&gt;
The teams_controller.rb file contains operations on teams like listing of teams of an assignment/course, updating a team, deleting teams of an assignment/course, copying teams between two assignments or courses among others. The model team.rb contains a lot of functions, with probable violations of single responsibility principle and this needs to be reimplemented with care. The files do not benefit from the complex names the functions are given.&lt;br /&gt;
&lt;br /&gt;
'''What needs to be done:''' &lt;br /&gt;
&lt;br /&gt;
'''Emphasize on Single Responsibility Principle''' - There are a questionable amount of functions that are directed at copying teams and team members between parents (courses/assignments). There are a lot of class functions in the model, which could be bad design. While reimplementing, make sure that SRP is maintained. See if any code is repetitive, and can be cut down.&lt;br /&gt;
&lt;br /&gt;
'''Improve naming''' - Some functions have confusing names. For example, the function “bequeath_copy” can definitely be given a better name if the functionality needs to be reimplemented. The over-populated “copy” related functions in this controller decrease the readability of the code.&lt;br /&gt;
&lt;br /&gt;
'''Better comments''' - Bigger files and functions require better comments for readability.&lt;br /&gt;
&lt;br /&gt;
'''2. Class Diagram:'''&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Teams assignment class diagram.png]]&lt;br /&gt;
&lt;br /&gt;
'''3. Functionality&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
In this project, we aim to:&lt;br /&gt;
&lt;br /&gt;
- Interact with teams assignment database (Basic CRUD) &lt;br /&gt;
- Interactions with a particular team assignment&lt;br /&gt;
&lt;br /&gt;
'''4. Project Design'''&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''4.1. Model'''&lt;br /&gt;
&lt;br /&gt;
This model is used to manage teams and their assignments. Here is a brief description of its key features:&lt;br /&gt;
&lt;br /&gt;
Associations: It has various associations with other models, including users, join_team_requests, team_node, signed_up_teams, and bids.&lt;br /&gt;
&lt;br /&gt;
CSV Import and Export: It contains methods for importing team data from a CSV file and exporting team data to a CSV file. The import method creates or finds teams and associates users with them based on the CSV data.&lt;br /&gt;
&lt;br /&gt;
Team Creation and Management: It includes methods to create a new team and add or remove users from teams. It checks for existing team membership before adding a user to a team.&lt;br /&gt;
&lt;br /&gt;
Team Name Generation: There is a method to generate a unique team name, which can be prefixed with a provided string.&lt;br /&gt;
&lt;br /&gt;
Version History: The model uses the has_paper_trail gem, which helps in tracking changes to the model's records over time.&lt;br /&gt;
&lt;br /&gt;
Code snippet can be found here:&lt;br /&gt;
&lt;br /&gt;
class TeamsAssignment &amp;lt; ApplicationRecord&lt;br /&gt;
  require 'csv'  # Require the 'csv' library&lt;br /&gt;
  &lt;br /&gt;
  has_many :users, through: :teams_users&lt;br /&gt;
  has_many :join_team_requests, dependent: :destroy&lt;br /&gt;
  has_one :team_node, foreign_key: :node_object_id, dependent: :destroy&lt;br /&gt;
  has_many :signed_up_teams, dependent: :destroy&lt;br /&gt;
  has_many :bids, dependent: :destroy&lt;br /&gt;
  has_paper_trail&lt;br /&gt;
&lt;br /&gt;
  # Import teams from a CSV file&lt;br /&gt;
  def self.import_teams_from_csv(file)&lt;br /&gt;
    CSV.foreach(file.path, headers: true) do |row|&lt;br /&gt;
      team = self.find_or_create_by(name: row['name'])&lt;br /&gt;
      team.users &amp;lt;&amp;lt; User.find_by(name: row['user_name'])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.export_teams_to_csv(file)&lt;br /&gt;
    CSV.open(file.path, 'w') do |csv|&lt;br /&gt;
    csv &amp;lt;&amp;lt; ['name', 'user_name'] # Add relevant column names&lt;br /&gt;
&lt;br /&gt;
      all.each do |team|&lt;br /&gt;
        team.users.each do |user|&lt;br /&gt;
          csv &amp;lt;&amp;lt; [team.name, user.name]&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Method to create a new team&lt;br /&gt;
  def create_team(name)&lt;br /&gt;
    team = Team.create(name: name, parent_id: self.id)&lt;br /&gt;
    TeamNode.create(parent_id: self.id, node_object_id: team.id)&lt;br /&gt;
    team&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Method to add a user to a team&lt;br /&gt;
  def add_user_to_team(team, user)&lt;br /&gt;
    # Check if the user is already a member of the team&lt;br /&gt;
    return if team.users.include?(user)&lt;br /&gt;
&lt;br /&gt;
    TeamsUser.create(team_id: team.id, user_id: user.id)&lt;br /&gt;
    # Optionally, you can add this user to any related associations, like CourseParticipants or AssignmentParticipants&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Method to remove a user from a team&lt;br /&gt;
  def remove_user_from_team(team, user)&lt;br /&gt;
    team_user = TeamsUser.find_by(team_id: team.id, user_id: user.id)&lt;br /&gt;
    team_user&amp;amp;.destroy&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Generate the team name&lt;br /&gt;
  def self.generate_team_name(team_name_prefix = '')&lt;br /&gt;
    counter = 1&lt;br /&gt;
    loop do&lt;br /&gt;
      team_name = &amp;quot;#{team_name_prefix} Team_#{counter}&amp;quot;&lt;br /&gt;
      return team_name unless TeamsAssignment.find_by(name: team_name)&lt;br /&gt;
&lt;br /&gt;
      counter += 1&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
'''4.2. Schema''' &lt;br /&gt;
&lt;br /&gt;
create_table &amp;quot;teams_assignments&amp;quot;, id: :integer, force: :cascade, options: &amp;quot;ENGINE=InnoDB DEFAULT CHARSET=latin1&amp;quot; do |t|&lt;br /&gt;
      t.string &amp;quot;name&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;parent_id&amp;quot;&lt;br /&gt;
      t.string &amp;quot;type&amp;quot;&lt;br /&gt;
      t.text &amp;quot;comments_for_advertisement&amp;quot;&lt;br /&gt;
      t.boolean &amp;quot;advertise_for_partner&amp;quot;&lt;br /&gt;
      t.text &amp;quot;submitted_hyperlinks&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;directory_num&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;grade_for_submission&amp;quot;&lt;br /&gt;
      t.text &amp;quot;comment_for_submission&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;pair_programming_request&amp;quot;, limit: 1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
'''4.3. Teams controller'''&lt;br /&gt;
&lt;br /&gt;
Api::V1::TeamsAssignmentController, which is responsible for handling HTTP requests related to a model named TeamAssignment. Here is a brief description of its key features:&lt;br /&gt;
&lt;br /&gt;
Before Actions: The controller specifies before actions using the before_action method. It sets up the @team_assignment instance variable for specific controller actions (show, update, destroy, and copy). It also uses rescue_from to handle exceptions.&lt;br /&gt;
&lt;br /&gt;
Index Action: The index action handles a GET request to list all team assignments. It retrieves all team assignments from the database and renders them as JSON.&lt;br /&gt;
&lt;br /&gt;
Show Action: The show action handles a GET request to retrieve a specific team assignment by its ID. It renders the team assignment as JSON.&lt;br /&gt;
&lt;br /&gt;
Create Action: The create action handles a POST request to create a new team assignment. It creates a new TeamAssignment instance with parameters from the request and saves it. It returns a JSON response with the created team assignment or error messages.&lt;br /&gt;
&lt;br /&gt;
Update Action: The update action handles a PUT or PATCH request to update an existing team assignment. It finds the team assignment, updates it with parameters from the request, and returns a JSON response with the updated team assignment or error messages.&lt;br /&gt;
&lt;br /&gt;
Destroy Action: The destroy action handles a DELETE request to delete a specific team assignment by its ID. It removes the team assignment from the database and returns a JSON response indicating the success of the deletion.&lt;br /&gt;
&lt;br /&gt;
Copy Action: The copy action handles a custom action to create a copy of a team assignment. It calls a method copy_team_assignment on the team assignment and returns a JSON response indicating the success or failure of the copy operation.&lt;br /&gt;
&lt;br /&gt;
Private Methods: There are several private methods used to encapsulate common functionality. set_team_assignment finds and sets the @team_assignment instance variable, team_assignment_params permits trusted parameters for creating or updating team assignments, and team_assignment_not_found and parameter_missing handle specific error cases.&lt;br /&gt;
&lt;br /&gt;
This controller provides a RESTful API for managing team assignments, including listing, creating, updating, and deleting team assignments, as well as a custom copy operation. It also includes error handling for common scenarios.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&lt;br /&gt;
class Api::V1::TeamsAssignmentController &amp;lt; ApplicationController&lt;br /&gt;
    &lt;br /&gt;
  before_action :set_team_assignment, only: %i[ show update destroy copy ]&lt;br /&gt;
  rescue_from ActiveRecord::RecordNotFound, with: :team_assignment_not_found&lt;br /&gt;
  rescue_from ActionController::ParameterMissing, with: :parameter_missing&lt;br /&gt;
&lt;br /&gt;
  # GET /team_assignments&lt;br /&gt;
  # List all the team_assignments&lt;br /&gt;
  def index&lt;br /&gt;
    team_assignment = TeamAssignment.all&lt;br /&gt;
    render json: team_assignment, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /team_assignments/1&lt;br /&gt;
  # Get a team_assignment&lt;br /&gt;
  def show&lt;br /&gt;
    render json: @team_assignment, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /team_assignments&lt;br /&gt;
  # Create a team_assignment&lt;br /&gt;
  def create&lt;br /&gt;
    team_assignment = TeamAssignment.new(team_assignment_params)&lt;br /&gt;
    if team_assignment.save&lt;br /&gt;
      render json: team_assignment, status: :created&lt;br /&gt;
    else&lt;br /&gt;
      render json: team_assignment.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PATCH/PUT /team_assignments/1&lt;br /&gt;
  # Update a team_assignment&lt;br /&gt;
  def update&lt;br /&gt;
    if @team_assignment.update(team_assignment_params)&lt;br /&gt;
      render json: @team_assignment, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: @team_assignment.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /team_assignments/1&lt;br /&gt;
  # Delete a team_assignment&lt;br /&gt;
  def destroy&lt;br /&gt;
    @team_assignment.destroy&lt;br /&gt;
    render json: { message: &amp;quot;Team assignment with id #{params[:id]}, deleted&amp;quot; }, status: :no_content&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Creates a copy of the team_assignment&lt;br /&gt;
  def copy&lt;br /&gt;
    if @team_assignment.copy_team_assignment&lt;br /&gt;
      render json: { message: &amp;quot;The team assignment #{@team_assignment.name} has been successfully copied&amp;quot; }, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: { message: &amp;quot;The team assignment was not able to be copied&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
&lt;br /&gt;
  # Use callbacks to share common setup or constraints between actions.&lt;br /&gt;
  def set_team_assignment&lt;br /&gt;
    @team_assignment = TeamAssignment.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Only allow a list of trusted parameters through.&lt;br /&gt;
  def team_assignment_params&lt;br /&gt;
    params.require(:team_assignment).permit(&lt;br /&gt;
        :name, :parent_id, :type, :comments_for_advertisement, :advertise_for_partner, :submitted_hyperlinks,&lt;br /&gt;
        :directory_num, :comment_for_submission, :pair_programming_request&lt;br /&gt;
    )&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def team_assignment_not_found&lt;br /&gt;
    render json: { error: &amp;quot;Team assignment with id #{params[:id]} not found&amp;quot; }, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def parameter_missing&lt;br /&gt;
    render json: { error: &amp;quot;Parameter missing&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
  &lt;br /&gt;
'''4.4 Testing Plan'''&lt;br /&gt;
&lt;br /&gt;
4.4.1. Model tests:&lt;br /&gt;
&lt;br /&gt;
Factory used:&lt;br /&gt;
&lt;br /&gt;
  factory :teams_assignment do&lt;br /&gt;
    name { &amp;quot;Sample Team Assignment&amp;quot; }&lt;br /&gt;
    parent_id { 1 } # You can adjust this value as needed&lt;br /&gt;
    type { &amp;quot;Assignment&amp;quot; }&lt;br /&gt;
    comments_for_advertisement { &amp;quot;Sample comments for advertisement&amp;quot; }&lt;br /&gt;
    advertise_for_partner { true }&lt;br /&gt;
    submitted_hyperlinks { &amp;quot;Sample hyperlinks&amp;quot; }&lt;br /&gt;
    directory_num { 1 }&lt;br /&gt;
    grade_for_submission { 100 }&lt;br /&gt;
    comment_for_submission { &amp;quot;Sample comment for submission&amp;quot; }&lt;br /&gt;
    pair_programming_request { 1 }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
To run model tests:&lt;br /&gt;
&lt;br /&gt;
1. git clone&lt;br /&gt;
&lt;br /&gt;
2. cd reimplementation-back-end/&lt;br /&gt;
&lt;br /&gt;
3. bundle install&lt;br /&gt;
&lt;br /&gt;
4. bundle exec rspec spec/models/teams_assignment_spec.rb&lt;br /&gt;
&lt;br /&gt;
To run controller tests:&lt;br /&gt;
&lt;br /&gt;
1. git clone&lt;br /&gt;
&lt;br /&gt;
2. cd reimplementation-back-end/&lt;br /&gt;
&lt;br /&gt;
3. bundle install&lt;br /&gt;
&lt;br /&gt;
4. 4. bundle exec rspec spec/requests/api/v1/teams_assignment_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
'''References:'''&lt;br /&gt;
&lt;br /&gt;
Github repo link[https://github.com/nitinjoseph11/reimplementation-back-end]&lt;br /&gt;
&lt;br /&gt;
Rspec documentation[https://rspec.info/documentation/3.8/rspec-core/]&lt;br /&gt;
&lt;br /&gt;
'''Team members:'''&lt;br /&gt;
&lt;br /&gt;
1. Reuben Vandezande&lt;br /&gt;
2. Nitin Joseph Madapally Abraham&lt;br /&gt;
&lt;br /&gt;
'''Mentor:'''&lt;br /&gt;
&lt;br /&gt;
Renji Joseph Sabu&lt;/div&gt;</summary>
		<author><name>Nmadapa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150778</id>
		<title>CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150778"/>
		<updated>2023-10-31T01:18:24Z</updated>

		<summary type="html">&lt;p&gt;Nmadapa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Project Overview'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
===1.1 Expertiza Background===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an online platform designed to facilitate peer review and submission of various types of academic work, including articles, codes, and websites. The application allows instructors to add assignments, grade them, and assign students to teams based on their topic preferences. The platform also enables students to provide feedback on each other's work through peer reviews, which can be helpful in improving the quality of their projects. Expertiza is backed by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
'''1.2 Problem Statement'''&lt;br /&gt;
&lt;br /&gt;
The teams_controller.rb file contains operations on teams like listing of teams of an assignment/course, updating a team, deleting teams of an assignment/course, copying teams between two assignments or courses among others. The model team.rb contains a lot of functions, with probable violations of single responsibility principle and this needs to be reimplemented with care. The files do not benefit from the complex names the functions are given.&lt;br /&gt;
&lt;br /&gt;
[['''What needs to be done:''']] &lt;br /&gt;
&lt;br /&gt;
'''Emphasize on Single Responsibility Principle''' - There are a questionable amount of functions that are directed at copying teams and team members between parents (courses/assignments). There are a lot of class functions in the model, which could be bad design. While reimplementing, make sure that SRP is maintained. See if any code is repetitive, and can be cut down.&lt;br /&gt;
&lt;br /&gt;
'''Improve naming''' - Some functions have confusing names. For example, the function “bequeath_copy” can definitely be given a better name if the functionality needs to be reimplemented. The over-populated “copy” related functions in this controller decrease the readability of the code.&lt;br /&gt;
&lt;br /&gt;
'''Better comments''' - Bigger files and functions require better comments for readability.&lt;br /&gt;
&lt;br /&gt;
'''2. Class Diagram:'''&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Teams assignment class diagram.png]]&lt;br /&gt;
&lt;br /&gt;
'''3. Functionality&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
In this project, we aim to:&lt;br /&gt;
&lt;br /&gt;
- Interact with teams assignment database (Basic CRUD) &lt;br /&gt;
- Interactions with a particular team assignment&lt;br /&gt;
&lt;br /&gt;
'''4. Project Design'''&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''4.1. Model'''&lt;br /&gt;
&lt;br /&gt;
This model is used to manage teams and their assignments. Here is a brief description of its key features:&lt;br /&gt;
&lt;br /&gt;
Associations: It has various associations with other models, including users, join_team_requests, team_node, signed_up_teams, and bids.&lt;br /&gt;
&lt;br /&gt;
CSV Import and Export: It contains methods for importing team data from a CSV file and exporting team data to a CSV file. The import method creates or finds teams and associates users with them based on the CSV data.&lt;br /&gt;
&lt;br /&gt;
Team Creation and Management: It includes methods to create a new team and add or remove users from teams. It checks for existing team membership before adding a user to a team.&lt;br /&gt;
&lt;br /&gt;
Team Name Generation: There is a method to generate a unique team name, which can be prefixed with a provided string.&lt;br /&gt;
&lt;br /&gt;
Version History: The model uses the has_paper_trail gem, which helps in tracking changes to the model's records over time.&lt;br /&gt;
&lt;br /&gt;
Code snippet can be found here:&lt;br /&gt;
&lt;br /&gt;
class TeamsAssignment &amp;lt; ApplicationRecord&lt;br /&gt;
  require 'csv'  # Require the 'csv' library&lt;br /&gt;
  &lt;br /&gt;
  has_many :users, through: :teams_users&lt;br /&gt;
  has_many :join_team_requests, dependent: :destroy&lt;br /&gt;
  has_one :team_node, foreign_key: :node_object_id, dependent: :destroy&lt;br /&gt;
  has_many :signed_up_teams, dependent: :destroy&lt;br /&gt;
  has_many :bids, dependent: :destroy&lt;br /&gt;
  has_paper_trail&lt;br /&gt;
&lt;br /&gt;
  # Import teams from a CSV file&lt;br /&gt;
  def self.import_teams_from_csv(file)&lt;br /&gt;
    CSV.foreach(file.path, headers: true) do |row|&lt;br /&gt;
      team = self.find_or_create_by(name: row['name'])&lt;br /&gt;
      team.users &amp;lt;&amp;lt; User.find_by(name: row['user_name'])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.export_teams_to_csv(file)&lt;br /&gt;
    CSV.open(file.path, 'w') do |csv|&lt;br /&gt;
    csv &amp;lt;&amp;lt; ['name', 'user_name'] # Add relevant column names&lt;br /&gt;
&lt;br /&gt;
      all.each do |team|&lt;br /&gt;
        team.users.each do |user|&lt;br /&gt;
          csv &amp;lt;&amp;lt; [team.name, user.name]&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Method to create a new team&lt;br /&gt;
  def create_team(name)&lt;br /&gt;
    team = Team.create(name: name, parent_id: self.id)&lt;br /&gt;
    TeamNode.create(parent_id: self.id, node_object_id: team.id)&lt;br /&gt;
    team&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Method to add a user to a team&lt;br /&gt;
  def add_user_to_team(team, user)&lt;br /&gt;
    # Check if the user is already a member of the team&lt;br /&gt;
    return if team.users.include?(user)&lt;br /&gt;
&lt;br /&gt;
    TeamsUser.create(team_id: team.id, user_id: user.id)&lt;br /&gt;
    # Optionally, you can add this user to any related associations, like CourseParticipants or AssignmentParticipants&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Method to remove a user from a team&lt;br /&gt;
  def remove_user_from_team(team, user)&lt;br /&gt;
    team_user = TeamsUser.find_by(team_id: team.id, user_id: user.id)&lt;br /&gt;
    team_user&amp;amp;.destroy&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Generate the team name&lt;br /&gt;
  def self.generate_team_name(team_name_prefix = '')&lt;br /&gt;
    counter = 1&lt;br /&gt;
    loop do&lt;br /&gt;
      team_name = &amp;quot;#{team_name_prefix} Team_#{counter}&amp;quot;&lt;br /&gt;
      return team_name unless TeamsAssignment.find_by(name: team_name)&lt;br /&gt;
&lt;br /&gt;
      counter += 1&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
'''4.2. Schema''' &lt;br /&gt;
&lt;br /&gt;
create_table &amp;quot;teams_assignments&amp;quot;, id: :integer, force: :cascade, options: &amp;quot;ENGINE=InnoDB DEFAULT CHARSET=latin1&amp;quot; do |t|&lt;br /&gt;
      t.string &amp;quot;name&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;parent_id&amp;quot;&lt;br /&gt;
      t.string &amp;quot;type&amp;quot;&lt;br /&gt;
      t.text &amp;quot;comments_for_advertisement&amp;quot;&lt;br /&gt;
      t.boolean &amp;quot;advertise_for_partner&amp;quot;&lt;br /&gt;
      t.text &amp;quot;submitted_hyperlinks&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;directory_num&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;grade_for_submission&amp;quot;&lt;br /&gt;
      t.text &amp;quot;comment_for_submission&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;pair_programming_request&amp;quot;, limit: 1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
'''4.3. Teams controller'''&lt;br /&gt;
&lt;br /&gt;
Api::V1::TeamsAssignmentController, which is responsible for handling HTTP requests related to a model named TeamAssignment. Here is a brief description of its key features:&lt;br /&gt;
&lt;br /&gt;
Before Actions: The controller specifies before actions using the before_action method. It sets up the @team_assignment instance variable for specific controller actions (show, update, destroy, and copy). It also uses rescue_from to handle exceptions.&lt;br /&gt;
&lt;br /&gt;
Index Action: The index action handles a GET request to list all team assignments. It retrieves all team assignments from the database and renders them as JSON.&lt;br /&gt;
&lt;br /&gt;
Show Action: The show action handles a GET request to retrieve a specific team assignment by its ID. It renders the team assignment as JSON.&lt;br /&gt;
&lt;br /&gt;
Create Action: The create action handles a POST request to create a new team assignment. It creates a new TeamAssignment instance with parameters from the request and saves it. It returns a JSON response with the created team assignment or error messages.&lt;br /&gt;
&lt;br /&gt;
Update Action: The update action handles a PUT or PATCH request to update an existing team assignment. It finds the team assignment, updates it with parameters from the request, and returns a JSON response with the updated team assignment or error messages.&lt;br /&gt;
&lt;br /&gt;
Destroy Action: The destroy action handles a DELETE request to delete a specific team assignment by its ID. It removes the team assignment from the database and returns a JSON response indicating the success of the deletion.&lt;br /&gt;
&lt;br /&gt;
Copy Action: The copy action handles a custom action to create a copy of a team assignment. It calls a method copy_team_assignment on the team assignment and returns a JSON response indicating the success or failure of the copy operation.&lt;br /&gt;
&lt;br /&gt;
Private Methods: There are several private methods used to encapsulate common functionality. set_team_assignment finds and sets the @team_assignment instance variable, team_assignment_params permits trusted parameters for creating or updating team assignments, and team_assignment_not_found and parameter_missing handle specific error cases.&lt;br /&gt;
&lt;br /&gt;
This controller provides a RESTful API for managing team assignments, including listing, creating, updating, and deleting team assignments, as well as a custom copy operation. It also includes error handling for common scenarios.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&lt;br /&gt;
class Api::V1::TeamsAssignmentController &amp;lt; ApplicationController&lt;br /&gt;
    &lt;br /&gt;
  before_action :set_team_assignment, only: %i[ show update destroy copy ]&lt;br /&gt;
  rescue_from ActiveRecord::RecordNotFound, with: :team_assignment_not_found&lt;br /&gt;
  rescue_from ActionController::ParameterMissing, with: :parameter_missing&lt;br /&gt;
&lt;br /&gt;
  # GET /team_assignments&lt;br /&gt;
  # List all the team_assignments&lt;br /&gt;
  def index&lt;br /&gt;
    team_assignment = TeamAssignment.all&lt;br /&gt;
    render json: team_assignment, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /team_assignments/1&lt;br /&gt;
  # Get a team_assignment&lt;br /&gt;
  def show&lt;br /&gt;
    render json: @team_assignment, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /team_assignments&lt;br /&gt;
  # Create a team_assignment&lt;br /&gt;
  def create&lt;br /&gt;
    team_assignment = TeamAssignment.new(team_assignment_params)&lt;br /&gt;
    if team_assignment.save&lt;br /&gt;
      render json: team_assignment, status: :created&lt;br /&gt;
    else&lt;br /&gt;
      render json: team_assignment.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PATCH/PUT /team_assignments/1&lt;br /&gt;
  # Update a team_assignment&lt;br /&gt;
  def update&lt;br /&gt;
    if @team_assignment.update(team_assignment_params)&lt;br /&gt;
      render json: @team_assignment, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: @team_assignment.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /team_assignments/1&lt;br /&gt;
  # Delete a team_assignment&lt;br /&gt;
  def destroy&lt;br /&gt;
    @team_assignment.destroy&lt;br /&gt;
    render json: { message: &amp;quot;Team assignment with id #{params[:id]}, deleted&amp;quot; }, status: :no_content&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Creates a copy of the team_assignment&lt;br /&gt;
  def copy&lt;br /&gt;
    if @team_assignment.copy_team_assignment&lt;br /&gt;
      render json: { message: &amp;quot;The team assignment #{@team_assignment.name} has been successfully copied&amp;quot; }, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: { message: &amp;quot;The team assignment was not able to be copied&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
&lt;br /&gt;
  # Use callbacks to share common setup or constraints between actions.&lt;br /&gt;
  def set_team_assignment&lt;br /&gt;
    @team_assignment = TeamAssignment.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Only allow a list of trusted parameters through.&lt;br /&gt;
  def team_assignment_params&lt;br /&gt;
    params.require(:team_assignment).permit(&lt;br /&gt;
        :name, :parent_id, :type, :comments_for_advertisement, :advertise_for_partner, :submitted_hyperlinks,&lt;br /&gt;
        :directory_num, :comment_for_submission, :pair_programming_request&lt;br /&gt;
    )&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def team_assignment_not_found&lt;br /&gt;
    render json: { error: &amp;quot;Team assignment with id #{params[:id]} not found&amp;quot; }, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def parameter_missing&lt;br /&gt;
    render json: { error: &amp;quot;Parameter missing&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
  &lt;br /&gt;
'''4.4 Testing Plan'''&lt;br /&gt;
&lt;br /&gt;
4.4.1. Model tests:&lt;br /&gt;
&lt;br /&gt;
Factory used:&lt;br /&gt;
&lt;br /&gt;
  factory :teams_assignment do&lt;br /&gt;
    name { &amp;quot;Sample Team Assignment&amp;quot; }&lt;br /&gt;
    parent_id { 1 } # You can adjust this value as needed&lt;br /&gt;
    type { &amp;quot;Assignment&amp;quot; }&lt;br /&gt;
    comments_for_advertisement { &amp;quot;Sample comments for advertisement&amp;quot; }&lt;br /&gt;
    advertise_for_partner { true }&lt;br /&gt;
    submitted_hyperlinks { &amp;quot;Sample hyperlinks&amp;quot; }&lt;br /&gt;
    directory_num { 1 }&lt;br /&gt;
    grade_for_submission { 100 }&lt;br /&gt;
    comment_for_submission { &amp;quot;Sample comment for submission&amp;quot; }&lt;br /&gt;
    pair_programming_request { 1 }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
To run model tests:&lt;br /&gt;
&lt;br /&gt;
1. git clone&lt;br /&gt;
&lt;br /&gt;
2. cd reimplementation-back-end/&lt;br /&gt;
&lt;br /&gt;
3. bundle install&lt;br /&gt;
&lt;br /&gt;
4. bundle exec rspec spec/models/teams_assignment_spec.rb&lt;br /&gt;
&lt;br /&gt;
To run controller tests:&lt;br /&gt;
&lt;br /&gt;
1. git clone&lt;br /&gt;
&lt;br /&gt;
2. cd reimplementation-back-end/&lt;br /&gt;
&lt;br /&gt;
3. bundle install&lt;br /&gt;
&lt;br /&gt;
4. 4. bundle exec rspec spec/requests/api/v1/teams_assignment_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
'''References:'''&lt;br /&gt;
&lt;br /&gt;
Github repo link[https://github.com/nitinjoseph11/reimplementation-back-end]&lt;br /&gt;
&lt;br /&gt;
Rspec documentation[https://rspec.info/documentation/3.8/rspec-core/]&lt;br /&gt;
&lt;br /&gt;
'''Team members:'''&lt;br /&gt;
&lt;br /&gt;
1. Reuben Vandezande&lt;br /&gt;
2. Nitin Joseph Madapally Abraham&lt;br /&gt;
&lt;br /&gt;
'''Mentor:'''&lt;br /&gt;
&lt;br /&gt;
Renji Joseph Sabu&lt;/div&gt;</summary>
		<author><name>Nmadapa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150777</id>
		<title>CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150777"/>
		<updated>2023-10-31T01:17:35Z</updated>

		<summary type="html">&lt;p&gt;Nmadapa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Project Overview'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
===1.1 Expertiza Background===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an online platform designed to facilitate peer review and submission of various types of academic work, including articles, codes, and websites. The application allows instructors to add assignments, grade them, and assign students to teams based on their topic preferences. The platform also enables students to provide feedback on each other's work through peer reviews, which can be helpful in improving the quality of their projects. Expertiza is backed by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
[['''1.2 Problem Statement''']]&lt;br /&gt;
&lt;br /&gt;
The teams_controller.rb file contains operations on teams like listing of teams of an assignment/course, updating a team, deleting teams of an assignment/course, copying teams between two assignments or courses among others. The model team.rb contains a lot of functions, with probable violations of single responsibility principle and this needs to be reimplemented with care. The files do not benefit from the complex names the functions are given.&lt;br /&gt;
&lt;br /&gt;
[['''What needs to be done:''']] &lt;br /&gt;
&lt;br /&gt;
'''Emphasize on Single Responsibility Principle''' - There are a questionable amount of functions that are directed at copying teams and team members between parents (courses/assignments). There are a lot of class functions in the model, which could be bad design. While reimplementing, make sure that SRP is maintained. See if any code is repetitive, and can be cut down.&lt;br /&gt;
&lt;br /&gt;
'''Improve naming''' - Some functions have confusing names. For example, the function “bequeath_copy” can definitely be given a better name if the functionality needs to be reimplemented. The over-populated “copy” related functions in this controller decrease the readability of the code.&lt;br /&gt;
&lt;br /&gt;
'''Better comments''' - Bigger files and functions require better comments for readability.&lt;br /&gt;
&lt;br /&gt;
'''2. Class Diagram:'''&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Teams assignment class diagram.png]]&lt;br /&gt;
&lt;br /&gt;
'''3. Functionality&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
In this project, we aim to:&lt;br /&gt;
&lt;br /&gt;
- Interact with teams assignment database (Basic CRUD) &lt;br /&gt;
- Interactions with a particular team assignment&lt;br /&gt;
&lt;br /&gt;
'''4. Project Design'''&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''4.1. Model'''&lt;br /&gt;
&lt;br /&gt;
This model is used to manage teams and their assignments. Here is a brief description of its key features:&lt;br /&gt;
&lt;br /&gt;
Associations: It has various associations with other models, including users, join_team_requests, team_node, signed_up_teams, and bids.&lt;br /&gt;
&lt;br /&gt;
CSV Import and Export: It contains methods for importing team data from a CSV file and exporting team data to a CSV file. The import method creates or finds teams and associates users with them based on the CSV data.&lt;br /&gt;
&lt;br /&gt;
Team Creation and Management: It includes methods to create a new team and add or remove users from teams. It checks for existing team membership before adding a user to a team.&lt;br /&gt;
&lt;br /&gt;
Team Name Generation: There is a method to generate a unique team name, which can be prefixed with a provided string.&lt;br /&gt;
&lt;br /&gt;
Version History: The model uses the has_paper_trail gem, which helps in tracking changes to the model's records over time.&lt;br /&gt;
&lt;br /&gt;
Code snippet can be found here:&lt;br /&gt;
&lt;br /&gt;
class TeamsAssignment &amp;lt; ApplicationRecord&lt;br /&gt;
  require 'csv'  # Require the 'csv' library&lt;br /&gt;
  &lt;br /&gt;
  has_many :users, through: :teams_users&lt;br /&gt;
  has_many :join_team_requests, dependent: :destroy&lt;br /&gt;
  has_one :team_node, foreign_key: :node_object_id, dependent: :destroy&lt;br /&gt;
  has_many :signed_up_teams, dependent: :destroy&lt;br /&gt;
  has_many :bids, dependent: :destroy&lt;br /&gt;
  has_paper_trail&lt;br /&gt;
&lt;br /&gt;
  # Import teams from a CSV file&lt;br /&gt;
  def self.import_teams_from_csv(file)&lt;br /&gt;
    CSV.foreach(file.path, headers: true) do |row|&lt;br /&gt;
      team = self.find_or_create_by(name: row['name'])&lt;br /&gt;
      team.users &amp;lt;&amp;lt; User.find_by(name: row['user_name'])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.export_teams_to_csv(file)&lt;br /&gt;
    CSV.open(file.path, 'w') do |csv|&lt;br /&gt;
    csv &amp;lt;&amp;lt; ['name', 'user_name'] # Add relevant column names&lt;br /&gt;
&lt;br /&gt;
      all.each do |team|&lt;br /&gt;
        team.users.each do |user|&lt;br /&gt;
          csv &amp;lt;&amp;lt; [team.name, user.name]&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Method to create a new team&lt;br /&gt;
  def create_team(name)&lt;br /&gt;
    team = Team.create(name: name, parent_id: self.id)&lt;br /&gt;
    TeamNode.create(parent_id: self.id, node_object_id: team.id)&lt;br /&gt;
    team&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Method to add a user to a team&lt;br /&gt;
  def add_user_to_team(team, user)&lt;br /&gt;
    # Check if the user is already a member of the team&lt;br /&gt;
    return if team.users.include?(user)&lt;br /&gt;
&lt;br /&gt;
    TeamsUser.create(team_id: team.id, user_id: user.id)&lt;br /&gt;
    # Optionally, you can add this user to any related associations, like CourseParticipants or AssignmentParticipants&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Method to remove a user from a team&lt;br /&gt;
  def remove_user_from_team(team, user)&lt;br /&gt;
    team_user = TeamsUser.find_by(team_id: team.id, user_id: user.id)&lt;br /&gt;
    team_user&amp;amp;.destroy&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Generate the team name&lt;br /&gt;
  def self.generate_team_name(team_name_prefix = '')&lt;br /&gt;
    counter = 1&lt;br /&gt;
    loop do&lt;br /&gt;
      team_name = &amp;quot;#{team_name_prefix} Team_#{counter}&amp;quot;&lt;br /&gt;
      return team_name unless TeamsAssignment.find_by(name: team_name)&lt;br /&gt;
&lt;br /&gt;
      counter += 1&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
'''4.2. Schema''' &lt;br /&gt;
&lt;br /&gt;
create_table &amp;quot;teams_assignments&amp;quot;, id: :integer, force: :cascade, options: &amp;quot;ENGINE=InnoDB DEFAULT CHARSET=latin1&amp;quot; do |t|&lt;br /&gt;
      t.string &amp;quot;name&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;parent_id&amp;quot;&lt;br /&gt;
      t.string &amp;quot;type&amp;quot;&lt;br /&gt;
      t.text &amp;quot;comments_for_advertisement&amp;quot;&lt;br /&gt;
      t.boolean &amp;quot;advertise_for_partner&amp;quot;&lt;br /&gt;
      t.text &amp;quot;submitted_hyperlinks&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;directory_num&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;grade_for_submission&amp;quot;&lt;br /&gt;
      t.text &amp;quot;comment_for_submission&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;pair_programming_request&amp;quot;, limit: 1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
'''4.3. Teams controller'''&lt;br /&gt;
&lt;br /&gt;
Api::V1::TeamsAssignmentController, which is responsible for handling HTTP requests related to a model named TeamAssignment. Here is a brief description of its key features:&lt;br /&gt;
&lt;br /&gt;
Before Actions: The controller specifies before actions using the before_action method. It sets up the @team_assignment instance variable for specific controller actions (show, update, destroy, and copy). It also uses rescue_from to handle exceptions.&lt;br /&gt;
&lt;br /&gt;
Index Action: The index action handles a GET request to list all team assignments. It retrieves all team assignments from the database and renders them as JSON.&lt;br /&gt;
&lt;br /&gt;
Show Action: The show action handles a GET request to retrieve a specific team assignment by its ID. It renders the team assignment as JSON.&lt;br /&gt;
&lt;br /&gt;
Create Action: The create action handles a POST request to create a new team assignment. It creates a new TeamAssignment instance with parameters from the request and saves it. It returns a JSON response with the created team assignment or error messages.&lt;br /&gt;
&lt;br /&gt;
Update Action: The update action handles a PUT or PATCH request to update an existing team assignment. It finds the team assignment, updates it with parameters from the request, and returns a JSON response with the updated team assignment or error messages.&lt;br /&gt;
&lt;br /&gt;
Destroy Action: The destroy action handles a DELETE request to delete a specific team assignment by its ID. It removes the team assignment from the database and returns a JSON response indicating the success of the deletion.&lt;br /&gt;
&lt;br /&gt;
Copy Action: The copy action handles a custom action to create a copy of a team assignment. It calls a method copy_team_assignment on the team assignment and returns a JSON response indicating the success or failure of the copy operation.&lt;br /&gt;
&lt;br /&gt;
Private Methods: There are several private methods used to encapsulate common functionality. set_team_assignment finds and sets the @team_assignment instance variable, team_assignment_params permits trusted parameters for creating or updating team assignments, and team_assignment_not_found and parameter_missing handle specific error cases.&lt;br /&gt;
&lt;br /&gt;
This controller provides a RESTful API for managing team assignments, including listing, creating, updating, and deleting team assignments, as well as a custom copy operation. It also includes error handling for common scenarios.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&lt;br /&gt;
class Api::V1::TeamsAssignmentController &amp;lt; ApplicationController&lt;br /&gt;
    &lt;br /&gt;
  before_action :set_team_assignment, only: %i[ show update destroy copy ]&lt;br /&gt;
  rescue_from ActiveRecord::RecordNotFound, with: :team_assignment_not_found&lt;br /&gt;
  rescue_from ActionController::ParameterMissing, with: :parameter_missing&lt;br /&gt;
&lt;br /&gt;
  # GET /team_assignments&lt;br /&gt;
  # List all the team_assignments&lt;br /&gt;
  def index&lt;br /&gt;
    team_assignment = TeamAssignment.all&lt;br /&gt;
    render json: team_assignment, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /team_assignments/1&lt;br /&gt;
  # Get a team_assignment&lt;br /&gt;
  def show&lt;br /&gt;
    render json: @team_assignment, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /team_assignments&lt;br /&gt;
  # Create a team_assignment&lt;br /&gt;
  def create&lt;br /&gt;
    team_assignment = TeamAssignment.new(team_assignment_params)&lt;br /&gt;
    if team_assignment.save&lt;br /&gt;
      render json: team_assignment, status: :created&lt;br /&gt;
    else&lt;br /&gt;
      render json: team_assignment.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PATCH/PUT /team_assignments/1&lt;br /&gt;
  # Update a team_assignment&lt;br /&gt;
  def update&lt;br /&gt;
    if @team_assignment.update(team_assignment_params)&lt;br /&gt;
      render json: @team_assignment, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: @team_assignment.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /team_assignments/1&lt;br /&gt;
  # Delete a team_assignment&lt;br /&gt;
  def destroy&lt;br /&gt;
    @team_assignment.destroy&lt;br /&gt;
    render json: { message: &amp;quot;Team assignment with id #{params[:id]}, deleted&amp;quot; }, status: :no_content&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Creates a copy of the team_assignment&lt;br /&gt;
  def copy&lt;br /&gt;
    if @team_assignment.copy_team_assignment&lt;br /&gt;
      render json: { message: &amp;quot;The team assignment #{@team_assignment.name} has been successfully copied&amp;quot; }, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: { message: &amp;quot;The team assignment was not able to be copied&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
&lt;br /&gt;
  # Use callbacks to share common setup or constraints between actions.&lt;br /&gt;
  def set_team_assignment&lt;br /&gt;
    @team_assignment = TeamAssignment.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Only allow a list of trusted parameters through.&lt;br /&gt;
  def team_assignment_params&lt;br /&gt;
    params.require(:team_assignment).permit(&lt;br /&gt;
        :name, :parent_id, :type, :comments_for_advertisement, :advertise_for_partner, :submitted_hyperlinks,&lt;br /&gt;
        :directory_num, :comment_for_submission, :pair_programming_request&lt;br /&gt;
    )&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def team_assignment_not_found&lt;br /&gt;
    render json: { error: &amp;quot;Team assignment with id #{params[:id]} not found&amp;quot; }, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def parameter_missing&lt;br /&gt;
    render json: { error: &amp;quot;Parameter missing&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
  &lt;br /&gt;
'''4.4 Testing Plan'''&lt;br /&gt;
&lt;br /&gt;
4.4.1. Model tests:&lt;br /&gt;
&lt;br /&gt;
Factory used:&lt;br /&gt;
&lt;br /&gt;
  factory :teams_assignment do&lt;br /&gt;
    name { &amp;quot;Sample Team Assignment&amp;quot; }&lt;br /&gt;
    parent_id { 1 } # You can adjust this value as needed&lt;br /&gt;
    type { &amp;quot;Assignment&amp;quot; }&lt;br /&gt;
    comments_for_advertisement { &amp;quot;Sample comments for advertisement&amp;quot; }&lt;br /&gt;
    advertise_for_partner { true }&lt;br /&gt;
    submitted_hyperlinks { &amp;quot;Sample hyperlinks&amp;quot; }&lt;br /&gt;
    directory_num { 1 }&lt;br /&gt;
    grade_for_submission { 100 }&lt;br /&gt;
    comment_for_submission { &amp;quot;Sample comment for submission&amp;quot; }&lt;br /&gt;
    pair_programming_request { 1 }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
To run model tests:&lt;br /&gt;
&lt;br /&gt;
1. git clone&lt;br /&gt;
&lt;br /&gt;
2. cd reimplementation-back-end/&lt;br /&gt;
&lt;br /&gt;
3. bundle install&lt;br /&gt;
&lt;br /&gt;
4. bundle exec rspec spec/models/teams_assignment_spec.rb&lt;br /&gt;
&lt;br /&gt;
To run controller tests:&lt;br /&gt;
&lt;br /&gt;
1. git clone&lt;br /&gt;
&lt;br /&gt;
2. cd reimplementation-back-end/&lt;br /&gt;
&lt;br /&gt;
3. bundle install&lt;br /&gt;
&lt;br /&gt;
4. 4. bundle exec rspec spec/requests/api/v1/teams_assignment_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
'''References:'''&lt;br /&gt;
&lt;br /&gt;
Github repo link[https://github.com/nitinjoseph11/reimplementation-back-end]&lt;br /&gt;
&lt;br /&gt;
Rspec documentation[https://rspec.info/documentation/3.8/rspec-core/]&lt;br /&gt;
&lt;br /&gt;
'''Team members:'''&lt;br /&gt;
&lt;br /&gt;
1. Reuben Vandezande&lt;br /&gt;
2. Nitin Joseph Madapally Abraham&lt;br /&gt;
&lt;br /&gt;
'''Mentor:'''&lt;br /&gt;
&lt;br /&gt;
Renji Joseph Sabu&lt;/div&gt;</summary>
		<author><name>Nmadapa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150773</id>
		<title>CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150773"/>
		<updated>2023-10-31T01:16:17Z</updated>

		<summary type="html">&lt;p&gt;Nmadapa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Project Overview'''&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
===1.1 Expertiza Background===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an online platform designed to facilitate peer review and submission of various types of academic work, including articles, codes, and websites. The application allows instructors to add assignments, grade them, and assign students to teams based on their topic preferences. The platform also enables students to provide feedback on each other's work through peer reviews, which can be helpful in improving the quality of their projects. Expertiza is backed by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
[['''1.2 Problem Statement''']]&lt;br /&gt;
&lt;br /&gt;
The teams_controller.rb file contains operations on teams like listing of teams of an assignment/course, updating a team, deleting teams of an assignment/course, copying teams between two assignments or courses among others. The model team.rb contains a lot of functions, with probable violations of single responsibility principle and this needs to be reimplemented with care. The files do not benefit from the complex names the functions are given.&lt;br /&gt;
&lt;br /&gt;
[['''What needs to be done:''']] &lt;br /&gt;
&lt;br /&gt;
'''Emphasize on Single Responsibility Principle''' - There are a questionable amount of functions that are directed at copying teams and team members between parents (courses/assignments). There are a lot of class functions in the model, which could be bad design. While reimplementing, make sure that SRP is maintained. See if any code is repetitive, and can be cut down.&lt;br /&gt;
&lt;br /&gt;
'''Improve naming''' - Some functions have confusing names. For example, the function “bequeath_copy” can definitely be given a better name if the functionality needs to be reimplemented. The over-populated “copy” related functions in this controller decrease the readability of the code.&lt;br /&gt;
&lt;br /&gt;
'''Better comments''' - Bigger files and functions require better comments for readability.&lt;br /&gt;
&lt;br /&gt;
'''2. Class Diagram:'''&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Teams assignment class diagram.png]]&lt;br /&gt;
&lt;br /&gt;
'''3. Functionality&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
In this project, we aim to:&lt;br /&gt;
&lt;br /&gt;
- Interact with teams assignment database (Basic CRUD) &lt;br /&gt;
- Interactions with a particular team assignment&lt;br /&gt;
&lt;br /&gt;
'''4. Project Design'''&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''4.1. Model'''&lt;br /&gt;
&lt;br /&gt;
This model is used to manage teams and their assignments. Here is a brief description of its key features:&lt;br /&gt;
&lt;br /&gt;
Associations: It has various associations with other models, including users, join_team_requests, team_node, signed_up_teams, and bids.&lt;br /&gt;
&lt;br /&gt;
CSV Import and Export: It contains methods for importing team data from a CSV file and exporting team data to a CSV file. The import method creates or finds teams and associates users with them based on the CSV data.&lt;br /&gt;
&lt;br /&gt;
Team Creation and Management: It includes methods to create a new team and add or remove users from teams. It checks for existing team membership before adding a user to a team.&lt;br /&gt;
&lt;br /&gt;
Team Name Generation: There is a method to generate a unique team name, which can be prefixed with a provided string.&lt;br /&gt;
&lt;br /&gt;
Version History: The model uses the has_paper_trail gem, which helps in tracking changes to the model's records over time.&lt;br /&gt;
&lt;br /&gt;
Code snippet can be found here:&lt;br /&gt;
&lt;br /&gt;
class TeamsAssignment &amp;lt; ApplicationRecord&lt;br /&gt;
  require 'csv'  # Require the 'csv' library&lt;br /&gt;
  &lt;br /&gt;
  has_many :users, through: :teams_users&lt;br /&gt;
  has_many :join_team_requests, dependent: :destroy&lt;br /&gt;
  has_one :team_node, foreign_key: :node_object_id, dependent: :destroy&lt;br /&gt;
  has_many :signed_up_teams, dependent: :destroy&lt;br /&gt;
  has_many :bids, dependent: :destroy&lt;br /&gt;
  has_paper_trail&lt;br /&gt;
&lt;br /&gt;
  # Import teams from a CSV file&lt;br /&gt;
  def self.import_teams_from_csv(file)&lt;br /&gt;
    CSV.foreach(file.path, headers: true) do |row|&lt;br /&gt;
      team = self.find_or_create_by(name: row['name'])&lt;br /&gt;
      team.users &amp;lt;&amp;lt; User.find_by(name: row['user_name'])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def self.export_teams_to_csv(file)&lt;br /&gt;
    CSV.open(file.path, 'w') do |csv|&lt;br /&gt;
    csv &amp;lt;&amp;lt; ['name', 'user_name'] # Add relevant column names&lt;br /&gt;
&lt;br /&gt;
      all.each do |team|&lt;br /&gt;
        team.users.each do |user|&lt;br /&gt;
          csv &amp;lt;&amp;lt; [team.name, user.name]&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Method to create a new team&lt;br /&gt;
  def create_team(name)&lt;br /&gt;
    team = Team.create(name: name, parent_id: self.id)&lt;br /&gt;
    TeamNode.create(parent_id: self.id, node_object_id: team.id)&lt;br /&gt;
    team&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Method to add a user to a team&lt;br /&gt;
  def add_user_to_team(team, user)&lt;br /&gt;
    # Check if the user is already a member of the team&lt;br /&gt;
    return if team.users.include?(user)&lt;br /&gt;
&lt;br /&gt;
    TeamsUser.create(team_id: team.id, user_id: user.id)&lt;br /&gt;
    # Optionally, you can add this user to any related associations, like CourseParticipants or AssignmentParticipants&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Method to remove a user from a team&lt;br /&gt;
  def remove_user_from_team(team, user)&lt;br /&gt;
    team_user = TeamsUser.find_by(team_id: team.id, user_id: user.id)&lt;br /&gt;
    team_user&amp;amp;.destroy&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Generate the team name&lt;br /&gt;
  def self.generate_team_name(team_name_prefix = '')&lt;br /&gt;
    counter = 1&lt;br /&gt;
    loop do&lt;br /&gt;
      team_name = &amp;quot;#{team_name_prefix} Team_#{counter}&amp;quot;&lt;br /&gt;
      return team_name unless TeamsAssignment.find_by(name: team_name)&lt;br /&gt;
&lt;br /&gt;
      counter += 1&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
'''4.2. Schema''' &lt;br /&gt;
&lt;br /&gt;
create_table &amp;quot;teams_assignments&amp;quot;, id: :integer, force: :cascade, options: &amp;quot;ENGINE=InnoDB DEFAULT CHARSET=latin1&amp;quot; do |t|&lt;br /&gt;
      t.string &amp;quot;name&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;parent_id&amp;quot;&lt;br /&gt;
      t.string &amp;quot;type&amp;quot;&lt;br /&gt;
      t.text &amp;quot;comments_for_advertisement&amp;quot;&lt;br /&gt;
      t.boolean &amp;quot;advertise_for_partner&amp;quot;&lt;br /&gt;
      t.text &amp;quot;submitted_hyperlinks&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;directory_num&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;grade_for_submission&amp;quot;&lt;br /&gt;
      t.text &amp;quot;comment_for_submission&amp;quot;&lt;br /&gt;
      t.integer &amp;quot;pair_programming_request&amp;quot;, limit: 1&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
'''4.3. Teams controller'''&lt;br /&gt;
&lt;br /&gt;
Api::V1::TeamsAssignmentController, which is responsible for handling HTTP requests related to a model named TeamAssignment. Here is a brief description of its key features:&lt;br /&gt;
&lt;br /&gt;
Before Actions: The controller specifies before actions using the before_action method. It sets up the @team_assignment instance variable for specific controller actions (show, update, destroy, and copy). It also uses rescue_from to handle exceptions.&lt;br /&gt;
&lt;br /&gt;
Index Action: The index action handles a GET request to list all team assignments. It retrieves all team assignments from the database and renders them as JSON.&lt;br /&gt;
&lt;br /&gt;
Show Action: The show action handles a GET request to retrieve a specific team assignment by its ID. It renders the team assignment as JSON.&lt;br /&gt;
&lt;br /&gt;
Create Action: The create action handles a POST request to create a new team assignment. It creates a new TeamAssignment instance with parameters from the request and saves it. It returns a JSON response with the created team assignment or error messages.&lt;br /&gt;
&lt;br /&gt;
Update Action: The update action handles a PUT or PATCH request to update an existing team assignment. It finds the team assignment, updates it with parameters from the request, and returns a JSON response with the updated team assignment or error messages.&lt;br /&gt;
&lt;br /&gt;
Destroy Action: The destroy action handles a DELETE request to delete a specific team assignment by its ID. It removes the team assignment from the database and returns a JSON response indicating the success of the deletion.&lt;br /&gt;
&lt;br /&gt;
Copy Action: The copy action handles a custom action to create a copy of a team assignment. It calls a method copy_team_assignment on the team assignment and returns a JSON response indicating the success or failure of the copy operation.&lt;br /&gt;
&lt;br /&gt;
Private Methods: There are several private methods used to encapsulate common functionality. set_team_assignment finds and sets the @team_assignment instance variable, team_assignment_params permits trusted parameters for creating or updating team assignments, and team_assignment_not_found and parameter_missing handle specific error cases.&lt;br /&gt;
&lt;br /&gt;
This controller provides a RESTful API for managing team assignments, including listing, creating, updating, and deleting team assignments, as well as a custom copy operation. It also includes error handling for common scenarios.&lt;br /&gt;
&lt;br /&gt;
Code snippet:&lt;br /&gt;
&lt;br /&gt;
class Api::V1::TeamsAssignmentController &amp;lt; ApplicationController&lt;br /&gt;
    &lt;br /&gt;
  before_action :set_team_assignment, only: %i[ show update destroy copy ]&lt;br /&gt;
  rescue_from ActiveRecord::RecordNotFound, with: :team_assignment_not_found&lt;br /&gt;
  rescue_from ActionController::ParameterMissing, with: :parameter_missing&lt;br /&gt;
&lt;br /&gt;
  # GET /team_assignments&lt;br /&gt;
  # List all the team_assignments&lt;br /&gt;
  def index&lt;br /&gt;
    team_assignment = TeamAssignment.all&lt;br /&gt;
    render json: team_assignment, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # GET /team_assignments/1&lt;br /&gt;
  # Get a team_assignment&lt;br /&gt;
  def show&lt;br /&gt;
    render json: @team_assignment, status: :ok&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # POST /team_assignments&lt;br /&gt;
  # Create a team_assignment&lt;br /&gt;
  def create&lt;br /&gt;
    team_assignment = TeamAssignment.new(team_assignment_params)&lt;br /&gt;
    if team_assignment.save&lt;br /&gt;
      render json: team_assignment, status: :created&lt;br /&gt;
    else&lt;br /&gt;
      render json: team_assignment.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # PATCH/PUT /team_assignments/1&lt;br /&gt;
  # Update a team_assignment&lt;br /&gt;
  def update&lt;br /&gt;
    if @team_assignment.update(team_assignment_params)&lt;br /&gt;
      render json: @team_assignment, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: @team_assignment.errors, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # DELETE /team_assignments/1&lt;br /&gt;
  # Delete a team_assignment&lt;br /&gt;
  def destroy&lt;br /&gt;
    @team_assignment.destroy&lt;br /&gt;
    render json: { message: &amp;quot;Team assignment with id #{params[:id]}, deleted&amp;quot; }, status: :no_content&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Creates a copy of the team_assignment&lt;br /&gt;
  def copy&lt;br /&gt;
    if @team_assignment.copy_team_assignment&lt;br /&gt;
      render json: { message: &amp;quot;The team assignment #{@team_assignment.name} has been successfully copied&amp;quot; }, status: :ok&lt;br /&gt;
    else&lt;br /&gt;
      render json: { message: &amp;quot;The team assignment was not able to be copied&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  private&lt;br /&gt;
&lt;br /&gt;
  # Use callbacks to share common setup or constraints between actions.&lt;br /&gt;
  def set_team_assignment&lt;br /&gt;
    @team_assignment = TeamAssignment.find(params[:id])&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Only allow a list of trusted parameters through.&lt;br /&gt;
  def team_assignment_params&lt;br /&gt;
    params.require(:team_assignment).permit(&lt;br /&gt;
        :name, :parent_id, :type, :comments_for_advertisement, :advertise_for_partner, :submitted_hyperlinks,&lt;br /&gt;
        :directory_num, :comment_for_submission, :pair_programming_request&lt;br /&gt;
    )&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def team_assignment_not_found&lt;br /&gt;
    render json: { error: &amp;quot;Team assignment with id #{params[:id]} not found&amp;quot; }, status: :not_found&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def parameter_missing&lt;br /&gt;
    render json: { error: &amp;quot;Parameter missing&amp;quot; }, status: :unprocessable_entity&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
  &lt;br /&gt;
'''4.4 Testing Plan'''&lt;br /&gt;
&lt;br /&gt;
4.4.1. Model tests:&lt;br /&gt;
&lt;br /&gt;
Factory used:&lt;br /&gt;
&lt;br /&gt;
  factory :teams_assignment do&lt;br /&gt;
    name { &amp;quot;Sample Team Assignment&amp;quot; }&lt;br /&gt;
    parent_id { 1 } # You can adjust this value as needed&lt;br /&gt;
    type { &amp;quot;Assignment&amp;quot; }&lt;br /&gt;
    comments_for_advertisement { &amp;quot;Sample comments for advertisement&amp;quot; }&lt;br /&gt;
    advertise_for_partner { true }&lt;br /&gt;
    submitted_hyperlinks { &amp;quot;Sample hyperlinks&amp;quot; }&lt;br /&gt;
    directory_num { 1 }&lt;br /&gt;
    grade_for_submission { 100 }&lt;br /&gt;
    comment_for_submission { &amp;quot;Sample comment for submission&amp;quot; }&lt;br /&gt;
    pair_programming_request { 1 }&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
To run model tests:&lt;br /&gt;
&lt;br /&gt;
1. git clone&lt;br /&gt;
&lt;br /&gt;
2. cd reimplementation-back-end/&lt;br /&gt;
&lt;br /&gt;
3. bundle install&lt;br /&gt;
&lt;br /&gt;
4. bundle exec rspec spec/models/teams_assignment_spec.rb&lt;br /&gt;
&lt;br /&gt;
To run controller tests:&lt;br /&gt;
&lt;br /&gt;
1. git clone&lt;br /&gt;
&lt;br /&gt;
2. cd reimplementation-back-end/&lt;br /&gt;
&lt;br /&gt;
3. bundle install&lt;br /&gt;
&lt;br /&gt;
4. 4. bundle exec rspec spec/requests/api/v1/teams_assignment_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
'''References:'''&lt;br /&gt;
&lt;br /&gt;
[https://github.com/nitinjoseph11/reimplementation-back-end]&lt;br /&gt;
&lt;br /&gt;
[https://rspec.info/documentation/3.8/rspec-core/]&lt;br /&gt;
&lt;br /&gt;
'''Team members:'''&lt;br /&gt;
&lt;br /&gt;
1. Reuben Vandezande&lt;br /&gt;
2. Nitin Joseph Madapally Abraham&lt;br /&gt;
&lt;br /&gt;
'''Mentor:'''&lt;br /&gt;
&lt;br /&gt;
Renji Joseph Sabu&lt;/div&gt;</summary>
		<author><name>Nmadapa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150752</id>
		<title>CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150752"/>
		<updated>2023-10-31T00:32:26Z</updated>

		<summary type="html">&lt;p&gt;Nmadapa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[['''1. Project Overview''']]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
===1.1 Expertiza Background===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an online platform designed to facilitate peer review and submission of various types of academic work, including articles, codes, and websites. The application allows instructors to add assignments, grade them, and assign students to teams based on their topic preferences. The platform also enables students to provide feedback on each other's work through peer reviews, which can be helpful in improving the quality of their projects. Expertiza is backed by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
[['''1.2 Problem Statement''']]&lt;br /&gt;
&lt;br /&gt;
The teams_controller.rb file contains operations on teams like listing of teams of an assignment/course, updating a team, deleting teams of an assignment/course, copying teams between two assignments or courses among others. The model team.rb contains a lot of functions, with probable violations of single responsibility principle and this needs to be reimplemented with care. The files do not benefit from the complex names the functions are given.&lt;br /&gt;
&lt;br /&gt;
[['''What needs to be done:''']] &lt;br /&gt;
&lt;br /&gt;
'''Emphasize on Single Responsibility Principle''' - There are a questionable amount of functions that are directed at copying teams and team members between parents (courses/assignments). There are a lot of class functions in the model, which could be bad design. While reimplementing, make sure that SRP is maintained. See if any code is repetitive, and can be cut down.&lt;br /&gt;
&lt;br /&gt;
'''Improve naming''' - Some functions have confusing names. For example, the function “bequeath_copy” can definitely be given a better name if the functionality needs to be reimplemented. The over-populated “copy” related functions in this controller decrease the readability of the code.&lt;br /&gt;
&lt;br /&gt;
'''Better comments''' - Bigger files and functions require better comments for readability.&lt;br /&gt;
&lt;br /&gt;
2. Class Diagram:&lt;br /&gt;
&lt;br /&gt;
[[File:Teams assignment class diagram.png]]&lt;/div&gt;</summary>
		<author><name>Nmadapa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Teams_assignment_class_diagram.png&amp;diff=150751</id>
		<title>File:Teams assignment class diagram.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Teams_assignment_class_diagram.png&amp;diff=150751"/>
		<updated>2023-10-31T00:31:45Z</updated>

		<summary type="html">&lt;p&gt;Nmadapa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nmadapa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150750</id>
		<title>CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150750"/>
		<updated>2023-10-31T00:31:10Z</updated>

		<summary type="html">&lt;p&gt;Nmadapa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[['''1. Project Overview''']]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
===1.1 Expertiza Background===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an online platform designed to facilitate peer review and submission of various types of academic work, including articles, codes, and websites. The application allows instructors to add assignments, grade them, and assign students to teams based on their topic preferences. The platform also enables students to provide feedback on each other's work through peer reviews, which can be helpful in improving the quality of their projects. Expertiza is backed by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
[['''1.2 Problem Statement''']]&lt;br /&gt;
&lt;br /&gt;
The teams_controller.rb file contains operations on teams like listing of teams of an assignment/course, updating a team, deleting teams of an assignment/course, copying teams between two assignments or courses among others. The model team.rb contains a lot of functions, with probable violations of single responsibility principle and this needs to be reimplemented with care. The files do not benefit from the complex names the functions are given.&lt;br /&gt;
&lt;br /&gt;
[['''What needs to be done:''']] &lt;br /&gt;
&lt;br /&gt;
'''Emphasize on Single Responsibility Principle''' - There are a questionable amount of functions that are directed at copying teams and team members between parents (courses/assignments). There are a lot of class functions in the model, which could be bad design. While reimplementing, make sure that SRP is maintained. See if any code is repetitive, and can be cut down.&lt;br /&gt;
&lt;br /&gt;
'''Improve naming''' - Some functions have confusing names. For example, the function “bequeath_copy” can definitely be given a better name if the functionality needs to be reimplemented. The over-populated “copy” related functions in this controller decrease the readability of the code.&lt;br /&gt;
&lt;br /&gt;
'''Better comments''' - Bigger files and functions require better comments for readability.&lt;br /&gt;
&lt;br /&gt;
2. Class Diagram:&lt;/div&gt;</summary>
		<author><name>Nmadapa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150744</id>
		<title>CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150744"/>
		<updated>2023-10-31T00:06:03Z</updated>

		<summary type="html">&lt;p&gt;Nmadapa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[['''Project Overview''']]&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
===Expertiza Background===&lt;br /&gt;
&lt;br /&gt;
Expertiza is an online platform designed to facilitate peer review and submission of various types of academic work, including articles, codes, and websites. The application allows instructors to add assignments, grade them, and assign students to teams based on their topic preferences. The platform also enables students to provide feedback on each other's work through peer reviews, which can be helpful in improving the quality of their projects. Expertiza is backed by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
[['''Problem Statement''']]&lt;br /&gt;
&lt;br /&gt;
The teams_controller.rb file contains operations on teams like listing of teams of an assignment/course, updating a team, deleting teams of an assignment/course, copying teams between two assignments or courses among others. The model team.rb contains a lot of functions, with probable violations of single responsibility principle and this needs to be reimplemented with care. The files do not benefit from the complex names the functions are given.&lt;br /&gt;
&lt;br /&gt;
[['''What needs to be done:''']] &lt;br /&gt;
&lt;br /&gt;
'''Emphasize on Single Responsibility Principle''' - There are a questionable amount of functions that are directed at copying teams and team members between parents (courses/assignments). There are a lot of class functions in the model, which could be bad design. While reimplementing, make sure that SRP is maintained. See if any code is repetitive, and can be cut down.&lt;br /&gt;
&lt;br /&gt;
'''Improve naming''' - Some functions have confusing names. For example, the function “bequeath_copy” can definitely be given a better name if the functionality needs to be reimplemented. The over-populated “copy” related functions in this controller decrease the readability of the code.&lt;br /&gt;
&lt;br /&gt;
'''Better comments''' - Bigger files and functions require better comments for readability.&lt;/div&gt;</summary>
		<author><name>Nmadapa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150742</id>
		<title>CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023_-_E2373._Reimplementation_of_teams_controller&amp;diff=150742"/>
		<updated>2023-10-31T00:03:10Z</updated>

		<summary type="html">&lt;p&gt;Nmadapa: Created page with &amp;quot;'''Project Overview'''  '''Expertiza Background'''  Expertiza is an online platform designed to facilitate peer review and submission of various types of academic work...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[['''Project Overview''']]&lt;br /&gt;
&lt;br /&gt;
[['''Expertiza Background''']]&lt;br /&gt;
&lt;br /&gt;
Expertiza is an online platform designed to facilitate peer review and submission of various types of academic work, including articles, codes, and websites. The application allows instructors to add assignments, grade them, and assign students to teams based on their topic preferences. The platform also enables students to provide feedback on each other's work through peer reviews, which can be helpful in improving the quality of their projects. Expertiza is backed by the National Science Foundation.&lt;br /&gt;
&lt;br /&gt;
[['''Problem Statement''']]&lt;br /&gt;
&lt;br /&gt;
The teams_controller.rb file contains operations on teams like listing of teams of an assignment/course, updating a team, deleting teams of an assignment/course, copying teams between two assignments or courses among others. The model team.rb contains a lot of functions, with probable violations of single responsibility principle and this needs to be reimplemented with care. The files do not benefit from the complex names the functions are given.&lt;br /&gt;
&lt;br /&gt;
[['''What needs to be done:''']] &lt;br /&gt;
&lt;br /&gt;
'''Emphasize on Single Responsibility Principle''' - There are a questionable amount of functions that are directed at copying teams and team members between parents (courses/assignments). There are a lot of class functions in the model, which could be bad design. While reimplementing, make sure that SRP is maintained. See if any code is repetitive, and can be cut down.&lt;br /&gt;
&lt;br /&gt;
'''Improve naming''' - Some functions have confusing names. For example, the function “bequeath_copy” can definitely be given a better name if the functionality needs to be reimplemented. The over-populated “copy” related functions in this controller decrease the readability of the code.&lt;br /&gt;
&lt;br /&gt;
'''Better comments''' - Bigger files and functions require better comments for readability.&lt;/div&gt;</summary>
		<author><name>Nmadapa</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023&amp;diff=150674</id>
		<title>CSC/ECE 517 Fall 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2023&amp;diff=150674"/>
		<updated>2023-10-30T23:12:48Z</updated>

		<summary type="html">&lt;p&gt;Nmadapa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Fall 2023 - E2358. Refactor student_quizzes_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2351. Finish mentor management for assignments without topics]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2356. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2359. Refactor user_controller.rb, user.rb, and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2367. Reimplement participants_controller.rb, participants.rb and its child classes]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2355. Improving Search Facility In Expertiza]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2365. Create a user interface for Questionnaire in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2364. Create a UI for Course's &amp;amp; Assignment's &amp;quot;Add Participants&amp;quot; page]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2361. Create a page to create and update a Questionnaire in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2362. Create a page to edit an Assignment's due date in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2363. Create a UI for Assignment Edit page &amp;quot;Etc&amp;quot; tab in ReactJS]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2375. Reimplement Waitlists]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2357. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2366. Reimplement assignment model and assignment controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2370. Reimplement join team requests controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2371. Reimplement quiz_questionnaires_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2369. Reimplement duties controller.rb and badges controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2353. Further refactoring and improvement of review mapping helper]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2023 - E2373. Reimplementation of teams controller]]&lt;/div&gt;</summary>
		<author><name>Nmadapa</name></author>
	</entry>
</feed>