<?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=Svenka25</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=Svenka25"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Svenka25"/>
	<updated>2026-05-18T02:39:13Z</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_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=145413</id>
		<title>CSC/ECE 517 Spring 2022 - E2243. Refactor student teams functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=145413"/>
		<updated>2022-04-26T03:45:42Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: /* Added Future Scope and updated Demo URL */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2243. Refactor student teams functionality which was a project in CSC517 Spring 2022. &lt;br /&gt;
&lt;br /&gt;
Please see below for a description of the design of the project.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
Users &amp;amp; Participants: Everyone who took the CSC517 OODD class at NC State is a user in Expertiza, and instructors can add users as participants in an assignment so that they can access it to contribute, make changes and submit their work to be graded.&lt;br /&gt;
&lt;br /&gt;
Almost all of the works within Assignments is done by participants, not users. All the tables use participant_id to track contributions to assignments, except teams_users. In the documentation, it can be noted that the team_users table references users instead of participants. This anomaly in the teams_users relation causes problems with how student teams are rendered in the UI, and it doesn’t mix well with the new functionality that was recently introduced. The participant_id field should be added to the model, and references that use user_id should also incorporate participant_id. Ideally, the application should use only participant_id, but to handle the existing data in the database without running a massive migration, the application should be able to handle both old records that use user_id and new ones that shall, from after this project is completed, use participant_id instead.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===Changing the schema ===&lt;br /&gt;
* Create a column that would be called “participant_id”, which will be a foreign key that references the participants table.&lt;br /&gt;
* Use this participant_id field in all operations for teams going forward. There are a number of workflows involving teams we have examined and worked on, which are elaborated below.&lt;br /&gt;
* However, it is to be noted that this must also work with the existing functionality and data which makes use of user_id, so the code written must take both into account in its working.&lt;br /&gt;
&lt;br /&gt;
=== Refactoring the teams rendering (/views/student_teams/view.html.erb) ===&lt;br /&gt;
The logic in the team's view (where participants can see their team members) that iterates and fetches information of all the team members and displays them would be refactored as this view is quite bloated and has lots of functionalities written on it. We have made partials and placed those functionality in their specific partials.&lt;br /&gt;
&lt;br /&gt;
=== Other Changes ===&lt;br /&gt;
&lt;br /&gt;
Updated logic for all the CRUD functionalities in teams_users controller (wherever applicable).&lt;br /&gt;
&lt;br /&gt;
Fixed tests to incorporate the new logic as a result of using both user_id and participant_id in the teams_user logic.&lt;br /&gt;
&lt;br /&gt;
== Schema Changes ==&lt;br /&gt;
&lt;br /&gt;
In teams_users table, we can add a new column '''participant_id''' which is a foreign key from participants table and remove the column '''user_id'''. We plan to remove the '''user_id''' column '''only after data migration''' since the user_id field is used predominantly in several other controllers in a variety of ways, and as such its removal must be done carefully.&lt;br /&gt;
&lt;br /&gt;
The participant_id field in the the teams_users relation is computed as follows:&lt;br /&gt;
&lt;br /&gt;
* Finding Assignment ID By Team ID&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id but not the participant_id. Since the same user_id can be associated with multiple participant_ids (since the same user can participate in multiple assignments and gets a unique participant_id in each assignment they take part in), we need to get the user_ids in the assignment for which we need the particular user's participant_id. For this reason, we need to first find the assignment_id.&lt;br /&gt;
&lt;br /&gt;
* Finding Participant ID By Assignment ID and User ID&lt;br /&gt;
With the assignment_id retrieved, we can find the list of participant_ids that participated in the assignment, and using the user_id, get the participant_id which is saved in the participants table. &lt;br /&gt;
&lt;br /&gt;
=== ER diagram for updated schema ===&lt;br /&gt;
[[File:ER_Updated.png |900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
Main files which were changed are&lt;br /&gt;
* app/models/participant.rb&lt;br /&gt;
* app/models/team.rb&lt;br /&gt;
* app/models/teams_user.rb&lt;br /&gt;
* app/models/user.rb&lt;br /&gt;
&lt;br /&gt;
As the project tries to introduce participant_id as a replacement of user_id, we've calculated all the details with both user_id and participant_id (whichever is available based on whether the data is old or new). We've also added comments everywhere to show the code snippets which need to be removed once user_id is deprecated. (Check for '''comments with #E2243''')&lt;br /&gt;
&lt;br /&gt;
Currently teams_user table has user_id or participant_id for now. So we've ensured that checks happen based on both the IDs unless user_id is removed. The default check is overridden to ensure newer datas which only have participant_id are also indexed and found using the function call here.&lt;br /&gt;
&lt;br /&gt;
'''Code Snippet'''&lt;br /&gt;
 &lt;br /&gt;
 TeamsUser.where(user_id: user_id).or(TeamsUser.where(participant_id: participant_id))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===find_by_team_id_and_user_id===&lt;br /&gt;
&lt;br /&gt;
''.where'' function makes a lot of DB calls when asked for user_id, we've introduced a module called &amp;quot;'''''find_by_team_id_and_user_id()'''''&amp;quot; which will override ''.where'' function. If user_id is not present in the table, it loads based on participant_id instead, as you can have only one as the key and not both.&lt;br /&gt;
&lt;br /&gt;
So wherever .where is used, &lt;br /&gt;
 TeamsUser.where('team_id = ? and user_id = ?', @team.id, @user.id), &lt;br /&gt;
we've replaced it with &lt;br /&gt;
 TeamsUser.find_by_team_id_and_user_id(@team.id, @user.id). &lt;br /&gt;
&lt;br /&gt;
[[File:Find_by_team_id_and_user_id.png |600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This way instead of changing the query for every call, we've used a single function for all the calls, thereby implementing '''DRY''' principle.&lt;br /&gt;
&lt;br /&gt;
===add_participant_to_team===&lt;br /&gt;
&lt;br /&gt;
The existing function to add a member&lt;br /&gt;
 add_member(user,team.parent_id)&lt;br /&gt;
adds user to a team based on the user_id and team_id.&lt;br /&gt;
&lt;br /&gt;
We've introduced a new function called&lt;br /&gt;
 add_participant_to_team(student, team.parent_id)&lt;br /&gt;
which adds participant(student) to a team based on participant_id(or user_id wherever participant_id is not available)&lt;br /&gt;
&lt;br /&gt;
This function takes participant and team_id, and assigns that participant to a team. In future, once user_id is removed, add_participant_to_team can be used as a replacement.&lt;br /&gt;
&lt;br /&gt;
[[File:Add_participant_to_team.png|600px]]&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
''user_id'' exists as a foreign key in 2 relations - Participants and teams_users. Although they crrespond to same attribute, user_id alone cannot be used to find corresponding Participants because same user_id can exist for multiple Participants - due to Expertiza's design wherein for every assignment, every user is added to participant's table. Therefore Participant ID can be mapped to (assignment_id, user_id) pair.&lt;br /&gt;
&lt;br /&gt;
== View Changes and Refactoring ==&lt;br /&gt;
&lt;br /&gt;
One of the requirements in E2243 is the refactoring of the student teams view in views/student_teams/view.html.erb&lt;br /&gt;
&lt;br /&gt;
This view is quite cluttered and as a result, makes editing, understanding and extension difficult and tiresome for any future updates to the expertiza application. The code in this file can be modularized to obtain simpler and easier-to-understand, which is what we have achieved. The view was reafactored to incorporate partials, and some of the partials created as a result are:&lt;br /&gt;
&lt;br /&gt;
* _invited_people.html.erb : partial for displaying the invited participants to the assignment team&lt;br /&gt;
* _display_advertisements.html.erb : partial for displaying advertisements in the view&lt;br /&gt;
* _send_invitaions.html.erb : partial for the send invitations functionality&lt;br /&gt;
* _received_invitations.html.erb : partial to display the received invitations for the current user&lt;br /&gt;
&lt;br /&gt;
Please see the next sections for some screenshots of the UI related to the above described partials.&lt;br /&gt;
&lt;br /&gt;
== Impacted Files ==&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller.rb (expertiza/app/controller/teams_user_controller.rb)&lt;br /&gt;
We will be adding code here to compute the participant_id using the methodologies described above.&lt;br /&gt;
&lt;br /&gt;
* teams_users.rb (expertiza/app/models/teams_user.rb)&lt;br /&gt;
The model will be updated (as can be seen in the ER diagram above) to have the participant_id added.&lt;br /&gt;
&lt;br /&gt;
* teams_users(expertiza/app/views/teams_users)&lt;br /&gt;
The view will be updated to reflect the new name of the model, and contain new partials that make use of the participant_id field.&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller_spec.rb(expertiza/spec/controllers/teams_users_controller_spec.rb)&lt;br /&gt;
The test file for the controller will be modified so that existing test cases pass the new changes, and also introduce new test cases to increase test coverage.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
The changes in teams_users means we need to re-examine the flows and user stories through where teams_users is used. This, in practice, means that we manually have checked the different ways in which a team for an assignment can be created in expertiza, and other associated operations such as removal of a user from a team, addition of a new user, deletion of a team etc. This testing was necessary to ensure that the functionality in expertiza still worked as expected even after our refactoring was completed. &lt;br /&gt;
&lt;br /&gt;
The main user stories we examined are:&lt;br /&gt;
&lt;br /&gt;
1. Student creates a team: A student, newly added to an assignment, opens the application and goes to &amp;quot;my team&amp;quot; after opening the assignment on expertiza. He enters his team's name and the team is created.&lt;br /&gt;
&lt;br /&gt;
[[File:Student_Creates_Team_SendInvite.png|600px]]&lt;br /&gt;
&lt;br /&gt;
2. Student joins a team: A student, is invited to join a team for an assignment, and accepts. He is added to an existing team, possibly created by another student or instructor.&lt;br /&gt;
&lt;br /&gt;
[[File:Student_Joins_Team_ReceivesInvite.png|600px]]&lt;br /&gt;
&lt;br /&gt;
3.  Instructor creates a team manually: An instructor who wishes to create a team with certain students on it, chooses the assignment on expertiza, and clicks on the icon to add a new team and in the manual section, creates a new team by giving a team name. They add students or participants to the newly created team and can remove them too.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_Teams_Instructors_Manually.png|600px]]&lt;br /&gt;
&lt;br /&gt;
4. Instructor creates teams automatically: An instructor wishes to assign all the students involved in an assignment randomly to teams of a certain size. They open expertiza, choose the assignment, and then click on the icon to add a new team, and in the &amp;quot;create teams automatically&amp;quot; section, enter the team size they wish to use. The system then creates teams of the specified size, adding students randomly to teams which is reflected in both student and instructor views.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_Teams_Instructors_Automatically.png|600px]]&lt;br /&gt;
&lt;br /&gt;
In addition to verifying team creation in all of the above scenarios, we also verified other operations such as addition of a team member after the team capacity was exhausted, deletion and re-addition of the same user, invitations to already existing participants in the same team etc and ensure the system was working as expected in these scenarios as well.&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing RSpec ===&lt;br /&gt;
Since this is a refactoring project, the scope of testing is limited to the changes made as part of refactoring and also to ensure that the existing test cases do not break or are modified accordingly.&lt;br /&gt;
In all the existing test cases in expertiza/spec/controllers/teams_users_controller_spec.rb :&lt;br /&gt;
&lt;br /&gt;
* ''object initialization''&lt;br /&gt;
* ''#update_duties''&lt;br /&gt;
* ''when user is added to assignment team''&lt;br /&gt;
* ''when user is added to assignment team''&lt;br /&gt;
* ''when user is added to course team''&lt;br /&gt;
* ''when user is already on an assignment team''&lt;br /&gt;
* ''when user is added to assignment team while on a team already'' &lt;br /&gt;
* ''when user is already on a course team'' &lt;br /&gt;
&lt;br /&gt;
the new methods which use both participant_id and user_id have been incorporated as needed to ensure continued quality of the testing suite and maintenance of code coverage.&lt;br /&gt;
&lt;br /&gt;
==== Fixed Test Files ====&lt;br /&gt;
&lt;br /&gt;
After our refactoring, we noticed failing tests in the below files, and we have worked on fixing these to work with the new and updated functionality. The main issues were involving tests using the old methods for creating a team, adding participants to the team etc. &lt;br /&gt;
&lt;br /&gt;
Models:&lt;br /&gt;
* spec/models/assignment_team_spec.rb&lt;br /&gt;
* spec/models/course_team_spec.rb&lt;br /&gt;
* spec/models/invitation_spec.rb&lt;br /&gt;
* spec/models/student_task_spec.rb&lt;br /&gt;
* spec/models/team_spec.rb&lt;br /&gt;
&lt;br /&gt;
Helper:&lt;br /&gt;
* spec/helpers/authorization_helper_spec.rb&lt;br /&gt;
* spec/helpers/grades_helper_spec.rb&lt;br /&gt;
* spec/helpers/sign_up_sheet_helper_spec.rb&lt;br /&gt;
&lt;br /&gt;
Controllers:&lt;br /&gt;
* spec/controllers/assessment360_controller_spec.rb&lt;br /&gt;
* spec/controllers/grades_controller_spec.rb&lt;br /&gt;
* spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
* spec/controllers/student_teams_controller_spec.rb&lt;br /&gt;
* spec/controllers/lottery_controller_spec.rb&lt;br /&gt;
* spec/controllers/sign_up_sheet_controller_spec.rb&lt;br /&gt;
* spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
* spec/controllers/teams_users_controller_spec.rb&lt;br /&gt;
* spec/controllers/invitations_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
== Future Scope ==&lt;br /&gt;
&lt;br /&gt;
# Create a migration to migrate all data with user_id to participant_id&lt;br /&gt;
# Replace participant_id with user_id for all the data&lt;br /&gt;
# Rename teams_user to teams_participant&lt;br /&gt;
# Modify functions which use user_id and replace them with functions using participant_id (Note: Look for code comments with #E2243 for all the replacement functions)&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Ashok Kumar Selvam (aselvam@ncsu.edu)&lt;br /&gt;
# Sri Athithya Kruth Babu (sbabu@ncsu.edu)&lt;br /&gt;
# Subramanian Venkataraman (svenka25@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Naman Shrimali&lt;br /&gt;
&lt;br /&gt;
== Code Details == &lt;br /&gt;
Github Pull Request - https://github.com/expertiza/expertiza/pull/2391&lt;br /&gt;
&lt;br /&gt;
Repo - https://github.com/sak1997/expertiza/tree/beta&lt;br /&gt;
&lt;br /&gt;
Demo - https://drive.google.com/file/d/1zWnHJNgSkioMd_xmB2L-7wPM2_OP7yka/view?usp=sharing&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:ER_Updated.png&amp;diff=145411</id>
		<title>File:ER Updated.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:ER_Updated.png&amp;diff=145411"/>
		<updated>2022-04-26T03:44:44Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=145371</id>
		<title>CSC/ECE 517 Spring 2022 - E2243. Refactor student teams functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=145371"/>
		<updated>2022-04-26T02:20:38Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: /* add_participant_to_team */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2243. Refactor student teams functionality which was a project in CSC517 Spring 2022. &lt;br /&gt;
&lt;br /&gt;
Please see below for a description of the design of the project.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
Users &amp;amp; Participants: Everyone who took the CSC517 OODD class at NC State is a user in Expertiza, and instructors can add users as participants in an assignment so that they can access it to contribute, make changes and submit their work to be graded.&lt;br /&gt;
&lt;br /&gt;
Almost all of the works within Assignments is done by participants, not users. All the tables use participant_id to track contributions to assignments, except teams_users. In the documentation, it can be noted that the team_users table references users instead of participants. This anomaly in the teams_users relation causes problems with how student teams are rendered in the UI, and it doesn’t mix well with the new functionality that was recently introduced. The participant_id field should be added to the model, and references that use user_id should also incorporate participant_id. Ideally, the application should use only participant_id, but to handle the existing data in the database without running a massive migration, the application should be able to handle both old records that use user_id and new ones that shall, from after this project is completed, use participant_id instead.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===Changing the schema ===&lt;br /&gt;
* Create a column that would be called “participant_id”, which will be a foreign key that references the participants table.&lt;br /&gt;
* Use this participant_id field in all operations for teams going forward. There are a number of workflows involving teams we have examined and worked on, which are elaborated below.&lt;br /&gt;
* However, it is to be noted that this must also work with the existing functionality and data which makes use of user_id, so the code written must take both into account in its working.&lt;br /&gt;
&lt;br /&gt;
=== Refactoring the teams rendering (/views/student_teams/view.html.erb) ===&lt;br /&gt;
The logic in the team's view (where participants can see their team members) that iterates and fetches information of all the team members and displays them would be refactored as this view is quite bloated and has lots of functionalities written on it. We have made partials and placed those functionality in their specific partials.&lt;br /&gt;
&lt;br /&gt;
=== Other Changes ===&lt;br /&gt;
&lt;br /&gt;
Updated logic for all the CRUD functionalities in teams_users controller (wherever applicable).&lt;br /&gt;
&lt;br /&gt;
Fixed tests to incorporate the new logic as a result of using both user_id and participant_id in the teams_user logic.&lt;br /&gt;
&lt;br /&gt;
== Schema Changes ==&lt;br /&gt;
&lt;br /&gt;
In teams_users table, we can add a new column '''participant_id''' which is a foreign key from participants table and remove the column '''user_id'''. We plan to remove the '''user_id''' column '''only after data migration''' since the user_id field is used predominantly in several other controllers in a variety of ways, and as such its removal must be done carefully.&lt;br /&gt;
&lt;br /&gt;
The participant_id field in the the teams_users relation is computed as follows:&lt;br /&gt;
&lt;br /&gt;
* Finding Assignment ID By Team ID&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id but not the participant_id. Since the same user_id can be associated with multiple participant_ids (since the same user can participate in multiple assignments and gets a unique participant_id in each assignment they take part in), we need to get the user_ids in the assignment for which we need the particular user's participant_id. For this reason, we need to first find the assignment_id.&lt;br /&gt;
&lt;br /&gt;
* Finding Participant ID By Assignment ID and User ID&lt;br /&gt;
With the assignment_id retrieved, we can find the list of participant_ids that participated in the assignment, and using the user_id, get the participant_id which is saved in the participants table. &lt;br /&gt;
&lt;br /&gt;
=== ER diagram for updated schema ===&lt;br /&gt;
[[File:Updated_Proposed_ERR_for_student_teams_E2243.png |900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
Main files which were changed are&lt;br /&gt;
* app/models/participant.rb&lt;br /&gt;
* app/models/team.rb&lt;br /&gt;
* app/models/teams_user.rb&lt;br /&gt;
* app/models/user.rb&lt;br /&gt;
&lt;br /&gt;
As the project tries to introduce participant_id as a replacement of user_id, we've calculated all the details with both user_id and participant_id (whichever is available based on whether the data is old or new). We've also added comments everywhere to show the code snippets which need to be removed once user_id is deprecated. (Check for '''comments with #E2243''')&lt;br /&gt;
&lt;br /&gt;
Currently teams_user table has user_id or participant_id for now. So we've ensured that checks happen based on both the IDs unless user_id is removed. The default check is overridden to ensure newer datas which only have participant_id are also indexed and found using the function call here.&lt;br /&gt;
&lt;br /&gt;
'''Code Snippet'''&lt;br /&gt;
 &lt;br /&gt;
 TeamsUser.where(user_id: user_id).or(TeamsUser.where(participant_id: participant_id))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===find_by_team_id_and_user_id===&lt;br /&gt;
&lt;br /&gt;
''.where'' function makes a lot of DB calls when asked for user_id, we've introduced a module called &amp;quot;'''''find_by_team_id_and_user_id()'''''&amp;quot; which will override ''.where'' function. If user_id is not present in the table, it loads based on participant_id instead, as you can have only one as the key and not both.&lt;br /&gt;
&lt;br /&gt;
So wherever .where is used, &lt;br /&gt;
 TeamsUser.where('team_id = ? and user_id = ?', @team.id, @user.id), &lt;br /&gt;
we've replaced it with &lt;br /&gt;
 TeamsUser.find_by_team_id_and_user_id(@team.id, @user.id). &lt;br /&gt;
&lt;br /&gt;
[[File:Find_by_team_id_and_user_id.png |600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This way instead of changing the query for every call, we've used a single function for all the calls, thereby implementing '''DRY''' principle.&lt;br /&gt;
&lt;br /&gt;
===add_participant_to_team===&lt;br /&gt;
&lt;br /&gt;
The existing function to add a member&lt;br /&gt;
 add_member(user,team.parent_id)&lt;br /&gt;
adds user to a team based on the user_id and team_id.&lt;br /&gt;
&lt;br /&gt;
We've introduced a new function called&lt;br /&gt;
 add_participant_to_team(student, team.parent_id)&lt;br /&gt;
which adds participant(student) to a team based on participant_id(or user_id wherever participant_id is not available)&lt;br /&gt;
&lt;br /&gt;
This function takes participant and team_id, and assigns that participant to a team. In future, once user_id is removed, add_participant_to_team can be used as a replacement.&lt;br /&gt;
&lt;br /&gt;
[[File:Add_participant_to_team.png|600px]]&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
''user_id'' exists as a foreign key in 2 relations - Participants and teams_users. Although they crrespond to same attribute, user_id alone cannot be used to find corresponding Participants because same user_id can exist for multiple Participants - due to Expertiza's design wherein for every assignment, every user is added to participant's table. Therefore Participant ID can be mapped to (assignment_id, user_id) pair.&lt;br /&gt;
&lt;br /&gt;
== View Changes and Refactoring ==&lt;br /&gt;
&lt;br /&gt;
One of the requirements in E2243 is the refactoring of the student teams view in views/student_teams/view.html.erb&lt;br /&gt;
&lt;br /&gt;
This view is quite cluttered and as a result, makes editing, understanding and extension difficult and tiresome for any future updates to the expertiza application. The code in this file can be modularized to obtain simpler and easier-to-understand, which is what we have achieved. The view was reafactored to incorporate partials, and some of the partials created as a result are:&lt;br /&gt;
&lt;br /&gt;
* _invited_people.html.erb : partial for displaying the invited participants to the assignment team&lt;br /&gt;
* _display_advertisements.html.erb : partial for displaying advertisements in the view&lt;br /&gt;
* _send_invitaions.html.erb : partial for the send invitations functionality&lt;br /&gt;
* _received_invitations.html.erb : partial to display the received invitations for the current user&lt;br /&gt;
&lt;br /&gt;
== Impacted Files ==&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller.rb (expertiza/app/controller/teams_user_controller.rb)&lt;br /&gt;
We will be adding code here to compute the participant_id using the methodologies described above.&lt;br /&gt;
&lt;br /&gt;
* teams_users.rb (expertiza/app/models/teams_user.rb)&lt;br /&gt;
The model will be updated (as can be seen in the ER diagram above) to have the participant_id added.&lt;br /&gt;
&lt;br /&gt;
* teams_users(expertiza/app/views/teams_users)&lt;br /&gt;
The view will be updated to reflect the new name of the model, and contain new partials that make use of the participant_id field.&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller_spec.rb(expertiza/spec/controllers/teams_users_controller_spec.rb)&lt;br /&gt;
The test file for the controller will be modified so that existing test cases pass the new changes, and also introduce new test cases to increase test coverage.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
The changes in teams_users means we need to re-examine the flows and user stories through where teams_users is used. This, in practice, means that we manually have checked the different ways in which a team for an assignment can be created in expertiza, and other associated operations such as removal of a user from a team, addition of a new user, deletion of a team etc. This testing was necessary to ensure that the functionality in expertiza still worked as expected even after our refactoring was completed. &lt;br /&gt;
&lt;br /&gt;
The main user stories we examined are:&lt;br /&gt;
&lt;br /&gt;
1. Student creates a team: A student, newly added to an assignment, opens the application and goes to &amp;quot;my team&amp;quot; after opening the assignment on expertiza. He enters his team's name and the team is created.&lt;br /&gt;
&lt;br /&gt;
[[File:Student_Creates_Team_SendInvite.png|600px]]&lt;br /&gt;
&lt;br /&gt;
2. Student joins a team: A student, is invited to join a team for an assignment, and accepts. He is added to an existing team, possibly created by another student or instructor.&lt;br /&gt;
&lt;br /&gt;
[[File:Student_Joins_Team_ReceivesInvite.png|600px]]&lt;br /&gt;
&lt;br /&gt;
3.  Instructor creates a team manually: An instructor who wishes to create a team with certain students on it, chooses the assignment on expertiza, and clicks on the icon to add a new team and in the manual section, creates a new team by giving a team name. They add students or participants to the newly created team and can remove them too.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_Teams_Instructors_Manually.png|600px]]&lt;br /&gt;
&lt;br /&gt;
4. Instructor creates teams automatically: An instructor wishes to assign all the students involved in an assignment randomly to teams of a certain size. They open expertiza, choose the assignment, and then click on the icon to add a new team, and in the &amp;quot;create teams automatically&amp;quot; section, enter the team size they wish to use. The system then creates teams of the specified size, adding students randomly to teams which is reflected in both student and instructor views.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_Teams_Instructors_Automatically.png|600px]]&lt;br /&gt;
&lt;br /&gt;
In addition to verifying team creation in all of the above scenarios, we also verified other operations such as addition of a team member after the team capacity was exhausted, deletion and re-addition of the same user, invitations to already existing participants in the same team etc and ensure the system was working as expected in these scenarios as well.&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing RSpec ===&lt;br /&gt;
Since this is a refactoring project, the scope of testing is limited to the changes made as part of refactoring and also to ensure that the existing test cases do not break or are modified accordingly.&lt;br /&gt;
In all the existing test cases in expertiza/spec/controllers/teams_users_controller_spec.rb :&lt;br /&gt;
&lt;br /&gt;
* ''object initialization''&lt;br /&gt;
* ''#update_duties''&lt;br /&gt;
* ''when user is added to assignment team''&lt;br /&gt;
* ''when user is added to assignment team''&lt;br /&gt;
* ''when user is added to course team''&lt;br /&gt;
* ''when user is already on an assignment team''&lt;br /&gt;
* ''when user is added to assignment team while on a team already'' &lt;br /&gt;
* ''when user is already on a course team'' &lt;br /&gt;
&lt;br /&gt;
the new methods which use both participant_id and user_id have been incorporated as needed to ensure continued quality of the testing suite and maintenance of code coverage.&lt;br /&gt;
&lt;br /&gt;
==== Fixed Test Files ====&lt;br /&gt;
&lt;br /&gt;
After our refactoring, we noticed failing tests in the below files, and we have worked on fixing these to work with the new and updated functionality. The main issues were involving tests using the old methods for creating a team, adding participants to the team etc. &lt;br /&gt;
&lt;br /&gt;
Models:&lt;br /&gt;
* spec/models/assignment_team_spec.rb&lt;br /&gt;
* spec/models/course_team_spec.rb&lt;br /&gt;
* spec/models/invitation_spec.rb&lt;br /&gt;
* spec/models/student_task_spec.rb&lt;br /&gt;
* spec/models/team_spec.rb&lt;br /&gt;
&lt;br /&gt;
Helper:&lt;br /&gt;
* spec/helpers/authorization_helper_spec.rb&lt;br /&gt;
* spec/helpers/grades_helper_spec.rb&lt;br /&gt;
* spec/helpers/sign_up_sheet_helper_spec.rb&lt;br /&gt;
&lt;br /&gt;
Controllers:&lt;br /&gt;
* spec/controllers/assessment360_controller_spec.rb&lt;br /&gt;
* spec/controllers/grades_controller_spec.rb&lt;br /&gt;
* spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
* spec/controllers/student_teams_controller_spec.rb&lt;br /&gt;
* spec/controllers/lottery_controller_spec.rb&lt;br /&gt;
* spec/controllers/sign_up_sheet_controller_spec.rb&lt;br /&gt;
* spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
* spec/controllers/teams_users_controller_spec.rb&lt;br /&gt;
* spec/controllers/invitations_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Ashok Kumar Selvam (aselvam@ncsu.edu)&lt;br /&gt;
# Sri Athithya Kruth Babu (sbabu@ncsu.edu)&lt;br /&gt;
# Subramanian Venkataraman (svenka25@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Naman Shrimali&lt;br /&gt;
&lt;br /&gt;
== Code Details == &lt;br /&gt;
Github Pull Request - https://github.com/expertiza/expertiza/pull/2391&lt;br /&gt;
&lt;br /&gt;
Repo - https://github.com/sak1997/expertiza/tree/beta&lt;br /&gt;
&lt;br /&gt;
Demo - https://drive.google.com/file/d/1RXINSdJYUv3Bd25epE8AP7vJgM6UXche/view (accessible only by users with ncsu.edu email address)&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=145370</id>
		<title>CSC/ECE 517 Spring 2022 - E2243. Refactor student teams functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=145370"/>
		<updated>2022-04-26T02:19:41Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2243. Refactor student teams functionality which was a project in CSC517 Spring 2022. &lt;br /&gt;
&lt;br /&gt;
Please see below for a description of the design of the project.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
Users &amp;amp; Participants: Everyone who took the CSC517 OODD class at NC State is a user in Expertiza, and instructors can add users as participants in an assignment so that they can access it to contribute, make changes and submit their work to be graded.&lt;br /&gt;
&lt;br /&gt;
Almost all of the works within Assignments is done by participants, not users. All the tables use participant_id to track contributions to assignments, except teams_users. In the documentation, it can be noted that the team_users table references users instead of participants. This anomaly in the teams_users relation causes problems with how student teams are rendered in the UI, and it doesn’t mix well with the new functionality that was recently introduced. The participant_id field should be added to the model, and references that use user_id should also incorporate participant_id. Ideally, the application should use only participant_id, but to handle the existing data in the database without running a massive migration, the application should be able to handle both old records that use user_id and new ones that shall, from after this project is completed, use participant_id instead.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===Changing the schema ===&lt;br /&gt;
* Create a column that would be called “participant_id”, which will be a foreign key that references the participants table.&lt;br /&gt;
* Use this participant_id field in all operations for teams going forward. There are a number of workflows involving teams we have examined and worked on, which are elaborated below.&lt;br /&gt;
* However, it is to be noted that this must also work with the existing functionality and data which makes use of user_id, so the code written must take both into account in its working.&lt;br /&gt;
&lt;br /&gt;
=== Refactoring the teams rendering (/views/student_teams/view.html.erb) ===&lt;br /&gt;
The logic in the team's view (where participants can see their team members) that iterates and fetches information of all the team members and displays them would be refactored as this view is quite bloated and has lots of functionalities written on it. We have made partials and placed those functionality in their specific partials.&lt;br /&gt;
&lt;br /&gt;
=== Other Changes ===&lt;br /&gt;
&lt;br /&gt;
Updated logic for all the CRUD functionalities in teams_users controller (wherever applicable).&lt;br /&gt;
&lt;br /&gt;
Fixed tests to incorporate the new logic as a result of using both user_id and participant_id in the teams_user logic.&lt;br /&gt;
&lt;br /&gt;
== Schema Changes ==&lt;br /&gt;
&lt;br /&gt;
In teams_users table, we can add a new column '''participant_id''' which is a foreign key from participants table and remove the column '''user_id'''. We plan to remove the '''user_id''' column '''only after data migration''' since the user_id field is used predominantly in several other controllers in a variety of ways, and as such its removal must be done carefully.&lt;br /&gt;
&lt;br /&gt;
The participant_id field in the the teams_users relation is computed as follows:&lt;br /&gt;
&lt;br /&gt;
* Finding Assignment ID By Team ID&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id but not the participant_id. Since the same user_id can be associated with multiple participant_ids (since the same user can participate in multiple assignments and gets a unique participant_id in each assignment they take part in), we need to get the user_ids in the assignment for which we need the particular user's participant_id. For this reason, we need to first find the assignment_id.&lt;br /&gt;
&lt;br /&gt;
* Finding Participant ID By Assignment ID and User ID&lt;br /&gt;
With the assignment_id retrieved, we can find the list of participant_ids that participated in the assignment, and using the user_id, get the participant_id which is saved in the participants table. &lt;br /&gt;
&lt;br /&gt;
=== ER diagram for updated schema ===&lt;br /&gt;
[[File:Updated_Proposed_ERR_for_student_teams_E2243.png |900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
Main files which were changed are&lt;br /&gt;
* app/models/participant.rb&lt;br /&gt;
* app/models/team.rb&lt;br /&gt;
* app/models/teams_user.rb&lt;br /&gt;
* app/models/user.rb&lt;br /&gt;
&lt;br /&gt;
As the project tries to introduce participant_id as a replacement of user_id, we've calculated all the details with both user_id and participant_id (whichever is available based on whether the data is old or new). We've also added comments everywhere to show the code snippets which need to be removed once user_id is deprecated. (Check for '''comments with #E2243''')&lt;br /&gt;
&lt;br /&gt;
Currently teams_user table has user_id or participant_id for now. So we've ensured that checks happen based on both the IDs unless user_id is removed. The default check is overridden to ensure newer datas which only have participant_id are also indexed and found using the function call here.&lt;br /&gt;
&lt;br /&gt;
'''Code Snippet'''&lt;br /&gt;
 &lt;br /&gt;
 TeamsUser.where(user_id: user_id).or(TeamsUser.where(participant_id: participant_id))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===find_by_team_id_and_user_id===&lt;br /&gt;
&lt;br /&gt;
''.where'' function makes a lot of DB calls when asked for user_id, we've introduced a module called &amp;quot;'''''find_by_team_id_and_user_id()'''''&amp;quot; which will override ''.where'' function. If user_id is not present in the table, it loads based on participant_id instead, as you can have only one as the key and not both.&lt;br /&gt;
&lt;br /&gt;
So wherever .where is used, &lt;br /&gt;
 TeamsUser.where('team_id = ? and user_id = ?', @team.id, @user.id), &lt;br /&gt;
we've replaced it with &lt;br /&gt;
 TeamsUser.find_by_team_id_and_user_id(@team.id, @user.id). &lt;br /&gt;
&lt;br /&gt;
[[File:Find_by_team_id_and_user_id.png |600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This way instead of changing the query for every call, we've used a single function for all the calls, thereby implementing '''DRY''' principle.&lt;br /&gt;
&lt;br /&gt;
===add_participant_to_team===&lt;br /&gt;
&lt;br /&gt;
The existing function to add a member&lt;br /&gt;
 add_member(user,team.parent_id)&lt;br /&gt;
adds user to a team based on the user_id and team_id.&lt;br /&gt;
&lt;br /&gt;
We've introduced a new function called&lt;br /&gt;
 add_participant_to_team(student, team.parent_id)&lt;br /&gt;
which adds participant(student) to a team based on participant_id(or user_id wherever participant_id is not available)&lt;br /&gt;
&lt;br /&gt;
This function takes participant and team_id, and assigns that participant to a team. In future, once user_id is removed, add_participant_to_team can be used as a replacement.&lt;br /&gt;
&lt;br /&gt;
[[File:Add_participant_to_team.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
''user_id'' exists as a foreign key in 2 relations - Participants and teams_users. Although they crrespond to same attribute, user_id alone cannot be used to find corresponding Participants because same user_id can exist for multiple Participants - due to Expertiza's design wherein for every assignment, every user is added to participant's table. Therefore Participant ID can be mapped to (assignment_id, user_id) pair.&lt;br /&gt;
&lt;br /&gt;
== View Changes and Refactoring ==&lt;br /&gt;
&lt;br /&gt;
One of the requirements in E2243 is the refactoring of the student teams view in views/student_teams/view.html.erb&lt;br /&gt;
&lt;br /&gt;
This view is quite cluttered and as a result, makes editing, understanding and extension difficult and tiresome for any future updates to the expertiza application. The code in this file can be modularized to obtain simpler and easier-to-understand, which is what we have achieved. The view was reafactored to incorporate partials, and some of the partials created as a result are:&lt;br /&gt;
&lt;br /&gt;
* _invited_people.html.erb : partial for displaying the invited participants to the assignment team&lt;br /&gt;
* _display_advertisements.html.erb : partial for displaying advertisements in the view&lt;br /&gt;
* _send_invitaions.html.erb : partial for the send invitations functionality&lt;br /&gt;
* _received_invitations.html.erb : partial to display the received invitations for the current user&lt;br /&gt;
&lt;br /&gt;
== Impacted Files ==&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller.rb (expertiza/app/controller/teams_user_controller.rb)&lt;br /&gt;
We will be adding code here to compute the participant_id using the methodologies described above.&lt;br /&gt;
&lt;br /&gt;
* teams_users.rb (expertiza/app/models/teams_user.rb)&lt;br /&gt;
The model will be updated (as can be seen in the ER diagram above) to have the participant_id added.&lt;br /&gt;
&lt;br /&gt;
* teams_users(expertiza/app/views/teams_users)&lt;br /&gt;
The view will be updated to reflect the new name of the model, and contain new partials that make use of the participant_id field.&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller_spec.rb(expertiza/spec/controllers/teams_users_controller_spec.rb)&lt;br /&gt;
The test file for the controller will be modified so that existing test cases pass the new changes, and also introduce new test cases to increase test coverage.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
The changes in teams_users means we need to re-examine the flows and user stories through where teams_users is used. This, in practice, means that we manually have checked the different ways in which a team for an assignment can be created in expertiza, and other associated operations such as removal of a user from a team, addition of a new user, deletion of a team etc. This testing was necessary to ensure that the functionality in expertiza still worked as expected even after our refactoring was completed. &lt;br /&gt;
&lt;br /&gt;
The main user stories we examined are:&lt;br /&gt;
&lt;br /&gt;
1. Student creates a team: A student, newly added to an assignment, opens the application and goes to &amp;quot;my team&amp;quot; after opening the assignment on expertiza. He enters his team's name and the team is created.&lt;br /&gt;
&lt;br /&gt;
[[File:Student_Creates_Team_SendInvite.png|600px]]&lt;br /&gt;
&lt;br /&gt;
2. Student joins a team: A student, is invited to join a team for an assignment, and accepts. He is added to an existing team, possibly created by another student or instructor.&lt;br /&gt;
&lt;br /&gt;
[[File:Student_Joins_Team_ReceivesInvite.png|600px]]&lt;br /&gt;
&lt;br /&gt;
3.  Instructor creates a team manually: An instructor who wishes to create a team with certain students on it, chooses the assignment on expertiza, and clicks on the icon to add a new team and in the manual section, creates a new team by giving a team name. They add students or participants to the newly created team and can remove them too.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_Teams_Instructors_Manually.png|600px]]&lt;br /&gt;
&lt;br /&gt;
4. Instructor creates teams automatically: An instructor wishes to assign all the students involved in an assignment randomly to teams of a certain size. They open expertiza, choose the assignment, and then click on the icon to add a new team, and in the &amp;quot;create teams automatically&amp;quot; section, enter the team size they wish to use. The system then creates teams of the specified size, adding students randomly to teams which is reflected in both student and instructor views.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_Teams_Instructors_Automatically.png|600px]]&lt;br /&gt;
&lt;br /&gt;
In addition to verifying team creation in all of the above scenarios, we also verified other operations such as addition of a team member after the team capacity was exhausted, deletion and re-addition of the same user, invitations to already existing participants in the same team etc and ensure the system was working as expected in these scenarios as well.&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing RSpec ===&lt;br /&gt;
Since this is a refactoring project, the scope of testing is limited to the changes made as part of refactoring and also to ensure that the existing test cases do not break or are modified accordingly.&lt;br /&gt;
In all the existing test cases in expertiza/spec/controllers/teams_users_controller_spec.rb :&lt;br /&gt;
&lt;br /&gt;
* ''object initialization''&lt;br /&gt;
* ''#update_duties''&lt;br /&gt;
* ''when user is added to assignment team''&lt;br /&gt;
* ''when user is added to assignment team''&lt;br /&gt;
* ''when user is added to course team''&lt;br /&gt;
* ''when user is already on an assignment team''&lt;br /&gt;
* ''when user is added to assignment team while on a team already'' &lt;br /&gt;
* ''when user is already on a course team'' &lt;br /&gt;
&lt;br /&gt;
the new methods which use both participant_id and user_id have been incorporated as needed to ensure continued quality of the testing suite and maintenance of code coverage.&lt;br /&gt;
&lt;br /&gt;
==== Fixed Test Files ====&lt;br /&gt;
&lt;br /&gt;
After our refactoring, we noticed failing tests in the below files, and we have worked on fixing these to work with the new and updated functionality. The main issues were involving tests using the old methods for creating a team, adding participants to the team etc. &lt;br /&gt;
&lt;br /&gt;
Models:&lt;br /&gt;
* spec/models/assignment_team_spec.rb&lt;br /&gt;
* spec/models/course_team_spec.rb&lt;br /&gt;
* spec/models/invitation_spec.rb&lt;br /&gt;
* spec/models/student_task_spec.rb&lt;br /&gt;
* spec/models/team_spec.rb&lt;br /&gt;
&lt;br /&gt;
Helper:&lt;br /&gt;
* spec/helpers/authorization_helper_spec.rb&lt;br /&gt;
* spec/helpers/grades_helper_spec.rb&lt;br /&gt;
* spec/helpers/sign_up_sheet_helper_spec.rb&lt;br /&gt;
&lt;br /&gt;
Controllers:&lt;br /&gt;
* spec/controllers/assessment360_controller_spec.rb&lt;br /&gt;
* spec/controllers/grades_controller_spec.rb&lt;br /&gt;
* spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
* spec/controllers/student_teams_controller_spec.rb&lt;br /&gt;
* spec/controllers/lottery_controller_spec.rb&lt;br /&gt;
* spec/controllers/sign_up_sheet_controller_spec.rb&lt;br /&gt;
* spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
* spec/controllers/teams_users_controller_spec.rb&lt;br /&gt;
* spec/controllers/invitations_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Ashok Kumar Selvam (aselvam@ncsu.edu)&lt;br /&gt;
# Sri Athithya Kruth Babu (sbabu@ncsu.edu)&lt;br /&gt;
# Subramanian Venkataraman (svenka25@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Naman Shrimali&lt;br /&gt;
&lt;br /&gt;
== Code Details == &lt;br /&gt;
Github Pull Request - https://github.com/expertiza/expertiza/pull/2391&lt;br /&gt;
&lt;br /&gt;
Repo - https://github.com/sak1997/expertiza/tree/beta&lt;br /&gt;
&lt;br /&gt;
Demo - https://drive.google.com/file/d/1RXINSdJYUv3Bd25epE8AP7vJgM6UXche/view (accessible only by users with ncsu.edu email address)&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Add_participant_to_team.png&amp;diff=145369</id>
		<title>File:Add participant to team.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Add_participant_to_team.png&amp;diff=145369"/>
		<updated>2022-04-26T02:18:25Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Find_by_team_id_and_user_id.png&amp;diff=145368</id>
		<title>File:Find by team id and user id.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Find_by_team_id_and_user_id.png&amp;diff=145368"/>
		<updated>2022-04-26T02:13:40Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=145367</id>
		<title>CSC/ECE 517 Spring 2022 - E2243. Refactor student teams functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=145367"/>
		<updated>2022-04-26T02:00:17Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2243. Refactor student teams functionality which was a project in CSC517 Spring 2022. &lt;br /&gt;
&lt;br /&gt;
Please see below for a description of the design of the project.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
Users &amp;amp; Participants: Everyone who took the CSC517 OODD class at NC State is a user in Expertiza, and instructors can add users as participants in an assignment so that they can access it to contribute, make changes and submit their work to be graded.&lt;br /&gt;
&lt;br /&gt;
Almost all of the works within Assignments is done by participants, not users. All the tables use participant_id to track contributions to assignments, except teams_users. In the documentation, it can be noted that the team_users table references users instead of participants. This anomaly in the teams_users relation causes problems with how student teams are rendered in the UI, and it doesn’t mix well with the new functionality that was recently introduced. The participant_id field should be added to the model, and references that use user_id should also incorporate participant_id. Ideally, the application should use only participant_id, but to handle the existing data in the database without running a massive migration, the application should be able to handle both old records that use user_id and new ones that shall, from after this project is completed, use participant_id instead.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===Changing the schema ===&lt;br /&gt;
* Create a column that would be called “participant_id”, which will be a foreign key that references the participants table.&lt;br /&gt;
* Use this participant_id field in all operations for teams going forward. There are a number of workflows involving teams we have examined and worked on, which are elaborated below.&lt;br /&gt;
* However, it is to be noted that this must also work with the existing functionality and data which makes use of user_id, so the code written must take both into account in its working.&lt;br /&gt;
&lt;br /&gt;
=== Refactoring the teams rendering (/views/student_teams/view.html.erb) ===&lt;br /&gt;
The logic in the team's view (where participants can see their team members) that iterates and fetches information of all the team members and displays them would be refactored as this view is quite bloated and has lots of functionalities written on it. We have made partials and placed those functionality in their specific partials.&lt;br /&gt;
&lt;br /&gt;
=== Other Changes ===&lt;br /&gt;
&lt;br /&gt;
Updated logic for all the CRUD functionalities in teams_users controller (wherever applicable).&lt;br /&gt;
&lt;br /&gt;
Fixed tests to incorporate the new logic as a result of using both user_id and participant_id in the teams_user logic.&lt;br /&gt;
&lt;br /&gt;
== Schema Changes ==&lt;br /&gt;
&lt;br /&gt;
In teams_users table, we can add a new column '''participant_id''' which is a foreign key from participants table and remove the column '''user_id'''. We plan to remove the '''user_id''' column '''only after data migration''' since the user_id field is used predominantly in several other controllers in a variety of ways, and as such its removal must be done carefully.&lt;br /&gt;
&lt;br /&gt;
The participant_id field in the the teams_users relation is computed as follows:&lt;br /&gt;
&lt;br /&gt;
* Finding Assignment ID By Team ID&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id but not the participant_id. Since the same user_id can be associated with multiple participant_ids (since the same user can participate in multiple assignments and gets a unique participant_id in each assignment they take part in), we need to get the user_ids in the assignment for which we need the particular user's participant_id. For this reason, we need to first find the assignment_id.&lt;br /&gt;
&lt;br /&gt;
* Finding Participant ID By Assignment ID and User ID&lt;br /&gt;
With the assignment_id retrieved, we can find the list of participant_ids that participated in the assignment, and using the user_id, get the participant_id which is saved in the participants table. &lt;br /&gt;
&lt;br /&gt;
=== ER diagram for updated schema ===&lt;br /&gt;
[[File:Updated_Proposed_ERR_for_student_teams_E2243.png |900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
Main files which were changed are&lt;br /&gt;
* app/models/participant.rb&lt;br /&gt;
* app/models/team.rb&lt;br /&gt;
* app/models/teams_user.rb&lt;br /&gt;
* app/models/user.rb&lt;br /&gt;
&lt;br /&gt;
As the project tries to introduce participant_id as a replacement of user_id, we've calculated all the details with both user_id and participant_id (whichever is available based on whether the data is old or new). We've also added comments everywhere to show the code snippets which need to be removed once user_id is deprecated. (Check for '''comments with #E2243''')&lt;br /&gt;
&lt;br /&gt;
Currently teams_user table has user_id or participant_id for now. So we've ensured that checks happen based on both the IDs unless user_id is removed. The default check is overridden to ensure newer datas which only have participant_id are also indexed and found using the function call here.&lt;br /&gt;
&lt;br /&gt;
'''Code Snippet'''&lt;br /&gt;
 &lt;br /&gt;
 TeamsUser.where(user_id: user_id).or(TeamsUser.where(participant_id: participant_id))&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;Picture WIP with light background&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
''.where'' function makes a lot of DB calls when asked for user_id, we've introduced a module called &amp;quot;'''''find_by_team_id_and_user_id()'''''&amp;quot; which will override ''.where'' function. If user_id is not present in the table, it loads based on participant_id instead, as you can have only one as the key and not both.&lt;br /&gt;
&lt;br /&gt;
So wherever .where is used, &lt;br /&gt;
 TeamsUser.where('team_id = ? and user_id = ?', @team.id, @user.id), &lt;br /&gt;
we've replaced it with &lt;br /&gt;
 TeamsUser.find_by_team_id_and_user_id(@team.id, @user.id). &lt;br /&gt;
&lt;br /&gt;
This way instead of changing the query for every call, we've used a single function for all the calls, thereby implementing '''DRY''' principle.&lt;br /&gt;
&lt;br /&gt;
The existing function to add a member&lt;br /&gt;
 add_member(user,team.parent_id) --- add user to a team&lt;br /&gt;
&lt;br /&gt;
We've introduced a new function called&lt;br /&gt;
 add_participant_to_team(student, team.parent_id) --- adds participant(student) to a team&lt;br /&gt;
&lt;br /&gt;
This function takes participant and team_id, and assigns that participant to a team. In future, once user_id is removed, add_participant_to_team can be used as a replacement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
''user_id'' exists as a foreign key in 2 relations - Participants and teams_users. Although they crrespond to same attribute, user_id alone cannot be used to find corresponding Participants because same user_id can exist for multiple Participants - due to Expertiza's design wherein for every assignment, every user is added to participant's table. Therefore Participant ID can be mapped to (assignment_id, user_id) pair.&lt;br /&gt;
&lt;br /&gt;
== View Changes and Refactoring ==&lt;br /&gt;
&lt;br /&gt;
One of the requirements in E2243 is the refactoring of the student teams view in views/student_teams/view.html.erb&lt;br /&gt;
&lt;br /&gt;
This view is quite cluttered and as a result, makes editing, understanding and extension difficult and tiresome for any future updates to the expertiza application. The code in this file can be modularized to obtain simpler and easier-to-understand, which is what we have achieved. The view was reafactored to incorporate partials, and some of the partials created as a result are:&lt;br /&gt;
&lt;br /&gt;
* _invited_people.html.erb : partial for displaying the invited participants to the assignment team&lt;br /&gt;
* _display_advertisements.html.erb : partial for displaying advertisements in the view&lt;br /&gt;
* _send_invitaions.html.erb : partial for the send invitations functionality&lt;br /&gt;
* _received_invitations.html.erb : partial to display the received invitations for the current user&lt;br /&gt;
&lt;br /&gt;
== Impacted Files ==&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller.rb (expertiza/app/controller/teams_user_controller.rb)&lt;br /&gt;
We will be adding code here to compute the participant_id using the methodologies described above.&lt;br /&gt;
&lt;br /&gt;
* teams_users.rb (expertiza/app/models/teams_user.rb)&lt;br /&gt;
The model will be updated (as can be seen in the ER diagram above) to have the participant_id added.&lt;br /&gt;
&lt;br /&gt;
* teams_users(expertiza/app/views/teams_users)&lt;br /&gt;
The view will be updated to reflect the new name of the model, and contain new partials that make use of the participant_id field.&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller_spec.rb(expertiza/spec/controllers/teams_users_controller_spec.rb)&lt;br /&gt;
The test file for the controller will be modified so that existing test cases pass the new changes, and also introduce new test cases to increase test coverage.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
The changes in teams_users means we need to re-examine the flows and user stories through where teams_users is used. This, in practice, means that we manually have checked the different ways in which a team for an assignment can be created in expertiza, and other associated operations such as removal of a user from a team, addition of a new user, deletion of a team etc. This testing was necessary to ensure that the functionality in expertiza still worked as expected even after our refactoring was completed. &lt;br /&gt;
&lt;br /&gt;
The main user stories we examined are:&lt;br /&gt;
&lt;br /&gt;
1. Student creates a team: A student, newly added to an assignment, opens the application and goes to &amp;quot;my team&amp;quot; after opening the assignment on expertiza. He enters his team's name and the team is created.&lt;br /&gt;
&lt;br /&gt;
[[File:Student_Creates_Team_SendInvite.png|600px]]&lt;br /&gt;
&lt;br /&gt;
2. Student joins a team: A student, is invited to join a team for an assignment, and accepts. He is added to an existing team, possibly created by another student or instructor.&lt;br /&gt;
&lt;br /&gt;
[[File:Student_Joins_Team_ReceivesInvite.png|600px]]&lt;br /&gt;
&lt;br /&gt;
3.  Instructor creates a team manually: An instructor who wishes to create a team with certain students on it, chooses the assignment on expertiza, and clicks on the icon to add a new team and in the manual section, creates a new team by giving a team name. They add students or participants to the newly created team and can remove them too.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_Teams_Instructors_Manually.png|600px]]&lt;br /&gt;
&lt;br /&gt;
4. Instructor creates teams automatically: An instructor wishes to assign all the students involved in an assignment randomly to teams of a certain size. They open expertiza, choose the assignment, and then click on the icon to add a new team, and in the &amp;quot;create teams automatically&amp;quot; section, enter the team size they wish to use. The system then creates teams of the specified size, adding students randomly to teams which is reflected in both student and instructor views.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_Teams_Instructors_Automatically.png|600px]]&lt;br /&gt;
&lt;br /&gt;
In addition to verifying team creation in all of the above scenarios, we also verified other operations such as addition of a team member after the team capacity was exhausted, deletion and re-addition of the same user, invitations to already existing participants in the same team etc and ensure the system was working as expected in these scenarios as well.&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing RSpec ===&lt;br /&gt;
Since this is a refactoring project, the scope of testing is limited to the changes made as part of refactoring and also to ensure that the existing test cases do not break or are modified accordingly.&lt;br /&gt;
In all the existing test cases in expertiza/spec/controllers/teams_users_controller_spec.rb :&lt;br /&gt;
&lt;br /&gt;
* ''object initialization''&lt;br /&gt;
* ''#update_duties''&lt;br /&gt;
* ''when user is added to assignment team''&lt;br /&gt;
* ''when user is added to assignment team''&lt;br /&gt;
* ''when user is added to course team''&lt;br /&gt;
* ''when user is already on an assignment team''&lt;br /&gt;
* ''when user is added to assignment team while on a team already'' &lt;br /&gt;
* ''when user is already on a course team'' &lt;br /&gt;
&lt;br /&gt;
the new methods which use both participant_id and user_id have been incorporated as needed to ensure continued quality of the testing suite and maintenance of code coverage.&lt;br /&gt;
&lt;br /&gt;
==== Fixed Test Files ====&lt;br /&gt;
&lt;br /&gt;
After our refactoring, we noticed failing tests in the below files, and we have worked on fixing these to work with the new and updated functionality. The main issues were involving tests using the old methods for creating a team, adding participants to the team etc. &lt;br /&gt;
&lt;br /&gt;
Models:&lt;br /&gt;
* spec/models/assignment_team_spec.rb&lt;br /&gt;
* spec/models/course_team_spec.rb&lt;br /&gt;
* spec/models/invitation_spec.rb&lt;br /&gt;
* spec/models/student_task_spec.rb&lt;br /&gt;
* spec/models/team_spec.rb&lt;br /&gt;
&lt;br /&gt;
Helper:&lt;br /&gt;
* spec/helpers/authorization_helper_spec.rb&lt;br /&gt;
* spec/helpers/grades_helper_spec.rb&lt;br /&gt;
* spec/helpers/sign_up_sheet_helper_spec.rb&lt;br /&gt;
&lt;br /&gt;
Controllers:&lt;br /&gt;
* spec/controllers/assessment360_controller_spec.rb&lt;br /&gt;
* spec/controllers/grades_controller_spec.rb&lt;br /&gt;
* spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
* spec/controllers/student_teams_controller_spec.rb&lt;br /&gt;
* spec/controllers/lottery_controller_spec.rb&lt;br /&gt;
* spec/controllers/sign_up_sheet_controller_spec.rb&lt;br /&gt;
* spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
* spec/controllers/teams_users_controller_spec.rb&lt;br /&gt;
* spec/controllers/invitations_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Ashok Kumar Selvam (aselvam@ncsu.edu)&lt;br /&gt;
# Sri Athithya Kruth Babu (sbabu@ncsu.edu)&lt;br /&gt;
# Subramanian Venkataraman (svenka25@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Naman Shrimali&lt;br /&gt;
&lt;br /&gt;
== Code Details == &lt;br /&gt;
Github Pull Request - https://github.com/expertiza/expertiza/pull/2391&lt;br /&gt;
&lt;br /&gt;
Repo - https://github.com/sak1997/expertiza/tree/beta&lt;br /&gt;
&lt;br /&gt;
Demo - https://drive.google.com/file/d/1RXINSdJYUv3Bd25epE8AP7vJgM6UXche/view (accessible only by users with ncsu.edu email address)&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=145366</id>
		<title>CSC/ECE 517 Spring 2022 - E2243. Refactor student teams functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=145366"/>
		<updated>2022-04-26T01:59:15Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2243. Refactor student teams functionality which was a project in CSC517 Spring 2022. &lt;br /&gt;
&lt;br /&gt;
Please see below for a description of the design of the project.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
Users &amp;amp; Participants: Everyone who took the CSC517 OODD class at NC State is a user in Expertiza, and instructors can add users as participants in an assignment so that they can access it to contribute, make changes and submit their work to be graded.&lt;br /&gt;
&lt;br /&gt;
Almost all of the works within Assignments is done by participants, not users. All the tables use participant_id to track contributions to assignments, except teams_users. In the documentation, it can be noted that the team_users table references users instead of participants. This anomaly in the teams_users relation causes problems with how student teams are rendered in the UI, and it doesn’t mix well with the new functionality that was recently introduced. The participant_id field should be added to the model, and references that use user_id should also incorporate participant_id. Ideally, the application should use only participant_id, but to handle the existing data in the database without running a massive migration, the application should be able to handle both old records that use user_id and new ones that shall, from after this project is completed, use participant_id instead.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===Changing the schema ===&lt;br /&gt;
* Create a column that would be called “participant_id”, which will be a foreign key that references the participants table.&lt;br /&gt;
* Use this participant_id field in all operations for teams going forward. There are a number of workflows involving teams we have examined and worked on, which are elaborated below.&lt;br /&gt;
* However, it is to be noted that this must also work with the existing functionality and data which makes use of user_id, so the code written must take both into account in its working.&lt;br /&gt;
&lt;br /&gt;
=== Refactoring the teams rendering (/views/student_teams/view.html.erb) ===&lt;br /&gt;
The logic in the team's view (where participants can see their team members) that iterates and fetches information of all the team members and displays them would be refactored as this view is quite bloated and has lots of functionalities written on it. We have made partials and placed those functionality in their specific partials.&lt;br /&gt;
&lt;br /&gt;
=== Other Changes ===&lt;br /&gt;
&lt;br /&gt;
Updated logic for all the CRUD functionalities in teams_users controller (wherever applicable).&lt;br /&gt;
&lt;br /&gt;
Fixed tests to incorporate the new logic as a result of using both user_id and participant_id in the teams_user logic.&lt;br /&gt;
&lt;br /&gt;
== Schema Changes ==&lt;br /&gt;
&lt;br /&gt;
In teams_users table, we can add a new column '''participant_id''' which is a foreign key from participants table and remove the column '''user_id'''. We plan to remove the '''user_id''' column '''only after data migration''' since the user_id field is used predominantly in several other controllers in a variety of ways, and as such its removal must be done carefully.&lt;br /&gt;
&lt;br /&gt;
The participant_id field in the the teams_users relation is computed as follows:&lt;br /&gt;
&lt;br /&gt;
* Finding Assignment ID By Team ID&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id but not the participant_id. Since the same user_id can be associated with multiple participant_ids (since the same user can participate in multiple assignments and gets a unique participant_id in each assignment they take part in), we need to get the user_ids in the assignment for which we need the particular user's participant_id. For this reason, we need to first find the assignment_id.&lt;br /&gt;
&lt;br /&gt;
* Finding Participant ID By Assignment ID and User ID&lt;br /&gt;
With the assignment_id retrieved, we can find the list of participant_ids that participated in the assignment, and using the user_id, get the participant_id which is saved in the participants table. &lt;br /&gt;
&lt;br /&gt;
=== ER diagram for updated schema ===&lt;br /&gt;
[[File:Updated_Proposed_ERR_for_student_teams_E2243.png |900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
Main files which were changed are&lt;br /&gt;
* app/models/participant.rb&lt;br /&gt;
* app/models/team.rb&lt;br /&gt;
* app/models/teams_user.rb&lt;br /&gt;
* app/models/user.rb&lt;br /&gt;
&lt;br /&gt;
As the project tries to introduce participant_id as a replacement of user_id, we've calculated all the details with both user_id and participant_id (whichever is available based on whether the data is old or new). We've also added comments everywhere to show the code snippets which need to be removed once user_id is deprecated. (Check for '''comments with #E2243''')&lt;br /&gt;
&lt;br /&gt;
Currently teams_user table has user_id or participant_id for now. So we've ensured that checks happen based on both the IDs unless user_id is removed. The default check is overridden to ensure newer datas which only have participant_id are also indexed and found using the function call here.&lt;br /&gt;
&lt;br /&gt;
'''Code Snippet'''&lt;br /&gt;
 &lt;br /&gt;
 TeamsUser.where(user_id: user_id).or(TeamsUser.where(participant_id: participant_id))&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;Picture WIP with light background&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
''.where'' function makes a lot of DB calls when asked for user_id, we've introduced a module called &amp;quot;'''''find_by_team_id_and_user_id()'''''&amp;quot; which will override ''.where'' function. If user_id is not present in the table, it loads based on participant_id instead, as you can have only one as the key and not both.&lt;br /&gt;
&lt;br /&gt;
So wherever .where is used, &lt;br /&gt;
 TeamsUser.where('team_id = ? and user_id = ?', @team.id, @user.id), &lt;br /&gt;
we've replaced it with &lt;br /&gt;
 TeamsUser.find_by_team_id_and_user_id(@team.id, @user.id). &lt;br /&gt;
&lt;br /&gt;
This way instead of changing the query for every call, we've used a single function for all the calls, thereby implementing '''DRY''' principle.&lt;br /&gt;
&lt;br /&gt;
There existing function to add a member&lt;br /&gt;
 add_member(user,team.parent_id) --- add user to a team&lt;br /&gt;
&lt;br /&gt;
We've introduced a new function called&lt;br /&gt;
 add_participant_to_team(student, team.parent_id) --- adds participant(student) to a team&lt;br /&gt;
&lt;br /&gt;
This function takes participant and team_id, and assigns that participant to a team. In future, once user_id is removed, add_participant_to_team can be used as a replacement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
''user_id'' exists as a foreign key in 2 relations - Participants and teams_users. Although they crrespond to same attribute, user_id alone cannot be used to find corresponding Participants because same user_id can exist for multiple Participants - due to Expertiza's design wherein for every assignment, every user is added to participant's table. Therefore Participant ID can be mapped to (assignment_id, user_id) pair.&lt;br /&gt;
&lt;br /&gt;
== View Changes and Refactoring ==&lt;br /&gt;
&lt;br /&gt;
One of the requirements in E2243 is the refactoring of the student teams view in views/student_teams/view.html.erb&lt;br /&gt;
&lt;br /&gt;
This view is quite cluttered and as a result, makes editing, understanding and extension difficult and tiresome for any future updates to the expertiza application. The code in this file can be modularized to obtain simpler and easier-to-understand, which is what we have achieved. The view was reafactored to incorporate partials, and some of the partials created as a result are:&lt;br /&gt;
&lt;br /&gt;
* _invited_people.html.erb : partial for displaying the invited participants to the assignment team&lt;br /&gt;
* _display_advertisements.html.erb : partial for displaying advertisements in the view&lt;br /&gt;
* _send_invitaions.html.erb : partial for the send invitations functionality&lt;br /&gt;
* _received_invitations.html.erb : partial to display the received invitations for the current user&lt;br /&gt;
&lt;br /&gt;
== Impacted Files ==&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller.rb (expertiza/app/controller/teams_user_controller.rb)&lt;br /&gt;
We will be adding code here to compute the participant_id using the methodologies described above.&lt;br /&gt;
&lt;br /&gt;
* teams_users.rb (expertiza/app/models/teams_user.rb)&lt;br /&gt;
The model will be updated (as can be seen in the ER diagram above) to have the participant_id added.&lt;br /&gt;
&lt;br /&gt;
* teams_users(expertiza/app/views/teams_users)&lt;br /&gt;
The view will be updated to reflect the new name of the model, and contain new partials that make use of the participant_id field.&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller_spec.rb(expertiza/spec/controllers/teams_users_controller_spec.rb)&lt;br /&gt;
The test file for the controller will be modified so that existing test cases pass the new changes, and also introduce new test cases to increase test coverage.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
The changes in teams_users means we need to re-examine the flows and user stories through where teams_users is used. This, in practice, means that we manually have checked the different ways in which a team for an assignment can be created in expertiza, and other associated operations such as removal of a user from a team, addition of a new user, deletion of a team etc. This testing was necessary to ensure that the functionality in expertiza still worked as expected even after our refactoring was completed. &lt;br /&gt;
&lt;br /&gt;
The main user stories we examined are:&lt;br /&gt;
&lt;br /&gt;
1. Student creates a team: A student, newly added to an assignment, opens the application and goes to &amp;quot;my team&amp;quot; after opening the assignment on expertiza. He enters his team's name and the team is created.&lt;br /&gt;
&lt;br /&gt;
[[File:Student_Creates_Team_SendInvite.png|600px]]&lt;br /&gt;
&lt;br /&gt;
2. Student joins a team: A student, is invited to join a team for an assignment, and accepts. He is added to an existing team, possibly created by another student or instructor.&lt;br /&gt;
&lt;br /&gt;
[[File:Student_Joins_Team_ReceivesInvite.png|600px]]&lt;br /&gt;
&lt;br /&gt;
3.  Instructor creates a team manually: An instructor who wishes to create a team with certain students on it, chooses the assignment on expertiza, and clicks on the icon to add a new team and in the manual section, creates a new team by giving a team name. They add students or participants to the newly created team and can remove them too.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_Teams_Instructors_Manually.png|600px]]&lt;br /&gt;
&lt;br /&gt;
4. Instructor creates teams automatically: An instructor wishes to assign all the students involved in an assignment randomly to teams of a certain size. They open expertiza, choose the assignment, and then click on the icon to add a new team, and in the &amp;quot;create teams automatically&amp;quot; section, enter the team size they wish to use. The system then creates teams of the specified size, adding students randomly to teams which is reflected in both student and instructor views.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_Teams_Instructors_Automatically.png|600px]]&lt;br /&gt;
&lt;br /&gt;
In addition to verifying team creation in all of the above scenarios, we also verified other operations such as addition of a team member after the team capacity was exhausted, deletion and re-addition of the same user, invitations to already existing participants in the same team etc and ensure the system was working as expected in these scenarios as well.&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing RSpec ===&lt;br /&gt;
Since this is a refactoring project, the scope of testing is limited to the changes made as part of refactoring and also to ensure that the existing test cases do not break or are modified accordingly.&lt;br /&gt;
In all the existing test cases in expertiza/spec/controllers/teams_users_controller_spec.rb :&lt;br /&gt;
&lt;br /&gt;
* ''object initialization''&lt;br /&gt;
* ''#update_duties''&lt;br /&gt;
* ''when user is added to assignment team''&lt;br /&gt;
* ''when user is added to assignment team''&lt;br /&gt;
* ''when user is added to course team''&lt;br /&gt;
* ''when user is already on an assignment team''&lt;br /&gt;
* ''when user is added to assignment team while on a team already'' &lt;br /&gt;
* ''when user is already on a course team'' &lt;br /&gt;
&lt;br /&gt;
the new methods which use both participant_id and user_id have been incorporated as needed to ensure continued quality of the testing suite and maintenance of code coverage.&lt;br /&gt;
&lt;br /&gt;
==== Fixed Test Files ====&lt;br /&gt;
&lt;br /&gt;
After our refactoring, we noticed failing tests in the below files, and we have worked on fixing these to work with the new and updated functionality. The main issues were involving tests using the old methods for creating a team, adding participants to the team etc. &lt;br /&gt;
&lt;br /&gt;
Models:&lt;br /&gt;
* spec/models/assignment_team_spec.rb&lt;br /&gt;
* spec/models/course_team_spec.rb&lt;br /&gt;
* spec/models/invitation_spec.rb&lt;br /&gt;
* spec/models/student_task_spec.rb&lt;br /&gt;
* spec/models/team_spec.rb&lt;br /&gt;
&lt;br /&gt;
Helper:&lt;br /&gt;
* spec/helpers/authorization_helper_spec.rb&lt;br /&gt;
* spec/helpers/grades_helper_spec.rb&lt;br /&gt;
* spec/helpers/sign_up_sheet_helper_spec.rb&lt;br /&gt;
&lt;br /&gt;
Controllers:&lt;br /&gt;
* spec/controllers/assessment360_controller_spec.rb&lt;br /&gt;
* spec/controllers/grades_controller_spec.rb&lt;br /&gt;
* spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
* spec/controllers/student_teams_controller_spec.rb&lt;br /&gt;
* spec/controllers/lottery_controller_spec.rb&lt;br /&gt;
* spec/controllers/sign_up_sheet_controller_spec.rb&lt;br /&gt;
* spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
* spec/controllers/teams_users_controller_spec.rb&lt;br /&gt;
* spec/controllers/invitations_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Ashok Kumar Selvam (aselvam@ncsu.edu)&lt;br /&gt;
# Sri Athithya Kruth Babu (sbabu@ncsu.edu)&lt;br /&gt;
# Subramanian Venkataraman (svenka25@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Naman Shrimali&lt;br /&gt;
&lt;br /&gt;
== Code Details == &lt;br /&gt;
Github Pull Request - https://github.com/expertiza/expertiza/pull/2391&lt;br /&gt;
&lt;br /&gt;
Repo - https://github.com/sak1997/expertiza/tree/beta&lt;br /&gt;
&lt;br /&gt;
Demo - https://drive.google.com/file/d/1RXINSdJYUv3Bd25epE8AP7vJgM6UXche/view (accessible only by users with ncsu.edu email address)&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=145351</id>
		<title>CSC/ECE 517 Spring 2022 - E2243. Refactor student teams functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=145351"/>
		<updated>2022-04-26T01:16:57Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2243. Refactor student teams functionality which was a project in CSC517 Spring 2022. &lt;br /&gt;
&lt;br /&gt;
Please see below for a description of the design of the project.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
Users &amp;amp; Participants: Everyone who took the CSC517 OODD class at NC State is a user in Expertiza, and instructors can add users as participants in an assignment so that they can access it to contribute, make changes and submit their work to be graded.&lt;br /&gt;
&lt;br /&gt;
Almost all of the works within Assignments is done by participants, not users. All the tables use participant_id to track contributions to assignments, except teams_users. In the documentation, it can be noted that the team_users table references users instead of participants. This anomaly in the teams_users relation causes problems with how student teams are rendered in the UI, and it doesn’t mix well with the new functionality that was recently introduced. The participant_id field should be added to the model, and references that use user_id should also incorporate participant_id. Ideally, the application should use only participant_id, but to handle the existing data in the database without running a massive migration, the application should be able to handle both old records that use user_id and new ones that shall, from after this project is completed, use participant_id instead.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===Changing the schema ===&lt;br /&gt;
* Create a column that would be called “participant_id”, which will be a foreign key that references the participants table.&lt;br /&gt;
* Use this participant_id field in all operations for teams going forward. There are a number of workflows involving teams we have examined and worked on, which are elaborated below.&lt;br /&gt;
* However, it is to be noted that this must also work with the existing functionality and data which makes use of user_id, so the code written must take both into account in its working.&lt;br /&gt;
&lt;br /&gt;
=== Refactoring the teams rendering (/views/student_teams/view.html.erb) ===&lt;br /&gt;
The logic in the team's view (where participants can see their team members) that iterates and fetches information of all the team members and displays them would be refactored as this view is quite bloated and has lots of functionalities written on it. We have made partials and placed those functionality in their specific partials.&lt;br /&gt;
&lt;br /&gt;
=== Other Changes ===&lt;br /&gt;
&lt;br /&gt;
Updated logic for all the CRUD functionalities in teams_users controller (wherever applicable).&lt;br /&gt;
&lt;br /&gt;
Fixed tests to incorporate the new logic as a result of using both user_id and participant_id in the teams_user logic.&lt;br /&gt;
&lt;br /&gt;
== Schema Changes ==&lt;br /&gt;
&lt;br /&gt;
In teams_users table, we can add a new column '''participant_id''' which is a foreign key from participants table and remove the column '''user_id'''. We plan to remove the '''user_id''' column '''only after data migration''' since the user_id field is used predominantly in several other controllers in a variety of ways, and as such its removal must be done carefully.&lt;br /&gt;
&lt;br /&gt;
The participant_id field in the the teams_users relation is computed as follows:&lt;br /&gt;
&lt;br /&gt;
* Finding Assignment ID By Team ID&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id but not the participant_id. Since the same user_id can be associated with multiple participant_ids (since the same user can participate in multiple assignments and gets a unique participant_id in each assignment they take part in), we need to get the user_ids in the assignment for which we need the particular user's participant_id. For this reason, we need to first find the assignment_id.&lt;br /&gt;
&lt;br /&gt;
* Finding Participant ID By Assignment ID and User ID&lt;br /&gt;
With the assignment_id retrieved, we can find the list of participant_ids that participated in the assignment, and using the user_id, get the participant_id which is saved in the participants table. &lt;br /&gt;
&lt;br /&gt;
=== ER diagram for updated schema ===&lt;br /&gt;
[[File:Updated_Proposed_ERR_for_student_teams_E2243.png |900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
==== Finding Assignment ID using Team ID ====&lt;br /&gt;
&lt;br /&gt;
Each team is associated with an assignment. The parent_id in teams table corresponds to assignment_id. Therefore, team_id in teams_users table can be used to get the Team object and in turn fetch the Assignment ID (present as parent_id in the teams table) &lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch assignment_id based on team_id&lt;br /&gt;
 assignment_id = Team.find(team_id).select(:parent_id)&lt;br /&gt;
&lt;br /&gt;
==== Finding Participant ID By Assignment ID and User ID ====&lt;br /&gt;
&lt;br /&gt;
The Assignment object can be fetched using the assignment ID. Each assignment contains a list of participants. The Participant object contains a user_id attribute. Since, a user can have only one entry in the Participants table for an assignment, we can use user_id to find the user's participant_id from this list.&lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch participant_id based on assignment_id and user_id&lt;br /&gt;
 participant_id = Assignment.find(assignment_id).participants.find_by(:user_id user_id)&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
''user_id'' exists as a foreign key in 2 relations - Participants and teams_users. Although they crrespond to same attribute, user_id alone cannot be used to find corresponding Participants because same user_id can exist for multiple Participants - due to Expertiza's design wherein for every assignment, every user is added to participant's table. Therefore Participant ID can be mapped to (assignment_id, user_id) pair.&lt;br /&gt;
&lt;br /&gt;
== View Changes and Refactoring ==&lt;br /&gt;
&lt;br /&gt;
One of the requirements in E2243 is the refactoring of the student teams view in views/student_teams/view.html.erb&lt;br /&gt;
&lt;br /&gt;
This view is quite cluttered and as a result, makes editing, understanding and extension difficult and tiresome for any future updates to the expertiza application. The code in this file can be modularized to obtain simpler and easier-to-understand, which is what we have achieved. The view was reafactored to incorporate partials, and some of the partials created as a result are:&lt;br /&gt;
&lt;br /&gt;
* _invited_people.html.erb : partial for displaying the invited participants to the assignment team&lt;br /&gt;
* _display_advertisements.html.erb : partial for displaying advertisements in the view&lt;br /&gt;
* _send_invitaions.html.erb : partial for the send invitations functionality&lt;br /&gt;
* _received_invitations.html.erb : partial to display the received invitations for the current user&lt;br /&gt;
&lt;br /&gt;
== Impacted Files ==&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller.rb (expertiza/app/controller/teams_user_controller.rb)&lt;br /&gt;
We will be adding code here to compute the participant_id using the methodologies described above.&lt;br /&gt;
&lt;br /&gt;
* teams_users.rb (expertiza/app/models/teams_user.rb)&lt;br /&gt;
The model will be updated (as can be seen in the ER diagram above) to have the participant_id added.&lt;br /&gt;
&lt;br /&gt;
* teams_users(expertiza/app/views/teams_users)&lt;br /&gt;
The view will be updated to reflect the new name of the model, and contain new partials that make use of the participant_id field.&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller_spec.rb(expertiza/spec/controllers/teams_users_controller_spec.rb)&lt;br /&gt;
The test file for the controller will be modified so that existing test cases pass the new changes, and also introduce new test cases to increase test coverage.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
The changes in teams_users means we need to re-examine the flows and user stories through where teams_users is used. This, in practice, means that we manually have checked the different ways in which a team for an assignment can be created in expertiza, and other associated operations such as removal of a user from a team, addition of a new user, deletion of a team etc. This testing was necessary to ensure that the functionality in expertiza still worked as expected even after our refactoring was completed. &lt;br /&gt;
&lt;br /&gt;
The main user stories we examined are:&lt;br /&gt;
&lt;br /&gt;
1. Student creates a team: A student, newly added to an assignment, opens the application and goes to &amp;quot;my team&amp;quot; after opening the assignment on expertiza. He enters his team's name and the team is created.&lt;br /&gt;
&lt;br /&gt;
[[File:Student_Creates_Team_SendInvite.png|600px]]&lt;br /&gt;
&lt;br /&gt;
2. Student joins a team: A student, is invited to join a team for an assignment, and accepts. He is added to an existing team, possibly created by another student or instructor.&lt;br /&gt;
&lt;br /&gt;
[[File:Student_Joins_Team_ReceivesInvite.png|600px]]&lt;br /&gt;
&lt;br /&gt;
3.  Instructor creates a team manually: An instructor who wishes to create a team with certain students on it, chooses the assignment on expertiza, and clicks on the icon to add a new team and in the manual section, creates a new team by giving a team name. They add students or participants to the newly created team and can remove them too.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_Teams_Instructors_Manually.png|600px]]&lt;br /&gt;
&lt;br /&gt;
4. Instructor creates teams automatically: An instructor wishes to assign all the students involved in an assignment randomly to teams of a certain size. They open expertiza, choose the assignment, and then click on the icon to add a new team, and in the &amp;quot;create teams automatically&amp;quot; section, enter the team size they wish to use. The system then creates teams of the specified size, adding students randomly to teams which is reflected in both student and instructor views.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_Teams_Instructors_Automatically.png|600px]]&lt;br /&gt;
&lt;br /&gt;
In addition to verifying team creation in all of the above scenarios, we also verified other operations such as addition of a team member after the team capacity was exhausted, deletion and re-addition of the same user, invitations to already existing participants in the same team etc and ensure the system was working as expected in these scenarios as well.&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing RSpec ===&lt;br /&gt;
Since this is a refactoring project, the scope of testing is limited to the changes made as part of refactoring and also to ensure that the existing test cases do not break or are modified accordingly.&lt;br /&gt;
In all the existing test cases in expertiza/spec/controllers/teams_users_controller_spec.rb :&lt;br /&gt;
&lt;br /&gt;
* ''object initialization''&lt;br /&gt;
* ''#update_duties''&lt;br /&gt;
* ''when user is added to assignment team''&lt;br /&gt;
* ''when user is added to assignment team''&lt;br /&gt;
* ''when user is added to course team''&lt;br /&gt;
* ''when user is already on an assignment team''&lt;br /&gt;
* ''when user is added to assignment team while on a team already'' &lt;br /&gt;
* ''when user is already on a course team'' &lt;br /&gt;
&lt;br /&gt;
the new methods which use both participant_id and user_id have been incorporated as needed to ensure continued quality of the testing suite and maintenance of code coverage.&lt;br /&gt;
&lt;br /&gt;
==== Fixed Test Files ====&lt;br /&gt;
&lt;br /&gt;
After our refactoring, we noticed failing tests in the below files, and we have worked on fixing these to work with the new and updated functionality. The main issues were involving tests using the old methods for creating a team, adding participants to the team etc. &lt;br /&gt;
&lt;br /&gt;
Models:&lt;br /&gt;
* spec/models/assignment_team_spec.rb&lt;br /&gt;
* spec/models/course_team_spec.rb&lt;br /&gt;
* spec/models/invitation_spec.rb&lt;br /&gt;
* spec/models/student_task_spec.rb&lt;br /&gt;
* spec/models/team_spec.rb&lt;br /&gt;
&lt;br /&gt;
Helper:&lt;br /&gt;
* spec/helpers/authorization_helper_spec.rb&lt;br /&gt;
* spec/helpers/grades_helper_spec.rb&lt;br /&gt;
* spec/helpers/sign_up_sheet_helper_spec.rb&lt;br /&gt;
&lt;br /&gt;
Controllers:&lt;br /&gt;
* spec/controllers/assessment360_controller_spec.rb&lt;br /&gt;
* spec/controllers/grades_controller_spec.rb&lt;br /&gt;
* spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
* spec/controllers/student_teams_controller_spec.rb&lt;br /&gt;
* spec/controllers/lottery_controller_spec.rb&lt;br /&gt;
* spec/controllers/sign_up_sheet_controller_spec.rb&lt;br /&gt;
* spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
* spec/controllers/teams_users_controller_spec.rb&lt;br /&gt;
* spec/controllers/invitations_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Ashok Kumar Selvam (aselvam@ncsu.edu)&lt;br /&gt;
# Sri Athithya Kruth Babu (sbabu@ncsu.edu)&lt;br /&gt;
# Subramanian Venkataraman (svenka25@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Naman Shrimali&lt;br /&gt;
&lt;br /&gt;
== Code Details == &lt;br /&gt;
Github Pull Request - https://github.com/expertiza/expertiza/pull/2391&lt;br /&gt;
&lt;br /&gt;
Repo - https://github.com/sak1997/expertiza/tree/beta&lt;br /&gt;
&lt;br /&gt;
Demo - https://drive.google.com/file/d/1RXINSdJYUv3Bd25epE8AP7vJgM6UXche/view (accessible only by users with ncsu.edu email address)&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Create_Teams_Instructors_Automatically.png&amp;diff=145349</id>
		<title>File:Create Teams Instructors Automatically.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Create_Teams_Instructors_Automatically.png&amp;diff=145349"/>
		<updated>2022-04-26T01:16:17Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Student_Joins_Team_ReceivesInvite.png&amp;diff=145347</id>
		<title>File:Student Joins Team ReceivesInvite.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Student_Joins_Team_ReceivesInvite.png&amp;diff=145347"/>
		<updated>2022-04-26T01:10:31Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Student_Creates_Team_SendInvite.png&amp;diff=145342</id>
		<title>File:Student Creates Team SendInvite.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Student_Creates_Team_SendInvite.png&amp;diff=145342"/>
		<updated>2022-04-26T01:00:20Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=145341</id>
		<title>CSC/ECE 517 Spring 2022 - E2243. Refactor student teams functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=145341"/>
		<updated>2022-04-26T00:57:30Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: /* Updated Code Details&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2243. Refactor student teams functionality which was a project in CSC517 Spring 2022. &lt;br /&gt;
&lt;br /&gt;
Please see below for a description of the design of the project.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
Users &amp;amp; Participants: Everyone who took the CSC517 OODD class at NC State is a user in Expertiza, and instructors can add users as participants in an assignment so that they can access it to contribute, make changes and submit their work to be graded.&lt;br /&gt;
&lt;br /&gt;
Almost all of the works within Assignments is done by participants, not users. All the tables use participant_id to track contributions to assignments, except teams_users. In the documentation, it can be noted that the team_users table references users instead of participants. This anomaly in the teams_users relation causes problems with how student teams are rendered in the UI, and it doesn’t mix well with the new functionality that was recently introduced. The participant_id field should be added to the model, and references that use user_id should also incorporate participant_id. Ideally, the application should use only participant_id, but to handle the existing data in the database without running a massive migration, the application should be able to handle both old records that use user_id and new ones that shall, from after this project is completed, use participant_id instead.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
===Changing the schema ===&lt;br /&gt;
* Create a column that would be called “participant_id”, which will be a foreign key that references the participants table.&lt;br /&gt;
* Use this participant_id field in all operations for teams going forward. There are a number of workflows involving teams we have examined and worked on, which are elaborated below.&lt;br /&gt;
* However, it is to be noted that this must also work with the existing functionality and data which makes use of user_id, so the code written must take both into account in its working.&lt;br /&gt;
&lt;br /&gt;
=== Refactoring the teams rendering (/views/student_teams/view.html.erb) ===&lt;br /&gt;
The logic in the team's view (where participants can see their team members) that iterates and fetches information of all the team members and displays them would be refactored as this view is quite bloated and has lots of functionalities written on it. We have made partials and placed those functionality in their specific partials.&lt;br /&gt;
&lt;br /&gt;
=== Other Changes ===&lt;br /&gt;
&lt;br /&gt;
Updated logic for all the CRUD functionalities in teams_users controller (wherever applicable).&lt;br /&gt;
&lt;br /&gt;
Fixed tests to incorporate the new logic as a result of using both user_id and participant_id in the teams_user logic.&lt;br /&gt;
&lt;br /&gt;
== Schema Changes ==&lt;br /&gt;
&lt;br /&gt;
In teams_users table, we can add a new column '''participant_id''' which is a foreign key from participants table and remove the column '''user_id'''. We plan to remove the '''user_id''' column '''only after data migration''' since the user_id field is used predominantly in several other controllers in a variety of ways, and as such its removal must be done carefully.&lt;br /&gt;
&lt;br /&gt;
The participant_id field in the the teams_users relation is computed as follows:&lt;br /&gt;
&lt;br /&gt;
* Finding Assignment ID By Team ID&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id but not the participant_id. Since the same user_id can be associated with multiple participant_ids (since the same user can participate in multiple assignments and gets a unique participant_id in each assignment they take part in), we need to get the user_ids in the assignment for which we need the particular user's participant_id. For this reason, we need to first find the assignment_id.&lt;br /&gt;
&lt;br /&gt;
* Finding Participant ID By Assignment ID and User ID&lt;br /&gt;
With the assignment_id retrieved, we can find the list of participant_ids that participated in the assignment, and using the user_id, get the participant_id which is saved in the participants table. &lt;br /&gt;
&lt;br /&gt;
=== ER diagram for updated schema ===&lt;br /&gt;
[[File:Updated_Proposed_ERR_for_student_teams_E2243.png |900px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
==== Finding Assignment ID using Team ID ====&lt;br /&gt;
&lt;br /&gt;
Each team is associated with an assignment. The parent_id in teams table corresponds to assignment_id. Therefore, team_id in teams_users table can be used to get the Team object and in turn fetch the Assignment ID (present as parent_id in the teams table) &lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch assignment_id based on team_id&lt;br /&gt;
 assignment_id = Team.find(team_id).select(:parent_id)&lt;br /&gt;
&lt;br /&gt;
==== Finding Participant ID By Assignment ID and User ID ====&lt;br /&gt;
&lt;br /&gt;
The Assignment object can be fetched using the assignment ID. Each assignment contains a list of participants. The Participant object contains a user_id attribute. Since, a user can have only one entry in the Participants table for an assignment, we can use user_id to find the user's participant_id from this list.&lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch participant_id based on assignment_id and user_id&lt;br /&gt;
 participant_id = Assignment.find(assignment_id).participants.find_by(:user_id user_id)&lt;br /&gt;
&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
''user_id'' exists as a foreign key in 2 relations - Participants and teams_users. Although they crrespond to same attribute, user_id alone cannot be used to find corresponding Participants because same user_id can exist for multiple Participants - due to Expertiza's design wherein for every assignment, every user is added to participant's table. Therefore Participant ID can be mapped to (assignment_id, user_id) pair.&lt;br /&gt;
&lt;br /&gt;
== View Changes and Refactoring ==&lt;br /&gt;
&lt;br /&gt;
One of the requirements in E2243 is the refactoring of the student teams view in views/student_teams/view.html.erb&lt;br /&gt;
&lt;br /&gt;
This view is quite cluttered and as a result, makes editing, understanding and extension difficult and tiresome for any future updates to the expertiza application. The code in this file can be modularized to obtain simpler and easier-to-understand, which is what we have achieved. The view was reafactored to incorporate partials, and some of the partials created as a result are:&lt;br /&gt;
&lt;br /&gt;
* _invited_people.html.erb : partial for displaying the invited participants to the assignment team&lt;br /&gt;
* _display_advertisements.html.erb : partial for displaying advertisements in the view&lt;br /&gt;
* _send_invitaions.html.erb : partial for the send invitations functionality&lt;br /&gt;
* _received_invitations.html.erb : partial to display the received invitations for the current user&lt;br /&gt;
&lt;br /&gt;
== Impacted Files ==&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller.rb (expertiza/app/controller/teams_user_controller.rb)&lt;br /&gt;
We will be adding code here to compute the participant_id using the methodologies described above.&lt;br /&gt;
&lt;br /&gt;
* teams_users.rb (expertiza/app/models/teams_user.rb)&lt;br /&gt;
The model will be updated (as can be seen in the ER diagram above) to have the participant_id added.&lt;br /&gt;
&lt;br /&gt;
* teams_users(expertiza/app/views/teams_users)&lt;br /&gt;
The view will be updated to reflect the new name of the model, and contain new partials that make use of the participant_id field.&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller_spec.rb(expertiza/spec/controllers/teams_users_controller_spec.rb)&lt;br /&gt;
The test file for the controller will be modified so that existing test cases pass the new changes, and also introduce new test cases to increase test coverage.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
&lt;br /&gt;
The changes in teams_users means we need to re-examine the flows and user stories through where teams_users is used. This, in practice, means that we manually have checked the different ways in which a team for an assignment can be created in expertiza, and other associated operations such as removal of a user from a team, addition of a new user, deletion of a team etc. This testing was necessary to ensure that the functionality in expertiza still worked as expected even after our refactoring was completed. &lt;br /&gt;
&lt;br /&gt;
The main user stories we examined are:&lt;br /&gt;
&lt;br /&gt;
# Student creates a team: A student, newly added to an assignment, opens the application and goes to &amp;quot;my team&amp;quot; after opening the assignment on expertiza. He enters his team's name and the team is created.&lt;br /&gt;
# Student joins a team: A student, is invited to join a team for an assignment, and accepts. He is added to an existing team, possibly created by another student or instructor.&lt;br /&gt;
# Instructor creates a team manually: An instructor who wishes to create a team with certain students on it, chooses the assignment on expertiza, and clicks on the icon to add a new team and in the manual section, creates a new team by giving a team name. They add students or participants to the newly created team and can remove them too.&lt;br /&gt;
[[File:Create_Teams_Instructors_Manually.png|900px]]&lt;br /&gt;
&lt;br /&gt;
# Instructor creates teams automatically: An instructor wishes to assign all the students involved in an assignment randomly to teams of a certain size. They open expertiza, choose the assignment, and then click on the icon to add a new team, and in the &amp;quot;create teams automatically&amp;quot; section, enter the team size they wish to use. The system then creates teams of the specified size, adding students randomly to teams which is reflected in both student and instructor views.&lt;br /&gt;
&lt;br /&gt;
In addition to verifying team creation in all of the above scenarios, we also verified other operations such as addition of a team member after the team capacity was exhausted, deletion and re-addition of the same user, invitations to already existing participants in the same team etc and ensure the system was working as expected in these scenarios as well.&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing RSpec ===&lt;br /&gt;
Since this is a refactoring project, the scope of testing is limited to the changes made as part of refactoring and also to ensure that the existing test cases do not break or are modified accordingly.&lt;br /&gt;
In all the existing test cases in expertiza/spec/controllers/teams_users_controller_spec.rb :&lt;br /&gt;
&lt;br /&gt;
* ''object initialization''&lt;br /&gt;
* ''#update_duties''&lt;br /&gt;
* ''when user is added to assignment team''&lt;br /&gt;
* ''when user is added to assignment team''&lt;br /&gt;
* ''when user is added to course team''&lt;br /&gt;
* ''when user is already on an assignment team''&lt;br /&gt;
* ''when user is added to assignment team while on a team already'' &lt;br /&gt;
* ''when user is already on a course team'' &lt;br /&gt;
&lt;br /&gt;
the new methods which use both participant_id and user_id have been incorporated as needed to ensure continued quality of the testing suite and maintenance of code coverage.&lt;br /&gt;
&lt;br /&gt;
==== Fixed Test Files ====&lt;br /&gt;
&lt;br /&gt;
After our refactoring, we noticed failing tests in the below files, and we have worked on fixing these to work with the new and updated functionality. The main issues were involving tests using the old methods for creating a team, adding participants to the team etc. &lt;br /&gt;
&lt;br /&gt;
Models:&lt;br /&gt;
* spec/models/assignment_team_spec.rb&lt;br /&gt;
* spec/models/course_team_spec.rb&lt;br /&gt;
* spec/models/invitation_spec.rb&lt;br /&gt;
* spec/models/student_task_spec.rb&lt;br /&gt;
* spec/models/team_spec.rb&lt;br /&gt;
&lt;br /&gt;
Helper:&lt;br /&gt;
* spec/helpers/authorization_helper_spec.rb&lt;br /&gt;
* spec/helpers/grades_helper_spec.rb&lt;br /&gt;
* spec/helpers/sign_up_sheet_helper_spec.rb&lt;br /&gt;
&lt;br /&gt;
Controllers:&lt;br /&gt;
* spec/controllers/assessment360_controller_spec.rb&lt;br /&gt;
* spec/controllers/grades_controller_spec.rb&lt;br /&gt;
* spec/controllers/join_team_request_controller_spec.rb&lt;br /&gt;
* spec/controllers/student_teams_controller_spec.rb&lt;br /&gt;
* spec/controllers/lottery_controller_spec.rb&lt;br /&gt;
* spec/controllers/sign_up_sheet_controller_spec.rb&lt;br /&gt;
* spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
* spec/controllers/teams_users_controller_spec.rb&lt;br /&gt;
* spec/controllers/invitations_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Ashok Kumar Selvam (aselvam@ncsu.edu)&lt;br /&gt;
# Sri Athithya Kruth Babu (sbabu@ncsu.edu)&lt;br /&gt;
# Subramanian Venkataraman (svenka25@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
Mentor: Naman Shrimali&lt;br /&gt;
&lt;br /&gt;
== Code Details == &lt;br /&gt;
Github Pull Request - https://github.com/expertiza/expertiza/pull/2391&lt;br /&gt;
&lt;br /&gt;
Repo - https://github.com/sak1997/expertiza/tree/beta&lt;br /&gt;
&lt;br /&gt;
Demo - https://drive.google.com/file/d/1RXINSdJYUv3Bd25epE8AP7vJgM6UXche/view (accessible only by users with ncsu.edu email address)&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Create_Teams_Instructors_Manually.png&amp;diff=145332</id>
		<title>File:Create Teams Instructors Manually.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Create_Teams_Instructors_Manually.png&amp;diff=145332"/>
		<updated>2022-04-26T00:39:02Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=144997</id>
		<title>CSC/ECE 517 Spring 2022 - E2243. Refactor student teams functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=144997"/>
		<updated>2022-04-12T04:14:55Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: Final update with Test Plan and Team Members&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2243. Refactor student teams functionality which was a project in CSC517 Spring 2022. &lt;br /&gt;
&lt;br /&gt;
Please see below for a description of the design of the project.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
Users &amp;amp; Participants: Everyone who took the CSC517 OODD class at NC State is a user in Expertiza, and instructors can add users as participants in an assignment so that they can access it to contribute, make changes and submit their work to be graded.&lt;br /&gt;
&lt;br /&gt;
Almost all of the works within Assignments is done by participants, not users. All the tables use participant_id to track contributions to assignments, except teams_users. In the documentation, it can be noted that the team_users table references users instead of participants. This anomaly in the teams_users relation causes problems with how student teams are rendered in the UI, and it doesn’t mix well with the new functionality that was recently introduced.&lt;br /&gt;
&lt;br /&gt;
As given in the specifications for the project, the name of the table &amp;quot;teams_users&amp;quot; should be changed to &amp;quot;teams_participants&amp;quot;. The participant_id field should be added to the model, and references that use user_id should also incorporate participant_id.&lt;br /&gt;
&lt;br /&gt;
== Given Requirements ==&lt;br /&gt;
&lt;br /&gt;
===Changing the schema ===&lt;br /&gt;
* We need to rename the table table teams_users to teams_participants.&lt;br /&gt;
* Create a column that would be called “participant_id”, which will be a foreign key that references the participants table.&lt;br /&gt;
* Create a migration that fetches the assignment_id for each tuple from the teams table. We would find the participant with the help of the assignment_id we just got from the teams table and the user_id that is already present in the current table, and store its “id” in the participant_id column we created in the last step.&lt;br /&gt;
&lt;br /&gt;
=== Refactoring the teams rendering (/views/student_teams/view.html.erb) ===&lt;br /&gt;
The logic in the team's view (where participants can see their team members) that iterates and fetches information of all the team members and displays them would be refactored so that it matches our new design. &lt;br /&gt;
The view is quite bloated and has lots of functionalities written on it. We’ll be making partials and placing those functionality in their specific partials.&lt;br /&gt;
&lt;br /&gt;
=== Other Changes ===&lt;br /&gt;
&lt;br /&gt;
Update logic for all the crud functionalities in teams_users controller (wherever applicable).&lt;br /&gt;
Rename the teams_users_controller to teams_participants_controller (and all its references)&lt;br /&gt;
&lt;br /&gt;
== Schema Changes ==&lt;br /&gt;
&lt;br /&gt;
In teams_users table, we can add a new column '''participant_id''' which is a foreign key from participants table and remove the column '''user_id'''. We plan to remove the '''user_id''' column '''only after data migration''' since the user_id field is used predominantly in several other controllers in a variety of ways, and as such its removal must be done carefully.&lt;br /&gt;
&lt;br /&gt;
The participant_id field in the the teams_users relation is computed as follows:&lt;br /&gt;
&lt;br /&gt;
* Finding Assignment ID By Team ID&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id but not the participant_id. Since the same user_id can be associated with multiple participant_ids (since the same user can participate in multiple assignments and gets a unique participant_id in each assignment they take part in), we need to get the user_ids in the assignment for which we need the particular user's participant_id. For this reason, we need to first find the assignment_id.&lt;br /&gt;
&lt;br /&gt;
* Finding Participant ID By Assignment ID and User ID&lt;br /&gt;
With the assignment_id retrieved, we can find the list of participant_ids that participated in the assignment, and using the user_id, get the participant_id which is saved in the participants table. &lt;br /&gt;
&lt;br /&gt;
=== ER diagram for updated schema ===&lt;br /&gt;
[[File:Updated_Proposed_ERR_for_student_teams_E2243.png |900px]]&lt;br /&gt;
&lt;br /&gt;
== Data Migration ==&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
''user_id'' exists as a foreign key in 2 relations - Participants and teams_users. Although they crrespond to same attribute, user_id alone cannot be used to find corresponding Participants because same user_id can exist for multiple Participants - due to Expertiza's design wherein for every assignment, every user is added to participant's table. Therefore Participant ID can be mapped to (assignment_id, user_id) pair.&lt;br /&gt;
&lt;br /&gt;
== Proposed Implementation ==&lt;br /&gt;
&lt;br /&gt;
==== Finding Assignment ID using Team ID ====&lt;br /&gt;
&lt;br /&gt;
Each team is associated with an assignment. The parent_id in teams table corresponds to assignment_id. Therefore, team_id in teams_users table can be used to get the Team object and in turn fetch the Assignment ID (present as parent_id in the teams table) &lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch assignment_id based on team_id&lt;br /&gt;
 assignment_id = Team.find(team_id).select(:parent_id)&lt;br /&gt;
&lt;br /&gt;
==== Finding Participant ID By Assignment ID and User ID ====&lt;br /&gt;
&lt;br /&gt;
The Assignment object can be fetched using the assignment ID. Each assignment contains a list of participants. The Participant object contains a user_id attribute. Since, a user can have only one entry in the Participants table for an assignment, we can use user_id to find the user's participant_id from this list.&lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch participant_id based on assignment_id and user_id&lt;br /&gt;
 participant_id = Assignment.find(assignment_id).participants.find_by(:user_id user_id)&lt;br /&gt;
&lt;br /&gt;
=== Approach One ===&lt;br /&gt;
&lt;br /&gt;
The above mentioned code snippets can be used for each tuple in the teams_users table.&lt;br /&gt;
&lt;br /&gt;
 # Brute Force Code Snippet&lt;br /&gt;
 TeamsUser.all.each do |teamsUser|&lt;br /&gt;
     assignment_id = Team.find(teamsUser.team_id).select(:parent_id)&lt;br /&gt;
     participant_id = Assignment.find(assignment_id).participants.find_by(:user_id teamsUser.user_id)&lt;br /&gt;
     teamsUser.update_attribute(:participant_id, participant_id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Approach Two ===&lt;br /&gt;
In the brute force approach (Approach One), database calls are made multiple times inside the loop. Moving the database calls out of the loop will give us a more efficient solution.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
&lt;br /&gt;
# Load all the TeamUser objects.&lt;br /&gt;
# Load all the Team objects for all the team_ids in TeamUser object&lt;br /&gt;
# Create a map with team_id as key and assignment_id as value. The resultant map usage: map[team_id] = assignment_id&lt;br /&gt;
# Load all the Assignment objects for all the assignment_ids from the map in the previous step. Also eager fetch participants along with the assignments.&lt;br /&gt;
# Create a nested map with assignment_id and user_id as key and participant_id as value. The resultant map usage: map[assignment_id][user_id] = participant_id&lt;br /&gt;
# For all TeamUser objects, find the participant_id from the maps generated from the previous steps and update the participant_id attribute.&lt;br /&gt;
&lt;br /&gt;
==== View Changes ====&lt;br /&gt;
&lt;br /&gt;
The existing views in relation to this functionality would not need to undergo signification refactoring since we are only adding a new field and removing any of the existing ones. That being said, we will be adding new partials to achieve similar views using the participant_id field instead of the user_id field in the partials for future changes to the application as mentioned in the specifications.&lt;br /&gt;
&lt;br /&gt;
== Effects of code changes in the Expertiza Application ==&lt;br /&gt;
&lt;br /&gt;
While the renaming of the table to teams_participants has rippling effects throughout the program since multiple files contain calls to this class, It must be noted that not much else needs to change apart from the class name. In most cases, only the class name would be changed since we are primarily adding a new field(participant_id) and not removing any existing fields. &lt;br /&gt;
&lt;br /&gt;
In most use cases noted in the application for the teams_users class, the main use cases seen are computed the team_id from the user_id and assignment_id or manipulations on the users in a teams_user object - adding and removing a team members from a team, for instance.&lt;br /&gt;
&lt;br /&gt;
The changes we plan to make here will not cause a need for changes in other parts of the application apart from the replacement of the class name to teams_participants.&lt;br /&gt;
&lt;br /&gt;
== Impacted Files ==&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller.rb (expertiza/app/controller/teams_user_controller.rb)&lt;br /&gt;
We will be adding code here to compute the participant_id using the methodologies described above.&lt;br /&gt;
&lt;br /&gt;
* teams_users.rb (expertiza/app/models/teams_user.rb)&lt;br /&gt;
The model will be updated (as can be seen in the ER diagram above) to have the participant_id added.&lt;br /&gt;
&lt;br /&gt;
* teams_users(expertiza/app/views/teams_users)&lt;br /&gt;
The view will be updated to reflect the new name of the model, and contain new partials that make use of the participant_id field.&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller_spec.rb(expertiza/spec/controllers/teams_users_controller_spec.rb)&lt;br /&gt;
The test file for the controller will be modified so that existing test cases pass the new changes, and also introduce new test cases to increase test coverage.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
=== Manual Testing ===&lt;br /&gt;
There is limited scope for testing this feature manually, as the refactoring targets computing participant_id in the teams_users table. This will improve the performance, and will not be shown in the user's view.&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing RSpec ===&lt;br /&gt;
Since this is a refactoring project, the scope of testing is limited to the changes made as part of refactoring and also to ensure that the existing test cases do not break or are modified accordingly.As per our proposed design, we're working on adding participant_id computation, which will not be used on the views for the end user.&lt;br /&gt;
&lt;br /&gt;
In all the existing test cases in expertiza/spec/controllers/teams_users_controller_spec.rb -- ''object initialization'', ''#update_duties'', ''when user is added to assignment team'', ''when user is added to assignment team'', ''when user is added to course team'', ''when user is already on an assignment team'', ''when user is added to assignment team while on a team already'' and ''when user is already on a course team'' participant_id needs to be incorporated and modified. &lt;br /&gt;
&lt;br /&gt;
The team is also planning to add more test scenarios based on the implementation of the proposed solution to increase the test coverage.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
# Ashok Kumar Selvam (aselvam@ncsu.edu)&lt;br /&gt;
# Sri Athithya Kruth Babu (sbabu@ncsu.edu)&lt;br /&gt;
# Subramanian Venkataraman (svenka25@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=144993</id>
		<title>CSC/ECE 517 Spring 2022 - E2243. Refactor student teams functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=144993"/>
		<updated>2022-04-12T04:01:18Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: /* ER diagram for updated schema */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2243. Refactor student teams functionality which was a project in CSC517 Spring 2022. &lt;br /&gt;
&lt;br /&gt;
Please see below for a description of the design of the project.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
Users &amp;amp; Participants: Everyone who took the CSC517 OODD class at NC State is a user in Expertiza, and instructors can add users as participants in an assignment so that they can access it to contribute, make changes and submit their work to be graded.&lt;br /&gt;
&lt;br /&gt;
Almost all of the works within Assignments is done by participants, not users. All the tables use participant_id to track contributions to assignments, except teams_users. In the documentation, it can be noted that the team_users table references users instead of participants. This anomaly in the teams_users relation causes problems with how student teams are rendered in the UI, and it doesn’t mix well with the new functionality that was recently introduced.&lt;br /&gt;
&lt;br /&gt;
As given in the specifications for the project, the name of the table &amp;quot;teams_users&amp;quot; should be changed to &amp;quot;teams_participants&amp;quot;. The participant_id field should be added to the model, and references that use user_id should also incorporate participant_id.&lt;br /&gt;
&lt;br /&gt;
== Given Requirements ==&lt;br /&gt;
&lt;br /&gt;
===Changing the schema ===&lt;br /&gt;
* We need to rename the table table teams_users to teams_participants.&lt;br /&gt;
* Create a column that would be called “participant_id”, which will be a foreign key that references the participants table.&lt;br /&gt;
* Create a migration that fetches the assignment_id for each tuple from the teams table. We would find the participant with the help of the assignment_id we just got from the teams table and the user_id that is already present in the current table, and store its “id” in the participant_id column we created in the last step.&lt;br /&gt;
&lt;br /&gt;
=== Refactoring the teams rendering (/views/student_teams/view.html.erb) ===&lt;br /&gt;
The logic in the team's view (where participants can see their team members) that iterates and fetches information of all the team members and displays them would be refactored so that it matches our new design. &lt;br /&gt;
The view is quite bloated and has lots of functionalities written on it. We’ll be making partials and placing those functionality in their specific partials.&lt;br /&gt;
&lt;br /&gt;
=== Other Changes ===&lt;br /&gt;
&lt;br /&gt;
Update logic for all the crud functionalities in teams_users controller (wherever applicable).&lt;br /&gt;
Rename the teams_users_controller to teams_participants_controller (and all its references)&lt;br /&gt;
&lt;br /&gt;
== Schema Changes ==&lt;br /&gt;
&lt;br /&gt;
In teams_users table, we can add a new column '''participant_id''' which is a foreign key from participants table and remove the column '''user_id'''. We plan to remove the '''user_id''' column '''only after data migration''' since the user_id field is used predominantly in several other controllers in a variety of ways, and as such its removal must be done carefully.&lt;br /&gt;
&lt;br /&gt;
The participant_id field in the the teams_users relation is computed as follows:&lt;br /&gt;
&lt;br /&gt;
* Finding Assignment ID By Team ID&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id but not the participant_id. Since the same user_id can be associated with multiple participant_ids (since the same user can participate in multiple assignments and gets a unique participant_id in each assignment they take part in), we need to get the user_ids in the assignment for which we need the particular user's participant_id. For this reason, we need to first find the assignment_id.&lt;br /&gt;
&lt;br /&gt;
* Finding Participant ID By Assignment ID and User ID&lt;br /&gt;
With the assignment_id retrieved, we can find the list of participant_ids that participated in the assignment, and using the user_id, get the participant_id which is saved in the participants table. &lt;br /&gt;
&lt;br /&gt;
=== ER diagram for updated schema ===&lt;br /&gt;
[[File:Updated_Proposed_ERR_for_student_teams_E2243.png |900px]]&lt;br /&gt;
&lt;br /&gt;
== Data Migration ==&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
''user_id'' exists as a foreign key in 2 relations - Participants and teams_users. Although they crrespond to same attribute, user_id alone cannot be used to find corresponding Participants because same user_id can exist for multiple Participants - due to Expertiza's design wherein for every assignment, every user is added to participant's table. Therefore Participant ID can be mapped to (assignment_id, user_id) pair.&lt;br /&gt;
&lt;br /&gt;
== Proposed Implementation ==&lt;br /&gt;
&lt;br /&gt;
==== Finding Assignment ID using Team ID ====&lt;br /&gt;
&lt;br /&gt;
Each team is associated with an assignment. The parent_id in teams table corresponds to assignment_id. Therefore, team_id in teams_users table can be used to get the Team object and in turn fetch the Assignment ID (present as parent_id in the teams table) &lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch assignment_id based on team_id&lt;br /&gt;
 assignment_id = Team.find(team_id).select(:parent_id)&lt;br /&gt;
&lt;br /&gt;
==== Finding Participant ID By Assignment ID and User ID ====&lt;br /&gt;
&lt;br /&gt;
The Assignment object can be fetched using the assignment ID. Each assignment contains a list of participants. The Participant object contains a user_id attribute. Since, a user can have only one entry in the Participants table for an assignment, we can use user_id to find the user's participant_id from this list.&lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch participant_id based on assignment_id and user_id&lt;br /&gt;
 participant_id = Assignment.find(assignment_id).participants.find_by(:user_id user_id)&lt;br /&gt;
&lt;br /&gt;
=== Approach One ===&lt;br /&gt;
&lt;br /&gt;
The above mentioned code snippets can be used for each tuple in the teams_users table.&lt;br /&gt;
&lt;br /&gt;
 # Brute Force Code Snippet&lt;br /&gt;
 TeamsUser.all.each do |teamsUser|&lt;br /&gt;
     assignment_id = Team.find(teamsUser.team_id).select(:parent_id)&lt;br /&gt;
     participant_id = Assignment.find(assignment_id).participants.find_by(:user_id teamsUser.user_id)&lt;br /&gt;
     teamsUser.update_attribute(:participant_id, participant_id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Approach Two ===&lt;br /&gt;
In the brute force approach (Approach One), database calls are made multiple times inside the loop. Moving the database calls out of the loop will give us a more efficient solution.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
&lt;br /&gt;
# Load all the TeamUser objects.&lt;br /&gt;
# Load all the Team objects for all the team_ids in TeamUser object&lt;br /&gt;
# Create a map with team_id as key and assignment_id as value. The resultant map usage: map[team_id] = assignment_id&lt;br /&gt;
# Load all the Assignment objects for all the assignment_ids from the map in the previous step. Also eager fetch participants along with the assignments.&lt;br /&gt;
# Create a nested map with assignment_id and user_id as key and participant_id as value. The resultant map usage: map[assignment_id][user_id] = participant_id&lt;br /&gt;
# For all TeamUser objects, find the participant_id from the maps generated from the previous steps and update the participant_id attribute.&lt;br /&gt;
&lt;br /&gt;
==== View Changes ====&lt;br /&gt;
&lt;br /&gt;
The existing views in relation to this functionality would not need to undergo signification refactoring since we are only adding a new field and removing any of the existing ones. That being said, we will be adding new partials to achieve similar views using the participant_id field instead of the user_id field in the partials for future changes to the application as mentioned in the specifications.&lt;br /&gt;
&lt;br /&gt;
== Effects of code changes in the Expertiza Application ==&lt;br /&gt;
&lt;br /&gt;
While the renaming of the table to teams_participants has rippling effects throughout the program since multiple files contain calls to this class, It must be noted that not much else needs to change apart from the class name. In most cases, only the class name would be changed since we are primarily adding a new field(participant_id) and not removing any existing fields. &lt;br /&gt;
&lt;br /&gt;
In most use cases noted in the application for the teams_users class, the main use cases seen are computed the team_id from the user_id and assignment_id or manipulations on the users in a teams_user object - adding and removing a team members from a team, for instance.&lt;br /&gt;
&lt;br /&gt;
The changes we plan to make here will not cause a need for changes in other parts of the application apart from the replacement of the class name to teams_participants.&lt;br /&gt;
&lt;br /&gt;
== Impacted Files ==&lt;br /&gt;
&lt;br /&gt;
* teams_users_controller.rb (expertiza/app/controller/teams_user_controller.rb)&lt;br /&gt;
We will be adding code here to compute the participant_id using the methodologies described above.&lt;br /&gt;
&lt;br /&gt;
* teams_users.rb (expertiza/app/models/teams_user.rb)&lt;br /&gt;
The model will be updated (as can be seen in the ER diagram above) to have the participant_id added.&lt;br /&gt;
&lt;br /&gt;
* teams_users(expertiza/app/views/teams_users)&lt;br /&gt;
The view will be updated to reflect the new name of the model, and contain new partials that make use of the participant_id field.&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Updated_Proposed_ERR_for_student_teams_E2243.png&amp;diff=144990</id>
		<title>File:Updated Proposed ERR for student teams E2243.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Updated_Proposed_ERR_for_student_teams_E2243.png&amp;diff=144990"/>
		<updated>2022-04-12T04:00:54Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=144507</id>
		<title>CSC/ECE 517 Spring 2022 - E2243. Refactor student teams functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=144507"/>
		<updated>2022-04-07T00:56:01Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: Final Edits for Proposed Implementation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2243. Refactor student teams functionality which was a project in CSC517 Spring 2022. &lt;br /&gt;
&lt;br /&gt;
Please see below for a description of the design of the project.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
Users &amp;amp; Participants: Everyone who took the CSC517 OODD class at NC State is a user in Expertiza, and instructors can add users as participants in an assignment so that they can access it to contribute, make changes and submit their work to be graded.&lt;br /&gt;
&lt;br /&gt;
Almost all of the works within Assignments is done by participants, not users. All the tables use participant_id to track contributions to assignments, except teams_users. In the documentation, it can be noted that the team_users table references users instead of participants. This anomaly in the teams_users relation causes problems with how student teams are rendered in the UI, and it doesn’t mix well with the new functionality that was recently introduced.&lt;br /&gt;
&lt;br /&gt;
teams_users should be changed to teams_participants. the team_id, user_id mapping in this table should be changed to team_id, participant_id. All the references of user_id should be updated to use participant_id.&lt;br /&gt;
&lt;br /&gt;
== Given Requirements ==&lt;br /&gt;
&lt;br /&gt;
===Changing the schema ===&lt;br /&gt;
* We need to rename the table table teams_users to teams_participants.&lt;br /&gt;
* Create a column that would be called “participant_id”, which will be a foreign key that references the participants table.&lt;br /&gt;
* Create a migration that fetches the assignment_id for each tuple from the teams table. We would find the participant with the help of the assignment_id we just got from the teams table and the user_id that is already present in the current table, and store its “id” in the participant_id column we created in the last step.&lt;br /&gt;
&lt;br /&gt;
=== Refactoring the teams rendering (/views/student_teams/view.html.erb) ===&lt;br /&gt;
The logic in the team's view (where participants can see their team members) that iterates and fetches information of all the team members and displays them would be refactored so that it matches our new design. &lt;br /&gt;
The view is quite bloated and has lots of functionalities written on it. We’ll be making partials and placing those functionality in their specific partials.&lt;br /&gt;
&lt;br /&gt;
=== Other Changes ===&lt;br /&gt;
&lt;br /&gt;
Update logic for all the crud functionalities in teams_users controller (wherever applicable).&lt;br /&gt;
Rename the teams_users_controller to teams_participants_controller (and all its references)&lt;br /&gt;
&lt;br /&gt;
== Schema Changes ==&lt;br /&gt;
&lt;br /&gt;
In teams_users table, we can add a new column '''participant_id''' which is a foreign key from participants table and remove the column '''user_id'''. We plan to remove the '''user_id''' column '''only after data migration''' since the user_id field is used predominantly in several other controllers in a variety of ways, and as such its removal must be done carefully.&lt;br /&gt;
&lt;br /&gt;
The participant_id field in the the teams_users relation is computed as follows:&lt;br /&gt;
&lt;br /&gt;
* Finding Assignment ID By Team ID&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id but not the participant_id. Since the same user_id can be associated with multiple participant_ids (since the same user can participate in multiple assignments and gets a unique participant_id in each assignment they take part in), we need to get the user_ids in the assignment for which we need the particular user's participant_id. For this reason, we need to first find the assignment_id.&lt;br /&gt;
&lt;br /&gt;
* Finding Participant ID By Assignment ID and User ID&lt;br /&gt;
With the assignment_id retrieved, we can find the list of participant_ids that participated in the assignment, and using the user_id, get the participant_id which is saved in the participants table. &lt;br /&gt;
&lt;br /&gt;
=== ER diagram for updated schema ===&lt;br /&gt;
[[File:Proposed_ERR_for_student_teams_E2243.png|900px]]&lt;br /&gt;
&lt;br /&gt;
== Data Migration ==&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
''user_id'' exists as a foreign key in 2 relations - Participants and teams_users. Although they ocrrespond to same attribute, it cannot be used to find corresponding Participants because same user_id can exist for multiple Participants - due to Expertiza's design wherein for every assignment, every user is added to participant's table. Therefore Participant ID can be mapped to (assignment_id, user_id) pair.&lt;br /&gt;
&lt;br /&gt;
== Proposed Implementation ==&lt;br /&gt;
&lt;br /&gt;
==== Finding Assignment ID using Team ID ====&lt;br /&gt;
&lt;br /&gt;
Each team is associated with an assignment. The parent_id in teams table corresponds to assignment_id. Therefore, team_id in teams_users table can be used to get the Team object and in turn fetch the Assignment ID (present as parent_id in the teams table) &lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch assignment_id based on team_id&lt;br /&gt;
 assignment_id = Team.find(team_id).select(:parent_id)&lt;br /&gt;
&lt;br /&gt;
==== Finding Participant ID By Assignment ID and User ID ====&lt;br /&gt;
&lt;br /&gt;
The Assignment object can be fetched using the assignment ID. Each assignment contains a list of participants. The Participant object contains a user_id attribute. Since, a user can have only one entry in the Participants table for an assignment, we can use user_id to find the user's participant_id from this list.&lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch participant_id based on assignment_id and user_id&lt;br /&gt;
 participant_id = Assignment.find(assignment_id).participants.find_by(:user_id user_id)&lt;br /&gt;
&lt;br /&gt;
=== Approach One ===&lt;br /&gt;
&lt;br /&gt;
The above mentioned code snippets can be used for each tuple in the teams_users table.&lt;br /&gt;
&lt;br /&gt;
 # Brute Force Code Snippet&lt;br /&gt;
 TeamsUser.all.each do |teamsUser|&lt;br /&gt;
     assignment_id = Team.find(teamsUser.team_id).select(:parent_id)&lt;br /&gt;
     participant_id = Assignment.find(assignment_id).participants.find_by(:user_id teamsUser.user_id)&lt;br /&gt;
     teamsUser.update_attribute(:participant_id, participant_id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Approach Two ===&lt;br /&gt;
In the brute force approach (Approach One), database calls are made multiple times inside the loop. Moving the database calls out of the loop will give us a more efficient solution.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
&lt;br /&gt;
# Load all the TeamUser objects.&lt;br /&gt;
# Load all the Team objects for all the team_ids in TeamUser object&lt;br /&gt;
# Create a map with team_id as key and assignment_id as value. The resultant map usage: map[team_id] = assignment_id&lt;br /&gt;
# Load all the Assignment objects for all the assignment_ids from the map in the previous step. Also eager fetch participants along with the assignments.&lt;br /&gt;
# Create a nested map with assignment_id and user_id as key and participant_id as value. The resultant map usage: map[assignment_id][user_id] = participant_id&lt;br /&gt;
# For all TeamUser objects, find the participant_id from the maps generated from the previous steps and update the participant_id attribute.&lt;br /&gt;
&lt;br /&gt;
=== Impacted Files ===&lt;br /&gt;
&lt;br /&gt;
# teams_users_controller.rb (expertiza/app/controller/teams_user_controller.rb)&lt;br /&gt;
# teams_users.rb (expertiza/app/models/teams_user.rb)&lt;br /&gt;
# teams_users(expertiza/app/views/teams_users)&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=144501</id>
		<title>CSC/ECE 517 Spring 2022 - E2243. Refactor student teams functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=144501"/>
		<updated>2022-04-07T00:28:46Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: Modifying Data Migration&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2243. Refactor student teams functionality which was a project in CSC517 Spring 2022. &lt;br /&gt;
&lt;br /&gt;
Please see below for a description of the design of the project.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
Users &amp;amp; Participants: Everyone who took the CSC517 OODD class at NC State is a user in Expertiza, and instructors can add users as participants in an assignment so that they can access it to contribute, make changes and submit their work to be graded.&lt;br /&gt;
&lt;br /&gt;
Almost all of the works within Assignments is done by participants, not users. All the tables use participant_id to track contributions to assignments, except teams_users. In the documentation, it can be noted that the team_users table references users instead of participants. This anomaly in the teams_users relation causes problems with how student teams are rendered in the UI, and it doesn’t mix well with the new functionality that was recently introduced.&lt;br /&gt;
&lt;br /&gt;
teams_users should be changed to teams_participants. the team_id, user_id mapping in this table should be changed to team_id, participant_id. All the references of user_id should be updated to use participant_id.&lt;br /&gt;
&lt;br /&gt;
== Given Requirements ==&lt;br /&gt;
&lt;br /&gt;
===Changing the schema ===&lt;br /&gt;
* We need to rename the table table teams_users to teams_participants.&lt;br /&gt;
* Create a column that would be called “participant_id”, which will be a foreign key that references the participants table.&lt;br /&gt;
* Create a migration that fetches the assignment_id for each tuple from the teams table. We would find the participant with the help of the assignment_id we just got from the teams table and the user_id that is already present in the current table, and store its “id” in the participant_id column we created in the last step.&lt;br /&gt;
* &amp;lt;s&amp;gt;Get rid of the user_id column.&amp;lt;/s&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactoring the teams rendering (/views/student_teams/view.html.erb) ===&lt;br /&gt;
The logic in the team's view (where participants can see their team members) that iterates and fetches information of all the team members and displays them would be refactored so that it matches our new design. &lt;br /&gt;
The view is quite bloated and has lots of functionalities written on it. We’ll be making partials and placing those functionality in their specific partials.&lt;br /&gt;
&lt;br /&gt;
=== Other Changes ===&lt;br /&gt;
&lt;br /&gt;
Update logic for all the crud functionalities in teams_users controller (wherever applicable).&lt;br /&gt;
Rename the teams_users_controller to teams_participants_controller (and all its references)&lt;br /&gt;
&lt;br /&gt;
== Schema Changes ==&lt;br /&gt;
&lt;br /&gt;
In teams_users table, we can add a new column '''participant_id''' which is a foreign key from participants table and remove the column '''user_id'''. We plan to remove the '''user_id''' column '''only after data migration''' since the user_id field is used predominantly in several other controllers in a variety of ways, and as such its removal must be done carefully.&lt;br /&gt;
&lt;br /&gt;
The participant_id field in the the teams_users relation is computed as follows:&lt;br /&gt;
&lt;br /&gt;
* Finding Assignment ID By Team ID&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id but not the participant_id. Since the same user_id can be associated with multiple participant_ids (since the same user can participate in multiple assignments and gets a unique participant_id in each assignment they take part in), we need to get the user_ids in the assignment for which we need the particular user's participant_id. For this reason, we need to first find the assignment_id.&lt;br /&gt;
&lt;br /&gt;
* Finding Participant ID By Assignment ID and User ID&lt;br /&gt;
With the assignment_id retrieved, we can find the list of participant_ids that participated in the assignment, and using the user_id, get the participant_id which is saved in the participants table. &lt;br /&gt;
&lt;br /&gt;
=== ER diagram for updated schema ===&lt;br /&gt;
[[File:Proposed_ERR_for_student_teams_E2243.png|900px]]&lt;br /&gt;
&lt;br /&gt;
== Data Migration ==&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
user_id exists as a foreign key in 2 relations - Participants and teams_users. Although they ocrrespond to same attribute, it cannot be used to find corresponding Participants because same user_id can exist for multiple Participants - due to Expertiza's design wherein for every assignment, every user is added to participant's table. Therefore Participant ID can be mapped to (assignment_id, user_id) pair.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;s&amp;gt;The Participants relation contains the user_id attribute which is a foreign key from users table. teams_users contains user_id which is also a foreign key from users table. Although the user_id field corresponds to same attribute, we cannot use this attribute alone to find the respective participant id because user_id is not a primary key in the participants table. i.e. same user_id can be associated with multiple participants. This is because in expertiza, all the users are stored in users table but, for each assignment, for each user, an entry is added in participants table. So, each user will have an entry in participants tables for all the assignments. &lt;br /&gt;
&lt;br /&gt;
An Assignment contains a list of participants (An Assignment has many Participants). Since a user can have only one entry in the participants table for each assignment, (assignment_id, user_id) pair will have only one participant id associated with it. &amp;lt;/s&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Proposed Implementation ==&lt;br /&gt;
&lt;br /&gt;
==== Finding Assignment ID using Team ID ====&lt;br /&gt;
&lt;br /&gt;
Each team is associated with an assignment. The parent_id in teams table corresponds to assignment_id. Therefore, team_id in teams_users table can be used to get the Team object and in turn fetch the Assignment ID (present as parent_id in the teams table) &lt;br /&gt;
&lt;br /&gt;
&amp;lt;s&amp;gt;The teams_users table contains team_id, user_id and duty_id. Each team is associated with an assignment. The parent_id attribute in the teams table corresponds to assignment id. So, team_id in the teams_users table can be used to get the Team object using which we can fetch the assignment ID (parent_id).&amp;lt;/s&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch assignment_id based on team_id&lt;br /&gt;
 assignment_id = Team.find(team_id).select(:parent_id)&lt;br /&gt;
&lt;br /&gt;
==== Finding Participant ID By Assignment ID and User ID ====&lt;br /&gt;
&lt;br /&gt;
The Assignment object can be fetched using the assignment ID. Each assignment contains a list of participants. The Participant object contains a user_id attribute. Since, a user can have only one entry in the Participants table for an assignment, we can use user_id to find the user's participant_id from this list.&lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch participant_id based on assignment_id and user_id&lt;br /&gt;
 participant_id = Assignment.find(assignment_id).participants.find_by(:user_id user_id)&lt;br /&gt;
&lt;br /&gt;
=== Approach One ===&lt;br /&gt;
&lt;br /&gt;
The above mentioned code snippets can be used for each tuple in the teams_users table.&lt;br /&gt;
&lt;br /&gt;
 # Brute Force Code Snippet&lt;br /&gt;
 TeamsUser.all.each do |teamsUser|&lt;br /&gt;
     assignment_id = Team.find(teamsUser.team_id).select(:parent_id)&lt;br /&gt;
     participant_id = Assignment.find(assignment_id).participants.find_by(:user_id teamsUser.user_id)&lt;br /&gt;
     teamsUser.update_attribute(:participant_id, participant_id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Approach Two ===&lt;br /&gt;
In the brute force approach (Approach One), database calls are made multiple times inside the loop. Moving the database calls out of the loop will give us a more efficient solution.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
&lt;br /&gt;
# Load all the TeamUser objects.&lt;br /&gt;
# Load all the Team objects for all the team_ids in TeamUser object&lt;br /&gt;
# Create a map with team_id as key and assignment_id as value. The resultant map usage: map[team_id] = assignment_id&lt;br /&gt;
# Load all the Assignment objects for all the assignment_ids from the map in the previous step. Also eager fetch participants along with the assignments.&lt;br /&gt;
# Create a nested map with assignment_id and user_id as key and participant_id as value. The resultant map usage: map[assignment_id][user_id] = participant_id&lt;br /&gt;
# For all TeamUser objects, find the participant_id from the maps generated from the previous steps and update the participant_id attribute.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;s&amp;gt;In this approach,  we make a total of 3 database calls which is considerably better than the previous brute-force approach.&amp;lt;/s&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Changes ==&lt;br /&gt;
&amp;lt;s&amp;gt;The user_id attribute is used in multiple places within the application. Since, the new schema changes do not include user_id attribute in teams_users table, all the references of user_id must be updated to use participant_id, which is its new equivalent instead.&amp;lt;/s&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Impacted Files ===&lt;br /&gt;
&lt;br /&gt;
# teams_users_controller&lt;br /&gt;
# suggestion_controller&lt;br /&gt;
# assessment360_controller&lt;br /&gt;
# grades_controller&lt;br /&gt;
# join_team_requests_controller&lt;br /&gt;
# review_mapping_controller&lt;br /&gt;
# student_teams_controller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;s&amp;gt; The respective test cases associated with these files must be fixed before fixing the code so that we can make sure that the proposed refactoring does not raise any new bugs.&amp;lt;/s&amp;gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=144496</id>
		<title>CSC/ECE 517 Spring 2022 - E2243. Refactor student teams functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=144496"/>
		<updated>2022-04-07T00:25:56Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: Edited Migration Analysis&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2243. Refactor student teams functionality which was a project in CSC517 Spring 2022. &lt;br /&gt;
&lt;br /&gt;
Please see below for a description of the design of the project.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
Users &amp;amp; Participants: Everyone who took the CSC517 OODD class at NC State is a user in Expertiza, and instructors can add users as participants in an assignment so that they can access it to contribute, make changes and submit their work to be graded.&lt;br /&gt;
&lt;br /&gt;
Almost all of the works within Assignments is done by participants, not users. All the tables use participant_id to track contributions to assignments, except teams_users. In the documentation, it can be noted that the team_users table references users instead of participants. This anomaly in the teams_users relation causes problems with how student teams are rendered in the UI, and it doesn’t mix well with the new functionality that was recently introduced.&lt;br /&gt;
&lt;br /&gt;
teams_users should be changed to teams_participants. the team_id, user_id mapping in this table should be changed to team_id, participant_id. All the references of user_id should be updated to use participant_id.&lt;br /&gt;
&lt;br /&gt;
== Given Requirements ==&lt;br /&gt;
&lt;br /&gt;
===Changing the schema ===&lt;br /&gt;
* We need to rename the table table teams_users to teams_participants.&lt;br /&gt;
* Create a column that would be called “participant_id”, which will be a foreign key that references the participants table.&lt;br /&gt;
* Create a migration that fetches the assignment_id for each tuple from the teams table. We would find the participant with the help of the assignment_id we just got from the teams table and the user_id that is already present in the current table, and store its “id” in the participant_id column we created in the last step.&lt;br /&gt;
* &amp;lt;s&amp;gt;Get rid of the user_id column.&amp;lt;/s&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactoring the teams rendering (/views/student_teams/view.html.erb) ===&lt;br /&gt;
The logic in the team's view (where participants can see their team members) that iterates and fetches information of all the team members and displays them would be refactored so that it matches our new design. &lt;br /&gt;
The view is quite bloated and has lots of functionalities written on it. We’ll be making partials and placing those functionality in their specific partials.&lt;br /&gt;
&lt;br /&gt;
=== Other Changes ===&lt;br /&gt;
&lt;br /&gt;
Update logic for all the crud functionalities in teams_users controller (wherever applicable).&lt;br /&gt;
Rename the teams_users_controller to teams_participants_controller (and all its references)&lt;br /&gt;
&lt;br /&gt;
== Schema Changes ==&lt;br /&gt;
&lt;br /&gt;
In teams_users table, we can add a new column '''participant_id''' which is a foreign key from participants table and remove the column '''user_id'''. We plan to remove the '''user_id''' column '''only after data migration''' since the user_id field is used predominantly in several other controllers in a variety of ways, and as such its removal must be done carefully.&lt;br /&gt;
&lt;br /&gt;
The participant_id field in the the teams_users relation is computed as follows:&lt;br /&gt;
&lt;br /&gt;
* Finding Assignment ID By Team ID&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id but not the participant_id. Since the same user_id can be associated with multiple participant_ids (since the same user can participate in multiple assignments and gets a unique participant_id in each assignment they take part in), we need to get the user_ids in the assignment for which we need the particular user's participant_id. For this reason, we need to first find the assignment_id.&lt;br /&gt;
&lt;br /&gt;
* Finding Participant ID By Assignment ID and User ID&lt;br /&gt;
With the assignment_id retrieved, we can find the list of participant_ids that participated in the assignment, and using the user_id, get the participant_id which is saved in the participants table. &lt;br /&gt;
&lt;br /&gt;
=== ER diagram for updated schema ===&lt;br /&gt;
[[File:Proposed_ERR_for_student_teams_E2243.png|900px]]&lt;br /&gt;
&lt;br /&gt;
== Data Migration ==&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
user_id exists as a foreign key in 2 relations - Participants and teams_users. Although they ocrrespond to same attribute, it cannot be used to find corresponding Participants because same user_id can exist for multiple Participants - due to Expertiza's design wherein for every assignment, every user is added to participant's table. Therefore Participant ID can be mapped to (assignment_id, user_id) pair.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;s&amp;gt;The Participants relation contains the user_id attribute which is a foreign key from users table. teams_users contains user_id which is also a foreign key from users table. Although the user_id field corresponds to same attribute, we cannot use this attribute alone to find the respective participant id because user_id is not a primary key in the participants table. i.e. same user_id can be associated with multiple participants. This is because in expertiza, all the users are stored in users table but, for each assignment, for each user, an entry is added in participants table. So, each user will have an entry in participants tables for all the assignments. &lt;br /&gt;
&lt;br /&gt;
An Assignment contains a list of participants (An Assignment has many Participants). Since a user can have only one entry in the participants table for each assignment, (assignment_id, user_id) pair will have only one participant id associated with it. &amp;lt;/s&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Proposed Implementation ==&lt;br /&gt;
&lt;br /&gt;
==== Finding Assignment ID using Team ID ====&lt;br /&gt;
&lt;br /&gt;
Each team is associated with an assignment. The parent_id in teams table corresponds to assignment_id. Therefore, team_id in teams_users table can be used to get the Team object and in turn fetch the Assignment ID (present as parent_id in the teams table) &lt;br /&gt;
&lt;br /&gt;
&amp;lt;s&amp;gt;The teams_users table contains team_id, user_id and duty_id. Each team is associated with an assignment. The parent_id attribute in the teams table corresponds to assignment id. So, team_id in the teams_users table can be used to get the Team object using which we can fetch the assignment ID (parent_id).&amp;lt;/s&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch assignment_id based on team_id&lt;br /&gt;
 assignment_id = Team.find(team_id).select(:parent_id)&lt;br /&gt;
&lt;br /&gt;
==== Finding Participant ID By Assignment ID and User ID ====&lt;br /&gt;
&lt;br /&gt;
The Assignment object can be fetched using the assignment ID. Each assignment contains a list of participants. The Participant object contains a user_id attribute. Since, a user can have only one entry in the Participants table for an assignment, we can use user_id to find the user's participant_id from this list.&lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch participant_id based on assignment_id and user_id&lt;br /&gt;
 participant_id = Assignment.find(assignment_id).participants.find_by(:user_id user_id)&lt;br /&gt;
&lt;br /&gt;
=== Brute Force Data Migration ===&lt;br /&gt;
&lt;br /&gt;
The above mentioned code snippets can be used for each tuple in the teams_users table.&lt;br /&gt;
&lt;br /&gt;
 # Brute Force Code Snippet&lt;br /&gt;
 TeamsUser.all.each do |teamsUser|&lt;br /&gt;
     assignment_id = Team.find(teamsUser.team_id).select(:parent_id)&lt;br /&gt;
     participant_id = Assignment.find(assignment_id).participants.find_by(:user_id teamsUser.user_id)&lt;br /&gt;
     teamsUser.update_attribute(:participant_id, participant_id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Efficient Data Migration ===&lt;br /&gt;
In the brute force approach, database calls are made multiple times inside the loop. Moving the database calls out of the loop will give us a more efficient solution.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
&lt;br /&gt;
# Load all the TeamUser objects.&lt;br /&gt;
# Load all the Team objects for all the team_ids in TeamUser object&lt;br /&gt;
# Create a map with team_id as key and assignment_id as value. The resultant map usage: map[team_id] = assignment_id&lt;br /&gt;
# Load all the Assignment objects for all the assignment_ids from the map in the previous step. Also eager fetch participants along with the assignments.&lt;br /&gt;
# Create a nested map with assignment_id and user_id as key and participant_id as value. The resultant map usage: map[assignment_id][user_id] = participant_id&lt;br /&gt;
# For all TeamUser objects, find the participant_id from the maps generated from the previous steps and update the participant_id attribute.&lt;br /&gt;
&lt;br /&gt;
In this approach,  we make a total of 3 database calls which is considerably better than the previous brute-force approach.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Changes ==&lt;br /&gt;
&amp;lt;s&amp;gt;The user_id attribute is used in multiple places within the application. Since, the new schema changes do not include user_id attribute in teams_users table, all the references of user_id must be updated to use participant_id, which is its new equivalent instead.&amp;lt;/s&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Impacted Files ===&lt;br /&gt;
&lt;br /&gt;
# teams_users_controller&lt;br /&gt;
# suggestion_controller&lt;br /&gt;
# assessment360_controller&lt;br /&gt;
# grades_controller&lt;br /&gt;
# join_team_requests_controller&lt;br /&gt;
# review_mapping_controller&lt;br /&gt;
# student_teams_controller&lt;br /&gt;
&lt;br /&gt;
&amp;lt;s&amp;gt; The respective test cases associated with these files must be fixed before fixing the code so that we can make sure that the proposed refactoring does not raise any new bugs.&amp;lt;/s&amp;gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=144307</id>
		<title>CSC/ECE 517 Spring 2022 - E2243. Refactor student teams functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=144307"/>
		<updated>2022-04-06T16:04:05Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: Added Proposed Implementation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2243. Refactor student teams functionality which was a project in CSC517 Spring 2022. &lt;br /&gt;
&lt;br /&gt;
Please see below for a description of the design of the project.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
Users &amp;amp; Participants: Everyone who took the CSC517 OODD class at NC State is a user in Expertiza, and instructors can add users as participants in an assignment so that they can access it to contribute, make changes and submit their work to be graded.&lt;br /&gt;
&lt;br /&gt;
Almost all of the works within Assignments is done by participants, not users. All the tables use participant_id to track contributions to assignments, except teams_users. In the documentation, it can be noted that the team_users table references users instead of participants. This anomaly in the teams_users relation causes problems with how student teams are rendered in the UI, and it doesn’t mix well with the new functionality that was recently introduced.&lt;br /&gt;
&lt;br /&gt;
teams_users should be changed to teams_participants. the team_id, user_id mapping in this table should be changed to team_id, participant_id. All the references of user_id should be updated to use participant_id.&lt;br /&gt;
&lt;br /&gt;
== Given Requirements ==&lt;br /&gt;
&lt;br /&gt;
===Changing the schema ===&lt;br /&gt;
* We need to rename the table table teams_users to teams_participants.&lt;br /&gt;
* Create a column that would be called “participant_id”, which will be a foreign key that references the participants table.&lt;br /&gt;
* Create a migration that fetches the assignment_id for each tuple from the teams table. We would find the participant with the help of the assignment_id we just got from the teams table and the user_id that is already present in the current table, and store its “id” in the participant_id column we created in the last step.&lt;br /&gt;
* &amp;lt;s&amp;gt;Get rid of the user_id column.&amp;lt;/s&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactoring the teams rendering (/views/student_teams/view.html.erb) ===&lt;br /&gt;
The logic in the team's view (where participants can see their team members) that iterates and fetches information of all the team members and displays them would be refactored so that it matches our new design. &lt;br /&gt;
The view is quite bloated and has lots of functionalities written on it. We’ll be making partials and placing those functionality in their specific partials.&lt;br /&gt;
&lt;br /&gt;
=== Other Changes ===&lt;br /&gt;
&lt;br /&gt;
Update logic for all the crud functionalities in teams_users controller (wherever applicable).&lt;br /&gt;
Rename the teams_users_controller to teams_participants_controller (and all its references)&lt;br /&gt;
&lt;br /&gt;
== Schema Changes ==&lt;br /&gt;
&lt;br /&gt;
In teams_users table, we can add a new column '''participant_id''' which is a foreign key from participants table and remove the column '''user_id'''. We plan to remove the '''user_id''' column '''only after data migration''' since the user_id field is used predominantly in several other controllers in a variety of ways, and as such its removal must be done carefully.&lt;br /&gt;
&lt;br /&gt;
The participant_id field in the the teams_users relation is computed as follows:&lt;br /&gt;
&lt;br /&gt;
* Finding Assignment ID By Team ID&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id but not the participant_id. Since the same user_id can be associated with multiple participant_ids (since the same user can participate in multiple assignments and gets a unique participant_id in each assignment they take part in), we need to get the user_ids in the assignment for which we need the particular user's participant_id. For this reason, we need to first find the assignment_id.&lt;br /&gt;
&lt;br /&gt;
* Finding Participant ID By Assignment ID and User ID&lt;br /&gt;
With the assignment_id retrieved, we can find the list of participant_ids that participated in the assignment, and using the user_id, get the participant_id which is saved in the participants table. &lt;br /&gt;
&lt;br /&gt;
=== ER diagram for updated schema ===&lt;br /&gt;
[[File:Proposed_ERR_for_student_teams_E2243.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Data Migration ==&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The Participants relation contains the user_id attribute which is a foreign key from users table. teams_users contains user_id which is also a foreign key from users table. Although the user_id field corresponds to same attribute, we cannot use this attribute alone to find the respective participant id because user_id is not a primary key in the participants table. i.e. same user_id can be associated with multiple participants. This is because in expertiza, all the users are stored in users table but, for each assignment, for each user, an entry is added in participants table. So, each user will have an entry in participants tables for all the assignments. &lt;br /&gt;
&lt;br /&gt;
An Assignment contains a list of participants (An Assignment has many Participants). Since a user can have only one entry in the participants table for each assignment, (assignment_id, user_id) pair will have only one participant id associated with it. &lt;br /&gt;
&lt;br /&gt;
== Proposed Implementation ==&lt;br /&gt;
&lt;br /&gt;
==== Finding Assignment ID By Team ID ====&lt;br /&gt;
&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id. Each team is associated with an assignment. The parent_id attribute in the teams table corresponds to assignment id. So, team_id in the teams_users table can be used to get the Team object using which we can fetch the assignment ID (parent_id).&lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch assignment_id based on team_id&lt;br /&gt;
 assignment_id = Team.find(team_id).select(:parent_id)&lt;br /&gt;
&lt;br /&gt;
==== Finding Participant ID By Assignment ID and User ID ====&lt;br /&gt;
&lt;br /&gt;
The Assignment object can be fetched using the assignment ID. Each assignment contains a list of participants. The Participant object contains a user_id attribute. Since, a user can have only one entry in the Participants table for an assignment, we can use user_id to find the user's participant_id from this list.&lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch participant_id based on assignment_id and user_id&lt;br /&gt;
 participant_id = Assignment.find(assignment_id).participants.find_by(:user_id user_id)&lt;br /&gt;
&lt;br /&gt;
=== Brute Force Data Migration ===&lt;br /&gt;
&lt;br /&gt;
The above mentioned code snippets can be used for each tuple in the teams_users table.&lt;br /&gt;
&lt;br /&gt;
 # Brute Force Code Snippet&lt;br /&gt;
 TeamsUser.all.each do |teamsUser|&lt;br /&gt;
     assignment_id = Team.find(teamsUser.team_id).select(:parent_id)&lt;br /&gt;
     participant_id = Assignment.find(assignment_id).participants.find_by(:user_id teamsUser.user_id)&lt;br /&gt;
     teamsUser.update_attribute(:participant_id, participant_id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Efficient Data Migration ===&lt;br /&gt;
In the brute force approach, database calls are made multiple times inside the loop. Moving the database calls out of the loop will give us a more efficient solution.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
&lt;br /&gt;
# Load all the TeamUser objects.&lt;br /&gt;
# Load all the Team objects for all the team_ids in TeamUser object&lt;br /&gt;
# Create a map with team_id as key and assignment_id as value. The resultant map usage: map[team_id] = assignment_id&lt;br /&gt;
# Load all the Assignment objects for all the assignment_ids from the map in the previous step. Also eager fetch participants along with the assignments.&lt;br /&gt;
# Create a nested map with assignment_id and user_id as key and participant_id as value. The resultant map usage: map[assignment_id][user_id] = participant_id&lt;br /&gt;
# For all TeamUser objects, find the participant_id from the maps generated from the previous steps and update the participant_id attribute.&lt;br /&gt;
&lt;br /&gt;
In this approach,  we make a total of 3 database calls which is considerably better than the previous brute-force approach.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Code Changes ==&lt;br /&gt;
The user_id attribute is used in multiple places within the application. Since, the new schema changes do not include user_id attribute in teams_users table, all the references of user_id must be updated to use participant_id, which is its new equivalent instead.&lt;br /&gt;
&lt;br /&gt;
=== Impacted Files ===&lt;br /&gt;
&lt;br /&gt;
# teams_users_controller&lt;br /&gt;
# suggestion_controller&lt;br /&gt;
# assessment360_controller&lt;br /&gt;
# grades_controller&lt;br /&gt;
# join_team_requests_controller&lt;br /&gt;
# review_mapping_controller&lt;br /&gt;
# student_teams_controller&lt;br /&gt;
&lt;br /&gt;
The respective test cases associated with these files must be fixed before fixing the code so that we can make sure that the proposed refactoring does not raise any new bugs.&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=144306</id>
		<title>CSC/ECE 517 Spring 2022 - E2243. Refactor student teams functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2243._Refactor_student_teams_functionality&amp;diff=144306"/>
		<updated>2022-04-06T16:01:11Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: Updating Implementation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2243. Refactor student teams functionality which was a project in CSC517 Spring 2022. &lt;br /&gt;
&lt;br /&gt;
Please see below for a description of the design of the project.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
Users &amp;amp; Participants: Everyone who took the CSC517 OODD class at NC State is a user in Expertiza, and instructors can add users as participants in an assignment so that they can access it to contribute, make changes and submit their work to be graded.&lt;br /&gt;
&lt;br /&gt;
Almost all of the works within Assignments is done by participants, not users. All the tables use participant_id to track contributions to assignments, except teams_users. In the documentation, it can be noted that the team_users table references users instead of participants. This anomaly in the teams_users relation causes problems with how student teams are rendered in the UI, and it doesn’t mix well with the new functionality that was recently introduced.&lt;br /&gt;
&lt;br /&gt;
teams_users should be changed to teams_participants. the team_id, user_id mapping in this table should be changed to team_id, participant_id. All the references of user_id should be updated to use participant_id.&lt;br /&gt;
&lt;br /&gt;
== Given Requirements ==&lt;br /&gt;
&lt;br /&gt;
===Changing the schema ===&lt;br /&gt;
* We need to rename the table table teams_users to teams_participants.&lt;br /&gt;
* Create a column that would be called “participant_id”, which will be a foreign key that references the participants table.&lt;br /&gt;
* Create a migration that fetches the assignment_id for each tuple from the teams table. We would find the participant with the help of the assignment_id we just got from the teams table and the user_id that is already present in the current table, and store its “id” in the participant_id column we created in the last step.&lt;br /&gt;
* &amp;lt;s&amp;gt;Get rid of the user_id column.&amp;lt;/s&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Refactoring the teams rendering (/views/student_teams/view.html.erb) ===&lt;br /&gt;
The logic in the team's view (where participants can see their team members) that iterates and fetches information of all the team members and displays them would be refactored so that it matches our new design. &lt;br /&gt;
The view is quite bloated and has lots of functionalities written on it. We’ll be making partials and placing those functionality in their specific partials.&lt;br /&gt;
&lt;br /&gt;
=== Other Changes ===&lt;br /&gt;
&lt;br /&gt;
Update logic for all the crud functionalities in teams_users controller (wherever applicable).&lt;br /&gt;
Rename the teams_users_controller to teams_participants_controller (and all its references)&lt;br /&gt;
&lt;br /&gt;
== Schema Changes ==&lt;br /&gt;
&lt;br /&gt;
In teams_users table, we can add a new column '''participant_id''' which is a foreign key from participants table and remove the column '''user_id'''. We plan to remove the '''user_id''' column '''only after data migration''' since the user_id field is used predominantly in several other controllers in a variety of ways, and as such its removal must be done carefully.&lt;br /&gt;
&lt;br /&gt;
The participant_id field in the the teams_users relation is computed as follows:&lt;br /&gt;
&lt;br /&gt;
* Finding Assignment ID By Team ID&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id but not the participant_id. Since the same user_id can be associated with multiple participant_ids (since the same user can participate in multiple assignments and gets a unique participant_id in each assignment they take part in), we need to get the user_ids in the assignment for which we need the particular user's participant_id. For this reason, we need to first find the assignment_id.&lt;br /&gt;
&lt;br /&gt;
* Finding Participant ID By Assignment ID and User ID&lt;br /&gt;
With the assignment_id retrieved, we can find the list of participant_ids that participated in the assignment, and using the user_id, get the participant_id which is saved in the participants table. &lt;br /&gt;
&lt;br /&gt;
=== ER diagram for updated schema ===&lt;br /&gt;
[[File:Proposed_ERR_for_student_teams_E2243.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Data Migration ==&lt;br /&gt;
=== Analysis ===&lt;br /&gt;
&lt;br /&gt;
The Participants relation contains the user_id attribute which is a foreign key from users table. teams_users contains user_id which is also a foreign key from users table. Although the user_id field corresponds to same attribute, we cannot use this attribute alone to find the respective participant id because user_id is not a primary key in the participants table. i.e. same user_id can be associated with multiple participants. This is because in expertiza, all the users are stored in users table but, for each assignment, for each user, an entry is added in participants table. So, each user will have an entry in participants tables for all the assignments. &lt;br /&gt;
&lt;br /&gt;
An Assignment contains a list of participants (An Assignment has many Participants). Since a user can have only one entry in the participants table for each assignment, (assignment_id, user_id) pair will have only one participant id associated with it. &lt;br /&gt;
&lt;br /&gt;
==== Finding Assignment ID By Team ID ====&lt;br /&gt;
&lt;br /&gt;
The teams_users table contains team_id, user_id and duty_id. Each team is associated with an assignment. The parent_id attribute in the teams table corresponds to assignment id. So, team_id in the teams_users table can be used to get the Team object using which we can fetch the assignment ID (parent_id).&lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch assignment_id based on team_id&lt;br /&gt;
 assignment_id = Team.find(team_id).select(:parent_id)&lt;br /&gt;
&lt;br /&gt;
==== Finding Participant ID By Assignment ID and User ID ====&lt;br /&gt;
&lt;br /&gt;
The Assignment object can be fetched using the assignment ID. Each assignment contains a list of participants. The Participant object contains a user_id attribute. Since, a user can have only one entry in the Participants table for an assignment, we can use user_id to find the user's participant_id from this list.&lt;br /&gt;
&lt;br /&gt;
 # Code snippet to fetch participant_id based on assignment_id and user_id&lt;br /&gt;
 participant_id = Assignment.find(assignment_id).participants.find_by(:user_id user_id)&lt;br /&gt;
&lt;br /&gt;
=== Brute Force Data Migration ===&lt;br /&gt;
&lt;br /&gt;
The above mentioned code snippets can be used for each tuple in the teams_users table.&lt;br /&gt;
&lt;br /&gt;
 # Brute Force Code Snippet&lt;br /&gt;
 TeamsUser.all.each do |teamsUser|&lt;br /&gt;
     assignment_id = Team.find(teamsUser.team_id).select(:parent_id)&lt;br /&gt;
     participant_id = Assignment.find(assignment_id).participants.find_by(:user_id teamsUser.user_id)&lt;br /&gt;
     teamsUser.update_attribute(:participant_id, participant_id)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Efficient Data Migration ===&lt;br /&gt;
In the brute force approach, database calls are made multiple times inside the loop. Moving the database calls out of the loop will give us a more efficient solution.&lt;br /&gt;
&lt;br /&gt;
Steps:&lt;br /&gt;
&lt;br /&gt;
# Load all the TeamUser objects.&lt;br /&gt;
# Load all the Team objects for all the team_ids in TeamUser object&lt;br /&gt;
# Create a map with team_id as key and assignment_id as value. The resultant map usage: map[team_id] = assignment_id&lt;br /&gt;
# Load all the Assignment objects for all the assignment_ids from the map in the previous step. Also eager fetch participants along with the assignments.&lt;br /&gt;
# Create a nested map with assignment_id and user_id as key and participant_id as value. The resultant map usage: map[assignment_id][user_id] = participant_id&lt;br /&gt;
# For all TeamUser objects, find the participant_id from the maps generated from the previous steps and update the participant_id attribute.&lt;br /&gt;
&lt;br /&gt;
In this approach,  we make a total of 3 database calls which is considerably better than the previous brute-force approach.&lt;br /&gt;
&lt;br /&gt;
== Code Changes ==&lt;br /&gt;
The user_id attribute is used in multiple places within the application. Since, the new schema changes do not include user_id attribute in teams_users table, all the references of user_id must be updated to use participant_id, which is its new equivalent instead.&lt;br /&gt;
&lt;br /&gt;
=== Impacted Files ===&lt;br /&gt;
&lt;br /&gt;
# teams_users_controller&lt;br /&gt;
# suggestion_controller&lt;br /&gt;
# assessment360_controller&lt;br /&gt;
# grades_controller&lt;br /&gt;
# join_team_requests_controller&lt;br /&gt;
# review_mapping_controller&lt;br /&gt;
# student_teams_controller&lt;br /&gt;
&lt;br /&gt;
The respective test cases associated with these files must be fixed before fixing the code so that we can make sure that the proposed refactoring does not raise any new bugs.&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2219:_Improve_assessment360_controller.rb&amp;diff=143535</id>
		<title>CSC/ECE 517 Spring 2022 - E2219: Improve assessment360 controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2219:_Improve_assessment360_controller.rb&amp;diff=143535"/>
		<updated>2022-03-22T06:22:09Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: Final changes to the wiki page before submission deadline&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2219 Improve assessment360_controller.rb which was a project in CSC517 Spring 2022. Please see below for a description of the improvements made, issues fixed, code changed, testing information, details required to peer-review the project, and future improvements.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users who would like to view and test the assessment 360 feature, the deployed Expertiza application can be found at the URL mentioned below and can be access using the credentials below: &lt;br /&gt;
&lt;br /&gt;
URL: http://152.7.99.75:8080&lt;br /&gt;
&lt;br /&gt;
Instructor login: &lt;br /&gt;
&lt;br /&gt;
Username: '''instructor6'''&lt;br /&gt;
&lt;br /&gt;
Password: '''password'''&lt;br /&gt;
&lt;br /&gt;
Click on courses and then click on the icon on any one course to go to the assessment 360 page, or log in and paste this URL into the browser: http://152.7.99.75:8080/assessment360/index?course_id=184&lt;br /&gt;
The course ID here is an example, you can add the course ID of your choice.&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 Navigation.jpeg|800px]]&lt;br /&gt;
&lt;br /&gt;
Please note that due to VCL constraints, the page will take few mins to load and render the data. Please wait for the page to '''load completely''' before starting the peer review. &lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
The Expertiza project contains a feature that allows instructors to get a full or 360-degree view of a course they teach that includes all students in the course, all assignments, and the scores of each student in each assignment, averages, and final scores as well. This feature, called assessment 360, was written in a previous year, and due to issues identified with the code such as variable names, redundancy, code smells etc, a need for improvement of the same was identified. &lt;br /&gt;
&lt;br /&gt;
== Issues and Description of Fixes ==&lt;br /&gt;
In our work on improving this feature, we have handled the following issues and made the following improvements:&lt;br /&gt;
&lt;br /&gt;
=== Refactoring ===&lt;br /&gt;
&lt;br /&gt;
The previous implementation of the controller made a number of database calls, several of which were extraneous and not required. We have refactored the functions pertaining to these calls so that the number of unneeded calls to the database is reduced for loading teammate and metareviews. &lt;br /&gt;
&lt;br /&gt;
The older implementation of the computation for class averages, and students average scores incorrectly factored in students who had not received grades for an assignment or who had not taken part in an assignment. &lt;br /&gt;
In addition to correcting this, we also simplified the process by refactoring the code(please see the next section for the code).&lt;br /&gt;
&lt;br /&gt;
The past implementation of the controller was unclear and non-Rubyistic in naming conventions, function names, and implementation in the code. We have refactored the controller to make it more Rubyistic overall and also re-written parts of the code to make it more understandable, as well as more CRUD-like. Additionally, we made several methods whose functionality was required and used only inside this controller private.&lt;br /&gt;
&lt;br /&gt;
=== UI changes ===&lt;br /&gt;
The previous implementation had 2 views – all_students_all_reviews and course_student_grade_summary. Both of these views cover some of the data required for a 360-degree view of the course. &lt;br /&gt;
We have combined these pages together into a single page that contains checkboxes which allow the user to select what data they would like to view and shows only those columns they would like to see. This both simplifies and enhances the functioning of the feature.&lt;br /&gt;
&lt;br /&gt;
=== Variable Names, Cosmetic Issues, Comments ===&lt;br /&gt;
&lt;br /&gt;
In the older implementation, there were some unclear variable names such as teamed_count, and some other minor cosmetic issues such as a hyphen being displayed for empty fields where a dash would more visible and clearer. These have been fixed in both the code and the UI of the application to be user-friendly and developer friendly.&lt;br /&gt;
Additionally, comments have been added everywhere to make the code easier to understand and modify for future improvements.&lt;br /&gt;
&lt;br /&gt;
== Fix details and Code Explanation ==&lt;br /&gt;
&lt;br /&gt;
=== Files Changed ===&lt;br /&gt;
The following files were altered and edited in the course of our work on this feature:&lt;br /&gt;
Assessment360_Controller.rb (under app/controller)&lt;br /&gt;
This file contains the controller for the assessment 360 feature which we have improved in our work. The code has been refactored to be cleaner, modular,  easier to understand and also to incorporate DRY. &lt;br /&gt;
&lt;br /&gt;
Index.html.erb (under app/views/assessment360)&lt;br /&gt;
The view for the assessment 360 feature have been combined as stated in the requirements and all the data is now viewable from the index.html.erb page. This page also features checkboxes so the user can view only the data they are interested in without cluttering caused by unneeded data.&lt;br /&gt;
&lt;br /&gt;
=== Issue Fix Details ===&lt;br /&gt;
&lt;br /&gt;
1) '''app/controllers/assessment360_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 2.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 3.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
'''Code changes'''&lt;br /&gt;
&lt;br /&gt;
1. In all_student_all_reviews function, the DB calls are by creating init_data function.&lt;br /&gt;
&lt;br /&gt;
2. The init_data function, removes DB calls inside nested for-loops (look for old code, below) which makes db call for every iteration, the code has been refactored in such a way that it preloads the required data using assignments.includes([:participants]) (look for new code, below). This way, instead of making multiple db calls across diff functions, we load the required data and thereby reduce the processing time.&lt;br /&gt;
&lt;br /&gt;
3. The major change, which we've incorporated here is moving the functions which weren't used in other modules into private. Moving excess functions to private, helps keep the controller more CRUD-like and differentiates to the developer which functions are used by the controller to work, and which ones are the functions of the controller.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Old Code (with complex for loops and more db calls)'''&lt;br /&gt;
&lt;br /&gt;
 @course_participants.each do |cp|&lt;br /&gt;
      # for each assignment&lt;br /&gt;
      # [aggregrate_review_grades_per_stu, review_count_per_stu] --&amp;gt; [0, 0]&lt;br /&gt;
      %w[teammate meta].each { |type| instance_variable_set(&amp;quot;@#{type}_review_info_per_stu&amp;quot;, [0, 0]) }&lt;br /&gt;
      students_teamed = StudentTask.teamed_students(cp.user)&lt;br /&gt;
      @teamed_count[cp.id] = students_teamed[course.id].try(:size).to_i&lt;br /&gt;
      @assignments.each do |assignment|&lt;br /&gt;
        @meta_review[cp.id] = {} unless @meta_review.key?(cp.id)&lt;br /&gt;
        @teammate_review[cp.id] = {} unless @teammate_review.key?(cp.id)&lt;br /&gt;
        assignment_participant = assignment.participants.find_by(user_id: cp.user_id)&lt;br /&gt;
        next if assignment_participant.nil?&lt;br /&gt;
        teammate_reviews = assignment_participant.teammate_reviews&lt;br /&gt;
        meta_reviews = assignment_participant.metareviews&lt;br /&gt;
        calc_overall_review_info(assignment,&lt;br /&gt;
                                 cp,&lt;br /&gt;
                                 teammate_reviews,&lt;br /&gt;
                                 @teammate_review,&lt;br /&gt;
                                 @overall_teammate_review_grades,&lt;br /&gt;
                                 @overall_teammate_review_count,&lt;br /&gt;
                                 @teammate_review_info_per_stu)&lt;br /&gt;
        calc_overall_review_info(assignment,&lt;br /&gt;
                                 cp,&lt;br /&gt;
                                 meta_reviews,&lt;br /&gt;
                                 @meta_review,&lt;br /&gt;
                                 @overall_meta_review_grades,&lt;br /&gt;
                                 @overall_meta_review_count,&lt;br /&gt;
                                 @meta_review_info_per_stu)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Refactored Code (with limited iteration and db calls)'''&lt;br /&gt;
    @assignments.each do |assignment|&lt;br /&gt;
      assignment.participants.each do |assignment_participant|&lt;br /&gt;
        reviews[assignment_participant.user_id] = {} unless reviews.key?(assignment_participant.user_id)&lt;br /&gt;
        assignment_reviews = assignment_participant.public_send(reviews_type) if assignment_participant.respond_to? reviews_type&lt;br /&gt;
        # If a student has not taken an assignment or if they have not received any grade for the same,&lt;br /&gt;
        # assign it as nil(not returning anything). This helps in easier calculation of overall grade&lt;br /&gt;
        score = calc_avg_score(assignment_reviews)&lt;br /&gt;
        reviews[assignment_participant.user_id][assignment.id] = score unless score.nil?&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2) '''app/views/assessment360/index.html.erb'''&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 indexhtmlerb 1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 indexhtmlerb 2.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 indexhtmlerb 3.png|800px]]&lt;br /&gt;
&lt;br /&gt;
1. We've created a new file called ''index.html.erb''. This file contains all the logic for the frontend of this module.&lt;br /&gt;
&lt;br /&gt;
2. Major change that has been made is the addition of checkboxes. This way, users can filter the data that they view and view the data efficiently. &lt;br /&gt;
&lt;br /&gt;
3. This page loads all the assignment data, and their metadata like - meta reviews, teammate reviews, peer score, topic and instructor grade. The table also contains Aggregate score and Total grade.&lt;br /&gt;
&lt;br /&gt;
4. The checkboxes have been programmed in a way that whenever a checkbox is disabled, the corresponding column gets removed and the colspan rendering gets adjusted. Along with that, when all assignment parameters are unchecked, the assignment columns disappear completely. Same applies for aggregate score and Total Instructor Grade.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3) '''config/routes.rb'''&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 routes 1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Removed old route to this page and pointed it to the newly created index page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can check all the issues fixed here - https://github.com/expertiza/expertiza/pull/2337&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing using RSPEC ===&lt;br /&gt;
Please note that we have removed several older tests which tested functions that are now private and inaccessible outside the controller class itself. However, the methods that call these private functions are still tested and tests are passing successfully.&lt;br /&gt;
&lt;br /&gt;
1. After refactoring, most of our test cases focus on functions which are the core of the controller - covering important aspects like who accesses the page, checking permissions for the page, how the page behaves on edge cases etc.&lt;br /&gt;
&lt;br /&gt;
2. Using RSpec, the test cases cover various scenarios and tests each scenario in depth. &lt;br /&gt;
Eg, for access control, we check the access for all roles for a user comprehensively to ensure that only people with permissions can view the page. &lt;br /&gt;
&lt;br /&gt;
3. Since most of the work in this module is computations in the back and rendering data in the frontend, we've ensured that the computations happen in their specific order and enough test cases are present for edge cases. &lt;br /&gt;
&lt;br /&gt;
4. For backend computations, we've covered lot of edge cases like no participants to a course, when there are no reviews made by a participant, when assignment doesn't exists, insure existence_of being called before executing index page etc. &lt;br /&gt;
&lt;br /&gt;
5. For frontend, we've covered cases like formatting of the data in the page, null dataset, score being int, float, null, displaying percentages when data is int, float, null etc.&lt;br /&gt;
&lt;br /&gt;
Even though we've moved most of the code into private functions, the core functionalities of the controller are refactored and appropriate test cases are written to ensure high coverage. &lt;br /&gt;
&lt;br /&gt;
=== Testing from UI ===&lt;br /&gt;
The following steps needs to be performed to test this code from UI:&lt;br /&gt;
&lt;br /&gt;
1.	Login as instructor(username: instructor6 , password: password). Please either do step 2 or 3, as both are not required.&lt;br /&gt;
&lt;br /&gt;
2.	Select Courses, and the page will show a list of courses. Please select the rightmost icons for any course (we recommend CSC517 Fall 2017, CSC517 Fall 2011 so there’s more data, but it can take some time for it load since there’s a lot of pre-loaded data in the VCL)&lt;br /&gt;
&lt;br /&gt;
3.	Alternatively, you can login and go to this URL: &amp;lt;needs to be added&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4.	You should be able to see a webpage with a table and checkboxes at the top. This table is an instructor’s 360-degree view of a course, containing the scores of each students in the course for every assignment the instructor has added to Expertiza. &lt;br /&gt;
&lt;br /&gt;
5.	Unchecking some or all of the checkboxes removes and brings back various columns from/to the page. Please feel free to test this out.&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
The UI of the index page which shows all of the data can be improved to make it look neater and more aesthetically pleasing. The table’s positioning and centering can be improved for a more convenient experience overall.&lt;br /&gt;
&lt;br /&gt;
The user’s preferred (checked on the UI checkboxes) can be saved to either the Database or a cache, and on subsequent reloads be the fields loaded on the page for a particular. We suggest using the database for this rather than a cache. &lt;br /&gt;
&lt;br /&gt;
Lazy loading can be implemented for the columns the user last chose(assuming these are stored in the DB) and other columns can lazy-loaded if the user clicks on the checkboxes on the screen.&lt;br /&gt;
&lt;br /&gt;
'''''course_student_grade_summary''''' function inside the assessment360_controller.rb contains few unnecessary db calls which can be refactored further to increase the efficiency and reduce the processing time of the module.&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_indexhtmlerb_3.png&amp;diff=143534</id>
		<title>File:E2219 indexhtmlerb 3.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_indexhtmlerb_3.png&amp;diff=143534"/>
		<updated>2022-03-22T06:08:09Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_indexhtmlerb_2.png&amp;diff=143533</id>
		<title>File:E2219 indexhtmlerb 2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_indexhtmlerb_2.png&amp;diff=143533"/>
		<updated>2022-03-22T06:08:00Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2219:_Improve_assessment360_controller.rb&amp;diff=143529</id>
		<title>CSC/ECE 517 Spring 2022 - E2219: Improve assessment360 controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2219:_Improve_assessment360_controller.rb&amp;diff=143529"/>
		<updated>2022-03-22T04:06:54Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2219 Improve assessment360_controller.rb which was a project in CSC517 Spring 2022. Please see below for a description of the improvements made, issues fixed, code changed, testing information, details required to peer-review the project, and future improvements.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users who would like to view and test the assessment 360 feature, the deployed Expertiza application can be found at the URL mentioned below and can be access using the credentials below: &lt;br /&gt;
&lt;br /&gt;
URL: http://152.7.99.75:8080&lt;br /&gt;
&lt;br /&gt;
Instructor login: &lt;br /&gt;
&lt;br /&gt;
Username: '''instructor6'''&lt;br /&gt;
&lt;br /&gt;
Password: '''password'''&lt;br /&gt;
&lt;br /&gt;
Click on courses and then click on the icon on any one course to go to the assessment 360 page, or log in and paste this URL into the browser: http://152.7.99.75:8080/assessment360/index?course_id=184&lt;br /&gt;
The course ID here is an example, you can add the course ID of your choice.&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 Navigation.jpeg|800px]]&lt;br /&gt;
&lt;br /&gt;
Please note that due to VCL constraints, the page will take few mins to load and render the data. Please wait for the page to '''load completely''' before starting the peer review. &lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
The Expertiza project contains a feature that allows instructors to get a full or 360-degree view of a course they teach that includes all students in the course, all assignments, and the scores of each student in each assignment, averages, and final scores as well. This feature, called assessment 360, was written in a previous year, and due to issues identified with the code such as variable names, redundancy, code smells etc, a need for improvement of the same was identified. &lt;br /&gt;
&lt;br /&gt;
== Issues and Description of Fixes ==&lt;br /&gt;
In our work on improving this feature, we have handled the following issues and made the following improvements:&lt;br /&gt;
&lt;br /&gt;
=== Refactoring ===&lt;br /&gt;
&lt;br /&gt;
The previous implementation of the controller made a number of database calls, several of which were extraneous and not required. We have refactored the functions pertaining to these calls so that the number of unneeded calls to the database is reduced for loading teammate and metareviews. &lt;br /&gt;
&lt;br /&gt;
The older implementation of the computation for class averages, and students average scores incorrectly factored in students who had not received grades for an assignment or who had not taken part in an assignment. &lt;br /&gt;
In addition to correcting this, we also simplified the process by refactoring the code(please see the next section for the code).&lt;br /&gt;
&lt;br /&gt;
The past implementation of the controller was unclear and non-Rubyistic in naming conventions, function names, and implementation in the code. We have refactored the controller to make it more Rubyistic overall and also re-written parts of the code to make it more understandable, as well as more CRUD-like. Additionally, we made several methods whose functionality was required and used only inside this controller private.&lt;br /&gt;
&lt;br /&gt;
=== UI changes ===&lt;br /&gt;
The previous implementation had 2 views – all_students_all_reviews and course_student_grade_summary. Both of these views cover some of the data required for a 360-degree view of the course. &lt;br /&gt;
We have combined these pages together into a single page that contains checkboxes which allow the user to select what data they would like to view and shows only those columns they would like to see. This both simplifies and enhances the functioning of the feature.&lt;br /&gt;
&lt;br /&gt;
=== Variable Names, Cosmetic Issues, Comments ===&lt;br /&gt;
&lt;br /&gt;
In the older implementation, there were some unclear variable names such as teamed_count, and some other minor cosmetic issues such as a hyphen being displayed for empty fields where a dash would more visible and clearer. These have been fixed in both the code and the UI of the application to be user-friendly and developer friendly.&lt;br /&gt;
Additionally, comments have been added everywhere to make the code easier to understand and modify for future improvements.&lt;br /&gt;
&lt;br /&gt;
== Fix details and Code Explanation ==&lt;br /&gt;
&lt;br /&gt;
=== Files Changed ===&lt;br /&gt;
The following files were altered and edited in the course of our work on this feature:&lt;br /&gt;
Assessment360_Controller.rb (under app/controller)&lt;br /&gt;
This file contains the controller for the assessment 360 feature which we have improved in our work. The code has been refactored to be cleaner, modular,  easier to understand and also to incorporate DRY. &lt;br /&gt;
&lt;br /&gt;
Index.html.erb (under app/views/assessment360)&lt;br /&gt;
The view for the assessment 360 feature have been combined as stated in the requirements and all the data is now viewable from the index.html.erb page. This page also features checkboxes so the user can view only the data they are interested in without cluttering caused by unneeded data.&lt;br /&gt;
&lt;br /&gt;
=== Issue Fix Details ===&lt;br /&gt;
&lt;br /&gt;
1) '''app/controllers/assessment360_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 2.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 3.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
'''Code changes'''&lt;br /&gt;
&lt;br /&gt;
1. In all_student_all_reviews function, the DB calls are by creating init_data function.&lt;br /&gt;
&lt;br /&gt;
2. The init_data function, removes DB calls inside nested for-loops (look for old code, below) which makes db call for every iteration, the code has been refactored in such a way that it preloads the required data using assignments.includes([:participants]) (look for new code, below). This way, instead of making multiple db calls across diff functions, we load the required data and thereby reduce the processing time.&lt;br /&gt;
&lt;br /&gt;
3. The major change, which we've incorporated here is moving the functions which weren't used in other modules into private. Moving excess functions to private, helps keep the controller more CRUD-like and differentiates to the developer which functions are used by the controller to work, and which ones are the functions of the controller.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Old Code (with complex for loops and more db calls)'''&lt;br /&gt;
&lt;br /&gt;
 @course_participants.each do |cp|&lt;br /&gt;
      # for each assignment&lt;br /&gt;
      # [aggregrate_review_grades_per_stu, review_count_per_stu] --&amp;gt; [0, 0]&lt;br /&gt;
      %w[teammate meta].each { |type| instance_variable_set(&amp;quot;@#{type}_review_info_per_stu&amp;quot;, [0, 0]) }&lt;br /&gt;
      students_teamed = StudentTask.teamed_students(cp.user)&lt;br /&gt;
      @teamed_count[cp.id] = students_teamed[course.id].try(:size).to_i&lt;br /&gt;
      @assignments.each do |assignment|&lt;br /&gt;
        @meta_review[cp.id] = {} unless @meta_review.key?(cp.id)&lt;br /&gt;
        @teammate_review[cp.id] = {} unless @teammate_review.key?(cp.id)&lt;br /&gt;
        assignment_participant = assignment.participants.find_by(user_id: cp.user_id)&lt;br /&gt;
        next if assignment_participant.nil?&lt;br /&gt;
        teammate_reviews = assignment_participant.teammate_reviews&lt;br /&gt;
        meta_reviews = assignment_participant.metareviews&lt;br /&gt;
        calc_overall_review_info(assignment,&lt;br /&gt;
                                 cp,&lt;br /&gt;
                                 teammate_reviews,&lt;br /&gt;
                                 @teammate_review,&lt;br /&gt;
                                 @overall_teammate_review_grades,&lt;br /&gt;
                                 @overall_teammate_review_count,&lt;br /&gt;
                                 @teammate_review_info_per_stu)&lt;br /&gt;
        calc_overall_review_info(assignment,&lt;br /&gt;
                                 cp,&lt;br /&gt;
                                 meta_reviews,&lt;br /&gt;
                                 @meta_review,&lt;br /&gt;
                                 @overall_meta_review_grades,&lt;br /&gt;
                                 @overall_meta_review_count,&lt;br /&gt;
                                 @meta_review_info_per_stu)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Refactored Code (with limited iteration and db calls)'''&lt;br /&gt;
    @assignments.each do |assignment|&lt;br /&gt;
      assignment.participants.each do |assignment_participant|&lt;br /&gt;
        reviews[assignment_participant.user_id] = {} unless reviews.key?(assignment_participant.user_id)&lt;br /&gt;
        assignment_reviews = assignment_participant.public_send(reviews_type) if assignment_participant.respond_to? reviews_type&lt;br /&gt;
        # If a student has not taken an assignment or if they have not received any grade for the same,&lt;br /&gt;
        # assign it as nil(not returning anything). This helps in easier calculation of overall grade&lt;br /&gt;
        score = calc_avg_score(assignment_reviews)&lt;br /&gt;
        reviews[assignment_participant.user_id][assignment.id] = score unless score.nil?&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2) '''app/views/assessment360/index.html.erb'''&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 indexhtmlerb 1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
1. We've created a new file called ''index.html.erb''. This file contains all the logic for the frontend of this module.&lt;br /&gt;
&lt;br /&gt;
2. Major change that has been made is the addition of checkboxes. This way, users can filter the data that they view and view the data efficiently. &lt;br /&gt;
&lt;br /&gt;
3. This page loads all the assignment data, and their metadata like - meta reviews, teammate reviews, peer score, topic and instructor grade. The table also contains Aggregate score and Total grade.&lt;br /&gt;
&lt;br /&gt;
4. The checkboxes have been programmed in a way that whenever a checkbox is disabled, the corresponding column gets removed and the colspan rendering gets adjusted. Along with that, when all assignment parameters are unchecked, the assignment columns disappear completely. Same applies for aggregate score and Total Instructor Grade.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3) '''config/routes.rb'''&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 routes 1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Removed old route to this page and pointed it to the newly created index page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can check all the issues fixed here - https://github.com/expertiza/expertiza/pull/2337&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing using RSPEC ===&lt;br /&gt;
Please note that we have removed several older tests which tested functions that are now private and inaccessible outside the controller class itself. However, the methods that call these private functions are still tested and tests are passing successfully.&lt;br /&gt;
&lt;br /&gt;
=== Testing from UI ===&lt;br /&gt;
The following steps needs to be performed to test this code from UI:&lt;br /&gt;
&lt;br /&gt;
1.	Login as instructor(username: instructor6 , password: password). Please either do step 2 or 3, as both are not required.&lt;br /&gt;
&lt;br /&gt;
2.	Select Courses, and the page will show a list of courses. Please select the rightmost icons for any course (we recommend CSC517 Fall 2017, CSC517 Fall 2011 so there’s more data, but it can take some time for it load since there’s a lot of pre-loaded data in the VCL)&lt;br /&gt;
&lt;br /&gt;
3.	Alternatively, you can login and go to this URL: &amp;lt;needs to be added&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4.	You should be able to see a webpage with a table and checkboxes at the top. This table is an instructor’s 360-degree view of a course, containing the scores of each students in the course for every assignment the instructor has added to Expertiza. &lt;br /&gt;
&lt;br /&gt;
5.	Unchecking some or all of the checkboxes removes and brings back various columns from/to the page. Please feel free to test this out.&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
The UI of the index page which shows all of the data can be improved to make it look neater and more aesthetically pleasing. The table’s positioning and centering can be improved for a more convenient experience overall.&lt;br /&gt;
&lt;br /&gt;
The user’s preferred (checked on the UI checkboxes) can be saved to either the Database or a cache, and on subsequent reloads be the fields loaded on the page for a particular. We suggest using the database for this rather than a cache. &lt;br /&gt;
&lt;br /&gt;
Lazy loading can be implemented for the columns the user last chose(assuming these are stored in the DB) and other columns can lazy-loaded if the user clicks on the checkboxes on the screen.&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_Navigation.jpeg&amp;diff=143527</id>
		<title>File:E2219 Navigation.jpeg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_Navigation.jpeg&amp;diff=143527"/>
		<updated>2022-03-22T04:03:24Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2219:_Improve_assessment360_controller.rb&amp;diff=143525</id>
		<title>CSC/ECE 517 Spring 2022 - E2219: Improve assessment360 controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2219:_Improve_assessment360_controller.rb&amp;diff=143525"/>
		<updated>2022-03-22T03:56:44Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2219 Improve assessment360_controller.rb which was a project in CSC517 Spring 2022. Please see below for a description of the improvements made, issues fixed, code changed, testing information, details required to peer-review the project, and future improvements.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users who would like to view and test the assessment 360 feature, the deployed Expertiza application can be found at the URL mentioned below and can be access using the credentials below: &lt;br /&gt;
&lt;br /&gt;
URL: http://152.7.99.75:8080&lt;br /&gt;
&lt;br /&gt;
Instructor login: &lt;br /&gt;
&lt;br /&gt;
Username: '''instructor6'''&lt;br /&gt;
&lt;br /&gt;
Password: '''password'''&lt;br /&gt;
&lt;br /&gt;
Click on courses and then click on the icon on any one course to go to the assessment 360 page, or log in and paste this URL into the browser: http://152.7.99.75:8080/assessment360/index?course_id=184&lt;br /&gt;
The course ID here is an example, you can add the course ID of your choice.&lt;br /&gt;
&lt;br /&gt;
Please note that due to VCL constraints, the page will take few mins to load and render the data. Please wait for the page to '''load completely''' before starting the peer review. &lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
The Expertiza project contains a feature that allows instructors to get a full or 360-degree view of a course they teach that includes all students in the course, all assignments, and the scores of each student in each assignment, averages, and final scores as well. This feature, called assessment 360, was written in a previous year, and due to issues identified with the code such as variable names, redundancy, code smells etc, a need for improvement of the same was identified. &lt;br /&gt;
&lt;br /&gt;
== Issues and Description of Fixes ==&lt;br /&gt;
In our work on improving this feature, we have handled the following issues and made the following improvements:&lt;br /&gt;
&lt;br /&gt;
=== Refactoring ===&lt;br /&gt;
&lt;br /&gt;
The previous implementation of the controller made a number of database calls, several of which were extraneous and not required. We have refactored the functions pertaining to these calls so that the number of unneeded calls to the database is reduced for loading teammate and metareviews. &lt;br /&gt;
&lt;br /&gt;
The older implementation of the computation for class averages, and students average scores incorrectly factored in students who had not received grades for an assignment or who had not taken part in an assignment. &lt;br /&gt;
In addition to correcting this, we also simplified the process by refactoring the code(please see the next section for the code).&lt;br /&gt;
&lt;br /&gt;
The past implementation of the controller was unclear and non-Rubyistic in naming conventions, function names, and implementation in the code. We have refactored the controller to make it more Rubyistic overall and also re-written parts of the code to make it more understandable, as well as more CRUD-like. Additionally, we made several methods whose functionality was required and used only inside this controller private.&lt;br /&gt;
&lt;br /&gt;
=== UI changes ===&lt;br /&gt;
The previous implementation had 2 views – all_students_all_reviews and course_student_grade_summary. Both of these views cover some of the data required for a 360-degree view of the course. &lt;br /&gt;
We have combined these pages together into a single page that contains checkboxes which allow the user to select what data they would like to view and shows only those columns they would like to see. This both simplifies and enhances the functioning of the feature.&lt;br /&gt;
&lt;br /&gt;
=== Variable Names, Cosmetic Issues, Comments ===&lt;br /&gt;
&lt;br /&gt;
In the older implementation, there were some unclear variable names such as teamed_count, and some other minor cosmetic issues such as a hyphen being displayed for empty fields where a dash would more visible and clearer. These have been fixed in both the code and the UI of the application to be user-friendly and developer friendly.&lt;br /&gt;
Additionally, comments have been added everywhere to make the code easier to understand and modify for future improvements.&lt;br /&gt;
&lt;br /&gt;
== Fix details and Code Explanation ==&lt;br /&gt;
&lt;br /&gt;
=== Files Changed ===&lt;br /&gt;
The following files were altered and edited in the course of our work on this feature:&lt;br /&gt;
Assessment360_Controller.rb (under app/controller)&lt;br /&gt;
This file contains the controller for the assessment 360 feature which we have improved in our work. The code has been refactored to be cleaner, modular,  easier to understand and also to incorporate DRY. &lt;br /&gt;
&lt;br /&gt;
Index.html.erb (under app/views/assessment360)&lt;br /&gt;
The view for the assessment 360 feature have been combined as stated in the requirements and all the data is now viewable from the index.html.erb page. This page also features checkboxes so the user can view only the data they are interested in without cluttering caused by unneeded data.&lt;br /&gt;
&lt;br /&gt;
=== Issue Fix Details ===&lt;br /&gt;
&lt;br /&gt;
1) '''app/controllers/assessment360_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 2.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 3.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
'''Code changes'''&lt;br /&gt;
&lt;br /&gt;
1. In all_student_all_reviews function, the DB calls are by creating init_data function.&lt;br /&gt;
&lt;br /&gt;
2. The init_data function, removes DB calls inside nested for-loops (look for old code, below) which makes db call for every iteration, the code has been refactored in such a way that it preloads the required data using assignments.includes([:participants]) (look for new code, below). This way, instead of making multiple db calls across diff functions, we load the required data and thereby reduce the processing time.&lt;br /&gt;
&lt;br /&gt;
3. The major change, which we've incorporated here is moving the functions which weren't used in other modules into private.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Old Code (with complex for loops and more db calls)'''&lt;br /&gt;
&lt;br /&gt;
 @course_participants.each do |cp|&lt;br /&gt;
      # for each assignment&lt;br /&gt;
      # [aggregrate_review_grades_per_stu, review_count_per_stu] --&amp;gt; [0, 0]&lt;br /&gt;
      %w[teammate meta].each { |type| instance_variable_set(&amp;quot;@#{type}_review_info_per_stu&amp;quot;, [0, 0]) }&lt;br /&gt;
      students_teamed = StudentTask.teamed_students(cp.user)&lt;br /&gt;
      @teamed_count[cp.id] = students_teamed[course.id].try(:size).to_i&lt;br /&gt;
      @assignments.each do |assignment|&lt;br /&gt;
        @meta_review[cp.id] = {} unless @meta_review.key?(cp.id)&lt;br /&gt;
        @teammate_review[cp.id] = {} unless @teammate_review.key?(cp.id)&lt;br /&gt;
        assignment_participant = assignment.participants.find_by(user_id: cp.user_id)&lt;br /&gt;
        next if assignment_participant.nil?&lt;br /&gt;
        teammate_reviews = assignment_participant.teammate_reviews&lt;br /&gt;
        meta_reviews = assignment_participant.metareviews&lt;br /&gt;
        calc_overall_review_info(assignment,&lt;br /&gt;
                                 cp,&lt;br /&gt;
                                 teammate_reviews,&lt;br /&gt;
                                 @teammate_review,&lt;br /&gt;
                                 @overall_teammate_review_grades,&lt;br /&gt;
                                 @overall_teammate_review_count,&lt;br /&gt;
                                 @teammate_review_info_per_stu)&lt;br /&gt;
        calc_overall_review_info(assignment,&lt;br /&gt;
                                 cp,&lt;br /&gt;
                                 meta_reviews,&lt;br /&gt;
                                 @meta_review,&lt;br /&gt;
                                 @overall_meta_review_grades,&lt;br /&gt;
                                 @overall_meta_review_count,&lt;br /&gt;
                                 @meta_review_info_per_stu)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Refactored Code (with limited iteration and db calls)'''&lt;br /&gt;
    @assignments.each do |assignment|&lt;br /&gt;
      assignment.participants.each do |assignment_participant|&lt;br /&gt;
        reviews[assignment_participant.user_id] = {} unless reviews.key?(assignment_participant.user_id)&lt;br /&gt;
        assignment_reviews = assignment_participant.public_send(reviews_type) if assignment_participant.respond_to? reviews_type&lt;br /&gt;
        # If a student has not taken an assignment or if they have not received any grade for the same,&lt;br /&gt;
        # assign it as nil(not returning anything). This helps in easier calculation of overall grade&lt;br /&gt;
        score = calc_avg_score(assignment_reviews)&lt;br /&gt;
        reviews[assignment_participant.user_id][assignment.id] = score unless score.nil?&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2) '''app/views/assessment360/index.html.erb'''&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 indexhtmlerb 1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
1. We've created a new file called ''index.html.erb''. This file contains all the logic for the frontend of this module. &lt;br /&gt;
2. Major change that has been made is the addition of checkboxes. This way, users can filter the data that they view and view the data efficiently. &lt;br /&gt;
&lt;br /&gt;
3. This page loads all the assignment data, and their metadata like - meta reviews, teammate reviews, peer score, topic and instructor grade. The table also contains Aggregate score and Total grade.&lt;br /&gt;
&lt;br /&gt;
4. The checkboxes have been programmed in a way that whenever a checkbox is disabled, the corresponding column gets removed and the colspan rendering gets adjusted. Along with that, when all assignment parameters are unchecked, the assignment columns disappear completely. Same applies for aggregate score and Total Instructor Grade.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3) '''config/routes.rb'''&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 routes 1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Removed old route to this page and pointed it to the newly created index page.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can check all the issues fixed here - https://github.com/expertiza/expertiza/pull/2337&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing using RSPEC ===&lt;br /&gt;
Please note that we have removed several older tests which tested functions that are now private and inaccessible outside the controller class itself. However, the methods that call these private functions are still tested and tests are passing successfully.&lt;br /&gt;
&lt;br /&gt;
=== Testing from UI ===&lt;br /&gt;
The following steps needs to be performed to test this code from UI:&lt;br /&gt;
&lt;br /&gt;
1.	Login as instructor(username: instructor6 , password: password). Please either do step 2 or 3, as both are not required.&lt;br /&gt;
&lt;br /&gt;
2.	Select Courses, and the page will show a list of courses. Please select the rightmost icons for any course (we recommend CSC517 Fall 2017, CSC517 Fall 2011 so there’s more data, but it can take some time for it load since there’s a lot of pre-loaded data in the VCL)&lt;br /&gt;
&lt;br /&gt;
3.	Alternatively, you can login and go to this URL: &amp;lt;needs to be added&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4.	You should be able to see a webpage with a table and checkboxes at the top. This table is an instructor’s 360-degree view of a course, containing the scores of each students in the course for every assignment the instructor has added to Expertiza. &lt;br /&gt;
&lt;br /&gt;
5.	Unchecking some or all of the checkboxes removes and brings back various columns from/to the page. Please feel free to test this out.&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
The UI of the index page which shows all of the data can be improved to make it look neater and more aesthetically pleasing. The table’s positioning and centering can be improved for a more convenient experience overall.&lt;br /&gt;
&lt;br /&gt;
The user’s preferred (checked on the UI checkboxes) can be saved to either the Database or a cache, and on subsequent reloads be the fields loaded on the page for a particular. We suggest using the database for this rather than a cache. &lt;br /&gt;
&lt;br /&gt;
Lazy loading can be implemented for the columns the user last chose(assuming these are stored in the DB) and other columns can lazy-loaded if the user clicks on the checkboxes on the screen.&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2219:_Improve_assessment360_controller.rb&amp;diff=143514</id>
		<title>CSC/ECE 517 Spring 2022 - E2219: Improve assessment360 controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2219:_Improve_assessment360_controller.rb&amp;diff=143514"/>
		<updated>2022-03-22T03:04:46Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2219 Improve assessment360_controller.rb which was a project in CSC517 Spring 2022. Please see below for a description of the improvements made, issues fixed, code changed, testing information, details required to peer-review the project, and future improvements.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users who would like to view and test the assessment 360 feature, the deployed Expertiza application can be found at the URL mentioned below and can be access using the credentials below: &lt;br /&gt;
&lt;br /&gt;
URL: http://152.7.99.75:8080&lt;br /&gt;
&lt;br /&gt;
Instructor login: &lt;br /&gt;
&lt;br /&gt;
Username: '''instructor6'''&lt;br /&gt;
&lt;br /&gt;
Password: '''password'''&lt;br /&gt;
&lt;br /&gt;
Click on courses and then click on the icon on any one course to go to the assessment 360 page, or log in and paste this URL into the browser: http://152.7.99.75:8080/assessment360/index?course_id=184&lt;br /&gt;
The course ID here is an example, you can add the course ID of your choice.&lt;br /&gt;
&lt;br /&gt;
Please note that due to VCL constraints, the page will take few mins to load and render the data. Please wait for the page to '''load completely''' before starting the peer review. &lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
The Expertiza project contains a feature that allows instructors to get a full or 360-degree view of a course they teach that includes all students in the course, all assignments, and the scores of each student in each assignment, averages, and final scores as well. This feature, called assessment 360, was written in a previous year, and due to issues identified with the code such as variable names, redundancy, code smells etc, a need for improvement of the same was identified. &lt;br /&gt;
&lt;br /&gt;
== Issues and Description of Fixes ==&lt;br /&gt;
In our work on improving this feature, we have handled the following issues and made the following improvements:&lt;br /&gt;
&lt;br /&gt;
=== Refactoring ===&lt;br /&gt;
&lt;br /&gt;
The previous implementation of the controller made a number of database calls, several of which were extraneous and not required. We have refactored the functions pertaining to these calls so that the number of unneeded calls to the database is reduced for loading teammate and metareviews. &lt;br /&gt;
&lt;br /&gt;
The older implementation of the computation for class averages, and students average scores incorrectly factored in students who had not received grades for an assignment or who had not taken part in an assignment. &lt;br /&gt;
In addition to correcting this, we also simplified the process by refactoring the code(please see the next section for the code).&lt;br /&gt;
&lt;br /&gt;
The past implementation of the controller was unclear and non-Rubyistic in naming conventions, function names, and implementation in the code. We have refactored the controller to make it more Rubyistic overall and also re-written parts of the code to make it more understandable, as well as more CRUD-like. Additionally, we made several methods whose functionality was required and used only inside this controller private.&lt;br /&gt;
&lt;br /&gt;
=== UI changes ===&lt;br /&gt;
The previous implementation had 2 views – all_students_all_reviews and course_student_grade_summary. Both of these views cover some of the data required for a 360-degree view of the course. &lt;br /&gt;
We have combined these pages together into a single page that contains checkboxes which allow the user to select what data they would like to view and shows only those columns they would like to see. This both simplifies and enhances the functioning of the feature.&lt;br /&gt;
&lt;br /&gt;
=== Variable Names, Cosmetic Issues, Comments ===&lt;br /&gt;
&lt;br /&gt;
In the older implementation, there were some unclear variable names such as teamed_count, and some other minor cosmetic issues such as a hyphen being displayed for empty fields where a dash would more visible and clearer. These have been fixed in both the code and the UI of the application to be user-friendly and developer friendly.&lt;br /&gt;
Additionally, comments have been added everywhere to make the code easier to understand and modify for future improvements.&lt;br /&gt;
&lt;br /&gt;
== Fix details and Code Explanation ==&lt;br /&gt;
&lt;br /&gt;
=== Files Changed ===&lt;br /&gt;
The following files were altered and edited in the course of our work on this feature:&lt;br /&gt;
Assessment360_Controller.rb (under app/controller)&lt;br /&gt;
This file contains the controller for the assessment 360 feature which we have improved in our work. The code has been refactored to be cleaner, modular,  easier to understand and also to incorporate DRY. &lt;br /&gt;
&lt;br /&gt;
Index.html.erb (under app/views/assessment360)&lt;br /&gt;
The view for the assessment 360 feature have been combined as stated in the requirements and all the data is now viewable from the index.html.erb page. This page also features checkboxes so the user can view only the data they are interested in without cluttering caused by unneeded data.&lt;br /&gt;
&lt;br /&gt;
=== Issue Fix Details ===&lt;br /&gt;
&lt;br /&gt;
1) '''app/controllers/assessment360_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 2.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 3.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2) '''app/views/assessment360/index.html.erb'''&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 indexhtmlerb 1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
3) '''config/routes.rb'''&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 routes 1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing using RSPEC ===&lt;br /&gt;
Please note that we have removed several older tests which tested functions that are now private and inaccessible outside the controller class itself. However, the methods that call these private functions are still tested and tests are passing successfully.&lt;br /&gt;
&lt;br /&gt;
=== Testing from UI ===&lt;br /&gt;
The following steps needs to be performed to test this code from UI:&lt;br /&gt;
&lt;br /&gt;
1.	Login as instructor(username: instructor6 , password: password). Please either do step 2 or 3, as both are not required.&lt;br /&gt;
&lt;br /&gt;
2.	Select Courses, and the page will show a list of courses. Please select the rightmost icons for any course (we recommend CSC517 Fall 2017, CSC517 Fall 2011 so there’s more data, but it can take some time for it load since there’s a lot of pre-loaded data in the VCL)&lt;br /&gt;
&lt;br /&gt;
3.	Alternatively, you can login and go to this URL: &amp;lt;needs to be added&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4.	You should be able to see a webpage with a table and checkboxes at the top. This table is an instructor’s 360-degree view of a course, containing the scores of each students in the course for every assignment the instructor has added to Expertiza. &lt;br /&gt;
&lt;br /&gt;
5.	Unchecking some or all of the checkboxes removes and brings back various columns from/to the page. Please feel free to test this out.&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
The UI of the index page which shows all of the data can be improved to make it look neater and more aesthetically pleasing. The table’s positioning and centering can be improved for a more convenient experience overall.&lt;br /&gt;
&lt;br /&gt;
The user’s preferred (checked on the UI checkboxes) can be saved to either the Database or a cache, and on subsequent reloads be the fields loaded on the page for a particular. We suggest using the database for this rather than a cache. &lt;br /&gt;
&lt;br /&gt;
Lazy loading can be implemented for the columns the user last chose(assuming these are stored in the DB) and other columns can lazy-loaded if the user clicks on the checkboxes on the screen.&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2219:_Improve_assessment360_controller.rb&amp;diff=143507</id>
		<title>CSC/ECE 517 Spring 2022 - E2219: Improve assessment360 controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2022_-_E2219:_Improve_assessment360_controller.rb&amp;diff=143507"/>
		<updated>2022-03-22T02:41:04Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains information about Expertiza Issue E2219 Improve assessment360_controller.rb which was a project in CSC517 Spring 2022. Please see below for a description of the improvements made, issues fixed, code changed, testing information, details required to peer-review the project, and future improvements.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users who would like to view and test the assessment 360 feature, the deployed Expertiza application can be found at the URL mentioned below and can be access using the credentials below: &lt;br /&gt;
&lt;br /&gt;
URL: &amp;lt;needs to be added&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instructor login: &lt;br /&gt;
&lt;br /&gt;
Username: '''instructor6'''&lt;br /&gt;
&lt;br /&gt;
Password: '''password'''&lt;br /&gt;
&lt;br /&gt;
Click on courses and then click on the icon on any one course to go to the assessment 360 page, or log in and paste this URL into the browser: &amp;lt;to be added&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The Expertiza project is software to create reusable learning objects through peer review. It also supports team projects, and the submission of almost any document type, including URLs and wiki pages.&lt;br /&gt;
The Expertiza project contains a feature that allows instructors to get a full or 360-degree view of a course they teach that includes all students in the course, all assignments, and the scores of each student in each assignment, averages, and final scores as well. This feature, called assessment 360, was written in a previous year, and due to issues identified with the code such as variable names, redundancy, code smells etc, a need for improvement of the same was identified. &lt;br /&gt;
&lt;br /&gt;
== Issues and Description of Fixes ==&lt;br /&gt;
In our work on improving this feature, we have handled the following issues and made the following improvements:&lt;br /&gt;
&lt;br /&gt;
=== Refactoring ===&lt;br /&gt;
&lt;br /&gt;
The previous implementation of the controller made a number of database calls, several of which were extraneous and not required. We have refactored the functions pertaining to these calls so that the number of unneeded calls to the database is reduced for loading teammate and metareviews. &lt;br /&gt;
&lt;br /&gt;
The older implementation of the computation for class averages, and students average scores incorrectly factored in students who had not received grades for an assignment or who had not taken part in an assignment. &lt;br /&gt;
In addition to correcting this, we also simplified the process by refactoring the code(please see the next section for the code).&lt;br /&gt;
&lt;br /&gt;
The past implementation of the controller was unclear and non-Rubyistic in naming conventions, function names, and implementation in the code. We have refactored the controller to make it more Rubyistic overall and also re-written parts of the code to make it more understandable, as well as more CRUD-like. Additionally, we made several methods whose functionality was required and used only inside this controller private.&lt;br /&gt;
&lt;br /&gt;
=== UI changes ===&lt;br /&gt;
The previous implementation had 2 views – all_students_all_reviews and course_student_grade_summary. Both of these views cover some of the data required for a 360-degree view of the course. &lt;br /&gt;
We have combined these pages together into a single page that contains checkboxes which allow the user to select what data they would like to view and shows only those columns they would like to see. This both simplifies and enhances the functioning of the feature.&lt;br /&gt;
&lt;br /&gt;
=== Variable Names, Cosmetic Issues, Comments ===&lt;br /&gt;
&lt;br /&gt;
In the older implementation, there were some unclear variable names such as teamed_count, and some other minor cosmetic issues such as a hyphen being displayed for empty fields where a dash would more visible and clearer. These have been fixed in both the code and the UI of the application to be user-friendly and developer friendly.&lt;br /&gt;
Additionally, comments have been added everywhere to make the code easier to understand and modify for future improvements.&lt;br /&gt;
&lt;br /&gt;
== Fix details and Code Explanation ==&lt;br /&gt;
&lt;br /&gt;
=== Files Changed ===&lt;br /&gt;
The following files were altered and edited in the course of our work on this feature:&lt;br /&gt;
Assessment360_Controller.rb (under app/controller)&lt;br /&gt;
This file contains the controller for the assessment 360 feature which we have improved in our work. The code has been refactored to be cleaner, modular,  easier to understand and also to incorporate DRY. &lt;br /&gt;
&lt;br /&gt;
Index.html.erb (under app/views/assessment360)&lt;br /&gt;
The view for the assessment 360 feature have been combined as stated in the requirements and all the data is now viewable from the index.html.erb page. This page also features checkboxes so the user can view only the data they are interested in without cluttering caused by unneeded data.&lt;br /&gt;
&lt;br /&gt;
=== Issue Fix Details ===&lt;br /&gt;
&lt;br /&gt;
1) '''app/controllers/assessment360_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 2.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 3.png|800px]]&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 assessment360 controller 4.png|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2) '''app/views/assessment360/index.html.erb'''&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 indexhtmlerb 1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
3) '''config/routes.rb'''&lt;br /&gt;
&lt;br /&gt;
[[File:E2219 routes 1.png|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing using RSPEC ===&lt;br /&gt;
Please note that we have removed several older tests which tested functions that are now private and inaccessible outside the controller class itself. However, the methods that call these private functions are still tested and tests are passing successfully.&lt;br /&gt;
&lt;br /&gt;
=== Testing from UI ===&lt;br /&gt;
The following steps needs to be performed to test this code from UI:&lt;br /&gt;
&lt;br /&gt;
1.	Login as instructor(username: instructor6 , password: password). Please either do step 2 or 3, as both are not required.&lt;br /&gt;
&lt;br /&gt;
2.	Select Courses, and the page will show a list of courses. Please select the rightmost icons for any course (we recommend CSC517 Fall 2017, CSC517 Fall 2011 so there’s more data, but it can take some time for it load since there’s a lot of pre-loaded data in the VCL)&lt;br /&gt;
&lt;br /&gt;
3.	Alternatively, you can login and go to this URL: &amp;lt;needs to be added&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4.	You should be able to see a webpage with a table and checkboxes at the top. This table is an instructor’s 360-degree view of a course, containing the scores of each students in the course for every assignment the instructor has added to Expertiza. &lt;br /&gt;
&lt;br /&gt;
5.	Unchecking some or all of the checkboxes removes and brings back various columns from/to the page. Please feel free to test this out.&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
&lt;br /&gt;
The UI of the index page which shows all of the data can be improved to make it look neater and more aesthetically pleasing. The table’s positioning and centering can be improved for a more convenient experience overall.&lt;br /&gt;
&lt;br /&gt;
The user’s preferred (checked on the UI checkboxes) can be saved to either the Database or a cache, and on subsequent reloads be the fields loaded on the page for a particular. We suggest using the database for this rather than a cache. &lt;br /&gt;
&lt;br /&gt;
Lazy loading can be implemented for the columns the user last chose(assuming these are stored in the DB) and other columns can lazy-loaded if the user clicks on the checkboxes on the screen.&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_routes_1.png&amp;diff=143504</id>
		<title>File:E2219 routes 1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_routes_1.png&amp;diff=143504"/>
		<updated>2022-03-22T02:30:08Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_indexhtmlerb_1.png&amp;diff=143503</id>
		<title>File:E2219 indexhtmlerb 1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_indexhtmlerb_1.png&amp;diff=143503"/>
		<updated>2022-03-22T02:29:55Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_assessment360_controller_4.png&amp;diff=143502</id>
		<title>File:E2219 assessment360 controller 4.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_assessment360_controller_4.png&amp;diff=143502"/>
		<updated>2022-03-22T02:29:40Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_assessment360_controller_3.png&amp;diff=143501</id>
		<title>File:E2219 assessment360 controller 3.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_assessment360_controller_3.png&amp;diff=143501"/>
		<updated>2022-03-22T02:29:27Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_assessment360_controller_2.png&amp;diff=143500</id>
		<title>File:E2219 assessment360 controller 2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_assessment360_controller_2.png&amp;diff=143500"/>
		<updated>2022-03-22T02:28:45Z</updated>

		<summary type="html">&lt;p&gt;Svenka25: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Svenka25</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_assessment360_controller_1.png&amp;diff=143499</id>
		<title>File:E2219 assessment360 controller 1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2219_assessment360_controller_1.png&amp;diff=143499"/>
		<updated>2022-03-22T02:27:59Z</updated>

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