<?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=Uraycha</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=Uraycha"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Uraycha"/>
	<updated>2026-05-06T16:47:54Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165156</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165156"/>
		<updated>2025-04-23T03:49:36Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* TeamsController */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
&lt;br /&gt;
* '''Teams:'''&lt;br /&gt;
** '''index:''' Fetches all teams and renders them.&lt;br /&gt;
** '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
** '''create:''' Persists a new team record.&lt;br /&gt;
:[[File:E2533 teams controller crud team.png]]&lt;br /&gt;
&lt;br /&gt;
* '''validate_team_type:''' Validates the team type before team creation to ensure it's among allowed types.&lt;br /&gt;
:[[File:E2533 teams controller validate team type.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Team members:'''&lt;br /&gt;
** '''members:''' Lists all members of a specific team&lt;br /&gt;
** '''add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
** '''remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
:[[File:E2533 teams controller members.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Join requests:'''&lt;br /&gt;
** '''create_join_request:'''  Creates a new join request for a team.&lt;br /&gt;
** '''join_requests:'''  Lists all join requests for the team.&lt;br /&gt;
** '''update_join_request:'''  Updates the status or details of a specific join request&lt;br /&gt;
:[[File:E2533 teams controller join requests.png]]&lt;br /&gt;
&lt;br /&gt;
=== TeamOperationsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamOperationsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. &amp;lt;br/&amp;gt;By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper2.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''full?:''' Checks if team if full and returns a boolean.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
* '''member?:''' Checks if a user is a member of the team.&lt;br /&gt;
* '''team_size:''' Returns the current count of team members.&lt;br /&gt;
* '''validate_membership:''' To be used by the subclasses.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model2.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''copy_to_course_team(course):''' Copies details if the assignment team to a course team. Includes team name, team members and team size.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in the assignment.&lt;br /&gt;
* '''type_must_be_assignment_or_mentored_team:''' Checks if the team type is either assignment team or mentored team.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model2.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
CourseTeam is designed for teams that persist across an entire course. It validates the course membership of a user.&lt;br /&gt;
&lt;br /&gt;
'''Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user is eligible for the course team before joining.&lt;br /&gt;
* '''copy_to_assignment_team:''' Copies the details of a course team, consisting of team name, team size and team members to a new assignment team.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in any assignment in the course.&lt;br /&gt;
* '''type_must_be_course_team:''' Checks if the team type is 'CourseTeam'  &lt;br /&gt;
&lt;br /&gt;
[[File:E2533 course team model2.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
''' Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user being added to the team is not already a mentor.&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., mentor role).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_must_have_mentor_role:''' Ensures that the chosen mentor is valid for the assignment and has the role 'mentor'.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model2.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment'''&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 2participant model.png]]&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
To successfully run the test cases, we would need to bypass the authentication controller, otherwise we will end up getting a 404 Unauthorized Error!&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: https://github.com/expertiza/reimplementation-back-end/pull/193&amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: https://youtu.be/gKZXYk8HNWc&amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_teams_controller_crud_team.png&amp;diff=165155</id>
		<title>File:E2533 teams controller crud team.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_teams_controller_crud_team.png&amp;diff=165155"/>
		<updated>2025-04-23T03:48:51Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165152</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165152"/>
		<updated>2025-04-23T03:46:14Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* TeamsHelper */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
:[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
:[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''validate_team_type:''' Validates the team type before team creation to ensure it's among allowed types.&lt;br /&gt;
:[[File:E2533 teams controller validate team type.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Team members:'''&lt;br /&gt;
** '''members:''' Lists all members of a specific team&lt;br /&gt;
** '''add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
** '''remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
:[[File:E2533 teams controller members.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Join requests:'''&lt;br /&gt;
** '''create_join_request:'''  Creates a new join request for a team.&lt;br /&gt;
** '''join_requests:'''  Lists all join requests for the team.&lt;br /&gt;
** '''update_join_request:'''  Updates the status or details of a specific join request&lt;br /&gt;
:[[File:E2533 teams controller join requests.png]]&lt;br /&gt;
&lt;br /&gt;
=== TeamOperationsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamOperationsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. &amp;lt;br/&amp;gt;By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper2.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''full?:''' Checks if team if full and returns a boolean.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
* '''member?:''' Checks if a user is a member of the team.&lt;br /&gt;
* '''team_size:''' Returns the current count of team members.&lt;br /&gt;
* '''validate_membership:''' To be used by the subclasses.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model2.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''copy_to_course_team(course):''' Copies details if the assignment team to a course team. Includes team name, team members and team size.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in the assignment.&lt;br /&gt;
* '''type_must_be_assignment_or_mentored_team:''' Checks if the team type is either assignment team or mentored team.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model2.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
CourseTeam is designed for teams that persist across an entire course. It validates the course membership of a user.&lt;br /&gt;
&lt;br /&gt;
'''Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user is eligible for the course team before joining.&lt;br /&gt;
* '''copy_to_assignment_team:''' Copies the details of a course team, consisting of team name, team size and team members to a new assignment team.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in any assignment in the course.&lt;br /&gt;
* '''type_must_be_course_team:''' Checks if the team type is 'CourseTeam'  &lt;br /&gt;
&lt;br /&gt;
[[File:E2533 course team model2.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
''' Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user being added to the team is not already a mentor.&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., mentor role).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_must_have_mentor_role:''' Ensures that the chosen mentor is valid for the assignment and has the role 'mentor'.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model2.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment'''&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 2participant model.png]]&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
To successfully run the test cases, we would need to bypass the authentication controller, otherwise we will end up getting a 404 Unauthorized Error!&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: https://github.com/expertiza/reimplementation-back-end/pull/193&amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: https://youtu.be/gKZXYk8HNWc&amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_team_helper2.png&amp;diff=165150</id>
		<title>File:E2533 team helper2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_team_helper2.png&amp;diff=165150"/>
		<updated>2025-04-23T03:45:15Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165149</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165149"/>
		<updated>2025-04-23T03:43:35Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* Team */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
:[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
:[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''validate_team_type:''' Validates the team type before team creation to ensure it's among allowed types.&lt;br /&gt;
:[[File:E2533 teams controller validate team type.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Team members:'''&lt;br /&gt;
** '''members:''' Lists all members of a specific team&lt;br /&gt;
** '''add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
** '''remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
:[[File:E2533 teams controller members.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Join requests:'''&lt;br /&gt;
** '''create_join_request:'''  Creates a new join request for a team.&lt;br /&gt;
** '''join_requests:'''  Lists all join requests for the team.&lt;br /&gt;
** '''update_join_request:'''  Updates the status or details of a specific join request&lt;br /&gt;
:[[File:E2533 teams controller join requests.png]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''full?:''' Checks if team if full and returns a boolean.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
* '''member?:''' Checks if a user is a member of the team.&lt;br /&gt;
* '''team_size:''' Returns the current count of team members.&lt;br /&gt;
* '''validate_membership:''' To be used by the subclasses.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model2.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''copy_to_course_team(course):''' Copies details if the assignment team to a course team. Includes team name, team members and team size.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in the assignment.&lt;br /&gt;
* '''type_must_be_assignment_or_mentored_team:''' Checks if the team type is either assignment team or mentored team.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model2.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
CourseTeam is designed for teams that persist across an entire course. It validates the course membership of a user.&lt;br /&gt;
&lt;br /&gt;
'''Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user is eligible for the course team before joining.&lt;br /&gt;
* '''copy_to_assignment_team:''' Copies the details of a course team, consisting of team name, team size and team members to a new assignment team.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in any assignment in the course.&lt;br /&gt;
* '''type_must_be_course_team:''' Checks if the team type is 'CourseTeam'  &lt;br /&gt;
&lt;br /&gt;
[[File:E2533 course team model2.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
''' Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user being added to the team is not already a mentor.&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., mentor role).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_must_have_mentor_role:''' Ensures that the chosen mentor is valid for the assignment and has the role 'mentor'.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model2.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment'''&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 2participant model.png]]&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
To successfully run the test cases, we would need to bypass the authentication controller, otherwise we will end up getting a 404 Unauthorized Error!&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: https://github.com/expertiza/reimplementation-back-end/pull/193&amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: https://youtu.be/gKZXYk8HNWc&amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_team_model2.png&amp;diff=165146</id>
		<title>File:E2533 team model2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_team_model2.png&amp;diff=165146"/>
		<updated>2025-04-23T03:40:02Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165145</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165145"/>
		<updated>2025-04-23T03:38:43Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* AssignmentTeam */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
:[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
:[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''validate_team_type:''' Validates the team type before team creation to ensure it's among allowed types.&lt;br /&gt;
:[[File:E2533 teams controller validate team type.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Team members:'''&lt;br /&gt;
** '''members:''' Lists all members of a specific team&lt;br /&gt;
** '''add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
** '''remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
:[[File:E2533 teams controller members.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Join requests:'''&lt;br /&gt;
** '''create_join_request:'''  Creates a new join request for a team.&lt;br /&gt;
** '''join_requests:'''  Lists all join requests for the team.&lt;br /&gt;
** '''update_join_request:'''  Updates the status or details of a specific join request&lt;br /&gt;
:[[File:E2533 teams controller join requests.png]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''copy_to_course_team(course):''' Copies details if the assignment team to a course team. Includes team name, team members and team size.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in the assignment.&lt;br /&gt;
* '''type_must_be_assignment_or_mentored_team:''' Checks if the team type is either assignment team or mentored team.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model2.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
CourseTeam is designed for teams that persist across an entire course. It validates the course membership of a user.&lt;br /&gt;
&lt;br /&gt;
'''Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user is eligible for the course team before joining.&lt;br /&gt;
* '''copy_to_assignment_team:''' Copies the details of a course team, consisting of team name, team size and team members to a new assignment team.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in any assignment in the course.&lt;br /&gt;
* '''type_must_be_course_team:''' Checks if the team type is 'CourseTeam'  &lt;br /&gt;
&lt;br /&gt;
[[File:E2533 course team model2.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
''' Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user being added to the team is not already a mentor.&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., mentor role).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_must_have_mentor_role:''' Ensures that the chosen mentor is valid for the assignment and has the role 'mentor'.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model2.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment'''&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 2participant model.png]]&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
To successfully run the test cases, we would need to bypass the authentication controller, otherwise we will end up getting a 404 Unauthorized Error!&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: https://github.com/expertiza/reimplementation-back-end/pull/193&amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: https://youtu.be/gKZXYk8HNWc&amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_assignment_team_model2.png&amp;diff=165144</id>
		<title>File:E2533 assignment team model2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_assignment_team_model2.png&amp;diff=165144"/>
		<updated>2025-04-23T03:34:47Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165142</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165142"/>
		<updated>2025-04-23T03:33:47Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* CourseTeam */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
:[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
:[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''validate_team_type:''' Validates the team type before team creation to ensure it's among allowed types.&lt;br /&gt;
:[[File:E2533 teams controller validate team type.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Team members:'''&lt;br /&gt;
** '''members:''' Lists all members of a specific team&lt;br /&gt;
** '''add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
** '''remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
:[[File:E2533 teams controller members.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Join requests:'''&lt;br /&gt;
** '''create_join_request:'''  Creates a new join request for a team.&lt;br /&gt;
** '''join_requests:'''  Lists all join requests for the team.&lt;br /&gt;
** '''update_join_request:'''  Updates the status or details of a specific join request&lt;br /&gt;
:[[File:E2533 teams controller join requests.png]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
CourseTeam is designed for teams that persist across an entire course. It validates the course membership of a user.&lt;br /&gt;
&lt;br /&gt;
'''Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user is eligible for the course team before joining.&lt;br /&gt;
* '''copy_to_assignment_team:''' Copies the details of a course team, consisting of team name, team size and team members to a new assignment team.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in any assignment in the course.&lt;br /&gt;
* '''type_must_be_course_team:''' Checks if the team type is 'CourseTeam'  &lt;br /&gt;
&lt;br /&gt;
[[File:E2533 course team model2.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
''' Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user being added to the team is not already a mentor.&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., mentor role).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_must_have_mentor_role:''' Ensures that the chosen mentor is valid for the assignment and has the role 'mentor'.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model2.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment'''&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 2participant model.png]]&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
To successfully run the test cases, we would need to bypass the authentication controller, otherwise we will end up getting a 404 Unauthorized Error!&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: https://github.com/expertiza/reimplementation-back-end/pull/193&amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: https://youtu.be/gKZXYk8HNWc&amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_course_team_model2.png&amp;diff=165141</id>
		<title>File:E2533 course team model2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_course_team_model2.png&amp;diff=165141"/>
		<updated>2025-04-23T03:33:31Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165139</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165139"/>
		<updated>2025-04-23T03:32:15Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* MentoredTeam */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
:[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
:[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''validate_team_type:''' Validates the team type before team creation to ensure it's among allowed types.&lt;br /&gt;
:[[File:E2533 teams controller validate team type.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Team members:'''&lt;br /&gt;
** '''members:''' Lists all members of a specific team&lt;br /&gt;
** '''add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
** '''remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
:[[File:E2533 teams controller members.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Join requests:'''&lt;br /&gt;
** '''create_join_request:'''  Creates a new join request for a team.&lt;br /&gt;
** '''join_requests:'''  Lists all join requests for the team.&lt;br /&gt;
** '''update_join_request:'''  Updates the status or details of a specific join request&lt;br /&gt;
:[[File:E2533 teams controller join requests.png]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
CourseTeam is designed for teams that persist across an entire course. It validates the course membership of a user.&lt;br /&gt;
&lt;br /&gt;
'''Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user is eligible for the course team before joining.&lt;br /&gt;
* '''copy_to_assignment_team:''' Copies the details of a course team, consisting of team name, team size and team members to a new assignment team.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in any assignment in the course.&lt;br /&gt;
* '''type_must_be_course_team:''' Checks if the team type is 'CourseTeam'  &lt;br /&gt;
&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
''' Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user being added to the team is not already a mentor.&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., mentor role).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_must_have_mentor_role:''' Ensures that the chosen mentor is valid for the assignment and has the role 'mentor'.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model2.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment'''&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 2participant model.png]]&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
To successfully run the test cases, we would need to bypass the authentication controller, otherwise we will end up getting a 404 Unauthorized Error!&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: https://github.com/expertiza/reimplementation-back-end/pull/193&amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: https://youtu.be/gKZXYk8HNWc&amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_mentored_team_model2.png&amp;diff=165137</id>
		<title>File:E2533 mentored team model2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_mentored_team_model2.png&amp;diff=165137"/>
		<updated>2025-04-23T03:31:36Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165130</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165130"/>
		<updated>2025-04-23T03:29:19Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* Participant */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
:[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
:[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''validate_team_type:''' Validates the team type before team creation to ensure it's among allowed types.&lt;br /&gt;
:[[File:E2533 teams controller validate team type.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Team members:'''&lt;br /&gt;
** '''members:''' Lists all members of a specific team&lt;br /&gt;
** '''add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
** '''remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
:[[File:E2533 teams controller members.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Join requests:'''&lt;br /&gt;
** '''create_join_request:'''  Creates a new join request for a team.&lt;br /&gt;
** '''join_requests:'''  Lists all join requests for the team.&lt;br /&gt;
** '''update_join_request:'''  Updates the status or details of a specific join request&lt;br /&gt;
:[[File:E2533 teams controller join requests.png]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
CourseTeam is designed for teams that persist across an entire course. It validates the course membership of a user.&lt;br /&gt;
&lt;br /&gt;
'''Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user is eligible for the course team before joining.&lt;br /&gt;
* '''copy_to_assignment_team:''' Copies the details of a course team, consisting of team name, team size and team members to a new assignment team.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in any assignment in the course.&lt;br /&gt;
* '''type_must_be_course_team:''' Checks if the team type is 'CourseTeam'  &lt;br /&gt;
&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
''' Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user being added to the team is not already a mentor.&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., mentor role).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_must_have_mentor_role:''' Ensures that the chosen mentor is valid for the assignment and has the role 'mentor'.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment'''&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 2participant model.png]]&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
To successfully run the test cases, we would need to bypass the authentication controller, otherwise we will end up getting a 404 Unauthorized Error!&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: https://github.com/expertiza/reimplementation-back-end/pull/193&amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: https://youtu.be/gKZXYk8HNWc&amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_2participant_model.png&amp;diff=165129</id>
		<title>File:E2533 2participant model.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_2participant_model.png&amp;diff=165129"/>
		<updated>2025-04-23T03:29:01Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_participant_model.png&amp;diff=165123</id>
		<title>File:E2533 participant model.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_participant_model.png&amp;diff=165123"/>
		<updated>2025-04-23T03:24:38Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: Uraycha uploaded a new version of File:E2533 participant model.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165108</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165108"/>
		<updated>2025-04-23T03:13:22Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* TeamsController */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
:[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
:[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''validate_team_type:''' Validates the team type before team creation to ensure it's among allowed types.&lt;br /&gt;
:[[File:E2533 teams controller validate team type.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Team members:'''&lt;br /&gt;
** '''members:''' Lists all members of a specific team&lt;br /&gt;
** '''add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
** '''remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
:[[File:E2533 teams controller members.png]]&lt;br /&gt;
&lt;br /&gt;
* '''Join requests:'''&lt;br /&gt;
** '''create_join_request:'''  Creates a new join request for a team.&lt;br /&gt;
** '''join_requests:'''  Lists all join requests for the team.&lt;br /&gt;
** '''update_join_request:'''  Updates the status or details of a specific join request&lt;br /&gt;
:[[File:E2533 teams controller join requests.png]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
CourseTeam is designed for teams that persist across an entire course. It validates the course membership of a user.&lt;br /&gt;
&lt;br /&gt;
'''Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user is eligible for the course team before joining.&lt;br /&gt;
* '''copy_to_assignment_team:''' Copies the details of a course team, consisting of team name, team size and team members to a new assignment team.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in any assignment in the course.&lt;br /&gt;
* '''type_must_be_course_team:''' Checks if the team type is 'CourseTeam'  &lt;br /&gt;
&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
''' Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user being added to the team is not already a mentor.&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., mentor role).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_must_have_mentor_role:''' Ensures that the chosen mentor is valid for the assignment and has the role 'mentor'.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment'''&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
To successfully run the test cases, we would need to bypass the authentication controller, otherwise we will end up getting a 404 Unauthorized Error!&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: https://github.com/expertiza/reimplementation-back-end/pull/193&amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: https://youtu.be/gKZXYk8HNWc&amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_teams_controller_members.png&amp;diff=165102</id>
		<title>File:E2533 teams controller members.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_teams_controller_members.png&amp;diff=165102"/>
		<updated>2025-04-23T03:11:42Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_teams_controller_validate_team_type.png&amp;diff=165098</id>
		<title>File:E2533 teams controller validate team type.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_teams_controller_validate_team_type.png&amp;diff=165098"/>
		<updated>2025-04-23T03:04:05Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165093</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=165093"/>
		<updated>2025-04-23T03:00:38Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* TeamsController */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
:[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
:[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
:[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''Join requests:'''&lt;br /&gt;
** '''create_join_request:'''  Creates a new join request for a team.&lt;br /&gt;
** '''join_requests:'''  Lists all join requests for the team.&lt;br /&gt;
** '''update_join_request:'''  Updates the status or details of a specific join request&lt;br /&gt;
** '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
:[[File:E2533 teams controller join requests.png]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
CourseTeam is designed for teams that persist across an entire course. It validates the course membership of a user.&lt;br /&gt;
&lt;br /&gt;
'''Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user is eligible for the course team before joining.&lt;br /&gt;
* '''copy_to_assignment_team:''' Copies the details of a course team, consisting of team name, team size and team members to a new assignment team.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in any assignment in the course.&lt;br /&gt;
* '''type_must_be_course_team:''' Checks if the team type is 'CourseTeam'  &lt;br /&gt;
&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
''' Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user being added to the team is not already a mentor.&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., mentor role).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_must_have_mentor_role:''' Ensures that the chosen mentor is valid for the assignment and has the role 'mentor'.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment'''&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
To successfully run the test cases, we would need to bypass the authentication controller, otherwise we will end up getting a 404 Unauthorized Error!&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: https://github.com/expertiza/reimplementation-back-end/pull/193&amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: https://youtu.be/gKZXYk8HNWc&amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_teams_controller_join_requests.png&amp;diff=165092</id>
		<title>File:E2533 teams controller join requests.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_teams_controller_join_requests.png&amp;diff=165092"/>
		<updated>2025-04-23T02:59:45Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164996</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164996"/>
		<updated>2025-04-23T02:07:51Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* CourseTeam */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
CourseTeam is designed for teams that persist across an entire course. It validates the course membership of a user.&lt;br /&gt;
&lt;br /&gt;
'''Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user is eligible for the course team before joining.&lt;br /&gt;
* '''copy_to_assignment_team:''' Copies the details of a course team, consisting of team name, team size and team members to a new assignment team.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in any assignment in the course.&lt;br /&gt;
* '''type_must_be_course_team:''' Checks if the team type is 'CourseTeam'  &lt;br /&gt;
&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
''' Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user being added to the team is not already a mentor.&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., mentor role).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_must_have_mentor_role:''' Ensures that the chosen mentor is valid for the assignment and has the role 'mentor'.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment'''&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
To successfully run the test cases, we would need to bypass the authentication controller, otherwise we will end up getting a 404 Unauthorized Error!&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: https://github.com/expertiza/reimplementation-back-end/pull/193&amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: https://youtu.be/gKZXYk8HNWc&amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164976</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164976"/>
		<updated>2025-04-23T01:55:25Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* Overview of classes and Implementation (In editing !!!) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
CourseTeam is designed for teams that persist across an entire course. It validates the course membership of a user.&lt;br /&gt;
&lt;br /&gt;
'''Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user is eligible for the course team before joining.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in any assignment in the course.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
''' Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user being added to the team is not already a mentor.&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., mentor role).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_must_have_mentor_role:''' Ensures that the chosen mentor is valid for the assignment and has the role 'mentor'.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment'''&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
To successfully run the test cases, we would need to bypass the authentication controller, otherwise we will end up getting a 404 Unauthorized Error!&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: https://github.com/expertiza/reimplementation-back-end/pull/193&amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: https://youtu.be/gKZXYk8HNWc&amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164962</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164962"/>
		<updated>2025-04-23T01:35:49Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* Relevant Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation (In editing !!!)==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
CourseTeam is designed for teams that persist across an entire course. It validates the course membership of a user.&lt;br /&gt;
&lt;br /&gt;
'''Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user is eligible for the course team before joining.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in any assignment in the course.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment'''&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
To successfully run the test cases, we would need to bypass the authentication controller, otherwise we will end up getting a 404 Unauthorized Error!&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: https://github.com/expertiza/reimplementation-back-end/pull/193&amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: https://youtu.be/gKZXYk8HNWc&amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164911</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164911"/>
		<updated>2025-04-23T01:03:30Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* CourseTeam */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation (In editing !!!)==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
CourseTeam is designed for teams that persist across an entire course. It validates the course membership of a user.&lt;br /&gt;
&lt;br /&gt;
'''Additions:'''&lt;br /&gt;
* '''add_member(user):''' Ensures the user is eligible for the course team before joining.&lt;br /&gt;
* '''validate_membership:''' Checks if user is enrolled in any assignment in the course.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment'''&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
To successfully run the test cases, we would need to bypass the authentication controller, otherwise we will end up getting a 404 Unauthorized Error!&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: &amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: &amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164896</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164896"/>
		<updated>2025-04-23T00:58:17Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* Participant */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation (In editing !!!)==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment'''&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
To successfully run the test cases, we would need to bypass the authentication controller, otherwise we will end up getting a 404 Unauthorized Error!&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: &amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: &amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164893</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164893"/>
		<updated>2025-04-23T00:57:06Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* Testing Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation (In editing !!!)==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment''' (if applicable)&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
To successfully run the test cases, we would need to bypass the authentication controller, otherwise we will end up getting a 404 Unauthorized Error!&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: &amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: &amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164878</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164878"/>
		<updated>2025-04-23T00:47:48Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* Final Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation (In editing !!!)==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment''' (if applicable)&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: &amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: &amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164876</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164876"/>
		<updated>2025-04-23T00:46:10Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* Testing Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation (In editing !!!)==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment''' (if applicable)&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Final Notes ===&lt;br /&gt;
* '''Implementation &amp;amp; Testing:'''  &lt;br /&gt;
We have not yet implemented or tested the classes and methods described here. Once we begin coding, we will follow these designs closely and write RSpec tests to ensure all functionalities work as intended.&lt;br /&gt;
&lt;br /&gt;
* '''Code Readability &amp;amp; Documentation:'''  &lt;br /&gt;
We plan to maintain thorough inline documentation and adopt clear method names. This will make it easier for new contributors to understand and modify our team hierarchy.&lt;br /&gt;
&lt;br /&gt;
* '''Project Mentorship:'''  &lt;br /&gt;
Sahithi Ammana is providing guidance throughout this project, ensuring that our approach aligns with best practices and remains scalable for future needs.&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: &amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: &amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164875</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164875"/>
		<updated>2025-04-23T00:45:09Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* Testing Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation (In editing !!!)==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment''' (if applicable)&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Final Notes ===&lt;br /&gt;
* '''Implementation &amp;amp; Testing:'''  &lt;br /&gt;
We have not yet implemented or tested the classes and methods described here. Once we begin coding, we will follow these designs closely and write RSpec tests to ensure all functionalities work as intended.&lt;br /&gt;
&lt;br /&gt;
* '''Code Readability &amp;amp; Documentation:'''  &lt;br /&gt;
We plan to maintain thorough inline documentation and adopt clear method names. This will make it easier for new contributors to understand and modify our team hierarchy.&lt;br /&gt;
&lt;br /&gt;
* '''Project Mentorship:'''  &lt;br /&gt;
Sahithi Ammana is providing guidance throughout this project, ensuring that our approach aligns with best practices and remains scalable for future needs.&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for teams_controller:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt; bundle exec rspec ./spec/requests/api/v1/teams_spec.rb &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output for TeamsController:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for AssignmentTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output for AssignmentTeam model:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for CourseTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/course_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output for CourseTeam model:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
* Command to run tests for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;code&amp;gt;bundle exec rspec spec/models/mentored_team_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: RSpec output for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
:[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: &amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: &amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164870</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164870"/>
		<updated>2025-04-23T00:33:17Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* Testing Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation (In editing !!!)==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment''' (if applicable)&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Final Notes ===&lt;br /&gt;
* '''Implementation &amp;amp; Testing:'''  &lt;br /&gt;
We have not yet implemented or tested the classes and methods described here. Once we begin coding, we will follow these designs closely and write RSpec tests to ensure all functionalities work as intended.&lt;br /&gt;
&lt;br /&gt;
* '''Code Readability &amp;amp; Documentation:'''  &lt;br /&gt;
We plan to maintain thorough inline documentation and adopt clear method names. This will make it easier for new contributors to understand and modify our team hierarchy.&lt;br /&gt;
&lt;br /&gt;
* '''Project Mentorship:'''  &lt;br /&gt;
Sahithi Ammana is providing guidance throughout this project, ensuring that our approach aligns with best practices and remains scalable for future needs.&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
&lt;br /&gt;
Implemented RSpec tests to validate all team-related operations. Positive and negative test cases have been covered through these test cases.&lt;br /&gt;
&lt;br /&gt;
RSpec output for TeamsController:&lt;br /&gt;
&lt;br /&gt;
[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
RSpec output for AssignmentTeam model:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RSpec output for CourseTeam model:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
RSpec output for MentoredTeam model:&lt;br /&gt;
&lt;br /&gt;
[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: &amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: &amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164848</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164848"/>
		<updated>2025-04-23T00:09:42Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* Relevant Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation (In editing !!!)==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment''' (if applicable)&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Final Notes ===&lt;br /&gt;
* '''Implementation &amp;amp; Testing:'''  &lt;br /&gt;
We have not yet implemented or tested the classes and methods described here. Once we begin coding, we will follow these designs closely and write RSpec tests to ensure all functionalities work as intended.&lt;br /&gt;
&lt;br /&gt;
* '''Code Readability &amp;amp; Documentation:'''  &lt;br /&gt;
We plan to maintain thorough inline documentation and adopt clear method names. This will make it easier for new contributors to understand and modify our team hierarchy.&lt;br /&gt;
&lt;br /&gt;
* '''Project Mentorship:'''  &lt;br /&gt;
Sahithi Ammana is providing guidance throughout this project, ensuring that our approach aligns with best practices and remains scalable for future needs.&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
TeamsController:&lt;br /&gt;
&lt;br /&gt;
[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
AssignmentTeam:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
CourseTeam:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
Mentored Team:&lt;br /&gt;
&lt;br /&gt;
[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
Repository: https://github.com/valorant-dhruv/reimplementation-back-end &amp;lt;br/&amp;gt;&lt;br /&gt;
Pull request: &amp;lt;br/&amp;gt;&lt;br /&gt;
Demo Video: &amp;lt;br/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164840</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164840"/>
		<updated>2025-04-22T23:42:42Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation (In editing !!!)==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment''' (if applicable)&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Final Notes ===&lt;br /&gt;
* '''Implementation &amp;amp; Testing:'''  &lt;br /&gt;
We have not yet implemented or tested the classes and methods described here. Once we begin coding, we will follow these designs closely and write RSpec tests to ensure all functionalities work as intended.&lt;br /&gt;
&lt;br /&gt;
* '''Code Readability &amp;amp; Documentation:'''  &lt;br /&gt;
We plan to maintain thorough inline documentation and adopt clear method names. This will make it easier for new contributors to understand and modify our team hierarchy.&lt;br /&gt;
&lt;br /&gt;
* '''Project Mentorship:'''  &lt;br /&gt;
Sahithi Ammana is providing guidance throughout this project, ensuring that our approach aligns with best practices and remains scalable for future needs.&lt;br /&gt;
&lt;br /&gt;
== Testing Plan ==&lt;br /&gt;
TeamsController:&lt;br /&gt;
&lt;br /&gt;
[[File:E2533-TeamsController-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
AssignmentTeam:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:E2533-AssignmentTeam-RSpec.jpg]] &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
CourseTeam:&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:E2533-course-team-rspec.jpg]]&lt;br /&gt;
&lt;br /&gt;
Mentored Team:&lt;br /&gt;
&lt;br /&gt;
[[File:E2533-MentoredTeam-RSpec.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533-MentoredTeam-RSpec.jpg&amp;diff=164839</id>
		<title>File:E2533-MentoredTeam-RSpec.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533-MentoredTeam-RSpec.jpg&amp;diff=164839"/>
		<updated>2025-04-22T23:42:04Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533-TeamsController-RSpec.jpg&amp;diff=164837</id>
		<title>File:E2533-TeamsController-RSpec.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533-TeamsController-RSpec.jpg&amp;diff=164837"/>
		<updated>2025-04-22T23:40:34Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533-AssignmentTeam-RSpec.jpg&amp;diff=164835</id>
		<title>File:E2533-AssignmentTeam-RSpec.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533-AssignmentTeam-RSpec.jpg&amp;diff=164835"/>
		<updated>2025-04-22T23:36:52Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533-course-team-rspec.jpg&amp;diff=164834</id>
		<title>File:E2533-course-team-rspec.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533-course-team-rspec.jpg&amp;diff=164834"/>
		<updated>2025-04-22T23:34:35Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164758</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164758"/>
		<updated>2025-04-22T22:00:32Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* TeamsHelper */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation (In editing !!!)==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team helper.png]]&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment''' (if applicable)&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
=== Final Notes ===&lt;br /&gt;
* '''Implementation &amp;amp; Testing:'''  &lt;br /&gt;
We have not yet implemented or tested the classes and methods described here. Once we begin coding, we will follow these designs closely and write RSpec tests to ensure all functionalities work as intended.&lt;br /&gt;
&lt;br /&gt;
* '''Code Readability &amp;amp; Documentation:'''  &lt;br /&gt;
We plan to maintain thorough inline documentation and adopt clear method names. This will make it easier for new contributors to understand and modify our team hierarchy.&lt;br /&gt;
&lt;br /&gt;
* '''Project Mentorship:'''  &lt;br /&gt;
Sahithi Ammana is providing guidance throughout this project, ensuring that our approach aligns with best practices and remains scalable for future needs.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_team_helper.png&amp;diff=164757</id>
		<title>File:E2533 team helper.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_team_helper.png&amp;diff=164757"/>
		<updated>2025-04-22T22:00:08Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164694</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164694"/>
		<updated>2025-04-22T18:04:57Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* Overview of classes and Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation (In editing !!!)==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment''' (if applicable)&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
=== Final Notes ===&lt;br /&gt;
* '''Implementation &amp;amp; Testing:'''  &lt;br /&gt;
We have not yet implemented or tested the classes and methods described here. Once we begin coding, we will follow these designs closely and write RSpec tests to ensure all functionalities work as intended.&lt;br /&gt;
&lt;br /&gt;
* '''Code Readability &amp;amp; Documentation:'''  &lt;br /&gt;
We plan to maintain thorough inline documentation and adopt clear method names. This will make it easier for new contributors to understand and modify our team hierarchy.&lt;br /&gt;
&lt;br /&gt;
* '''Project Mentorship:'''  &lt;br /&gt;
Sahithi Ammana is providing guidance throughout this project, ensuring that our approach aligns with best practices and remains scalable for future needs.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164693</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164693"/>
		<updated>2025-04-22T18:04:03Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* CourseTeam */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
[[File:E2533 course team model.png]]&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment''' (if applicable)&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
=== Final Notes ===&lt;br /&gt;
* '''Implementation &amp;amp; Testing:'''  &lt;br /&gt;
We have not yet implemented or tested the classes and methods described here. Once we begin coding, we will follow these designs closely and write RSpec tests to ensure all functionalities work as intended.&lt;br /&gt;
&lt;br /&gt;
* '''Code Readability &amp;amp; Documentation:'''  &lt;br /&gt;
We plan to maintain thorough inline documentation and adopt clear method names. This will make it easier for new contributors to understand and modify our team hierarchy.&lt;br /&gt;
&lt;br /&gt;
* '''Project Mentorship:'''  &lt;br /&gt;
Sahithi Ammana is providing guidance throughout this project, ensuring that our approach aligns with best practices and remains scalable for future needs.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_course_team_model.png&amp;diff=164692</id>
		<title>File:E2533 course team model.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_course_team_model.png&amp;diff=164692"/>
		<updated>2025-04-22T18:03:41Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164691</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164691"/>
		<updated>2025-04-22T18:02:29Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* Overview of classes and Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== CourseTeam ===&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment''' (if applicable)&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
=== Final Notes ===&lt;br /&gt;
* '''Implementation &amp;amp; Testing:'''  &lt;br /&gt;
We have not yet implemented or tested the classes and methods described here. Once we begin coding, we will follow these designs closely and write RSpec tests to ensure all functionalities work as intended.&lt;br /&gt;
&lt;br /&gt;
* '''Code Readability &amp;amp; Documentation:'''  &lt;br /&gt;
We plan to maintain thorough inline documentation and adopt clear method names. This will make it easier for new contributors to understand and modify our team hierarchy.&lt;br /&gt;
&lt;br /&gt;
* '''Project Mentorship:'''  &lt;br /&gt;
Sahithi Ammana is providing guidance throughout this project, ensuring that our approach aligns with best practices and remains scalable for future needs.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164644</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164644"/>
		<updated>2025-04-22T16:45:18Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* Team */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 team model.png]]&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment''' (if applicable)&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
=== Final Notes ===&lt;br /&gt;
* '''Implementation &amp;amp; Testing:'''  &lt;br /&gt;
We have not yet implemented or tested the classes and methods described here. Once we begin coding, we will follow these designs closely and write RSpec tests to ensure all functionalities work as intended.&lt;br /&gt;
&lt;br /&gt;
* '''Code Readability &amp;amp; Documentation:'''  &lt;br /&gt;
We plan to maintain thorough inline documentation and adopt clear method names. This will make it easier for new contributors to understand and modify our team hierarchy.&lt;br /&gt;
&lt;br /&gt;
* '''Project Mentorship:'''  &lt;br /&gt;
Sahithi Ammana is providing guidance throughout this project, ensuring that our approach aligns with best practices and remains scalable for future needs.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_team_model.png&amp;diff=164643</id>
		<title>File:E2533 team model.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_team_model.png&amp;diff=164643"/>
		<updated>2025-04-22T16:44:52Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164641</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164641"/>
		<updated>2025-04-22T16:43:42Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* Participant */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment''' (if applicable)&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 participant model.png]]&lt;br /&gt;
&lt;br /&gt;
=== Final Notes ===&lt;br /&gt;
* '''Implementation &amp;amp; Testing:'''  &lt;br /&gt;
We have not yet implemented or tested the classes and methods described here. Once we begin coding, we will follow these designs closely and write RSpec tests to ensure all functionalities work as intended.&lt;br /&gt;
&lt;br /&gt;
* '''Code Readability &amp;amp; Documentation:'''  &lt;br /&gt;
We plan to maintain thorough inline documentation and adopt clear method names. This will make it easier for new contributors to understand and modify our team hierarchy.&lt;br /&gt;
&lt;br /&gt;
* '''Project Mentorship:'''  &lt;br /&gt;
Sahithi Ammana is providing guidance throughout this project, ensuring that our approach aligns with best practices and remains scalable for future needs.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_participant_model.png&amp;diff=164640</id>
		<title>File:E2533 participant model.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_participant_model.png&amp;diff=164640"/>
		<updated>2025-04-22T16:43:20Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164639</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164639"/>
		<updated>2025-04-22T16:41:15Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* MentoredTeam */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 mentored team model.png]]&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment''' (if applicable)&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
=== Final Notes ===&lt;br /&gt;
* '''Implementation &amp;amp; Testing:'''  &lt;br /&gt;
We have not yet implemented or tested the classes and methods described here. Once we begin coding, we will follow these designs closely and write RSpec tests to ensure all functionalities work as intended.&lt;br /&gt;
&lt;br /&gt;
* '''Code Readability &amp;amp; Documentation:'''  &lt;br /&gt;
We plan to maintain thorough inline documentation and adopt clear method names. This will make it easier for new contributors to understand and modify our team hierarchy.&lt;br /&gt;
&lt;br /&gt;
* '''Project Mentorship:'''  &lt;br /&gt;
Sahithi Ammana is providing guidance throughout this project, ensuring that our approach aligns with best practices and remains scalable for future needs.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_mentored_team_model.png&amp;diff=164638</id>
		<title>File:E2533 mentored team model.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_mentored_team_model.png&amp;diff=164638"/>
		<updated>2025-04-22T16:40:40Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164636</id>
		<title>CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2533._%E2%80%8B%E2%80%8BReimplement_the_Team_hierarchy&amp;diff=164636"/>
		<updated>2025-04-22T16:39:46Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: /* AssignmentTeam */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wiki page for E2533 - reimplementing the Team hierarchy&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The Team hierarchy consists of classes that manage student teams within Expertiza. These teams can reserve topics and submit assignments. The hierarchy includes four classes: Team (the superclass), CourseTeam, AssignmentTeam, and MentoredTeam. Since all functional teams belong to one of the three subclasses, direct instances of the Team superclass should never be created.&lt;br /&gt;
&lt;br /&gt;
CourseTeams remain intact throughout a course, collaborating on all assignments. While some instructors opt not to use them, others find CourseTeams beneficial, especially in Team-Based Learning environments. These teams can be converted into AssignmentTeams (and vice versa) as needed.&lt;br /&gt;
&lt;br /&gt;
AssignmentTeams are formed specifically for individual assignments. However, if an assignment is configured to automatically assign mentors, teams are instantiated as MentoredTeams—a subclass of AssignmentTeam with a designated mentor guiding the group.&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
This project seeks to modernize and streamline Expertiza’s Team hierarchy, transforming it into a leaner, more intuitive system by eliminating legacy inefficiencies. The current design suffers from code bloat, tangled dependencies, and duplicated logic, particularly in the Team and AssignmentTeam classes, which host numerous overlapping methods. By rearchitecting the hierarchy, we will enforce cleaner inheritance, remove redundant functions, and introduce a more flexible team membership model—shifting from Users to Participants for better alignment with the platform’s evolving structure. The overhaul will emphasize modularity, maintainability, and scalability, ensuring a robust foundation for future enhancements. Through principled object-oriented design, we will redefine relationships between CourseTeam, AssignmentTeam, and MentoredTeam, optimizing their interactions while preserving functionality. The end goal is a decluttered, high-performance team management system that supports seamless collaboration across courses and assignments.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
The project requires the implementation of a well-structured team hierarchy with clearly defined responsibilities. &lt;br /&gt;
# Base Team Class must be created to serve as the parent class, encapsulating core team functionality such as managing members (adding/removing), checking team size, and verifying if a team is empty. &lt;br /&gt;
# Specialized subclasses that must be implemented with distinct behaviors while inheriting shared logic:&lt;br /&gt;
## CourseTeam.rb - teams persisting throughout a course&lt;br /&gt;
## AssignmentTeam,rb - assignment-specific teams&lt;br /&gt;
## MentoredTeam.rb - mentor-included variant of AssignmentTeam &lt;br /&gt;
# Team membership rules must enforce valid user assignments, ensuring course participants are correctly mapped to CourseTeams and assignment participants to AssignmentTeams.&lt;br /&gt;
# Team operations must support copying teams between categories (e.g., converting a CourseTeam to an AssignmentTeam) while maintaining data integrity. &lt;br /&gt;
# Comprehensive RSpec tests must validate all team operations, including edge cases like exceeding team limits or handling empty teams. &lt;br /&gt;
# Code readability and documentation are critical—methods should be self-documenting with clear naming conventions, supplemented by detailed comments explaining complex logic. The implementation must prioritize modularity, maintainability, and adherence to object-oriented principles to ensure long-term scalability.&lt;br /&gt;
&lt;br /&gt;
== Existing Issues ==&lt;br /&gt;
&lt;br /&gt;
The current Team hierarchy in Expertiza suffers from several structural and functional deficiencies that hinder maintainability and scalability. The system exhibits excessive code duplication, particularly between the Team superclass and its subclasses (AssignmentTeam, CourseTeam), with redundant methods bloating the codebase (e.g., AssignmentTeam contains many methods that overlap with Team's methods). Poor inheritance design forces subclasses to reimplement logic that should be inherited, violating DRY principles. Team membership is tightly coupled to the User model, requiring a disruptive migration to the newer Participant system. Additionally, ambiguous team-type relationships complicate operations like copying teams between course and assignment contexts. The lack of modular boundaries creates brittle dependencies, while insufficient test coverage for edge cases (e.g., team size limits, empty teams) risks regression errors. These issues collectively result in a fragile, hard-to-extend architecture that necessitates a thorough redesign.&lt;br /&gt;
&lt;br /&gt;
While code duplication, inheritance issues, and the User-to-Participant transition were addressed in the previous implementation, foundational work like base class implementation, membership rules, comprehensive testing, and documentation remains to be completed.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
=== Controller diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram illustrates the interaction between the controller, helper, and models in the proposed Team hierarchy reimplementation. The controller acts as the main entry point for all team-related API calls, delegating logic to helpers and interacting with the appropriate Team subclass.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 ControllerDiagram.jpg|center|500px|Controller, Helper, and Model Interaction Diagram]]&lt;br /&gt;
&lt;br /&gt;
=== TeamsController.rb: Method / API calls ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! # !! Method !! Endpoint !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || index || GET /teams/:type || Return a list of teams of a specific type (CourseTeam / AssignmentTeam)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || show || GET /teams/:id || Return details of a specific team&lt;br /&gt;
|-&lt;br /&gt;
| 3 || create || POST /teams || Create a new team&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add_members || PATCH /teams/:id/add_member || Add a participant to a team&lt;br /&gt;
|-&lt;br /&gt;
| 5 || remove_member || DELETE /teams/:id/remove_member/:participant_id || Remove a participant from a team&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy_to_assignment || POST /teams/:id/copy_to_assignment/:assignment_id || Copy a course team to a new assignment team&lt;br /&gt;
|-&lt;br /&gt;
| 7 || check_size || GET /teams/:id/size || Return current size of the team&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Empty || GET /teams/:id/empty || Returns true/false if the team has no members&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper.rb methods ===&lt;br /&gt;
&lt;br /&gt;
1.	Valid_member?(user, team_type) – It will check if a user is valid for a given team type (e.g., participant type matches).&amp;lt;br&amp;gt;&lt;br /&gt;
2.	team_full?(team) – It will cehck if the team has reached max size.&amp;lt;br&amp;gt;&lt;br /&gt;
3.	sanitize_team_params() – It will ensure only permitted params are accepted for team creation.&amp;lt;br&amp;gt;&lt;br /&gt;
4.	mentor_of?(user, team) – It will check if a user is the designated mentor (MentoredTeam only).&amp;lt;br&amp;gt;&lt;br /&gt;
5.	copy_team_structure() – It will be used for copying team members and metadata.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Patterns ===&lt;br /&gt;
&lt;br /&gt;
'''Template Method Pattern'''&lt;br /&gt;
&lt;br /&gt;
This project will use the Template Method Pattern, which allows subclasses to override certain stages without changing the general structure. It defines the foundation of fundamental team-related processes in a base class. This pattern is especially useful for creating a uniform but adaptable team hierarchy architecture, where each team type adheres to the same overall process but implements its own unique logic.&lt;br /&gt;
&lt;br /&gt;
'''Where Will It Be Used?''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Base Class: Team'''  &amp;lt;br&amp;gt;&lt;br /&gt;
Generic methods like `add_member`, `remove_member`, `copy_to`, and `empty?` will be defined by the `Team` class. These methods will use placeholder or hook methods, such as `validate_participant_type` or `handle_special_roles`, which will be implemented by subclasses, while adhering to a standard structure.&lt;br /&gt;
&lt;br /&gt;
'''Subclasses: CourseTeam, AssignmentTeam, and MentoredTeam''' &amp;lt;br&amp;gt;&lt;br /&gt;
These subclasses will define unique validations and behaviors by overriding the hook methods:&lt;br /&gt;
* `CourseTeam` will validate participants in the course.&lt;br /&gt;
* `AssignmentTeam` will define assignment-specific logic.&lt;br /&gt;
* `MentoredTeam` will take precedence over the member addition rationale to handle mentor responsibilities.&lt;br /&gt;
&lt;br /&gt;
'''Reason for Using Template Method:'''&lt;br /&gt;
* Promotes code reuse by including shared functionality in the main `Team` class.&lt;br /&gt;
* Enforces a consistent framework for all team operations.&lt;br /&gt;
* Allows customizable behavior in subclasses without duplicating code.&lt;br /&gt;
* Simplifies future enhancements by offering a scalable and maintainable solution (e.g., when introducing new team types).&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles ===&lt;br /&gt;
&lt;br /&gt;
'''Open/Closed Principle (OCP)'''&amp;lt;br&amp;gt;&lt;br /&gt;
The Open/Closed Principle states that software entities should be open for extension but closed for modification. This principle will be a core part of the Team hierarchy reimplementation.&amp;lt;br&amp;gt;&lt;br /&gt;
The Team base class in this project will be created so that when more team kinds are added, it doesn't need to be changed. Instead, by constructing subclasses like CourseTeam, AssignmentTeam, and MentoredTeam, developers will be able to expand the current structure.&amp;lt;br&amp;gt;&lt;br /&gt;
Without changing the shared logic specified in the Team base class, each subclass will extend or override particular methods (such as add_member, validate_participant_type, or copy_to). With this design, the basic class will continue to be dependable and robust while providing room for expansion and personalisation&lt;br /&gt;
&lt;br /&gt;
== Overview of classes and Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== TeamsController ===&lt;br /&gt;
'''Inherits From:''' ApplicationController&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
The TeamsController is our main interface for handling team-related requests. It orchestrates creating, showing, updating, and removing teams while also providing actions for specific operations like copying teams to assignments. By extending ApplicationController, it leverages Rails conventions for RESTful endpoints.&lt;br /&gt;
&lt;br /&gt;
'''Key Actions (as referenced in the diagram):'''&lt;br /&gt;
* '''add / add_member:''' Prepares data for adding a new team or adding members to an existing team.&lt;br /&gt;
[[File:E2533 teams controller add member.png]]&lt;br /&gt;
* '''show:''' Retrieves and displays a team’s details.&lt;br /&gt;
[[File:E2533 teams controller show team.png]]&lt;br /&gt;
* '''create:''' Persists a new team record.&lt;br /&gt;
[[File:E2533 teams controller create team.png]]&lt;br /&gt;
* '''remove / remove_member:''' Handles deletion of teams or the removal of a specific member from a team.&lt;br /&gt;
[[File:E2533 teams controller remove member.png]]&lt;br /&gt;
* '''copy_to_assignment:''' Allows teams to be copied or migrated into the context of an assignment.&lt;br /&gt;
* '''empty:''' Checks if a team currently has no members, useful for certain validations or cleanup tasks.&lt;br /&gt;
&lt;br /&gt;
=== TeamsHelper ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
TeamsHelper provides shared view or utility methods that can be reused across different views related to teams. This might include form helpers, formatting functions, or any specialized logic that doesn’t belong directly in the controller or model. By extracting these methods into a helper, we keep our controllers lean and our views consistent.&lt;br /&gt;
&lt;br /&gt;
=== Validation / Utility ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
These are modules or classes that encapsulate common validation logic or utility functions. For example, methods may ensure that team size constraints are met or that certain data formats are respected. The TeamsController can call these utilities to keep business logic separate from controller actions.&lt;br /&gt;
&lt;br /&gt;
=== Team ===&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Team is our base model, defining attributes and behaviors common to all team types. It maintains core relationships (like having many members) and implements fundamental methods that child classes can inherit or override.&lt;br /&gt;
&lt;br /&gt;
'''Key Methods:'''&lt;br /&gt;
* '''add_member(user):''' Adds a user to the team, performing basic checks like duplicate membership.&lt;br /&gt;
* '''remove_member(user):''' Removes a user from the team.&lt;br /&gt;
* '''size:''' Returns the current count of team members.&lt;br /&gt;
* '''empty?:''' Checks whether the team has no members, useful for validating if a team is still active or viable.&lt;br /&gt;
&lt;br /&gt;
Because Team is the parent class, it keeps the shared logic centralized, ensuring consistency across specialized team models.&lt;br /&gt;
&lt;br /&gt;
=== AssignmentTeam ===&lt;br /&gt;
'''Inherits From:''' Team&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
AssignmentTeam is designed for short-term or one-off teams formed specifically for an assignment. It enforces membership rules based on assignment criteria, such as whether a user is actually participating in that assignment.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''add_assignment_member(user):''' Ensures the user is eligible for the assignment before joining.&lt;br /&gt;
* '''validate_team:''' Checks constraints like maximum size or required roles for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:E2533 assignment team model.png]]&lt;br /&gt;
&lt;br /&gt;
By keeping assignment-specific logic here, we avoid mixing it with course-level concerns.&lt;br /&gt;
&lt;br /&gt;
=== MentoredTeam ===&lt;br /&gt;
'''Inherits From:''' AssignmentTeam&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
MentoredTeam extends AssignmentTeam by adding a designated mentor role. This can be especially helpful for assignments requiring expert oversight or guidance.&lt;br /&gt;
&lt;br /&gt;
'''Possible Additions/Overrides:'''&lt;br /&gt;
* '''assign_mentor(user):''' Sets a mentor for the team after confirming they meet certain criteria (e.g., correct privileges or expertise).&lt;br /&gt;
* '''remove_mentor:''' Allows for unassigning a mentor if needed.&lt;br /&gt;
* '''mentor_validation:''' Ensures that the chosen mentor is valid for the assignment.&lt;br /&gt;
* '''view_team_with_mentor:''' Presents a combined view of the team members and mentor details.&lt;br /&gt;
&lt;br /&gt;
By placing mentor logic in its own subclass, we keep assignment-level functionality clean while MentoredTeam handles the extra mentorship features.&lt;br /&gt;
&lt;br /&gt;
=== Participant ===&lt;br /&gt;
'''Associations:'''&lt;br /&gt;
* '''belongs_to :team'''&lt;br /&gt;
* '''belongs_to :user'''&lt;br /&gt;
* '''belongs_to :assignment''' (if applicable)&lt;br /&gt;
&lt;br /&gt;
'''Purpose:'''  &lt;br /&gt;
Participant acts as a linking model in some contexts, ensuring we can track which user belongs to which team for a given assignment or course. This model helps us keep membership records organized and may include additional data (like submission status or peer reviews).&lt;br /&gt;
&lt;br /&gt;
=== Final Notes ===&lt;br /&gt;
* '''Implementation &amp;amp; Testing:'''  &lt;br /&gt;
We have not yet implemented or tested the classes and methods described here. Once we begin coding, we will follow these designs closely and write RSpec tests to ensure all functionalities work as intended.&lt;br /&gt;
&lt;br /&gt;
* '''Code Readability &amp;amp; Documentation:'''  &lt;br /&gt;
We plan to maintain thorough inline documentation and adopt clear method names. This will make it easier for new contributors to understand and modify our team hierarchy.&lt;br /&gt;
&lt;br /&gt;
* '''Project Mentorship:'''  &lt;br /&gt;
Sahithi Ammana is providing guidance throughout this project, ensuring that our approach aligns with best practices and remains scalable for future needs.&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
'''Mentor''' &amp;lt;/br&amp;gt;&lt;br /&gt;
Sahithi Ammana&lt;br /&gt;
&lt;br /&gt;
'''Team Members '''&lt;br /&gt;
* Dhruv Soni (dbsoni)&lt;br /&gt;
* Ananya Doshi (avdoshi)&lt;br /&gt;
* Udita Raychaudhury (uraycha)&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_assignment_team_model.png&amp;diff=164633</id>
		<title>File:E2533 assignment team model.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2533_assignment_team_model.png&amp;diff=164633"/>
		<updated>2025-04-22T16:37:46Z</updated>

		<summary type="html">&lt;p&gt;Uraycha: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Uraycha</name></author>
	</entry>
</feed>