<?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=Akuchib</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=Akuchib"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Akuchib"/>
	<updated>2026-08-12T22:25:27Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=142740</id>
		<title>CSC/ECE 517 Fall 2021 - E2163. Refactor waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=142740"/>
		<updated>2021-12-08T21:41:00Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza ==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. It also allows the instructor to create a list of topics the students can sign up for. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
When a team requests a topic which is not available, the team is waitlisted for the topic, given that bidding is not in use for the assignment. When another team drops a topic, then a waitlisted team will be assigned the topic, if there are any teams waitlisted for it. Implement a waitlist object associated with each topic, and a team that requested it when it was not available would just be queued on the waitlist. The waitlist would just enqueue ordered pairs〈team_id, topic_id〉&lt;br /&gt;
Currently, the functionality relevant to waitlisting is scattered across the multiple files. These functions need to be consolidated and placed in a single class. &lt;br /&gt;
&lt;br /&gt;
== Control Flow ==&lt;br /&gt;
In the current implementation, multiple models and controllers perform actions that indirectly affect the teams in the waitlist and require to be added or removed from the waitlist. Due to this the same redundant operations of modifying the waitlist is being performed by multiple models and controllers. In order to improve the functionality all the redundant operations being performed on the waitlist need to be moved to the 'waitlist.rb' file and all the other controllers and models will be utilising these methods to manipulate the waitlists.&lt;br /&gt;
&lt;br /&gt;
'''Planned implementation:''' The Context object in our case the waitlist object delegates an algorithm to different Strategy objects to execute waitlist functions as shown below. The Context calls algorithm() on a Strategy1 object, which performs the algorithm and returns the result to Context.&lt;br /&gt;
&lt;br /&gt;
'''Existing Control Flow'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Block diagram waitlist current.png|850px]]&lt;br /&gt;
&lt;br /&gt;
'''Modified Control Flow'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Block diagram waitlist modified.png|850px]]&lt;br /&gt;
&lt;br /&gt;
== Solution Approach == &lt;br /&gt;
&lt;br /&gt;
===Refactoring===&lt;br /&gt;
Goal of the project is to simplify waitlist functionality by moving all the functions manipulating waitlists to waitlist.rb, along with a WaitingTeam class that would consist of a 〈team_id, topic_id〉pair to store information regarding teams on waitlist for a particular topic. Classes should just invoke methods of waitlist.rb for the following functionality: &lt;br /&gt;
# Add themselves to waitlists&lt;br /&gt;
# Add another team to a waitlist&lt;br /&gt;
# Take a team off a waitlist&lt;br /&gt;
# Purge all waitlists of a specific team&lt;br /&gt;
# Clear a specific waitlist of all waiting teams&lt;br /&gt;
&lt;br /&gt;
Introduce a waitlist object associated with each topic so that any team that requested it when it was not available would just be queued on the waitlist.  The waitlist would just enqueue ordered pairs〈team_id, topic_id〉&lt;br /&gt;
 &lt;br /&gt;
===Design Pattern===&lt;br /&gt;
As we are decoupling the functionality manipulating waitlists that is scattered across various files and putting it all under a single class the design pattern opted for is Strategy Design Pattern. It is a behavioural design pattern that lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable.  The plan is to isolate the code, internal data, and dependencies of various algorithms related to waitlist from the rest of the code. Various clients now get a simple class to execute the algorithms and switch them at runtime.&lt;br /&gt;
&lt;br /&gt;
'''Tentative list of files to be modified'''&lt;br /&gt;
# sign_up_topic.rb&lt;br /&gt;
# invitation.rb&lt;br /&gt;
# waitlist.rb&lt;br /&gt;
# lottery_controller.rb&lt;br /&gt;
# suggestion_controller.rb &lt;br /&gt;
# signed_up_team.rb&lt;br /&gt;
# student_teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
== UI Test Steps ==&lt;br /&gt;
* Step 1: Signup as an instructor and click on Manage Assignments&lt;br /&gt;
&lt;br /&gt;
[[File:Manage assignments.png|550px]]&lt;br /&gt;
[[File:Add assignment.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 2: Create an assignment with the required configurations and click on create.&lt;br /&gt;
&lt;br /&gt;
[[File:Create assignment.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 3: Post assignment creation, go to manage assignments, and edit the newly created assignment&lt;br /&gt;
&lt;br /&gt;
[[File:Edit new assignment.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 4: Selected the 'has topics' options and create new topics for the students to sign up using the topics tab.&lt;br /&gt;
&lt;br /&gt;
[[File:Has_topics_assignment_option.png|550px]]&lt;br /&gt;
[[File:Create topics.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 5: Add participants to the assignment using the participant tab and then assign the participants to teams using the teams tab and save the changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Add participants and teams.png|550px]]&lt;br /&gt;
[[File:Add teams.png|550px]]&lt;br /&gt;
[[File:Add participants.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 6: Impersonate one student that you had added to one team in the previous step.&lt;br /&gt;
&lt;br /&gt;
[[File:Impersonate user.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 7: In the assignment tabs, choose the assignment that you had created in the previous step and click on sign-up sheet to sign up for a topic. &lt;br /&gt;
&lt;br /&gt;
[[File:Signup_sheet.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 8: Sign up for any topic of your choice. If it is available then you will be assigned the slot and the number of available slots will be updated.&lt;br /&gt;
&lt;br /&gt;
[[File:Student7488 signup.png|550px]]&lt;br /&gt;
[[File:Student7488 signedup.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 9: Impersonate as another student from another team that you had created for the same assignment in the previous steps and follow the same steps as mentioned above to sign up for a topic. Sign up for the same topic as the previously impersonated student.&lt;br /&gt;
&lt;br /&gt;
[[File:Student431 signup.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 10: You will now notice that since there was only one available slot and the previous team already signed up for it, the current team will be added to the waitlist for that topic.&lt;br /&gt;
&lt;br /&gt;
[[File:Student 431 waitlisted.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 11: You can also check the student currently assigned to a topic and the waitlisted students in the manage assignments tab on logging in as an instructor(As done in the previous steps)&lt;br /&gt;
&lt;br /&gt;
[[File:Teams signedup waitlisted.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 12: Following the above mentioned steps various scenarios can be tested via the UI like: &lt;br /&gt;
# Adding more topics&lt;br /&gt;
# Multiple teams signing up for the same topic&lt;br /&gt;
# Teams dropping topics etc.&lt;br /&gt;
&lt;br /&gt;
'''In the current implemention the following issue exists which will be fixed:'''&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1:''' Assigned teams dropping topics&lt;br /&gt;
&lt;br /&gt;
'''Expected Behaviour :'''&lt;br /&gt;
After one team signs up for a topic and the second team that signs up for the same topic is added to the waitlist, if the first team drops the topic, ideally the available slots should be updated and the second team should be assigned the topic since it is the first on the waitlist.&lt;br /&gt;
&lt;br /&gt;
'''Current Issue :'''&lt;br /&gt;
The available slot after one team drops the topic does not update due to which the first team in the waitlist is not automatically assigned the topic.&lt;br /&gt;
[[File:Topic dropped.png|550px]]&lt;br /&gt;
&lt;br /&gt;
'''Proposed Solution :'''&lt;br /&gt;
Implement a new waitlist object to maintain the list of topics and the teams in the waitlist as ordered pairs: 〈team_id, topic_id〉as soon as the first team drops the topic the team_id field will be updated to the second team since it is the first on the waitlist.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2:''' Instructor intervention when assigned teams drops topics&lt;br /&gt;
&lt;br /&gt;
'''Expected Behaviour :'''&lt;br /&gt;
After one team signs up for a topic and the second team that signs up for the same topic is added to the waitlist, if the first team drops the topic, ideally the available slots should be updated and the second team should be assigned the topic since it is the first on the waitlist also we know that the manage topics tab while the instructor edits the assignment also contains the team that is currently assigned the topic and the list of waitlisted teams it should be updated when a change occurs.&lt;br /&gt;
&lt;br /&gt;
'''Current Issue :'''&lt;br /&gt;
The instructor does not see in the manage assignments topics tab that the topic is not assigned to the first team once it chooses to drop it.&lt;br /&gt;
[[File:Teams signedup waitlisted.png|550px]]&lt;br /&gt;
&lt;br /&gt;
'''Proposed Solution :'''&lt;br /&gt;
Since the same functionality of maintaining the waitlist is being done at multiple places, the code does not update for the manage assignments topic tab for the instructor. In order to fix this, implementation of a new waitlist object is done to maintain the list of topics and the teams in the waitlist as ordered pairs: 〈team_id, topic_id〉as soon as the first team drops the topic the team_id field will be updated to the second team since it is the first on the waitlist and the same object will be consumed everywhere. Hence, the manage assignments topic will be updated automatically.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
This project entails code refactoring such that all functionality relevant to waitlist is easily available under one class. Focus is on ensuring existing tests work as expected as the newly added code will not impact functionality per se. However, new unit tests will be written for testing waitlist.rb independently. Furthermore, test cases for suggestion_controller.rb &amp;amp; signed_up_team.rb are missing in the current implementation. Hence, we will be adding spec files for the aforementioned files as well. Certain edge cases will also be tested which have not been covered by the current tests.&lt;br /&gt;
&lt;br /&gt;
'''Test Files'''&lt;br /&gt;
# sign_up_topic_spec.rb&lt;br /&gt;
# invitation_spec.rb&lt;br /&gt;
# waitlist_spec.rb&lt;br /&gt;
# lottery_controller_spec.rb&lt;br /&gt;
# suggestion_controller_spec.rb&lt;br /&gt;
# signed_up_team_spec.rb&lt;br /&gt;
# student_teams_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
'''Cases To Be Tested'''&lt;br /&gt;
# Add team to waitlist if topic isn't available: When a team signs up for a topic already assigned to another team they automatically get added to the waitlist of that topic.&lt;br /&gt;
# Push the first waitlisted member (if exists) in case a confirmed slot is deleted: When a team drops the topic assigned to them or the instructor deletes the assignment of a topic to a particular team then the first team on the waitlist get assigned the topic for that assignment.&lt;br /&gt;
# Remove waitlists for team if a topic is confirmed: Once a team on the waitlists of multiple topics gets assigned a topic, the team is removed from the other waitlists.&lt;br /&gt;
# Clean waitlists &amp;amp; assign topic if the user has a team but not a topic: If a team hasn't signed up for a topic it should get auto-assigned one topic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Automated Tests'''&lt;br /&gt;
&lt;br /&gt;
Automated testing can be done using Capybara. Since a major part of the scenario can be tested using the UI, an automated test to create teams and sign up for topics can be created using Capybara with Cucumber. These tests can be written using the TDD approach prior to defining the code.&lt;br /&gt;
&lt;br /&gt;
'''Code Coverage:''' Code coverage for the test cases can be obtained using the Code Coverage plugin and SimpleCov gem. The lines in the functions for which test cases are written in the corresponding spec file are highlighted in green and the rest of the lines are highlighted in red.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.r80b3xxz9peq Problem Statement]&lt;br /&gt;
# [https://github.com/nehajaideep/expertiza Forked Repository]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
* Ankit Singh (asingh072318)&lt;br /&gt;
&lt;br /&gt;
* Asrita Kuchibhotla (kAsrita)&lt;br /&gt;
&lt;br /&gt;
* Neha Kotcherlakota (nehajaideep)&lt;br /&gt;
&lt;br /&gt;
* Vinit Desai (VinitDesai1998)&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=142739</id>
		<title>CSC/ECE 517 Fall 2021 - E2163. Refactor waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=142739"/>
		<updated>2021-12-08T21:31:40Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza ==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. It also allows the instructor to create a list of topics the students can sign up for. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
When a team requests a topic which is not available, the team is waitlisted for the topic, given that bidding is not in use for the assignment. When another team drops a topic, then a waitlisted team will be assigned the topic, if there are any teams waitlisted for it. Implement a waitlist object associated with each topic, and a team that requested it when it was not available would just be queued on the waitlist. The waitlist would just enqueue ordered pairs〈team_id, topic_id〉&lt;br /&gt;
Currently, the functionality relevant to waitlisting is scattered across the multiple files. These functions need to be consolidated and placed in a single class. &lt;br /&gt;
&lt;br /&gt;
== Control Flow ==&lt;br /&gt;
In the current implementation, multiple models and controllers perform actions that indirectly affect the teams in the waitlist and require to be added or removed from the waitlist. Due to this the same redundant operations of modifying the waitlist is being performed by multiple models and controllers. In order to improve the functionality all the redundant operations being performed on the waitlist need to be moved to the 'waitlist.rb' file and all the other controllers and models will be utilising these methods to manipulate the waitlists.&lt;br /&gt;
&lt;br /&gt;
'''Planned implementation:''' The Context object in our case the waitlist object delegates an algorithm to different Strategy objects to execute waitlist functions as shown below. The Context calls algorithm() on a Strategy1 object, which performs the algorithm and returns the result to Context.&lt;br /&gt;
&lt;br /&gt;
'''Existing Control Flow'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Block diagram waitlist current.png|850px]]&lt;br /&gt;
&lt;br /&gt;
'''Modified Control Flow'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Block diagram waitlist modified.png|850px]]&lt;br /&gt;
&lt;br /&gt;
== Solution Approach == &lt;br /&gt;
&lt;br /&gt;
===Refactoring===&lt;br /&gt;
Goal of the project is to simplify waitlist functionality by moving all the functions manipulating waitlists to waitlist.rb, along with a WaitingTeam class that would consist of a 〈team_id, topic_id〉pair to store information regarding teams on waitlist for a particular topic. Classes should just invoke methods of waitlist.rb for the following functionality: &lt;br /&gt;
# Add themselves to waitlists&lt;br /&gt;
# Add another team to a waitlist&lt;br /&gt;
# Take a team off a waitlist&lt;br /&gt;
# Purge all waitlists of a specific team&lt;br /&gt;
# Clear a specific waitlist of all waiting teams&lt;br /&gt;
&lt;br /&gt;
Introduce a waitlist object associated with each topic so that any team that requested it when it was not available would just be queued on the waitlist.  The waitlist would just enqueue ordered pairs〈team_id, topic_id〉&lt;br /&gt;
 &lt;br /&gt;
===Design Pattern===&lt;br /&gt;
As we are decoupling the functionality manipulating waitlists that is scattered across various files and putting it all under a single class the design pattern opted for is Strategy Design Pattern. It is a behavioural design pattern that lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable.  The plan is to isolate the code, internal data, and dependencies of various algorithms related to waitlist from the rest of the code. Various clients now get a simple class to execute the algorithms and switch them at runtime.&lt;br /&gt;
&lt;br /&gt;
'''Tentative list of files to be modified'''&lt;br /&gt;
# sign_up_topic.rb&lt;br /&gt;
# invitation.rb&lt;br /&gt;
# waitlist.rb&lt;br /&gt;
# lottery_controller.rb&lt;br /&gt;
# suggestion_controller.rb &lt;br /&gt;
# signed_up_team.rb&lt;br /&gt;
# student_teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
== UI Test Steps ==&lt;br /&gt;
* Step 1: Signup as an instructor and click on Manage Assignments&lt;br /&gt;
&lt;br /&gt;
[[File:Manage assignments.png|550px]]&lt;br /&gt;
[[File:Add assignment.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 2: Create an assignment with the required configurations and click on create.&lt;br /&gt;
&lt;br /&gt;
[[File:Create assignment.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 3: Post assignment creation, go to manage assignments, and edit the newly created assignment&lt;br /&gt;
&lt;br /&gt;
[[File:Edit new assignment.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 4: Selected the 'has topics' options and create new topics for the students to sign up using the topics tab.&lt;br /&gt;
&lt;br /&gt;
[[File:Has_topics_assignment_option.png|550px]]&lt;br /&gt;
[[File:Create topics.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 5: Add participants to the assignment using the participant tab and then assign the participants to teams using the teams tab and save the changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Add participants and teams.png|550px]]&lt;br /&gt;
[[File:Add teams.png|550px]]&lt;br /&gt;
[[File:Add participants.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 6: Impersonate one student that you had added to one team in the previous step.&lt;br /&gt;
&lt;br /&gt;
[[File:Impersonate user.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 7: In the assignment tabs, choose the assignment that you had created in the previous step and click on sign-up sheet to sign up for a topic. &lt;br /&gt;
&lt;br /&gt;
[[File:Signup_sheet.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 8: Sign up for any topic of your choice. If it is available then you will be assigned the slot and the number of available slots will be updated.&lt;br /&gt;
&lt;br /&gt;
[[File:Student7488 signup.png|550px]]&lt;br /&gt;
[[File:Student7488 signedup.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 9: Impersonate as another student from another team that you had created for the same assignment in the previous steps and follow the same steps as mentioned above to sign up for a topic. Sign up for the same topic as the previously impersonated student.&lt;br /&gt;
&lt;br /&gt;
[[File:Student431 signup.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 10: You will now notice that since there was only one available slot and the previous team already signed up for it, the current team will be added to the waitlist for that topic.&lt;br /&gt;
&lt;br /&gt;
[[File:Student 431 waitlisted.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 11: You can also check the student currently assigned to a topic and the waitlisted students in the manage assignments tab on logging in as an instructor(As done in the previous steps)&lt;br /&gt;
&lt;br /&gt;
[[File:Teams signedup waitlisted.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 12: Following the above mentioned steps various scenarios can be tested via the UI like: &lt;br /&gt;
# Adding more topics&lt;br /&gt;
# Multiple teams signing up for the same topic&lt;br /&gt;
# Teams dropping topics etc.&lt;br /&gt;
&lt;br /&gt;
'''In the current implemention the following issue exists which will be fixed:'''&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1:''' Assigned teams dropping topics&lt;br /&gt;
&lt;br /&gt;
'''Expected Behaviour :'''&lt;br /&gt;
After one team signs up for a topic and the second team that signs up for the same topic is added to the waitlist, if the first team drops the topic, ideally the available slots should be updated and the second team should be assigned the topic since it is the first on the waitlist.&lt;br /&gt;
&lt;br /&gt;
'''Current Issue :'''&lt;br /&gt;
The available slot after one team drops the topic does not update due to which the first team in the waitlist is not automatically assigned the topic.&lt;br /&gt;
[[File:Topic dropped.png|550px]]&lt;br /&gt;
&lt;br /&gt;
'''Proposed Solution :'''&lt;br /&gt;
Implement a new waitlist object to maintain the list of topics and the teams in the waitlist as ordered pairs: 〈team_id, topic_id〉as soon as the first team drops the topic the team_id field will be updated to the second team since it is the first on the waitlist.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2:''' Instructor intervention when assigned teams drops topics&lt;br /&gt;
&lt;br /&gt;
'''Expected Behaviour :'''&lt;br /&gt;
After one team signs up for a topic and the second team that signs up for the same topic is added to the waitlist, if the first team drops the topic, ideally the available slots should be updated and the second team should be assigned the topic since it is the first on the waitlist also we know that the manage topics tab while the instructor edits the assignment also contains the team that is currently assigned the topic and the list of waitlisted teams it should be updated when a change occurs.&lt;br /&gt;
&lt;br /&gt;
'''Current Issue :'''&lt;br /&gt;
The instructor does not see in the manage assignments topics tab that the topic is not assigned to the first team once it chooses to drop it.&lt;br /&gt;
[[File:Teams signedup waitlisted.png|550px]]&lt;br /&gt;
&lt;br /&gt;
'''Proposed Solution :'''&lt;br /&gt;
Since the same functionality of maintaining the waitlist is being done at multiple places, the code does not update for the manage assignments topic tab for the instructor. In order to fix this, implementation of a new waitlist object is done to maintain the list of topics and the teams in the waitlist as ordered pairs: 〈team_id, topic_id〉as soon as the first team drops the topic the team_id field will be updated to the second team since it is the first on the waitlist and the same object will be consumed everywhere. Hence, the manage assignments topic will be updated automatically.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
This project entails code refactoring such that all functionality relevant to waitlist is easily available under one class. Focus is on ensuring existing tests work as expected as the newly added code will not impact functionality per se. However, new unit tests will be written for testing waitlist.rb independently. Furthermore, test cases for suggestion_controller.rb &amp;amp; signed_up_team.rb are missing in the current implementation. Hence, we will be adding spec files for the aforementioned files as well. Certain edge cases will also be tested which have not been covered by the current tests.&lt;br /&gt;
&lt;br /&gt;
'''Test Files'''&lt;br /&gt;
# sign_up_topic_spec.rb&lt;br /&gt;
# invitation_spec.rb&lt;br /&gt;
# waitlist_spec.rb&lt;br /&gt;
# lottery_controller_spec.rb&lt;br /&gt;
# suggestion_controller_spec.rb&lt;br /&gt;
# signed_up_team_spec.rb&lt;br /&gt;
# student_teams_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
'''Cases To Be Tested'''&lt;br /&gt;
# Add team to waitlist if topic isn't available: When a team signs up for a topic already assigned to another team they automatically get added to the waitlist of that topic.&lt;br /&gt;
# Push the first waitlisted member (if exists) in case a confirmed slot is deleted: When a team drops the topic assigned to them or the instructor deletes the assignment of a topic to a particular team then the first team on the waitlist get assigned the topic for that assignment.&lt;br /&gt;
# Remove waitlists for team if a topic is confirmed: Once a team on the waitlists of multiple topics gets assigned a topic, the team is removed from the other waitlists.&lt;br /&gt;
# Clean waitlists &amp;amp; assign topic if the user has a team but not a topic.&lt;br /&gt;
# Remove old team from waitlists.&lt;br /&gt;
&lt;br /&gt;
'''Automated Tests'''&lt;br /&gt;
&lt;br /&gt;
Automated testing can be done using Capybara. Since a major part of the scenario can be tested using the UI, an automated test to create teams and sign up for topics can be created using Capybara with Cucumber. These tests can be written using the TDD approach prior to defining the code.&lt;br /&gt;
&lt;br /&gt;
'''Code Coverage:''' Code coverage for the test cases can be obtained using the Code Coverage plugin and SimpleCov gem. The lines in the functions for which test cases are written in the corresponding spec file are highlighted in green and the rest of the lines are highlighted in red.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.r80b3xxz9peq Problem Statement]&lt;br /&gt;
# [https://github.com/nehajaideep/expertiza Forked Repository]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
* Ankit Singh (asingh072318)&lt;br /&gt;
&lt;br /&gt;
* Asrita Kuchibhotla (kAsrita)&lt;br /&gt;
&lt;br /&gt;
* Neha Kotcherlakota (nehajaideep)&lt;br /&gt;
&lt;br /&gt;
* Vinit Desai (VinitDesai1998)&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=141569</id>
		<title>CSC/ECE 517 Fall 2021 - E2163. Refactor waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=141569"/>
		<updated>2021-11-09T21:23:11Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: /* Control Flow */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza ==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. It also allows the instructor to create a list of topics the students can sign up for. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
When a team requests a topic which is not available, the team is waitlisted for the topic, given that bidding is not in use for the assignment. When another team drops a topic, then a waitlisted team will be assigned the topic, if there are any teams waitlisted for it. Implement a waitlist object associated with each topic, and a team that requested it when it was not available would just be queued on the waitlist. The waitlist would just enqueue ordered pairs〈team_id, topic_id〉&lt;br /&gt;
Currently, the functionality relevant to waitlisting is scattered across the multiple files. These functions need to be consolidated and placed in a single class. &lt;br /&gt;
&lt;br /&gt;
== Control Flow ==&lt;br /&gt;
In the current implementation, multiple models and controllers perform actions that indirectly affect the teams in the waitlist and require to be added or removed from the waitlist. Due to this the same redundant operations of modifying the waitlist is being performed by multiple models and controllers. In order to improve the functionality all the redundant operations being performed on the waitlist need to be moved to the 'waitlist.rb' file and all the other controllers and models will be utilising these methods to manipulate the waitlists.&lt;br /&gt;
Planned implementation: The Context object in our case the waitlist object delegates an algorithm to different Strategy objects to execute waitlist functions as shown below. The Context calls algorithm() on a Strategy1 object, which performs the algorithm and returns the result to Context.&lt;br /&gt;
&lt;br /&gt;
'''Existing Control Flow'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Block diagram waitlist current.png|850px]]&lt;br /&gt;
&lt;br /&gt;
'''Modified Control Flow'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Block diagram waitlist modified.png|850px]]&lt;br /&gt;
&lt;br /&gt;
== Solution Approach == &lt;br /&gt;
&lt;br /&gt;
===Refactoring===&lt;br /&gt;
Goal of the project is to simplify waitlist functionality by moving all the functions manipulating waitlists to waitlist.rb, along with a WaitingTeam class that would consist of a 〈team_id, topic_id〉pair to store information regarding teams on waitlist for a particular topic. Classes should just invoke methods of waitlist.rb for the following functionality: &lt;br /&gt;
# Add themselves to waitlists&lt;br /&gt;
# Add another team to a waitlist&lt;br /&gt;
# Take a team off a waitlist&lt;br /&gt;
# Purge all waitlists of a specific team&lt;br /&gt;
# Clear a specific waitlist of all waiting teams&lt;br /&gt;
&lt;br /&gt;
Introduce a waitlist object associated with each topic so that any team that requested it when it was not available would just be queued on the waitlist.  The waitlist would just enqueue ordered pairs〈team_id, topic_id〉&lt;br /&gt;
 &lt;br /&gt;
===Design Pattern===&lt;br /&gt;
As we are decoupling the functionality manipulating waitlists that is scattered across various files and putting it all under a single class the design pattern opted for is Strategy Design Pattern. It is a behavioral design pattern that lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable.  The plan is to isolate the code, internal data, and dependencies of various algorithms related to waitlist from the rest of the code. Various clients now get a simple class to execute the algorithms and switch them at runtime.&lt;br /&gt;
&lt;br /&gt;
'''Tentative list of files to be modified'''&lt;br /&gt;
# sign_up_topic.rb&lt;br /&gt;
# invitation.rb&lt;br /&gt;
# waitlist.rb&lt;br /&gt;
# lottery_controller.rb&lt;br /&gt;
# suggestion_controller.rb &lt;br /&gt;
# signed_up_team.rb&lt;br /&gt;
# student_teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
== UI Test Steps ==&lt;br /&gt;
* Step 1: Signup as an instructor and click on Manage Assignments&lt;br /&gt;
&lt;br /&gt;
[[File:Manage assignments.png|550px]]&lt;br /&gt;
[[File:Add assignment.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 2: Create an assignment with the required configurations and click on create.&lt;br /&gt;
&lt;br /&gt;
[[File:Create assignment.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 3: Post assignment creation, go to manage assignments, and edit the newly created assignment&lt;br /&gt;
&lt;br /&gt;
[[File:Edit new assignment.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 4: Selected the 'has topics' options and create new topics for the students to sign up using the topics tab.&lt;br /&gt;
&lt;br /&gt;
[[File:Has_topics_assignment_option.png|550px]]&lt;br /&gt;
[[File:Create topics.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 5: Add participants to the assignment using the participant tab and then assign the participants to teams using the teams tab and save the changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Add participants and teams.png|550px]]&lt;br /&gt;
[[File:Add teams.png|550px]]&lt;br /&gt;
[[File:Add participants.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 6: Impersonate one student that you had added to one team in the previous step.&lt;br /&gt;
&lt;br /&gt;
[[File:Impersonate user.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 7: In the assignment tabs, choose the assignment that you had created in the previous step and click on sign-up sheet to sign up for a topic. &lt;br /&gt;
&lt;br /&gt;
[[File:Signup_sheet.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 8: Sign up for any topic of your choice. If it is available then you will be assigned the slot and the number of available slots will be updated.&lt;br /&gt;
&lt;br /&gt;
[[File:Student7488 signup.png|550px]]&lt;br /&gt;
[[File:Student7488 signedup.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 9: Impersonate as another student from another team that you had created for the same assignment in the previous steps and follow the same steps as mentioned above to sign up for a topic. Sign up for the same topic as the previously impersonated student.&lt;br /&gt;
&lt;br /&gt;
[[File:Student431 signup.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 10: You will now notice that since there was only one available slot and the previous team already signed up for it, the current team will be added to the waitlist for that topic.&lt;br /&gt;
&lt;br /&gt;
[[File:Student 431 waitlisted.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 11: You can also check the student currently assigned to a topic and the waitlisted students in the manage assignments tab on logging in as an instructor(As done in the previous steps)&lt;br /&gt;
&lt;br /&gt;
[[File:Teams signedup waitlisted.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 12: Following the above mentioned steps various scenarios can be tested via the UI like: &lt;br /&gt;
# Adding more topics&lt;br /&gt;
# Multiple teams signing up for the same topic&lt;br /&gt;
# Teams dropping topics etc.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
This project entails code refactoring such that all functionality relevant to waitlist is easily available under one class. Focus is on ensuring existing tests work as expected as the newly added code will not impact functionality per se. However, new unit tests will be written for testing waitlist.rb independently. Furthermore, test cases for suggestion_controller.rb &amp;amp; signed_up_team.rb are missing in the current implementation. Hence, we will be adding spec files for the aforementioned files as well. Certain edge cases will also be tested which have not been covered by the current tests.&lt;br /&gt;
&lt;br /&gt;
'''Test Files'''&lt;br /&gt;
# sign_up_topic_spec.rb&lt;br /&gt;
# invitation_spec.rb&lt;br /&gt;
# waitlist_spec.rb&lt;br /&gt;
# lottery_controller_spec.rb&lt;br /&gt;
# suggestion_controller_spec.rb&lt;br /&gt;
# signed_up_team_spec.rb&lt;br /&gt;
# student_teams_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
'''Cases To Be Tested'''&lt;br /&gt;
# Add team to waitlist if topic isn't available.&lt;br /&gt;
# Push the first waitlisted member (if exists) in case a confirmed slot is deleted.&lt;br /&gt;
# Remove waitlists for team if a topic is confirmed.&lt;br /&gt;
# Clean waitlists &amp;amp; assign topic if the user has a team but not a topic.&lt;br /&gt;
# Remove old team from waitlists.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.r80b3xxz9peq Problem Statement]&lt;br /&gt;
# [https://github.com/nehajaideep/expertiza Forked Repository]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
* Ankit Singh (asingh072318)&lt;br /&gt;
&lt;br /&gt;
* Asrita Kuchibhotla (kAsrita)&lt;br /&gt;
&lt;br /&gt;
* Neha Kotcherlakota (nehajaideep)&lt;br /&gt;
&lt;br /&gt;
* Vinit Desai (VinitDesai1998)&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=141568</id>
		<title>CSC/ECE 517 Fall 2021 - E2163. Refactor waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=141568"/>
		<updated>2021-11-09T21:05:17Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: /* Design Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza ==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. It also allows the instructor to create a list of topics the students can sign up for. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
When a team requests a topic which is not available, the team is waitlisted for the topic, given that bidding is not in use for the assignment. When another team drops a topic, then a waitlisted team will be assigned the topic, if there are any teams waitlisted for it. Implement a waitlist object associated with each topic, and a team that requested it when it was not available would just be queued on the waitlist. The waitlist would just enqueue ordered pairs〈team_id, topic_id〉&lt;br /&gt;
Currently, the functionality relevant to waitlisting is scattered across the multiple files. These functions need to be consolidated and placed in a single class. &lt;br /&gt;
&lt;br /&gt;
== Control Flow ==&lt;br /&gt;
In the current implementation, multiple models and controllers perform actions that indirectly affect the teams in the waitlist and require to be added or removed from the waitlist. Due to this the same redundant operations of modifying the waitlist is being performed by multiple models and controllers. In order to improve the functionality all the redundant operations being performed on the waitlist need to be moved to the 'waitlist.rb' file and all the other controllers and models will be utilising these methods to manipulate the waitlists.&lt;br /&gt;
&lt;br /&gt;
'''Existing Control Flow'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Block diagram waitlist current.png|850px]]&lt;br /&gt;
&lt;br /&gt;
'''Modified Control Flow'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Block diagram waitlist modified.png|850px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution Approach == &lt;br /&gt;
&lt;br /&gt;
===Refactoring===&lt;br /&gt;
Goal of the project is to simplify waitlist functionality by moving all the functions manipulating waitlists to waitlist.rb, along with a WaitingTeam class that would consist of a 〈team_id, topic_id〉pair to store information regarding teams on waitlist for a particular topic. Classes should just invoke methods of waitlist.rb for the following functionality: &lt;br /&gt;
# Add themselves to waitlists&lt;br /&gt;
# Add another team to a waitlist&lt;br /&gt;
# Take a team off a waitlist&lt;br /&gt;
# Purge all waitlists of a specific team&lt;br /&gt;
# Clear a specific waitlist of all waiting teams&lt;br /&gt;
&lt;br /&gt;
Introduce a waitlist object associated with each topic so that any team that requested it when it was not available would just be queued on the waitlist.  The waitlist would just enqueue ordered pairs〈team_id, topic_id〉&lt;br /&gt;
 &lt;br /&gt;
===Design Pattern===&lt;br /&gt;
As we are decoupling the functionality manipulating waitlists that is scattered across various files and putting it all under a single class the design pattern opted for is Strategy Design Pattern. It is a behavioral design pattern that lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable.  The plan is to isolate the code, internal data, and dependencies of various algorithms related to waitlist from the rest of the code. Various clients now get a simple class to execute the algorithms and switch them at runtime.&lt;br /&gt;
&lt;br /&gt;
'''Tentative list of files to be modified'''&lt;br /&gt;
# sign_up_topic.rb&lt;br /&gt;
# invitation.rb&lt;br /&gt;
# waitlist.rb&lt;br /&gt;
# lottery_controller.rb&lt;br /&gt;
# suggestion_controller.rb &lt;br /&gt;
# signed_up_team.rb&lt;br /&gt;
# student_teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
== UI Test Steps ==&lt;br /&gt;
* Step 1: Signup as an instructor and click on Manage Assignments&lt;br /&gt;
&lt;br /&gt;
[[File:Manage assignments.png|550px]]&lt;br /&gt;
[[File:Add assignment.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 2: Create an assignment with the required configurations and click on create.&lt;br /&gt;
&lt;br /&gt;
[[File:Create assignment.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 3: Post assignment creation, go to manage assignments, and edit the newly created assignment&lt;br /&gt;
&lt;br /&gt;
[[File:Edit new assignment.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 4: Selected the 'has topics' options and create new topics for the students to sign up using the topics tab.&lt;br /&gt;
&lt;br /&gt;
[[File:Has_topics_assignment_option.png|550px]]&lt;br /&gt;
[[File:Create topics.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 5: Add participants to the assignment using the participant tab and then assign the participants to teams using the teams tab and save the changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Add participants and teams.png|550px]]&lt;br /&gt;
[[File:Add teams.png|550px]]&lt;br /&gt;
[[File:Add participants.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 6: Impersonate one student that you had added to one team in the previous step.&lt;br /&gt;
&lt;br /&gt;
[[File:Impersonate user.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 7: In the assignment tabs, choose the assignment that you had created in the previous step and click on sign-up sheet to sign up for a topic. &lt;br /&gt;
&lt;br /&gt;
[[File:Signup_sheet.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 8: Sign up for any topic of your choice. If it is available then you will be assigned the slot and the number of available slots will be updated.&lt;br /&gt;
&lt;br /&gt;
[[File:Student7488 signup.png|550px]]&lt;br /&gt;
[[File:Student7488 signedup.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 9: Impersonate as another student from another team that you had created for the same assignment in the previous steps and follow the same steps as mentioned above to sign up for a topic. Sign up for the same topic as the previously impersonated student.&lt;br /&gt;
&lt;br /&gt;
[[File:Student431 signup.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 10: You will now notice that since there was only one available slot and the previous team already signed up for it, the current team will be added to the waitlist for that topic.&lt;br /&gt;
&lt;br /&gt;
[[File:Student 431 waitlisted.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 11: You can also check the student currently assigned to a topic and the waitlisted students in the manage assignments tab on logging in as an instructor(As done in the previous steps)&lt;br /&gt;
&lt;br /&gt;
[[File:Teams signedup waitlisted.png|550px]]&lt;br /&gt;
&lt;br /&gt;
* Step 12: Following the above mentioned steps various scenarios can be tested via the UI like: &lt;br /&gt;
# Adding more topics&lt;br /&gt;
# Multiple teams signing up for the same topic&lt;br /&gt;
# Teams dropping topics etc.&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
This project entails code refactoring such that all functionality relevant to waitlist is easily available under one class. Focus is on ensuring existing tests work as expected as the newly added code will not impact functionality per se. However, new unit tests will be written for testing waitlist.rb independently. Furthermore, test cases for suggestion_controller.rb &amp;amp; signed_up_team.rb are missing in the current implementation. Hence, we will be adding spec files for the aforementioned files as well. Certain edge cases will also be tested which have not been covered by the current tests.&lt;br /&gt;
&lt;br /&gt;
'''Test Files'''&lt;br /&gt;
# sign_up_topic_spec.rb&lt;br /&gt;
# invitation_spec.rb&lt;br /&gt;
# waitlist_spec.rb&lt;br /&gt;
# lottery_controller_spec.rb&lt;br /&gt;
# suggestion_controller_spec.rb&lt;br /&gt;
# signed_up_team_spec.rb&lt;br /&gt;
# student_teams_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
'''Cases To Be Tested'''&lt;br /&gt;
# Add team to waitlist if topic isn't available.&lt;br /&gt;
# Push the first waitlisted member (if exists) in case a confirmed slot is deleted.&lt;br /&gt;
# Remove waitlists for team if a topic is confirmed.&lt;br /&gt;
# Clean waitlists &amp;amp; assign topic if the user has a team but not a topic.&lt;br /&gt;
# Remove old team from waitlists.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.r80b3xxz9peq Problem Statement]&lt;br /&gt;
# [https://github.com/nehajaideep/expertiza Forked Repository]&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
* Ankit Singh (asingh072318)&lt;br /&gt;
&lt;br /&gt;
* Asrita Kuchibhotla (kAsrita)&lt;br /&gt;
&lt;br /&gt;
* Neha Kotcherlakota (nehajaideep)&lt;br /&gt;
&lt;br /&gt;
* Vinit Desai (VinitDesai1998)&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=140706</id>
		<title>CSC/ECE 517 Fall 2021 - E2163. Refactor waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=140706"/>
		<updated>2021-11-03T22:37:56Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza ==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. It also allows the instructor to create a list of topics the students can sign up for. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
When a team requests a topic which is not available, the team is waitlisted for the topic, given that bidding is not in use for the assignment. When another team drops a topic, then a waitlisted team will be assigned the topic, if there are any teams waitlisted for it. Implement a waitlist object associated with each topic, and a team that requested it when it was not available would just be queued on the waitlist. The waitlist would just enqueue ordered pairs〈team_id, topic_id〉&lt;br /&gt;
Currently, the functionality relevant to waitlisting is scattered across the multiple files. These functions need to be consolidated and placed in a single class. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Control Flow ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution Approach == &lt;br /&gt;
&lt;br /&gt;
===  Refactoring ===&lt;br /&gt;
Goal of the project is to simplify waitlist functionality by moving all the functions manipulating waitlists to waitlist.rb, along with a WaitingTeam class that would consist of a 〈team_id, topic_id〉pair to store information regarding teams on waitlist for a particular topic. Classes should just invoke methods of waitlist.rb for the following functionality: &lt;br /&gt;
# Add themselves to waitlists&lt;br /&gt;
# Add another team to a waitlist&lt;br /&gt;
# Take a team off a waitlist&lt;br /&gt;
# Purge all waitlists of a specific team&lt;br /&gt;
# Clear a specific waitlist of all waiting teams&lt;br /&gt;
&lt;br /&gt;
Introduce a waitlist object associated with each topic so that any team that requested it when it was not available would just be queued on the waitlist.  The waitlist would just enqueue ordered pairs〈team_id, topic_id〉&lt;br /&gt;
 &lt;br /&gt;
=== Design Pattern ===&lt;br /&gt;
As we are decoupling the functionality manipulating waitlists that is scattered across various files and putting it all under a single class the design pattern opted for is Strategy Design Pattern. It is a behavioral design pattern that lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable.  &lt;br /&gt;
&lt;br /&gt;
=== Tentative list of files to be modified === &lt;br /&gt;
# sign_up_topic.rb&lt;br /&gt;
# invitation.rb&lt;br /&gt;
# waitlist.rb&lt;br /&gt;
# suggestion_controller.rb &lt;br /&gt;
# signed_up_team.rb&lt;br /&gt;
# student_teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
This project entails code refactoring such that all functionality relevant to wailtist is easily available under one class. Focus is on ensuring existing tests work as expected as the newly added code will not impact functionality per se.&lt;br /&gt;
&lt;br /&gt;
=== Test Files ===&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.r80b3xxz9peq Problem Statement]&lt;br /&gt;
# [https://github.com/nehajaideep/expertiza Forked Repository]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
* Ankit Singh (asingh072318)&lt;br /&gt;
&lt;br /&gt;
* Asrita Kuchibhotla (kAsrita)&lt;br /&gt;
&lt;br /&gt;
* Neha Kotcherlakota (nehajaideep)&lt;br /&gt;
&lt;br /&gt;
* Vinit Desai (VinitDesai1998)&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=140697</id>
		<title>CSC/ECE 517 Fall 2021 - E2163. Refactor waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=140697"/>
		<updated>2021-11-03T22:30:05Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About Expertiza ==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. It also allows the instructor to create a list of topics the students can sign up for. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
When a team requests a topic which is not available, the team is waitlisted for the topic, given that bidding is not in use for the assignment. When another team drops a topic, then a waitlisted team will be assigned the topic, if there are any teams waitlisted for it. Implement a waitlist object associated with each topic, and a team that requested it when it was not available would just be queued on the waitlist. The waitlist would just enqueue ordered pairs〈team_id, topic_id〉 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Control Flow ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution Approach == &lt;br /&gt;
&lt;br /&gt;
===  Refactoring ===&lt;br /&gt;
Goal of the project is to simplify waitlist functionality by moving all the functions manipulating waitlists to waitlist.rb, along with a WaitingTeam class that would consist of a 〈team_id, topic_id〉pair to store information regarding teams on waitlist for a particular topic. Classes should just invoke methods of waitlist.rb for the following functionality: &lt;br /&gt;
# Add themselves to waitlists&lt;br /&gt;
# Add another team to a waitlist&lt;br /&gt;
# Take a team off a waitlist&lt;br /&gt;
# Purge all waitlists of a specific team&lt;br /&gt;
# Clear a specific waitlist of all waiting teams&lt;br /&gt;
&lt;br /&gt;
Introduce a waitlist object associated with each topic so that any team that requested it when it was not available would just be queued on the waitlist.  The waitlist would just enqueue ordered pairs〈team_id, topic_id〉&lt;br /&gt;
 &lt;br /&gt;
=== Design Pattern ===&lt;br /&gt;
As we are decoupling the functionality manipulating waitlists that is scattered across various files and putting it all under a single class the design pattern opted for Strategy Design Pattern. is a behavioral design pattern that lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable. &lt;br /&gt;
=== Tentative list of files to be modified === &lt;br /&gt;
# sign_up_topic.rb&lt;br /&gt;
# invitation.rb&lt;br /&gt;
# waitlist.rb&lt;br /&gt;
# suggestion_controller.rb &lt;br /&gt;
# signed_up_team.rb&lt;br /&gt;
# student_teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
This project entails code refactoring such that all functionality relevant to wailtist is easily available under one class. Focus is on ensuring existing tests work as expected as the newly added code will not impact functionality per se.&lt;br /&gt;
&lt;br /&gt;
=== Test Files ===&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.r80b3xxz9peq Problem Statement]&lt;br /&gt;
# [https://github.com/nehajaideep/expertiza Forked Repository]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
* Ankit Singh (asingh072318)&lt;br /&gt;
&lt;br /&gt;
* Asrita Kuchibhotla (kAsrita)&lt;br /&gt;
&lt;br /&gt;
* Neha Kotcherlakota (nehajaideep)&lt;br /&gt;
&lt;br /&gt;
* Vinit Desai (VinitDesai1998)&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=140693</id>
		<title>CSC/ECE 517 Fall 2021 - E2163. Refactor waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=140693"/>
		<updated>2021-11-03T22:26:14Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Expertiza Background ==&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==&lt;br /&gt;
When a team requests a topic which is not available, the team is waitlisted for the topic, given that bidding is not in use for the assignment. When another team drops a topic, then a waitlisted team will be assigned the topic, if there are any teams waitlisted for it. Implement a waitlist object associated with each topic, and a team that requested it when it was not available would just be queued on the waitlist. The waitlist would just enqueue ordered pairs〈team_id, topic_id〉 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Control Flow ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution Approach == &lt;br /&gt;
&lt;br /&gt;
===  Refactoring ===&lt;br /&gt;
Goal of the project is to simplify waitlist functionality by moving all the functions manipulating waitlists to waitlist.rb, along with a WaitingTeam class that would consist of a 〈team_id, topic_id〉pair to store information regarding teams on waitlist for a particular topic. Classes should just invoke methods of waitlist.rb for the following functionality: &lt;br /&gt;
# Add themselves to waitlists&lt;br /&gt;
# Add another team to a waitlist&lt;br /&gt;
# Take a team off a waitlist&lt;br /&gt;
# Purge all waitlists of a specific team&lt;br /&gt;
# Clear a specific waitlist of all waiting teams&lt;br /&gt;
&lt;br /&gt;
Introduce a waitlist object associated with each topic so that any team that requested it when it was not available would just be queued on the waitlist.  The waitlist would just enqueue ordered pairs〈team_id, topic_id〉&lt;br /&gt;
 &lt;br /&gt;
=== Design Pattern ===&lt;br /&gt;
As we are decoupling the functionality manipulating waitlists that is scattered across various files and putting it all under a single class the design pattern opted for Strategy Design Pattern. is a behavioral design pattern that lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable. &lt;br /&gt;
=== Tentative list of files to be modified === &lt;br /&gt;
# sign_up_topic.rb&lt;br /&gt;
# invitation.rb&lt;br /&gt;
# waitlist.rb&lt;br /&gt;
# suggestion_controller.rb &lt;br /&gt;
# signed_up_team.rb&lt;br /&gt;
# student_teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
This project entails code refactoring such that all functionality relevant to wailtist is easily available under one class. Focus is on ensuring existing tests work as expected as the newly added code will not impact functionality per se.&lt;br /&gt;
&lt;br /&gt;
=== Test Files ===&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.r80b3xxz9peq Problem Statement]&lt;br /&gt;
# [https://github.com/nehajaideep/expertiza Forked Repository]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
* Ankit Singh (asingh072318)&lt;br /&gt;
&lt;br /&gt;
* Asrita Kuchibhotla (kAsrita)&lt;br /&gt;
&lt;br /&gt;
* Neha Kotcherlakota (nehajaideep)&lt;br /&gt;
&lt;br /&gt;
* Vinit Desai (VinitDesai1998)&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=140679</id>
		<title>CSC/ECE 517 Fall 2021 - E2163. Refactor waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=140679"/>
		<updated>2021-11-03T22:13:03Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Problem Statement ==&lt;br /&gt;
When a team requests a topic which is not available, the team is waitlisted for the topic, given that bidding is not in use for the assignment. When another team drops a topic, then a waitlisted team will be assigned the topic, if there are any teams waitlisted for it. Implement a waitlist object associated with each topic, and a team that requested it when it was not available would just be queued on the waitlist. The waitlist would just enqueue ordered pairs〈team_id, topic_id〉 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Control Flow ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution Approach == &lt;br /&gt;
&lt;br /&gt;
===  Refactoring ===&lt;br /&gt;
Goal of the project is to simplify waitlist functionality by moving all the functions manipulating waitlists to waitlist.rb, along with a WaitingTeam class that would consist of a 〈team_id, topic_id〉pair to store information regarding teams on waitlist for a particular topic. Classes should just invoke methods of waitlist.rb for the following functionality: &lt;br /&gt;
# Add themselves to waitlists&lt;br /&gt;
# Add another team to a waitlist&lt;br /&gt;
# Take a team off a waitlist&lt;br /&gt;
# Purge all waitlists of a specific team&lt;br /&gt;
# Clear a specific waitlist of all waiting teams&lt;br /&gt;
&lt;br /&gt;
Introduce a waitlist object associated with each topic so that any team that requested it when it was not available would just be queued on the waitlist.  The waitlist would just enqueue ordered pairs〈team_id, topic_id〉&lt;br /&gt;
 &lt;br /&gt;
=== Design Pattern ===&lt;br /&gt;
Strategy is a behavioral design pattern that lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable. &lt;br /&gt;
=== Tentative list of files to be modified === &lt;br /&gt;
# sign_up_topic.rb&lt;br /&gt;
# invitation.rb&lt;br /&gt;
# waitlist.rb&lt;br /&gt;
# suggestion_controller.rb &lt;br /&gt;
# signed_up_team.rb&lt;br /&gt;
# student_teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
This project entails code refactoring such that all functionality relevant to wailtist is easily available under one class. Focus is on ensuring existing tests work as expected as the newly added code will not impact functionality per se.&lt;br /&gt;
&lt;br /&gt;
=== Test Files ===&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.r80b3xxz9peq Problem Statement]&lt;br /&gt;
# [https://github.com/nehajaideep/expertiza Forked Repository]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
* Ankit Singh (asingh072318)&lt;br /&gt;
&lt;br /&gt;
* Asrita Kuchibhotla (kAsrita)&lt;br /&gt;
&lt;br /&gt;
* Neha Kotcherlakota (nehajaideep)&lt;br /&gt;
&lt;br /&gt;
* Vinit Desai (VinitDesai1998)&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=140665</id>
		<title>CSC/ECE 517 Fall 2021 - E2163. Refactor waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=140665"/>
		<updated>2021-11-03T21:54:18Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Problem Statement ==&lt;br /&gt;
When a team requests a topic which is not available, the team is waitlisted for the topic, given that bidding is not in use for the assignment. When another team drops a topic, then a waitlisted team will be assigned the topic, if there are any teams waitlisted for it. Implement a waitlist object associated with each topic, and a team that requested it when it was not available would just be queued on the waitlist. The waitlist would just enqueue ordered pairs〈team_id, topic_id〉 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Control Flow ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution Approach == &lt;br /&gt;
&lt;br /&gt;
===  Refactoring ===&lt;br /&gt;
Have a waitlist object associated with each topic, and a team that requested it when it was not available would just be queued on the waitlist.  The waitlist would just enqueue ordered pairs〈team_id, topic_id〉&lt;br /&gt;
&lt;br /&gt;
=== Design Pattern ===&lt;br /&gt;
Strategy is a behavioral design pattern that lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable. &lt;br /&gt;
=== Tentative list of files to be modified === &lt;br /&gt;
# sign_up_topic.rb&lt;br /&gt;
# invitation.rb&lt;br /&gt;
# waitlist.rb&lt;br /&gt;
# suggestion_controller.rb &lt;br /&gt;
# signed_up_team.rb&lt;br /&gt;
# student_teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
This project entails code refactoring such that all functionality relevant to wailtist is easily available under one class. Focus is on ensuring existing tests work as expected as the newly added code will not impact functionality per se.&lt;br /&gt;
&lt;br /&gt;
=== Test Files ===&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.r80b3xxz9peq Problem Statement]&lt;br /&gt;
# [https://github.com/nehajaideep/expertiza Forked Repository]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
* Ankit Singh (asingh072318)&lt;br /&gt;
&lt;br /&gt;
* Asrita Kuchibhotla (kAsrita)&lt;br /&gt;
&lt;br /&gt;
* Neha Kotcherlakota (nehajaideep)&lt;br /&gt;
&lt;br /&gt;
* Vinit Desai (VinitDesai1998)&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=140664</id>
		<title>CSC/ECE 517 Fall 2021 - E2163. Refactor waitlist functionality</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality&amp;diff=140664"/>
		<updated>2021-11-03T21:53:24Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: Created page with &amp;quot;== Problem Statement == When a team requests a topic which is not available, the team is waitlisted for the topic, given that bidding is not in use for the assignment. When an...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Problem Statement ==&lt;br /&gt;
When a team requests a topic which is not available, the team is waitlisted for the topic, given that bidding is not in use for the assignment. When another team drops a topic, then a waitlisted team will be assigned the topic, if there are any teams waitlisted for it. Implement a waitlist object associated with each topic, and a team that requested it when it was not available would just be queued on the waitlist. The waitlist would just enqueue ordered pairs〈team_id, topic_id〉 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Control Flow ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Solution Approach == &lt;br /&gt;
&lt;br /&gt;
===  Refactoring ===&lt;br /&gt;
Have a waitlist object associated with each topic, and a team that requested it when it was not available would just be queued on the waitlist.  The waitlist would just enqueue ordered pairs〈team_id, topic_id〉&lt;br /&gt;
&lt;br /&gt;
=== Design Pattern ===&lt;br /&gt;
Strategy is a behavioral design pattern that lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable. &lt;br /&gt;
=== Tentative list of files to be modified === &lt;br /&gt;
# sign_up_topic.rb&lt;br /&gt;
# invitation.rb&lt;br /&gt;
# waitlist.rb&lt;br /&gt;
# suggestion_controller.rb &lt;br /&gt;
# signed_up_team.rb&lt;br /&gt;
# student_teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
This project entails code refactoring such that all functionality relevant to wailtist is easily available under one class. Focus is on ensuring existing tests work as expected as the newly added code will not impact functionality per se.&lt;br /&gt;
&lt;br /&gt;
=== Test Files ===&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
# https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.r80b3xxz9peq [Problem Statement]&lt;br /&gt;
# https://github.com/nehajaideep/expertiza (Forked Repository)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Team ==&lt;br /&gt;
&lt;br /&gt;
* Ankit Singh (asingh072318)&lt;br /&gt;
&lt;br /&gt;
* Asrita Kuchibhotla (kAsrita)&lt;br /&gt;
&lt;br /&gt;
* Neha Kotcherlakota (nehajaideep)&lt;br /&gt;
&lt;br /&gt;
* Vinit Desai (VinitDesai1998)&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=140642</id>
		<title>CSC/ECE 517 Fall 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=140642"/>
		<updated>2021-11-03T21:09:59Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: /* Final Projects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OSS Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2117. Refactor questionaires_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2128. Refactor student_quizzes_controller.rb &amp;amp; late_policies_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2129. Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2132. Add tests cases for review mapping helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2134. Write unit tests for admin_controller.rb and institution_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2138. Auto-generate submission directory names based on assignment]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2133. Write tests for popup_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2120. Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2139. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2131. Improve assessment360_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2121. Refactor suggestion_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2122. Refactor impersonate_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2123. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2126. Refactor account_request_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2124. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2125. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2127. Refactor teams_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2130. Refactor submitted_content_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2140. Create new late policy successfully and fix Bank link]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2141. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2144. Refactor delayed mailer and scheduled task]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2147. Role-based reviewing]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2145. OSS Project Beige]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2146. Introduce a Student View for instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - Refactor Evaluation of SQL Queries]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2135. Email notification to reviewers and instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2168. Testing - Reputations]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations]]&lt;br /&gt;
&lt;br /&gt;
== Final Projects ==&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades#Description_about_project CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring_and_Grades]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2150._Integrate_suggestion_detection_algorithm#Description_about_project CSC/ECE 517 Fall 2021 - E2150. Integrate suggestion detection algorithm]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2152._Revision_planning_tool#Description_about_project CSC/ECE 517 Fall 2021 - E2152. Revision_planning_tool]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2170._Testing_-_Response_Maps#Description_about_project CSC/ECE 517 Fall 2021 - E2170. Testing - Response Maps]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2153._Improving_search_facility_in_Expertiza#Description_about_project CSC/ECE 517 Fall 2021 - E2153. Improving search facility in Expertiza]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper CSC/ECE 517 Fall 2021 - E2162. Further refactoring and improvement of review mapping helper]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2163._Refactor_waitlist_functionality CSC/ECE 517 Fall 2021 - E2163.  Refactor waitlist functionality]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2165._Fix_teammate-review_view CSC/ECE 517 Fall 2021 - E2165. Fix teammate review view ]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2155._Calibration_submissions_should_be_copied_along_with_calibration_assignments CSC/ECE 517 Fall 2021 - E2155. Calibration submissions should be copied along with calibration assignments]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2148._Completion/Progress_View CSC/ECE 517 Fall 2021 - E2148. Completion/Progress view]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2158._Grading_audit_trail CSC/ECE 517 Fall 2021 - E2158. Grading audit trail ]&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2160._Implementing_and_testing_import_export_controllers#Description_about_project CSC/ECE 517 Fall 2021 - E2160. Implementing and testing import and export controllers]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2164._Heatgrid_fixes_and_improvements#Description_about_project CSC/ECE 517 Fall 2021 - E2164. Heatgrid fixes and improvements]&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=140640</id>
		<title>CSC/ECE 517 Fall 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=140640"/>
		<updated>2021-11-03T21:05:46Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: /* Final Projects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OSS Projects ==&lt;br /&gt;
&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2117. Refactor questionaires_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2128. Refactor student_quizzes_controller.rb &amp;amp; late_policies_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2129. Refactor auth_controller.rb &amp;amp; password_retrieval_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2132. Add tests cases for review mapping helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2134. Write unit tests for admin_controller.rb and institution_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2138. Auto-generate submission directory names based on assignment]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2133. Write tests for popup_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2120. Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2139. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2131. Improve assessment360_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2121. Refactor suggestion_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2122. Refactor impersonate_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2123. Refactor sign_up_sheet_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2126. Refactor account_request_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2124. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2125. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2127. Refactor teams_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2130. Refactor submitted_content_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2140. Create new late policy successfully and fix Bank link]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2141. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2144. Refactor delayed mailer and scheduled task]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2147. Role-based reviewing]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2145. OSS Project Beige]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2146. Introduce a Student View for instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - Refactor Evaluation of SQL Queries]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2135. Email notification to reviewers and instructors]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2168. Testing - Reputations]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2149. Finish Github metrics integration - Reputations]]&lt;br /&gt;
&lt;br /&gt;
== Final Projects ==&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2166._Testing_-_Scoring_%26_Grades#Description_about_project CSC/ECE 517 Fall 2021 - E2166. Testing - Scoring_and_Grades]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2150._Integrate_suggestion_detection_algorithm#Description_about_project CSC/ECE 517 Fall 2021 - E2150. Integrate suggestion detection algorithm]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2151._Allow_reviewers_to_bid_on_what_to_review CSC/ECE 517 Fall 2021 - E2151. Allow reviewers to bid on what to review]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2152._Revision_planning_tool#Description_about_project CSC/ECE 517 Fall 2021 - E2152. Revision_planning_tool]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2170._Testing_-_Response_Maps#Description_about_project CSC/ECE 517 Fall 2021 - E2170. Testing - Response Maps]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2153._Improving_search_facility_in_Expertiza#Description_about_project CSC/ECE 517 Fall 2021 - E2153. Improving search facility in Expertiza]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2162._Further_refactoring_and_improvement_of_review_mapping_helper CSC/ECE 517 Fall 2021 - E2162. Further refactoring and improvement of review mapping helper]&lt;br /&gt;
* [https://docs.google.com/document/d/1slx4HPIbgTH-psIKMSCF-HDF9brxf-FuYhzVT9ZiIrM/edit#heading=h.r80b3xxz9peq CSC/ECE 517 Fall 2021 - E2163.  Refactor waitlist functionality]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2165._Fix_teammate-review_view CSC/ECE 517 Fall 2021 - E2165. Fix teammate review view ]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2155._Calibration_submissions_should_be_copied_along_with_calibration_assignments CSC/ECE 517 Fall 2021 - E2155. Calibration submissions should be copied along with calibration assignments]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2148._Completion/Progress_View CSC/ECE 517 Fall 2021 - E2148. Completion/Progress view]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2158._Grading_audit_trail CSC/ECE 517 Fall 2021 - E2158. Grading audit trail ]&lt;br /&gt;
*[https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2159._Expertiza_internationalization CSC/ECE 517 Fall 2021 - E2159. Expertiza internationalization]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2160._Implementing_and_testing_import_export_controllers#Description_about_project CSC/ECE 517 Fall 2021 - E2160. Implementing and testing import and export controllers]&lt;br /&gt;
* [https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2021_-_E2164._Heatgrid_fixes_and_improvements#Description_about_project CSC/ECE 517 Fall 2021 - E2164. Heatgrid fixes and improvements]&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=140221</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=140221"/>
		<updated>2021-10-27T03:23:38Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' '''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar function adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction of modular code in order to make each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
==Problems and Solutions ==&lt;br /&gt;
* '''Problem 1''': action_allowed method should be changed to use new_access_control methods. &lt;br /&gt;
:The original code does not make use of the new access control methods which are a part of the authorization_helper.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    ['Instructor',&lt;br /&gt;
     'Teaching Assistant',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Super-Administrator',&lt;br /&gt;
     'Student'].include? current_role_name and&lt;br /&gt;
    ((%w[edit].include? action_name) ? are_needed_authorizations_present?(params[:id], &amp;quot;reader&amp;quot;, &amp;quot;reviewer&amp;quot;) : true) and&lt;br /&gt;
    one_team_can_submit_work?&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* '''Solution''': On using the new access control methods: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def action_allowed?&lt;br /&gt;
    if %w[edit update list_submissions].include? params[:action]&lt;br /&gt;
      current_user_has_admin_privileges? || current_user_teaching_staff_of_assignment?(params[:id])&lt;br /&gt;
    else&lt;br /&gt;
      current_user_has_ta_privileges?&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'edit'&lt;br /&gt;
      current_user_has_student_privileges? &amp;amp;&amp;amp;&lt;br /&gt;
      are_needed_authorizations_present?(params[:id], &amp;quot;reader&amp;quot;, &amp;quot;reviewer&amp;quot;)&lt;br /&gt;
    when 'submit_file', 'submit_hyperlink'&lt;br /&gt;
      current_user_has_student_privileges? &amp;amp;&amp;amp;&lt;br /&gt;
      one_team_can_submit_work?&lt;br /&gt;
    else&lt;br /&gt;
      current_user_has_student_privileges?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. '''Problem 2''': Remove the comment  “# hence use team count for the check”.&lt;br /&gt;
::The current code no longer checks for the team count to see if a participant belongs to a team. Comment on line #19 removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. '''Problem 3''': Change the method name view to something more informative of the method.&lt;br /&gt;
:The original code uses the generic 'view' method name to display a view corresponding to a case when submissions cannot be accepted, for instance in the case when a deadline is passed. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def view&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* '''Solution''': We found changing the name to disable_submission to be more apt in this case&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def disable_submission&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. '''Problem 4''': submit_hyperlink is filled with a lot of logging code.&lt;br /&gt;
:Logging is essential to understand the behavior of the application and to debug unexpected issues or for simply tracking events as in the production environment, we can’t debug issues without proper log files.&lt;br /&gt;
* '''Solution''': We added a function for the sole purpose of logging so that it can be reused wherever required.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def log_info(controller_name, participant_name, message, request)&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, participant_name, message, request)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. '''Problem 5''': Check the validity of the comment ”# Note: This is not used yet in the view until we all decide to do so”.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': The function to remove_hyperlink performs as expected, hence the comment is no longer valid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. '''Problem 6''': submit_file method is long.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': Implemented modular code by separating the function into simpler functions.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def tested&lt;br /&gt;
    @current_folder = DisplayOption.new&lt;br /&gt;
    @current_folder.name = &amp;quot;/&amp;quot;&lt;br /&gt;
    @current_folder.name = FileHelper.sanitize_folder(params[:current_folder][:name]) if params[:current_folder]&lt;br /&gt;
    curr_directory = if params[:origin] == 'review'&lt;br /&gt;
                       participant.review_file_path(params[:response_map_id]).to_s + @current_folder.name&lt;br /&gt;
                     else&lt;br /&gt;
                       participant.team.path.to_s + @current_folder.name&lt;br /&gt;
                     end&lt;br /&gt;
    return curr_directory&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. '''Problem 7''': Move mail_assigned_reviewers to a mailer class.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': Moved the mail_assigned_reviewers to mailer_helper.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def self.mail_assigned_reviewers(team)&lt;br /&gt;
    maps = ResponseMap.where(reviewed_object_id: @participant.assignment.id, reviewee_id: team.id, type: 'ReviewResponseMap')&lt;br /&gt;
    unless maps.nil?&lt;br /&gt;
      maps.each do |map|&lt;br /&gt;
        # Mailing function&lt;br /&gt;
        Mailer.general_email(&lt;br /&gt;
          to: User.find(Participant.find(map.reviewer_id).user_id).email,&lt;br /&gt;
          subject:  &amp;quot;Link to update the review for Assignment '#{@participant.assignment.name}'&amp;quot;,&lt;br /&gt;
          cc: User.find_by(@participant.assignment.instructor_id).email,&lt;br /&gt;
          link: &amp;quot;Link: https://expertiza.ncsu.edu/response/new?id=#{map.id}&amp;quot;,&lt;br /&gt;
          assignment: @participant.assignment.name&lt;br /&gt;
        ).deliver_now&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. '''Problem 8''': Change the method name of folder_action.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': Renamed folder_action to perform_folder_action. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def perform_folder_action&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @current_folder = DisplayOption.new&lt;br /&gt;
    @current_folder.name = &amp;quot;/&amp;quot;&lt;br /&gt;
    @current_folder.name = FileHelper.sanitize_folder(params[:current_folder][:name]) if params[:current_folder]&lt;br /&gt;
    if params[:faction][:delete]&lt;br /&gt;
      SubmittedFiles.delete_selected_files&lt;br /&gt;
    elsif params[:faction][:rename]&lt;br /&gt;
      SubmittedFiles.rename_selected_file&lt;br /&gt;
    elsif params[:faction][:move]&lt;br /&gt;
      SubmittedFiles.move_selected_file&lt;br /&gt;
    elsif params[:faction][:copy]&lt;br /&gt;
      SubmittedFiles.copy_selected_file&lt;br /&gt;
    elsif params[:faction][:create]&lt;br /&gt;
      create_new_folder&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'edit', id: @participant.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. '''Problem 9''': Some of the actions in the code (from line 187 to 247) could perhaps be moved to another class&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': Separated functions related to submission of files into a new helper class called submitted_files_helper.rb.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module SubmittedFiles&lt;br /&gt;
&lt;br /&gt;
def move_selected_file&lt;br /&gt;
  old_filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
  newloc = @participant.dir_path&lt;br /&gt;
  newloc += &amp;quot;/&amp;quot;&lt;br /&gt;
  newloc += params[:faction][:move]&lt;br /&gt;
  begin&lt;br /&gt;
      FileHelper.move_file(old_filename, newloc)&lt;br /&gt;
      flash[:note] = &amp;quot;The file was successfully moved from \&amp;quot;/#{params[:filenames][params[:chk_files]]}\&amp;quot; to \&amp;quot;/#{params[:faction][:move]}\&amp;quot;&amp;quot;&lt;br /&gt;
    rescue StandardError =&amp;gt; e&lt;br /&gt;
      flash[:error] = &amp;quot;There was a problem moving the file: &amp;quot; + e.message&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def rename_selected_file&lt;br /&gt;
old_filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
new_filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + FileHelper.sanitize_filename(params[:faction][:rename])&lt;br /&gt;
begin&lt;br /&gt;
  raise &amp;quot;A file already exists in this directory with the name \&amp;quot;#{params[:faction][:rename]}\&amp;quot;&amp;quot; if File.exist?(new_filename)&lt;br /&gt;
  File.send(&amp;quot;rename&amp;quot;, old_filename, new_filename)&lt;br /&gt;
rescue StandardError =&amp;gt; e&lt;br /&gt;
  flash[:error] = &amp;quot;There was a problem renaming the file: &amp;quot; + e.message&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def delete_selected_files&lt;br /&gt;
&lt;br /&gt;
  filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
  FileUtils.rm_r(filename)&lt;br /&gt;
  participant = Participant.find_by(id: params[:id])&lt;br /&gt;
  assignment = participant.try(:assignment)&lt;br /&gt;
  team = participant.try(:team)&lt;br /&gt;
  SubmissionRecord.create(team_id: team.try(:id),&lt;br /&gt;
                          content: filename,&lt;br /&gt;
                          user: participant.try(:name),&lt;br /&gt;
                          assignment_id: assignment.try(:id),&lt;br /&gt;
                          operation: &amp;quot;Remove File&amp;quot;)&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, @participant.name, 'The selected file has been deleted.', request)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def copy_selected_file&lt;br /&gt;
  old_filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
  new_filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + FileHelper.sanitize_filename(params[:faction][:copy])&lt;br /&gt;
  begin&lt;br /&gt;
    raise &amp;quot;A file with this name already exists. Please delete the existing file before copying.&amp;quot; if File.exist?(new_filename)&lt;br /&gt;
    raise &amp;quot;The referenced file does not exist.&amp;quot; unless File.exist?(old_filename)&lt;br /&gt;
    FileUtils.cp_r(old_filename, new_filename)&lt;br /&gt;
  rescue StandardError =&amp;gt; e&lt;br /&gt;
    flash[:error] = &amp;quot;There was a problem copying the file: &amp;quot; + e.message&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza&lt;br /&gt;
&lt;br /&gt;
2. Change directory to expertiza. Run &amp;quot;bundle install&amp;quot; and rails db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server.&lt;br /&gt;
&lt;br /&gt;
4. Run the following command in a new terminal of the expertiza directory: &lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb (Test file mentioned missing)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139706</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139706"/>
		<updated>2021-10-21T02:10:49Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' '''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar function adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction of modular code in order to make each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
==Problems and Solutions ==&lt;br /&gt;
* '''Problem 1''': action_allowed method should be changed to use new_access_control methods. &lt;br /&gt;
:The original code does not make use of the new access control methods which are a part of the authorization_helper.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    ['Instructor',&lt;br /&gt;
     'Teaching Assistant',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Super-Administrator',&lt;br /&gt;
     'Student'].include? current_role_name and&lt;br /&gt;
    ((%w[edit].include? action_name) ? are_needed_authorizations_present?(params[:id], &amp;quot;reader&amp;quot;, &amp;quot;reviewer&amp;quot;) : true) and&lt;br /&gt;
    one_team_can_submit_work?&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* '''Solution''': On using the new access control methods: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def action_allowed?&lt;br /&gt;
    if %w[edit update list_submissions].include? params[:action]&lt;br /&gt;
      current_user_has_admin_privileges? || current_user_teaching_staff_of_assignment?(params[:id])&lt;br /&gt;
    else&lt;br /&gt;
      current_user_has_ta_privileges?&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'edit'&lt;br /&gt;
      current_user_has_student_privileges? &amp;amp;&amp;amp;&lt;br /&gt;
      are_needed_authorizations_present?(params[:id], &amp;quot;reader&amp;quot;, &amp;quot;reviewer&amp;quot;)&lt;br /&gt;
    when 'submit_file', 'submit_hyperlink'&lt;br /&gt;
      current_user_has_student_privileges? &amp;amp;&amp;amp;&lt;br /&gt;
      one_team_can_submit_work?&lt;br /&gt;
    else&lt;br /&gt;
      current_user_has_student_privileges?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. '''Problem 2''': Remove the comment  “# hence use team count for the check”.&lt;br /&gt;
::The current code no longer checks for the team count to see if a participant belongs to a team. Comment on line #19 removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. '''Problem 3''': Change the method name view to something more informative of the method.&lt;br /&gt;
:The original code uses the generic 'view' method name to display a view corresponding to a case when submissions cannot be accepted, for instance in the case when a deadline is passed. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def view&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* '''Solution''': We found changing the name to disable_submission to be more apt in this case&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def disable_submission&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. '''Problem 4''': submit_hyperlink is filled with a lot of logging code.&lt;br /&gt;
:Logging is essential to understand the behavior of the application and to debug unexpected issues or for simply tracking events as in the production environment, we can’t debug issues without proper log files.&lt;br /&gt;
* '''Solution''': We added a function for the sole purpose of logging so that it can be reused wherever required.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def log_info(controller_name, participant_name, message, request)&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, participant_name, message, request)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. '''Problem 5''': Check the validity of the comment ”# Note: This is not used yet in the view until we all decide to do so”.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': The function to remove_hyperlink performs as expected, hence the comment is no longer valid.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. '''Problem 6''': submit_file method is long.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': Implemented modular code by separating the function into simpler functions.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def tested&lt;br /&gt;
    @current_folder = DisplayOption.new&lt;br /&gt;
    @current_folder.name = &amp;quot;/&amp;quot;&lt;br /&gt;
    @current_folder.name = FileHelper.sanitize_folder(params[:current_folder][:name]) if params[:current_folder]&lt;br /&gt;
    curr_directory = if params[:origin] == 'review'&lt;br /&gt;
                       participant.review_file_path(params[:response_map_id]).to_s + @current_folder.name&lt;br /&gt;
                     else&lt;br /&gt;
                       participant.team.path.to_s + @current_folder.name&lt;br /&gt;
                     end&lt;br /&gt;
    return curr_directory&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. '''Problem 7''': Move mail_assigned_reviewers to a mailer class.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': Moved the mail_assigned_reviewers to mailer_helper.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def self.mail_assigned_reviewers(team)&lt;br /&gt;
    maps = ResponseMap.where(reviewed_object_id: @participant.assignment.id, reviewee_id: team.id, type: 'ReviewResponseMap')&lt;br /&gt;
    unless maps.nil?&lt;br /&gt;
      maps.each do |map|&lt;br /&gt;
        # Mailing function&lt;br /&gt;
        Mailer.general_email(&lt;br /&gt;
          to: User.find(Participant.find(map.reviewer_id).user_id).email,&lt;br /&gt;
          subject:  &amp;quot;Link to update the review for Assignment '#{@participant.assignment.name}'&amp;quot;,&lt;br /&gt;
          cc: User.find_by(@participant.assignment.instructor_id).email,&lt;br /&gt;
          link: &amp;quot;Link: https://expertiza.ncsu.edu/response/new?id=#{map.id}&amp;quot;,&lt;br /&gt;
          assignment: @participant.assignment.name&lt;br /&gt;
        ).deliver_now&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. '''Problem 8''': Change the method name of folder_action.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': Renamed folder_action to perform_folder_action. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def perform_folder_action&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @current_folder = DisplayOption.new&lt;br /&gt;
    @current_folder.name = &amp;quot;/&amp;quot;&lt;br /&gt;
    @current_folder.name = FileHelper.sanitize_folder(params[:current_folder][:name]) if params[:current_folder]&lt;br /&gt;
    if params[:faction][:delete]&lt;br /&gt;
      SubmittedFiles.delete_selected_files&lt;br /&gt;
    elsif params[:faction][:rename]&lt;br /&gt;
      SubmittedFiles.rename_selected_file&lt;br /&gt;
    elsif params[:faction][:move]&lt;br /&gt;
      SubmittedFiles.move_selected_file&lt;br /&gt;
    elsif params[:faction][:copy]&lt;br /&gt;
      SubmittedFiles.copy_selected_file&lt;br /&gt;
    elsif params[:faction][:create]&lt;br /&gt;
      create_new_folder&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'edit', id: @participant.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. '''Problem 9''': Some of the actions in the code (from line 187 to 247) could perhaps be moved to another class&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': Separated functions related to submission of files into a new helper class called submitted_files_helper.rb.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
module SubmittedFiles&lt;br /&gt;
&lt;br /&gt;
def move_selected_file&lt;br /&gt;
  old_filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
  newloc = @participant.dir_path&lt;br /&gt;
  newloc += &amp;quot;/&amp;quot;&lt;br /&gt;
  newloc += params[:faction][:move]&lt;br /&gt;
  begin&lt;br /&gt;
      FileHelper.move_file(old_filename, newloc)&lt;br /&gt;
      flash[:note] = &amp;quot;The file was successfully moved from \&amp;quot;/#{params[:filenames][params[:chk_files]]}\&amp;quot; to \&amp;quot;/#{params[:faction][:move]}\&amp;quot;&amp;quot;&lt;br /&gt;
    rescue StandardError =&amp;gt; e&lt;br /&gt;
      flash[:error] = &amp;quot;There was a problem moving the file: &amp;quot; + e.message&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def rename_selected_file&lt;br /&gt;
old_filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
new_filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + FileHelper.sanitize_filename(params[:faction][:rename])&lt;br /&gt;
begin&lt;br /&gt;
  raise &amp;quot;A file already exists in this directory with the name \&amp;quot;#{params[:faction][:rename]}\&amp;quot;&amp;quot; if File.exist?(new_filename)&lt;br /&gt;
  File.send(&amp;quot;rename&amp;quot;, old_filename, new_filename)&lt;br /&gt;
rescue StandardError =&amp;gt; e&lt;br /&gt;
  flash[:error] = &amp;quot;There was a problem renaming the file: &amp;quot; + e.message&lt;br /&gt;
end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def delete_selected_files&lt;br /&gt;
&lt;br /&gt;
  filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
  FileUtils.rm_r(filename)&lt;br /&gt;
  participant = Participant.find_by(id: params[:id])&lt;br /&gt;
  assignment = participant.try(:assignment)&lt;br /&gt;
  team = participant.try(:team)&lt;br /&gt;
  SubmissionRecord.create(team_id: team.try(:id),&lt;br /&gt;
                          content: filename,&lt;br /&gt;
                          user: participant.try(:name),&lt;br /&gt;
                          assignment_id: assignment.try(:id),&lt;br /&gt;
                          operation: &amp;quot;Remove File&amp;quot;)&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, @participant.name, 'The selected file has been deleted.', request)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def copy_selected_file&lt;br /&gt;
  old_filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + params[:filenames][params[:chk_files]]&lt;br /&gt;
  new_filename = params[:directories][params[:chk_files]] + &amp;quot;/&amp;quot; + FileHelper.sanitize_filename(params[:faction][:copy])&lt;br /&gt;
  begin&lt;br /&gt;
    raise &amp;quot;A file with this name already exists. Please delete the existing file before copying.&amp;quot; if File.exist?(new_filename)&lt;br /&gt;
    raise &amp;quot;The referenced file does not exist.&amp;quot; unless File.exist?(old_filename)&lt;br /&gt;
    FileUtils.cp_r(old_filename, new_filename)&lt;br /&gt;
  rescue StandardError =&amp;gt; e&lt;br /&gt;
    flash[:error] = &amp;quot;There was a problem copying the file: &amp;quot; + e.message&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza&lt;br /&gt;
&lt;br /&gt;
2. Change directory to expertiza. Run &amp;quot;bundle install&amp;quot; and rails db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server.&lt;br /&gt;
&lt;br /&gt;
4. Run the following command in a new terminal of the expertiza directory: &lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139683</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139683"/>
		<updated>2021-10-21T01:59:10Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' '''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar function adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction of modular code in order to make each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
==Problems and Solutions ==&lt;br /&gt;
* '''Problem 1''': action_allowed method should be changed to use new_access_control methods. &lt;br /&gt;
:The original code does not make use of the new access control methods which are a part of the authorization_helper.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    ['Instructor',&lt;br /&gt;
     'Teaching Assistant',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Super-Administrator',&lt;br /&gt;
     'Student'].include? current_role_name and&lt;br /&gt;
    ((%w[edit].include? action_name) ? are_needed_authorizations_present?(params[:id], &amp;quot;reader&amp;quot;, &amp;quot;reviewer&amp;quot;) : true) and&lt;br /&gt;
    one_team_can_submit_work?&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* '''Solution''': On using the new access control methods: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def action_allowed?&lt;br /&gt;
    if %w[edit update list_submissions].include? params[:action]&lt;br /&gt;
      current_user_has_admin_privileges? || current_user_teaching_staff_of_assignment?(params[:id])&lt;br /&gt;
    else&lt;br /&gt;
      current_user_has_ta_privileges?&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'edit'&lt;br /&gt;
      current_user_has_student_privileges? &amp;amp;&amp;amp;&lt;br /&gt;
      are_needed_authorizations_present?(params[:id], &amp;quot;reader&amp;quot;, &amp;quot;reviewer&amp;quot;)&lt;br /&gt;
    when 'submit_file', 'submit_hyperlink'&lt;br /&gt;
      current_user_has_student_privileges? &amp;amp;&amp;amp;&lt;br /&gt;
      one_team_can_submit_work?&lt;br /&gt;
    else&lt;br /&gt;
      current_user_has_student_privileges?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. '''Problem 2''': Remove the comment  “# hence use team count for the check”.&lt;br /&gt;
::The current code no longer checks for the team count to see if a participant belongs to a team. Comment on line #19 removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. '''Problem 3''': Change the method name view to something more informative of the method.&lt;br /&gt;
:The original code uses the generic 'view' method name to display a view corresponding to a case when submissions cannot be accepted, for instance in the case when a deadline is passed. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def view&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* '''Solution''': We found changing the name to disable_submission to be more apt in this case&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def disable_submission&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. '''Problem 4''': submit_hyperlink is filled with a lot of logging code.&lt;br /&gt;
:Logging is essential to understand the behavior of the application and to debug unexpected issues or for simply tracking events as in the production environment, we can’t debug issues without proper log files.&lt;br /&gt;
* '''Solution''': We added a function for the sole purpose of logging so that it can be reused wherever required.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def log_info(controller_name, participant_name, message, request)&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, participant_name, message, request)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. '''Problem 5''': Check the validity of the comment ”# Note: This is not used yet in the view until we all decide to do so”.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. '''Problem 6''': submit_file method is long.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': Implemented modular code by separating the function into simpler functions.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def tested&lt;br /&gt;
    @current_folder = DisplayOption.new&lt;br /&gt;
    @current_folder.name = &amp;quot;/&amp;quot;&lt;br /&gt;
    @current_folder.name = FileHelper.sanitize_folder(params[:current_folder][:name]) if params[:current_folder]&lt;br /&gt;
    curr_directory = if params[:origin] == 'review'&lt;br /&gt;
                       participant.review_file_path(params[:response_map_id]).to_s + @current_folder.name&lt;br /&gt;
                     else&lt;br /&gt;
                       participant.team.path.to_s + @current_folder.name&lt;br /&gt;
                     end&lt;br /&gt;
    return curr_directory&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. '''Problem 7''': Move mail_assigned_reviewers to a mailer class.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': Moved the mail_assigned_reviewers to mailer_helper.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def self.mail_assigned_reviewers(team)&lt;br /&gt;
    maps = ResponseMap.where(reviewed_object_id: @participant.assignment.id, reviewee_id: team.id, type: 'ReviewResponseMap')&lt;br /&gt;
    unless maps.nil?&lt;br /&gt;
      maps.each do |map|&lt;br /&gt;
        # Mailing function&lt;br /&gt;
        Mailer.general_email(&lt;br /&gt;
          to: User.find(Participant.find(map.reviewer_id).user_id).email,&lt;br /&gt;
          subject:  &amp;quot;Link to update the review for Assignment '#{@participant.assignment.name}'&amp;quot;,&lt;br /&gt;
          cc: User.find_by(@participant.assignment.instructor_id).email,&lt;br /&gt;
          link: &amp;quot;Link: https://expertiza.ncsu.edu/response/new?id=#{map.id}&amp;quot;,&lt;br /&gt;
          assignment: @participant.assignment.name&lt;br /&gt;
        ).deliver_now&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. '''Problem 8''': Change the method name of folder_action.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': Renamed folder_action to perform_folder_action. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def perform_folder_action&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @current_folder = DisplayOption.new&lt;br /&gt;
    @current_folder.name = &amp;quot;/&amp;quot;&lt;br /&gt;
    @current_folder.name = FileHelper.sanitize_folder(params[:current_folder][:name]) if params[:current_folder]&lt;br /&gt;
    if params[:faction][:delete]&lt;br /&gt;
      SubmittedFiles.delete_selected_files&lt;br /&gt;
    elsif params[:faction][:rename]&lt;br /&gt;
      SubmittedFiles.rename_selected_file&lt;br /&gt;
    elsif params[:faction][:move]&lt;br /&gt;
      SubmittedFiles.move_selected_file&lt;br /&gt;
    elsif params[:faction][:copy]&lt;br /&gt;
      SubmittedFiles.copy_selected_file&lt;br /&gt;
    elsif params[:faction][:create]&lt;br /&gt;
      create_new_folder&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'edit', id: @participant.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. '''Problem 9''': Some of the actions in the code (from line 187 to 247) could perhaps be moved to another class&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza&lt;br /&gt;
&lt;br /&gt;
2. Change directory to expertiza. Run &amp;quot;bundle install&amp;quot; and rails db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server.&lt;br /&gt;
&lt;br /&gt;
4. Run the following command in a new terminal of the expertiza directory: &lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139594</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139594"/>
		<updated>2021-10-20T23:58:55Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' '''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar function adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction of modular code in order to make each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
==Problems and Solutions ==&lt;br /&gt;
* '''Problem 1''': action_allowed method should be changed to use new_access_control methods. &lt;br /&gt;
:The original code does not make use of the new access control methods which are a part of the authorization_helper.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    ['Instructor',&lt;br /&gt;
     'Teaching Assistant',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Super-Administrator',&lt;br /&gt;
     'Student'].include? current_role_name and&lt;br /&gt;
    ((%w[edit].include? action_name) ? are_needed_authorizations_present?(params[:id], &amp;quot;reader&amp;quot;, &amp;quot;reviewer&amp;quot;) : true) and&lt;br /&gt;
    one_team_can_submit_work?&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* '''Solution''': On using the new access control methods: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def action_allowed?&lt;br /&gt;
    if %w[edit update list_submissions].include? params[:action]&lt;br /&gt;
      current_user_has_admin_privileges? || current_user_teaching_staff_of_assignment?(params[:id])&lt;br /&gt;
    else&lt;br /&gt;
      current_user_has_ta_privileges?&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'edit'&lt;br /&gt;
      current_user_has_student_privileges? &amp;amp;&amp;amp;&lt;br /&gt;
      are_needed_authorizations_present?(params[:id], &amp;quot;reader&amp;quot;, &amp;quot;reviewer&amp;quot;)&lt;br /&gt;
    when 'submit_file', 'submit_hyperlink'&lt;br /&gt;
      current_user_has_student_privileges? &amp;amp;&amp;amp;&lt;br /&gt;
      one_team_can_submit_work?&lt;br /&gt;
    else&lt;br /&gt;
      current_user_has_student_privileges?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. '''Problem 2''': Remove the comment  “# hence use team count for the check”.&lt;br /&gt;
::The current code no longer checks for the team count to see if a participant belongs to a team. Comment on line #19 removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. '''Problem 3''': Change the method name view to something more informative of the method.&lt;br /&gt;
:The original code uses the generic 'view' method name to display a view corresponding to a case when submissions cannot be accepted, for instance in the case when a deadline is passed. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def view&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* '''Solution''': We found changing the name to disable_submission to be more apt in this case&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def disable_submission&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. '''Problem 4''': submit_hyperlink is filled with a lot of logging code.&lt;br /&gt;
:Logging is essential to understand the behavior of the application and to debug unexpected issues or for simply tracking events as in the production environment, we can’t debug issues without proper log files.&lt;br /&gt;
* '''Solution''': We added a function for the sole purpose of logging so that it can be reused wherever required.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def log_info(controller_name, participant_name, message, request)&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, participant_name, message, request)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. '''Problem 5''': Check the validity of the comment ”# Note: This is not used yet in the view until we all decide to do so”.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. '''Problem 6''': submit_file method is long. Try to break it into multiple methods.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. '''Problem 7''': Move mail_assigned_reviewers to a mailer class.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. '''Problem 8''': Change the method name of folder_action.&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. '''Problem 9''': Some of the actions in the code (from line 187 to 247) could perhaps be moved to another class&lt;br /&gt;
:&lt;br /&gt;
* '''Solution''': &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza&lt;br /&gt;
&lt;br /&gt;
2. Change directory to expertiza. Run &amp;quot;bundle install&amp;quot; and rails db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server.&lt;br /&gt;
&lt;br /&gt;
4. Run the following command in a new terminal of the expertiza directory: &lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139592</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139592"/>
		<updated>2021-10-20T23:55:12Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' '''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar function adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction of modular code in order to make each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
==Problems and Solutions ==&lt;br /&gt;
* '''Problem 1''': action_allowed method should be changed to use new_access_control methods. &lt;br /&gt;
:The original code does not make use of the new access control methods which are a part of the authorization_helper.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    ['Instructor',&lt;br /&gt;
     'Teaching Assistant',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Super-Administrator',&lt;br /&gt;
     'Student'].include? current_role_name and&lt;br /&gt;
    ((%w[edit].include? action_name) ? are_needed_authorizations_present?(params[:id], &amp;quot;reader&amp;quot;, &amp;quot;reviewer&amp;quot;) : true) and&lt;br /&gt;
    one_team_can_submit_work?&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* '''Solution''': On using the new access control methods: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def action_allowed?&lt;br /&gt;
    if %w[edit update list_submissions].include? params[:action]&lt;br /&gt;
      current_user_has_admin_privileges? || current_user_teaching_staff_of_assignment?(params[:id])&lt;br /&gt;
    else&lt;br /&gt;
      current_user_has_ta_privileges?&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'edit'&lt;br /&gt;
      current_user_has_student_privileges? &amp;amp;&amp;amp;&lt;br /&gt;
      are_needed_authorizations_present?(params[:id], &amp;quot;reader&amp;quot;, &amp;quot;reviewer&amp;quot;)&lt;br /&gt;
    when 'submit_file', 'submit_hyperlink'&lt;br /&gt;
      current_user_has_student_privileges? &amp;amp;&amp;amp;&lt;br /&gt;
      one_team_can_submit_work?&lt;br /&gt;
    else&lt;br /&gt;
      current_user_has_student_privileges?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. '''Problem 2''': Remove the comment  “# hence use team count for the check”.&lt;br /&gt;
::The current code no longer checks for the team count to see if a participant belongs to a team. Comment on line #19 removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. '''Problem 3''': Change the method name view to something more informative of the method.&lt;br /&gt;
:The original code uses the generic 'view' method name to display a view corresponding to a case when submissions cannot be accepted, for instance in the case when a deadline is passed. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def view&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* '''Solution''': We found changing the name to disable_submission to be more apt in this case&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def disable_submission&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. '''Problem 4''': submit_hyperlink is filled with a lot of logging code.&lt;br /&gt;
:Logging is essential to understand the behavior of the application and to debug unexpected issues or for simply tracking events as in the production environment, we can’t debug issues without proper log files.&lt;br /&gt;
* '''Solution''': We added a function for the sole purpose of logging so that it can be reused wherever required.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def log_info(controller_name, participant_name, message, request)&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, participant_name, message, request)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza&lt;br /&gt;
&lt;br /&gt;
2. Change directory to expertiza. Run &amp;quot;bundle install&amp;quot; and rails db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server.&lt;br /&gt;
&lt;br /&gt;
4. Run the following command in a new terminal of the expertiza directory: &lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139591</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139591"/>
		<updated>2021-10-20T23:50:56Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' '''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar function adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction of modular code in order to make each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
==Problems and Solutions ==&lt;br /&gt;
* '''Problem 1''': action_allowed method should be changed to use new_access_control methods. &lt;br /&gt;
:The original code does not make use of the new access control methods which are a part of the authorization_helper.rb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def action_allowed?&lt;br /&gt;
    ['Instructor',&lt;br /&gt;
     'Teaching Assistant',&lt;br /&gt;
     'Administrator',&lt;br /&gt;
     'Super-Administrator',&lt;br /&gt;
     'Student'].include? current_role_name and&lt;br /&gt;
    ((%w[edit].include? action_name) ? are_needed_authorizations_present?(params[:id], &amp;quot;reader&amp;quot;, &amp;quot;reviewer&amp;quot;) : true) and&lt;br /&gt;
    one_team_can_submit_work?&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* '''Solution''': On using the new access control methods: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def action_allowed?&lt;br /&gt;
    if %w[edit update list_submissions].include? params[:action]&lt;br /&gt;
      current_user_has_admin_privileges? || current_user_teaching_staff_of_assignment?(params[:id])&lt;br /&gt;
    else&lt;br /&gt;
      current_user_has_ta_privileges?&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    case params[:action]&lt;br /&gt;
    when 'edit'&lt;br /&gt;
      current_user_has_student_privileges? &amp;amp;&amp;amp;&lt;br /&gt;
      are_needed_authorizations_present?(params[:id], &amp;quot;reader&amp;quot;, &amp;quot;reviewer&amp;quot;)&lt;br /&gt;
    when 'submit_file', 'submit_hyperlink'&lt;br /&gt;
      current_user_has_student_privileges? &amp;amp;&amp;amp;&lt;br /&gt;
      one_team_can_submit_work?&lt;br /&gt;
    else&lt;br /&gt;
      current_user_has_student_privileges?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. '''Problem 2''': Remove the comment  “# hence use team count for the check”.&lt;br /&gt;
::The current code no longer checks for the team count to see if a participant belongs to a team. Comment on line #19 removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. '''Problem 3''': Change the method name view to something more informative of the method.&lt;br /&gt;
:The original code uses the generic 'view' method name to display a view corresponding to a case when submissions cannot be accepted, for instance in the case when a deadline is passed. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def view&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* '''Solution''': We found changing the name to disable_submission to be more apt in this case&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def disable_submission&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza&lt;br /&gt;
&lt;br /&gt;
2. Change directory to expertiza. Run &amp;quot;bundle install&amp;quot; and rails db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server.&lt;br /&gt;
&lt;br /&gt;
4. Run the following command in a new terminal of the expertiza directory: &lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139589</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139589"/>
		<updated>2021-10-20T23:36:49Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' '''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar function adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction of modular code in order to make each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
==Problems and Solutions ==&lt;br /&gt;
1. '''Problem 2''': Remove the comment  “# hence use team count for the check”.&lt;br /&gt;
::The current code no longer checks for the team count to see if a participant belongs to a team. Comment on line #19 removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. '''Problem 3''': Change the method name view to something more informative of the method.&lt;br /&gt;
:The original code uses the generic 'view' method name to display a view corresponding to a case when submissions cannot be accepted, for instance in the case when a deadline is passed. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def view&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* '''Solution''': We found changing the name to disable_submission to be more apt in this case&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def disable_submission&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza&lt;br /&gt;
&lt;br /&gt;
2. Change directory to expertiza. Run &amp;quot;bundle install&amp;quot; and rails db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server.&lt;br /&gt;
&lt;br /&gt;
4. Run the following command in a new terminal of the expertiza directory: &lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139588</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139588"/>
		<updated>2021-10-20T23:20:54Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' '''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar function adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction of modular code in order to make each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
==Problems and Solutions ==&lt;br /&gt;
1. '''Problem 1''': Remove the comment  “# hence use team count for the check”.&lt;br /&gt;
::The current code no longer checks for the team count to see if a participant belongs to a team. Comment on line #19 removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. '''Problem 2''': Change the method name view to something more informative of the method.&lt;br /&gt;
:The original code uses the generic 'view' method name to display a view corresponding to a case when submissions cannot be accepted, for instance in the case when a deadline is passed. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def view&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* '''Solution''': We found changing the name to disable_submission to be more apt in this case&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def disable_submission&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza&lt;br /&gt;
&lt;br /&gt;
2. Change directory to expertiza. Run &amp;quot;bundle install&amp;quot; and rails db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server.&lt;br /&gt;
&lt;br /&gt;
4. Run the following command in a new terminal of the expertiza directory: &lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139587</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139587"/>
		<updated>2021-10-20T23:20:18Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' '''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar function adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction of modular code in order to make each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
==Problems and Solutions ==&lt;br /&gt;
1. '''Problem 1''': Remove the comment  “# hence use team count for the check”.&lt;br /&gt;
::The current code no longer checks for the team count to see if a participant belongs to a team. Comment on line #19 removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. '''Problem 2''': Change the method name view to something more informative of the method.&lt;br /&gt;
::The original code uses the generic 'view' method name to display a view corresponding to a case when submissions cannot be accepted, for instance in the case when a deadline is passed. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def view&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* '''Solution''': We found changing the name to disable_submission to be more apt in this case&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def disable_submission&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    @assignment = @participant.assignment&lt;br /&gt;
    # @can_submit is the flag indicating if the user can submit or not in current stage&lt;br /&gt;
    @can_submit = false&lt;br /&gt;
    @stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))&lt;br /&gt;
    redirect_to action: 'edit', id: params[:id], view: true&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza&lt;br /&gt;
&lt;br /&gt;
2. Change directory to expertiza. Run &amp;quot;bundle install&amp;quot; and rails db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server.&lt;br /&gt;
&lt;br /&gt;
4. Run the following command in a new terminal of the expertiza directory: &lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139584</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139584"/>
		<updated>2021-10-20T23:15:13Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' '''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar function adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction of modular code in order to make each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
==Problems and Solutions ==&lt;br /&gt;
* '''Problem 1''': Remove the comment  “# hence use team count for the check”.&lt;br /&gt;
::The current code no longer checks for the team count to see if a participant belongs to a team. Comment on line #19 removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza&lt;br /&gt;
&lt;br /&gt;
2. Change directory to expertiza. Run &amp;quot;bundle install&amp;quot; and rails db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server.&lt;br /&gt;
&lt;br /&gt;
4. Run the following command in a new terminal of the expertiza directory: &lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139583</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139583"/>
		<updated>2021-10-20T23:14:38Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' Controller'''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar function adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction of modular code in order to make each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
==Problems and Solutions ==&lt;br /&gt;
* '''Problem 1''': Remove the comment  “# hence use team count for the check”.&lt;br /&gt;
::The current code no longer checks for the team count to see if a participant belongs to a team. Comment on line #19 removed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza&lt;br /&gt;
&lt;br /&gt;
2. Change directory to expertiza. Run &amp;quot;bundle install&amp;quot; and rails db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server.&lt;br /&gt;
&lt;br /&gt;
4. Run the following command in a new terminal of the expertiza directory: &lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139547</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139547"/>
		<updated>2021-10-20T21:58:50Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' Controller'''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar function adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction of modular code in order to make each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
== Testing Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza&lt;br /&gt;
&lt;br /&gt;
2. Change directory to expertiza. Run &amp;quot;bundle install&amp;quot; and rails db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server.&lt;br /&gt;
&lt;br /&gt;
4. Run the following command in a new terminal of the expertiza directory: &lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139546</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139546"/>
		<updated>2021-10-20T21:58:00Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' Controller'''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction modular making each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
== Testing Requirements ==&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza&lt;br /&gt;
&lt;br /&gt;
2. Change directory to expertiza. Run &amp;quot;bundle install&amp;quot; and rails db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server.&lt;br /&gt;
&lt;br /&gt;
4. Run the following command in a new terminal of the expertiza directory: &lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139545</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139545"/>
		<updated>2021-10-20T21:57:20Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' Controller'''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction modular making each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
== Testing Requirements ==&lt;br /&gt;
&lt;br /&gt;
== Steps to test the submitted_content_controller ==&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza&lt;br /&gt;
&lt;br /&gt;
2. Change directory to expertiza. Run &amp;quot;bundle install&amp;quot; and rails db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server.&lt;br /&gt;
&lt;br /&gt;
4. Run the following command in a new terminal of the expertiza directory: &lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139544</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139544"/>
		<updated>2021-10-20T21:56:39Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' Controller'''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction modular making each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
== Testing Requirements ==&lt;br /&gt;
&lt;br /&gt;
=== Steps to test the submitted_content_controller ===&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza&lt;br /&gt;
2. Change directory to expertiza. Run &amp;quot;bundle install&amp;quot; and rails db:migrate.&lt;br /&gt;
3. Start the rails server.&lt;br /&gt;
4. Run the following command in a new terminal of the expertiza directory: &lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139542</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139542"/>
		<updated>2021-10-20T21:52:12Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' Controller'''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
Broadly, the following issues were addressed as a part of refactoring this controller: &lt;br /&gt;
* Renaming methods to more appropriate and functionality specific names.&lt;br /&gt;
* The existing code was reused to perform either the same function or re-purposed to do a similar adhering to standards and improving overall quality of the code. &lt;br /&gt;
* Introduction modular making each module easier to understand, test and refactor independently of others.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139535</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139535"/>
		<updated>2021-10-20T21:42:26Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' Controller'''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential Rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139534</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139534"/>
		<updated>2021-10-20T21:41:52Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' Controller'''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''submitted_content_controller''' had some problems that violate essential Rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139533</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139533"/>
		<updated>2021-10-20T21:40:22Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' Controller'''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
The [http://expertiza.ncsu.edu/ Expertiza] platform employs a divide-and-conquer strategy for creating reusable learning objects via active-learning exercises built entirely on [http://rubyonrails.org/ Ruby on Rails] framework. Students get to choose from a list of tasks to complete either individually or in teams. They then prepare their work and submit it to a peer-review mechanism. On submission, other students can assess their peers work and provide feedback. Expertiza encourages students to collaborate in order to improve the learning experiences from one another. It aids their learning by making them translate what is taught in the lectures and apply those concepts to a real-world issue.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''submitted_content_Controller''' had some problems that violate essential Rails design principles which needed to be rectified. Issues included some methods being too long which needed to be broken down, a few methods needed better naming and a few that were no longer needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139526</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139526"/>
		<updated>2021-10-20T21:22:06Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2130: Refactor 'submitted_content_controller' Controller'''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==Introduction to Expertiza==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a peer review based system which provides incremental learning from the class. This project has been developed together by faculty and students using [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create, edit and delete assignments, create new assignment topics, assign them to a particular class or selected students, have students work on teams and then review each other's assignments at the end. For the students, they can signup for topics, form teams, and submit their projects and assignments. &lt;br /&gt;
Students then review the work done by other students and give suggestions to improve. Teams after reviews are allotted scores and they can refer to the peer comments to further improve their work. It also supports submission of different file types for assignments, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''submitted_content_Controller''' had some problems that violate some essential Rails design principles which needed to be rectified. There are few methods in this controller that are far too long and need to be broken down into multiple methods. A few methods need to be commented as well. Few Methods need to be renamed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Create Method===&lt;br /&gt;
The method '''Create''' is called when an instructor tries to create a team manually. This works for both, creating ''assignment teams'' and ''course teams''. Assignment teams are teams made to do a particular assignment together and ''Course Teams'' are teams which are made for the whole course.&lt;br /&gt;
&lt;br /&gt;
===Delete Method===&lt;br /&gt;
The method '''Delete''' is called when an instructor tries to delete a team manually. This works for both, deleting ''assignment teams'' and ''course teams''.&lt;br /&gt;
&lt;br /&gt;
===List Method===&lt;br /&gt;
The method '''List''' lists all the team nodes and the instructor is able to expand each team node to see the user nodes as well.&lt;br /&gt;
&lt;br /&gt;
===Inherit Method===&lt;br /&gt;
The method '''Inherit''' inherits teams from course to assignments, but the “Inherit Teams From Course” option should not display when either 1) we are editing a course object or 2) the current assignment object does not have a course associated with it.&lt;br /&gt;
&lt;br /&gt;
===Running Tests===&lt;br /&gt;
  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Files Modified===&lt;br /&gt;
  1. teams_controller.rb&lt;br /&gt;
  2. team.rb&lt;br /&gt;
  3. signed_up_team.rb&lt;br /&gt;
  4. routes.rb&lt;br /&gt;
  5. app/views/teams/new.html.erb&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring '''Refactoring'''] is restructuring of code without the need of changing any external behavior. It reduces complexity and improves readability. It also becomes easy to extend the application with respect to different modules and their functionalities.&lt;br /&gt;
Some common techniques to refactor are:&lt;br /&gt;
&lt;br /&gt;
* Moving methods to appropriate modules&lt;br /&gt;
* Breaking methods into more meaningful functionality&lt;br /&gt;
* Creating more generalized code.&lt;br /&gt;
* Renaming methods and variable.&lt;br /&gt;
* Inheritance&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
===Refactoring delete method===&lt;br /&gt;
Description: The delete method manipulates a waitlist. This code is moved to signed_up_team.rb model class.&lt;br /&gt;
&lt;br /&gt;
Initially, the code was:&lt;br /&gt;
&lt;br /&gt;
  def delete&lt;br /&gt;
    # delete records in team, teams_users, signed_up_teams table&lt;br /&gt;
    @team = Team.find_by(id: params[:id])&lt;br /&gt;
    unless @team.nil?&lt;br /&gt;
      course = Object.const_get(session[:team_type]).find(@team.parent_id)&lt;br /&gt;
      @signed_up_team = SignedUpTeam.where(team_id: @team.id)&lt;br /&gt;
      @teams_users = TeamsUser.where(team_id: @team.id)&lt;br /&gt;
      if @signed_up_team == 1 &amp;amp;&amp;amp; !@signUps.first.is_waitlisted # this team hold a topic&lt;br /&gt;
        # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
        topic_id = @signed_up_team.first.topic_id&lt;br /&gt;
        next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
        # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
        SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
      end&lt;br /&gt;
      @sign_up_team.destroy_all if @sign_up_team&lt;br /&gt;
      @teams_users.destroy_all if @teams_users&lt;br /&gt;
      @team.destroy if @team&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully deleted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to :back&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Which was changed to:&lt;br /&gt;
&lt;br /&gt;
  def delete&lt;br /&gt;
    # delete records in team, teams_users, signed_up_teams table&lt;br /&gt;
    @team = Team.find_by(id: params[:id])&lt;br /&gt;
    unless @team.nil?&lt;br /&gt;
      course = Object.const_get(session[:team_type]).find(@team.parent_id)&lt;br /&gt;
      @signed_up_team = SignedUpTeam.where(team_id: @team.id)&lt;br /&gt;
      @teams_users = TeamsUser.where(team_id: @team.id)&lt;br /&gt;
      # On team deletion topic team was holding will be assigned to first team in waitlist.&lt;br /&gt;
      SignedUpTeam.assign_topic_to_first_in_waitlist_post_team_deletion(@signed_up_team, @signups)&lt;br /&gt;
      @sign_up_team.destroy_all if @sign_up_team&lt;br /&gt;
      @teams_users.destroy_all if @teams_users&lt;br /&gt;
      @team.destroy if @team&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully deleted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to :back&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
and a new method was introduced in signed_up_team.rb model:&lt;br /&gt;
  # this method checks when a team is deleted if there is a team in waitlist for the topic&lt;br /&gt;
  # deleted team was holding, then assign topic to first team in waitlist&lt;br /&gt;
  def self.assign_topic_to_first_in_waitlist_post_team_deletion (signed_up_team, signups)&lt;br /&gt;
    if signed_up_team == 1 &amp;amp;&amp;amp; !signups.first.is_waitlisted # this team hold a topic&lt;br /&gt;
      # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
      topic_id = signed_up_team.first.topic_id&lt;br /&gt;
      next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
      # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
      SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
    end&lt;br /&gt;
  end &lt;br /&gt;
&lt;br /&gt;
===Refactoring inherit method===&lt;br /&gt;
&lt;br /&gt;
Description: The code that copies a list is moved to team.rb model class.&lt;br /&gt;
&lt;br /&gt;
Initially, the code was:&lt;br /&gt;
  def inherit&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    if assignment.course_id &amp;gt;= 0&lt;br /&gt;
      course = Course.find(assignment.course_id)&lt;br /&gt;
      teams = course.get_teams&lt;br /&gt;
      unless teams.empty?&lt;br /&gt;
        teams.each do |team|&lt;br /&gt;
          team.copy(assignment.id)&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:note] = &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'teams', action: 'list', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Which was changed to:&lt;br /&gt;
  def inherit&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    if assignment.course_id &amp;gt;= 0&lt;br /&gt;
      course = Course.find(assignment.course_id)&lt;br /&gt;
      teams = course.get_teams&lt;br /&gt;
      unless teams.empty?&lt;br /&gt;
        # copy_assignment method copies teams to assignment&lt;br /&gt;
        Team.copy_assignment(teams,assignment)&lt;br /&gt;
      else&lt;br /&gt;
        flash[:note] = &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'teams', action: 'list', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
and a new method was introduced in team.rb model:&lt;br /&gt;
  def self.copy_assignment(teams,assignment)&lt;br /&gt;
    teams.each do |team|&lt;br /&gt;
      team.copy(assignment.id)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===Refactoring create method===&lt;br /&gt;
&lt;br /&gt;
Description: It creates new teams against a parent id&lt;br /&gt;
&lt;br /&gt;
Initially the create method was: &lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      Team.check_for_existing(parent, params[:team][:name], session[:team_type])&lt;br /&gt;
      @team = Object.const_get(session[:team_type] + 'Team').create(name: params[:team][:name], parent_id: parent.id)&lt;br /&gt;
      TeamNode.create(parent_id: parent.id, node_object_id: @team.id)&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully created.&amp;quot;)&lt;br /&gt;
      redirect_to action: 'list', id: parent.id&lt;br /&gt;
    rescue TeamExistsError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
      redirect_to action: 'new', id: parent.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Which changed to:&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    begin&lt;br /&gt;
      parent = get_parent_and_check_if_exists(params[:id])&lt;br /&gt;
      @team = Object.const_get(session[:team_type] + 'Team').create(name: params[:team][:name], parent_id: parent.id)&lt;br /&gt;
      TeamNode.create(parent_id: parent.id, node_object_id: @team.id)&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully created.&amp;quot;)&lt;br /&gt;
      redirect_to action: 'list', id: parent.id&lt;br /&gt;
    rescue TeamExistsError&lt;br /&gt;
      flash_and_redirect_on_update_or_create_error('new', parent_id)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # called to fetch parent and check if team with same name and type already exists.&lt;br /&gt;
  def get_parent_and_check_if_exists(parent_id)&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(parent_id)&lt;br /&gt;
    Team.check_for_existing(parent, params[:team][:name], session[:team_type])&lt;br /&gt;
    return parent&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # to flash and redirect the user when there is any update or create error&lt;br /&gt;
  def flash_and_redirect_on_update_or_create_error(action, id)&lt;br /&gt;
    flash[:error] = $ERROR_INFO&lt;br /&gt;
    redirect_to action: action, id: id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===Refactoring update method===&lt;br /&gt;
&lt;br /&gt;
Description: It updates an existing team name&lt;br /&gt;
&lt;br /&gt;
Initially the update method was:&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    @team = Team.find(params[:id])&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(@team.parent_id)&lt;br /&gt;
    begin&lt;br /&gt;
      Team.check_for_existing(parent, params[:team][:name], session[:team_type])&lt;br /&gt;
      @team.name = params[:team][:name]&lt;br /&gt;
      @team.save&lt;br /&gt;
      flash[:success] = &amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
      undo_link(&amp;quot;&amp;quot;)&lt;br /&gt;
      redirect_to action: 'list', id: parent.id&lt;br /&gt;
    rescue TeamExistsError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
      redirect_to action: 'edit', id: @team.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Which changed to: &lt;br /&gt;
&lt;br /&gt;
  # It updates an existing team name&lt;br /&gt;
  def update&lt;br /&gt;
    @team = Team.find(params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      parent = get_parent_and_check_if_exists(@team.parent_id)&lt;br /&gt;
      @team.name = params[:team][:name]&lt;br /&gt;
      @team.save&lt;br /&gt;
      flash[:success] = &amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
      undo_link(&amp;quot;&amp;quot;)&lt;br /&gt;
      redirect_to action: 'list', id: parent.id&lt;br /&gt;
    rescue TeamExistsError&lt;br /&gt;
      flash_and_redirect_on_update_or_create_error('edit', @team.id)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # called to fetch parent and check if team with same name and type already exists.&lt;br /&gt;
  def get_parent_and_check_if_exists(parent_id)&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(parent_id)&lt;br /&gt;
    Team.check_for_existing(parent, params[:team][:name], session[:team_type])&lt;br /&gt;
    return parent&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # to flash and redirect the user when there is any update or create error&lt;br /&gt;
  def flash_and_redirect_on_update_or_create_error(action, id)&lt;br /&gt;
    flash[:error] = $ERROR_INFO&lt;br /&gt;
    redirect_to action: action, id: id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Create Teams===&lt;br /&gt;
&lt;br /&gt;
The new method self.create_teams() is created in Team.rb model and placed the common of create_teams method.&lt;br /&gt;
  # This function is used to create teams with random names.&lt;br /&gt;
  # Instructors can call by clicking &amp;quot;Create temas&amp;quot; icon anc then click &amp;quot;Create teams&amp;quot; at the bottom.&lt;br /&gt;
  def self.create_teams(session,params)&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(params[:id])&lt;br /&gt;
    Team.randomize_all_by_parent(parent, session[:team_type], params[:team_size].to_i)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Exiting code of create_teams() method in teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
  # This function is used to create teams with random names.	&lt;br /&gt;
  # Instructors can call by clicking &amp;quot;Create temas&amp;quot; icon anc then click &amp;quot;Create teams&amp;quot; at the bottom.	&lt;br /&gt;
  def create_teams	&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(params[:id])	&lt;br /&gt;
    Team.randomize_all_by_parent(parent, session[:team_type], params[:team_size].to_i)	&lt;br /&gt;
    undo_link(&amp;quot;Random teams have been successfully created.&amp;quot;)	&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Random teams have been successfully created', request)	&lt;br /&gt;
    redirect_to action: 'list', id: parent.id	&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Modified the teams_controller.rb file and it is now using the Team.create_teams(session,params) present in Team.rb model to create teams.&lt;br /&gt;
&lt;br /&gt;
  # This function is used to create teams with random names.&lt;br /&gt;
  # Instructors can call by clicking &amp;quot;Create temas&amp;quot; icon anc then click &amp;quot;Create teams&amp;quot; at the bottom.&lt;br /&gt;
  def create_teams&lt;br /&gt;
    Team.create_teams(session,params)&lt;br /&gt;
    undo_link(&amp;quot;Random teams have been successfully created.&amp;quot;)&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Random teams have been successfully created', request)&lt;br /&gt;
    redirect_to action: 'list', id: parent.id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===signUps should be signups===&lt;br /&gt;
Existing code for the signUps nouns are modified to signups.&lt;br /&gt;
&lt;br /&gt;
Existing code teams_controller.rb &lt;br /&gt;
&lt;br /&gt;
 def delete&lt;br /&gt;
    # delete records in team, teams_users, signed_up_teams table&lt;br /&gt;
    @team = Team.find_by(id: params[:id])&lt;br /&gt;
    unless @team.nil?&lt;br /&gt;
      course = Object.const_get(session[:team_type]).find(@team.parent_id)&lt;br /&gt;
      @signed_up_team = SignedUpTeam.where(team_id: @team.id)&lt;br /&gt;
      @teams_users = TeamsUser.where(team_id: @team.id)&lt;br /&gt;
&lt;br /&gt;
      SignedUpTeam.assign_topic_to_first_in_waitlist_post_team_deletion(@signed_up_team, @signUps)&lt;br /&gt;
&lt;br /&gt;
      @sign_up_team.destroy_all if @sign_up_team&lt;br /&gt;
      @teams_users.destroy_all if @teams_users&lt;br /&gt;
      @team.destroy if @team&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully deleted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to :back&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Modified code in teams_controller.rb &lt;br /&gt;
&lt;br /&gt;
 def delete&lt;br /&gt;
    # delete records in team, teams_users, signed_up_teams table&lt;br /&gt;
    @team = Team.find_by(id: params[:id])&lt;br /&gt;
    unless @team.nil?&lt;br /&gt;
      course = Object.const_get(session[:team_type]).find(@team.parent_id)&lt;br /&gt;
      @signed_up_team = SignedUpTeam.where(team_id: @team.id)&lt;br /&gt;
      @teams_users = TeamsUser.where(team_id: @team.id)&lt;br /&gt;
&lt;br /&gt;
      SignedUpTeam.assign_topic_to_first_in_waitlist_post_team_deletion(@signed_up_team, @signups)&lt;br /&gt;
&lt;br /&gt;
      @sign_up_team.destroy_all if @sign_up_team&lt;br /&gt;
      @teams_users.destroy_all if @teams_users&lt;br /&gt;
      @team.destroy if @team&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully deleted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to :back&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Existing code signed_up_team.rb &lt;br /&gt;
&lt;br /&gt;
  def self.assign_topic_to_first_in_waitlist_post_team_deletion (signed_up_team, signUps)&lt;br /&gt;
    if signed_up_team == 1 &amp;amp;&amp;amp; !signups.first.is_waitlisted # this team hold a topic&lt;br /&gt;
      # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
      topic_id = signed_up_team.first.topic_id&lt;br /&gt;
      next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
      # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
      SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Modified code in signed_up_team.rb &lt;br /&gt;
&lt;br /&gt;
  def self.assign_topic_to_first_in_waitlist_post_team_deletion (signed_up_team, signups)&lt;br /&gt;
    if signed_up_team == 1 &amp;amp;&amp;amp; !signups.first.is_waitlisted # this team hold a topic&lt;br /&gt;
      # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
      topic_id = signed_up_team.first.topic_id&lt;br /&gt;
      next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
      # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
      SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Testing the submitted_content_controller ==&lt;br /&gt;
&lt;br /&gt;
=== Instructions for testing Rspecs ===&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza.git&lt;br /&gt;
&lt;br /&gt;
2. Change to the expertiza directory and then perform &amp;quot;bundle install&amp;quot; and rake db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server&lt;br /&gt;
&lt;br /&gt;
4. In a new terminal and in the expertiza directory, perform the following commands:&lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing Inherit Method===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing Create Method===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing Delete Method===&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
===Testing List Method===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139525</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139525"/>
		<updated>2021-10-20T21:21:36Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2127: Refactor 'submitted_content_controller' Controller'''&lt;br /&gt;
&lt;br /&gt;
This page provides detailed explanation of the Submitted Content Controller which is a part of the '''Expertiza''' project. The aim of the project is to refactor the 'submitted_content_controller', which contains the methods to submit assignment related information such as submit &amp;amp; remove hyperlinks, files and other relevant information that could be part of the assignment. It also handles views based on the user roles and permissions they have.&lt;br /&gt;
The project involved refactoring some parts of the controller to incorporate the OODD principles so that the readability of code could be improved. &lt;br /&gt;
&lt;br /&gt;
==Introduction to Expertiza==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a peer review based system which provides incremental learning from the class. This project has been developed together by faculty and students using [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create, edit and delete assignments, create new assignment topics, assign them to a particular class or selected students, have students work on teams and then review each other's assignments at the end. For the students, they can signup for topics, form teams, and submit their projects and assignments. &lt;br /&gt;
Students then review the work done by other students and give suggestions to improve. Teams after reviews are allotted scores and they can refer to the peer comments to further improve their work. It also supports submission of different file types for assignments, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''submitted_content_Controller''' had some problems that violate some essential Rails design principles which needed to be rectified. There are few methods in this controller that are far too long and need to be broken down into multiple methods. A few methods need to be commented as well. Few Methods need to be renamed. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Create Method===&lt;br /&gt;
The method '''Create''' is called when an instructor tries to create a team manually. This works for both, creating ''assignment teams'' and ''course teams''. Assignment teams are teams made to do a particular assignment together and ''Course Teams'' are teams which are made for the whole course.&lt;br /&gt;
&lt;br /&gt;
===Delete Method===&lt;br /&gt;
The method '''Delete''' is called when an instructor tries to delete a team manually. This works for both, deleting ''assignment teams'' and ''course teams''.&lt;br /&gt;
&lt;br /&gt;
===List Method===&lt;br /&gt;
The method '''List''' lists all the team nodes and the instructor is able to expand each team node to see the user nodes as well.&lt;br /&gt;
&lt;br /&gt;
===Inherit Method===&lt;br /&gt;
The method '''Inherit''' inherits teams from course to assignments, but the “Inherit Teams From Course” option should not display when either 1) we are editing a course object or 2) the current assignment object does not have a course associated with it.&lt;br /&gt;
&lt;br /&gt;
===Running Tests===&lt;br /&gt;
  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Files Modified===&lt;br /&gt;
  1. teams_controller.rb&lt;br /&gt;
  2. team.rb&lt;br /&gt;
  3. signed_up_team.rb&lt;br /&gt;
  4. routes.rb&lt;br /&gt;
  5. app/views/teams/new.html.erb&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring '''Refactoring'''] is restructuring of code without the need of changing any external behavior. It reduces complexity and improves readability. It also becomes easy to extend the application with respect to different modules and their functionalities.&lt;br /&gt;
Some common techniques to refactor are:&lt;br /&gt;
&lt;br /&gt;
* Moving methods to appropriate modules&lt;br /&gt;
* Breaking methods into more meaningful functionality&lt;br /&gt;
* Creating more generalized code.&lt;br /&gt;
* Renaming methods and variable.&lt;br /&gt;
* Inheritance&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
===Refactoring delete method===&lt;br /&gt;
Description: The delete method manipulates a waitlist. This code is moved to signed_up_team.rb model class.&lt;br /&gt;
&lt;br /&gt;
Initially, the code was:&lt;br /&gt;
&lt;br /&gt;
  def delete&lt;br /&gt;
    # delete records in team, teams_users, signed_up_teams table&lt;br /&gt;
    @team = Team.find_by(id: params[:id])&lt;br /&gt;
    unless @team.nil?&lt;br /&gt;
      course = Object.const_get(session[:team_type]).find(@team.parent_id)&lt;br /&gt;
      @signed_up_team = SignedUpTeam.where(team_id: @team.id)&lt;br /&gt;
      @teams_users = TeamsUser.where(team_id: @team.id)&lt;br /&gt;
      if @signed_up_team == 1 &amp;amp;&amp;amp; !@signUps.first.is_waitlisted # this team hold a topic&lt;br /&gt;
        # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
        topic_id = @signed_up_team.first.topic_id&lt;br /&gt;
        next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
        # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
        SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
      end&lt;br /&gt;
      @sign_up_team.destroy_all if @sign_up_team&lt;br /&gt;
      @teams_users.destroy_all if @teams_users&lt;br /&gt;
      @team.destroy if @team&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully deleted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to :back&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Which was changed to:&lt;br /&gt;
&lt;br /&gt;
  def delete&lt;br /&gt;
    # delete records in team, teams_users, signed_up_teams table&lt;br /&gt;
    @team = Team.find_by(id: params[:id])&lt;br /&gt;
    unless @team.nil?&lt;br /&gt;
      course = Object.const_get(session[:team_type]).find(@team.parent_id)&lt;br /&gt;
      @signed_up_team = SignedUpTeam.where(team_id: @team.id)&lt;br /&gt;
      @teams_users = TeamsUser.where(team_id: @team.id)&lt;br /&gt;
      # On team deletion topic team was holding will be assigned to first team in waitlist.&lt;br /&gt;
      SignedUpTeam.assign_topic_to_first_in_waitlist_post_team_deletion(@signed_up_team, @signups)&lt;br /&gt;
      @sign_up_team.destroy_all if @sign_up_team&lt;br /&gt;
      @teams_users.destroy_all if @teams_users&lt;br /&gt;
      @team.destroy if @team&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully deleted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to :back&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
and a new method was introduced in signed_up_team.rb model:&lt;br /&gt;
  # this method checks when a team is deleted if there is a team in waitlist for the topic&lt;br /&gt;
  # deleted team was holding, then assign topic to first team in waitlist&lt;br /&gt;
  def self.assign_topic_to_first_in_waitlist_post_team_deletion (signed_up_team, signups)&lt;br /&gt;
    if signed_up_team == 1 &amp;amp;&amp;amp; !signups.first.is_waitlisted # this team hold a topic&lt;br /&gt;
      # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
      topic_id = signed_up_team.first.topic_id&lt;br /&gt;
      next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
      # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
      SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
    end&lt;br /&gt;
  end &lt;br /&gt;
&lt;br /&gt;
===Refactoring inherit method===&lt;br /&gt;
&lt;br /&gt;
Description: The code that copies a list is moved to team.rb model class.&lt;br /&gt;
&lt;br /&gt;
Initially, the code was:&lt;br /&gt;
  def inherit&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    if assignment.course_id &amp;gt;= 0&lt;br /&gt;
      course = Course.find(assignment.course_id)&lt;br /&gt;
      teams = course.get_teams&lt;br /&gt;
      unless teams.empty?&lt;br /&gt;
        teams.each do |team|&lt;br /&gt;
          team.copy(assignment.id)&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:note] = &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'teams', action: 'list', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Which was changed to:&lt;br /&gt;
  def inherit&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    if assignment.course_id &amp;gt;= 0&lt;br /&gt;
      course = Course.find(assignment.course_id)&lt;br /&gt;
      teams = course.get_teams&lt;br /&gt;
      unless teams.empty?&lt;br /&gt;
        # copy_assignment method copies teams to assignment&lt;br /&gt;
        Team.copy_assignment(teams,assignment)&lt;br /&gt;
      else&lt;br /&gt;
        flash[:note] = &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'teams', action: 'list', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
and a new method was introduced in team.rb model:&lt;br /&gt;
  def self.copy_assignment(teams,assignment)&lt;br /&gt;
    teams.each do |team|&lt;br /&gt;
      team.copy(assignment.id)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===Refactoring create method===&lt;br /&gt;
&lt;br /&gt;
Description: It creates new teams against a parent id&lt;br /&gt;
&lt;br /&gt;
Initially the create method was: &lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      Team.check_for_existing(parent, params[:team][:name], session[:team_type])&lt;br /&gt;
      @team = Object.const_get(session[:team_type] + 'Team').create(name: params[:team][:name], parent_id: parent.id)&lt;br /&gt;
      TeamNode.create(parent_id: parent.id, node_object_id: @team.id)&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully created.&amp;quot;)&lt;br /&gt;
      redirect_to action: 'list', id: parent.id&lt;br /&gt;
    rescue TeamExistsError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
      redirect_to action: 'new', id: parent.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Which changed to:&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    begin&lt;br /&gt;
      parent = get_parent_and_check_if_exists(params[:id])&lt;br /&gt;
      @team = Object.const_get(session[:team_type] + 'Team').create(name: params[:team][:name], parent_id: parent.id)&lt;br /&gt;
      TeamNode.create(parent_id: parent.id, node_object_id: @team.id)&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully created.&amp;quot;)&lt;br /&gt;
      redirect_to action: 'list', id: parent.id&lt;br /&gt;
    rescue TeamExistsError&lt;br /&gt;
      flash_and_redirect_on_update_or_create_error('new', parent_id)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # called to fetch parent and check if team with same name and type already exists.&lt;br /&gt;
  def get_parent_and_check_if_exists(parent_id)&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(parent_id)&lt;br /&gt;
    Team.check_for_existing(parent, params[:team][:name], session[:team_type])&lt;br /&gt;
    return parent&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # to flash and redirect the user when there is any update or create error&lt;br /&gt;
  def flash_and_redirect_on_update_or_create_error(action, id)&lt;br /&gt;
    flash[:error] = $ERROR_INFO&lt;br /&gt;
    redirect_to action: action, id: id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===Refactoring update method===&lt;br /&gt;
&lt;br /&gt;
Description: It updates an existing team name&lt;br /&gt;
&lt;br /&gt;
Initially the update method was:&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    @team = Team.find(params[:id])&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(@team.parent_id)&lt;br /&gt;
    begin&lt;br /&gt;
      Team.check_for_existing(parent, params[:team][:name], session[:team_type])&lt;br /&gt;
      @team.name = params[:team][:name]&lt;br /&gt;
      @team.save&lt;br /&gt;
      flash[:success] = &amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
      undo_link(&amp;quot;&amp;quot;)&lt;br /&gt;
      redirect_to action: 'list', id: parent.id&lt;br /&gt;
    rescue TeamExistsError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
      redirect_to action: 'edit', id: @team.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Which changed to: &lt;br /&gt;
&lt;br /&gt;
  # It updates an existing team name&lt;br /&gt;
  def update&lt;br /&gt;
    @team = Team.find(params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      parent = get_parent_and_check_if_exists(@team.parent_id)&lt;br /&gt;
      @team.name = params[:team][:name]&lt;br /&gt;
      @team.save&lt;br /&gt;
      flash[:success] = &amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
      undo_link(&amp;quot;&amp;quot;)&lt;br /&gt;
      redirect_to action: 'list', id: parent.id&lt;br /&gt;
    rescue TeamExistsError&lt;br /&gt;
      flash_and_redirect_on_update_or_create_error('edit', @team.id)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # called to fetch parent and check if team with same name and type already exists.&lt;br /&gt;
  def get_parent_and_check_if_exists(parent_id)&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(parent_id)&lt;br /&gt;
    Team.check_for_existing(parent, params[:team][:name], session[:team_type])&lt;br /&gt;
    return parent&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # to flash and redirect the user when there is any update or create error&lt;br /&gt;
  def flash_and_redirect_on_update_or_create_error(action, id)&lt;br /&gt;
    flash[:error] = $ERROR_INFO&lt;br /&gt;
    redirect_to action: action, id: id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Create Teams===&lt;br /&gt;
&lt;br /&gt;
The new method self.create_teams() is created in Team.rb model and placed the common of create_teams method.&lt;br /&gt;
  # This function is used to create teams with random names.&lt;br /&gt;
  # Instructors can call by clicking &amp;quot;Create temas&amp;quot; icon anc then click &amp;quot;Create teams&amp;quot; at the bottom.&lt;br /&gt;
  def self.create_teams(session,params)&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(params[:id])&lt;br /&gt;
    Team.randomize_all_by_parent(parent, session[:team_type], params[:team_size].to_i)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Exiting code of create_teams() method in teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
  # This function is used to create teams with random names.	&lt;br /&gt;
  # Instructors can call by clicking &amp;quot;Create temas&amp;quot; icon anc then click &amp;quot;Create teams&amp;quot; at the bottom.	&lt;br /&gt;
  def create_teams	&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(params[:id])	&lt;br /&gt;
    Team.randomize_all_by_parent(parent, session[:team_type], params[:team_size].to_i)	&lt;br /&gt;
    undo_link(&amp;quot;Random teams have been successfully created.&amp;quot;)	&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Random teams have been successfully created', request)	&lt;br /&gt;
    redirect_to action: 'list', id: parent.id	&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Modified the teams_controller.rb file and it is now using the Team.create_teams(session,params) present in Team.rb model to create teams.&lt;br /&gt;
&lt;br /&gt;
  # This function is used to create teams with random names.&lt;br /&gt;
  # Instructors can call by clicking &amp;quot;Create temas&amp;quot; icon anc then click &amp;quot;Create teams&amp;quot; at the bottom.&lt;br /&gt;
  def create_teams&lt;br /&gt;
    Team.create_teams(session,params)&lt;br /&gt;
    undo_link(&amp;quot;Random teams have been successfully created.&amp;quot;)&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Random teams have been successfully created', request)&lt;br /&gt;
    redirect_to action: 'list', id: parent.id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===signUps should be signups===&lt;br /&gt;
Existing code for the signUps nouns are modified to signups.&lt;br /&gt;
&lt;br /&gt;
Existing code teams_controller.rb &lt;br /&gt;
&lt;br /&gt;
 def delete&lt;br /&gt;
    # delete records in team, teams_users, signed_up_teams table&lt;br /&gt;
    @team = Team.find_by(id: params[:id])&lt;br /&gt;
    unless @team.nil?&lt;br /&gt;
      course = Object.const_get(session[:team_type]).find(@team.parent_id)&lt;br /&gt;
      @signed_up_team = SignedUpTeam.where(team_id: @team.id)&lt;br /&gt;
      @teams_users = TeamsUser.where(team_id: @team.id)&lt;br /&gt;
&lt;br /&gt;
      SignedUpTeam.assign_topic_to_first_in_waitlist_post_team_deletion(@signed_up_team, @signUps)&lt;br /&gt;
&lt;br /&gt;
      @sign_up_team.destroy_all if @sign_up_team&lt;br /&gt;
      @teams_users.destroy_all if @teams_users&lt;br /&gt;
      @team.destroy if @team&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully deleted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to :back&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Modified code in teams_controller.rb &lt;br /&gt;
&lt;br /&gt;
 def delete&lt;br /&gt;
    # delete records in team, teams_users, signed_up_teams table&lt;br /&gt;
    @team = Team.find_by(id: params[:id])&lt;br /&gt;
    unless @team.nil?&lt;br /&gt;
      course = Object.const_get(session[:team_type]).find(@team.parent_id)&lt;br /&gt;
      @signed_up_team = SignedUpTeam.where(team_id: @team.id)&lt;br /&gt;
      @teams_users = TeamsUser.where(team_id: @team.id)&lt;br /&gt;
&lt;br /&gt;
      SignedUpTeam.assign_topic_to_first_in_waitlist_post_team_deletion(@signed_up_team, @signups)&lt;br /&gt;
&lt;br /&gt;
      @sign_up_team.destroy_all if @sign_up_team&lt;br /&gt;
      @teams_users.destroy_all if @teams_users&lt;br /&gt;
      @team.destroy if @team&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully deleted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to :back&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Existing code signed_up_team.rb &lt;br /&gt;
&lt;br /&gt;
  def self.assign_topic_to_first_in_waitlist_post_team_deletion (signed_up_team, signUps)&lt;br /&gt;
    if signed_up_team == 1 &amp;amp;&amp;amp; !signups.first.is_waitlisted # this team hold a topic&lt;br /&gt;
      # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
      topic_id = signed_up_team.first.topic_id&lt;br /&gt;
      next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
      # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
      SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Modified code in signed_up_team.rb &lt;br /&gt;
&lt;br /&gt;
  def self.assign_topic_to_first_in_waitlist_post_team_deletion (signed_up_team, signups)&lt;br /&gt;
    if signed_up_team == 1 &amp;amp;&amp;amp; !signups.first.is_waitlisted # this team hold a topic&lt;br /&gt;
      # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
      topic_id = signed_up_team.first.topic_id&lt;br /&gt;
      next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
      # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
      SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Testing the submitted_content_controller ==&lt;br /&gt;
&lt;br /&gt;
=== Instructions for testing Rspecs ===&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/Neelkanth7/expertiza.git&lt;br /&gt;
&lt;br /&gt;
2. Change to the expertiza directory and then perform &amp;quot;bundle install&amp;quot; and rake db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server&lt;br /&gt;
&lt;br /&gt;
4. In a new terminal and in the expertiza directory, perform the following commands:&lt;br /&gt;
    i.  rspec spec/controllers/submitted_content_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing Inherit Method===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing Create Method===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Testing Delete Method===&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
===Testing List Method===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/Neelkanth7/expertiza Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/19FHqVoYUw0HzqGfZ68H-Z-SYmeP_LoHS2rkXjnxeaSE/edit#heading=h.jpaayj9sgw5h Link] to the project description.&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139507</id>
		<title>CSC/ECE 517 Fall 2021 - E2130. Refactor submitted content controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021_-_E2130._Refactor_submitted_content_controller.rb&amp;diff=139507"/>
		<updated>2021-10-20T20:29:55Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: Created page with &amp;quot;'''E2127: Refactor 'submitted_content_controller' Controller'''  This page provides a brief description of the '''Expertiza''' project. The project is aimed at refactoring the...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''E2127: Refactor 'submitted_content_controller' Controller'''&lt;br /&gt;
&lt;br /&gt;
This page provides a brief description of the '''Expertiza''' project. The project is aimed at refactoring the 'Teams_Controller' Controller, which contains the methods to create new teams, list the existing teams, create new teams by inheriting existing teams, deleting existing teams and creating multiple teams at once by assigning them random topics. The project entailed, refactoring some part of the controller to improve the readability of code and then creating test cases in [https://en.wikipedia.org/wiki/RSpec RSpec] to verify the methods it possesses. &lt;br /&gt;
&lt;br /&gt;
==Introduction to Expertiza==&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a peer review based system which provides incremental learning from the class. This project has been developed together by faculty and students using [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create, edit and delete assignments, create new assignment topics, assign them to a particular class or selected students, have students work on teams and then review each other's assignments at the end. For the students, they can signup for topics, form teams, and submit their projects and assignments. &lt;br /&gt;
Students then review the work done by other students and give suggestions to improve. Teams after reviews are allotted scores and they can refer to the peer comments to further improve their work. It also supports submission of different file types for assignments, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
== Project Description ==&lt;br /&gt;
'''Teams_Controller''' primarily handles the team creation, deletion and other behaviours. Most of those are called from the instructor’s view. When manual testing is done, most of the methods can be called by clicking the “Create teams” icon from both assignments and courses. &lt;br /&gt;
The following tasks have been performed as per the requirements.&lt;br /&gt;
&lt;br /&gt;
===Create Method===&lt;br /&gt;
The method '''Create''' is called when an instructor tries to create a team manually. This works for both, creating ''assignment teams'' and ''course teams''. Assignment teams are teams made to do a particular assignment together and ''Course Teams'' are teams which are made for the whole course.&lt;br /&gt;
&lt;br /&gt;
===Delete Method===&lt;br /&gt;
The method '''Delete''' is called when an instructor tries to delete a team manually. This works for both, deleting ''assignment teams'' and ''course teams''.&lt;br /&gt;
&lt;br /&gt;
===List Method===&lt;br /&gt;
The method '''List''' lists all the team nodes and the instructor is able to expand each team node to see the user nodes as well.&lt;br /&gt;
&lt;br /&gt;
===Inherit Method===&lt;br /&gt;
The method '''Inherit''' inherits teams from course to assignments, but the “Inherit Teams From Course” option should not display when either 1) we are editing a course object or 2) the current assignment object does not have a course associated with it.&lt;br /&gt;
&lt;br /&gt;
===Running Tests===&lt;br /&gt;
  rspec spec/controllers/teams_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Files Modified===&lt;br /&gt;
  1. teams_controller.rb&lt;br /&gt;
  2. team.rb&lt;br /&gt;
  3. signed_up_team.rb&lt;br /&gt;
  4. routes.rb&lt;br /&gt;
  5. app/views/teams/new.html.erb&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring '''Refactoring'''] is restructuring of code without the need of changing any external behavior. It reduces complexity and improves readability. It also becomes easy to extend the application with respect to different modules and their functionalities.&lt;br /&gt;
Some common techniques to refactor are:&lt;br /&gt;
&lt;br /&gt;
* Moving methods to appropriate modules&lt;br /&gt;
* Breaking methods into more meaningful functionality&lt;br /&gt;
* Creating more generalized code.&lt;br /&gt;
* Renaming methods and variable.&lt;br /&gt;
* Inheritance&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
===Refactoring delete method===&lt;br /&gt;
Description: The delete method manipulates a waitlist. This code is moved to signed_up_team.rb model class.&lt;br /&gt;
&lt;br /&gt;
Initially, the code was:&lt;br /&gt;
&lt;br /&gt;
  def delete&lt;br /&gt;
    # delete records in team, teams_users, signed_up_teams table&lt;br /&gt;
    @team = Team.find_by(id: params[:id])&lt;br /&gt;
    unless @team.nil?&lt;br /&gt;
      course = Object.const_get(session[:team_type]).find(@team.parent_id)&lt;br /&gt;
      @signed_up_team = SignedUpTeam.where(team_id: @team.id)&lt;br /&gt;
      @teams_users = TeamsUser.where(team_id: @team.id)&lt;br /&gt;
      if @signed_up_team == 1 &amp;amp;&amp;amp; !@signUps.first.is_waitlisted # this team hold a topic&lt;br /&gt;
        # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
        topic_id = @signed_up_team.first.topic_id&lt;br /&gt;
        next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
        # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
        SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
      end&lt;br /&gt;
      @sign_up_team.destroy_all if @sign_up_team&lt;br /&gt;
      @teams_users.destroy_all if @teams_users&lt;br /&gt;
      @team.destroy if @team&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully deleted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to :back&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Which was changed to:&lt;br /&gt;
&lt;br /&gt;
  def delete&lt;br /&gt;
    # delete records in team, teams_users, signed_up_teams table&lt;br /&gt;
    @team = Team.find_by(id: params[:id])&lt;br /&gt;
    unless @team.nil?&lt;br /&gt;
      course = Object.const_get(session[:team_type]).find(@team.parent_id)&lt;br /&gt;
      @signed_up_team = SignedUpTeam.where(team_id: @team.id)&lt;br /&gt;
      @teams_users = TeamsUser.where(team_id: @team.id)&lt;br /&gt;
      # On team deletion topic team was holding will be assigned to first team in waitlist.&lt;br /&gt;
      SignedUpTeam.assign_topic_to_first_in_waitlist_post_team_deletion(@signed_up_team, @signups)&lt;br /&gt;
      @sign_up_team.destroy_all if @sign_up_team&lt;br /&gt;
      @teams_users.destroy_all if @teams_users&lt;br /&gt;
      @team.destroy if @team&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully deleted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to :back&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
and a new method was introduced in signed_up_team.rb model:&lt;br /&gt;
  # this method checks when a team is deleted if there is a team in waitlist for the topic&lt;br /&gt;
  # deleted team was holding, then assign topic to first team in waitlist&lt;br /&gt;
  def self.assign_topic_to_first_in_waitlist_post_team_deletion (signed_up_team, signups)&lt;br /&gt;
    if signed_up_team == 1 &amp;amp;&amp;amp; !signups.first.is_waitlisted # this team hold a topic&lt;br /&gt;
      # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
      topic_id = signed_up_team.first.topic_id&lt;br /&gt;
      next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
      # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
      SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
    end&lt;br /&gt;
  end &lt;br /&gt;
&lt;br /&gt;
===Refactoring inherit method===&lt;br /&gt;
&lt;br /&gt;
Description: The code that copies a list is moved to team.rb model class.&lt;br /&gt;
&lt;br /&gt;
Initially, the code was:&lt;br /&gt;
  def inherit&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    if assignment.course_id &amp;gt;= 0&lt;br /&gt;
      course = Course.find(assignment.course_id)&lt;br /&gt;
      teams = course.get_teams&lt;br /&gt;
      unless teams.empty?&lt;br /&gt;
        teams.each do |team|&lt;br /&gt;
          team.copy(assignment.id)&lt;br /&gt;
        end&lt;br /&gt;
      else&lt;br /&gt;
        flash[:note] = &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'teams', action: 'list', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Which was changed to:&lt;br /&gt;
  def inherit&lt;br /&gt;
    assignment = Assignment.find(params[:id])&lt;br /&gt;
    if assignment.course_id &amp;gt;= 0&lt;br /&gt;
      course = Course.find(assignment.course_id)&lt;br /&gt;
      teams = course.get_teams&lt;br /&gt;
      unless teams.empty?&lt;br /&gt;
        # copy_assignment method copies teams to assignment&lt;br /&gt;
        Team.copy_assignment(teams,assignment)&lt;br /&gt;
      else&lt;br /&gt;
        flash[:note] = &amp;quot;No teams were found when trying to inherit.&amp;quot;&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;No course was found for this assignment.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'teams', action: 'list', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
and a new method was introduced in team.rb model:&lt;br /&gt;
  def self.copy_assignment(teams,assignment)&lt;br /&gt;
    teams.each do |team|&lt;br /&gt;
      team.copy(assignment.id)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===Refactoring create method===&lt;br /&gt;
&lt;br /&gt;
Description: It creates new teams against a parent id&lt;br /&gt;
&lt;br /&gt;
Initially the create method was: &lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      Team.check_for_existing(parent, params[:team][:name], session[:team_type])&lt;br /&gt;
      @team = Object.const_get(session[:team_type] + 'Team').create(name: params[:team][:name], parent_id: parent.id)&lt;br /&gt;
      TeamNode.create(parent_id: parent.id, node_object_id: @team.id)&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully created.&amp;quot;)&lt;br /&gt;
      redirect_to action: 'list', id: parent.id&lt;br /&gt;
    rescue TeamExistsError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
      redirect_to action: 'new', id: parent.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Which changed to:&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    begin&lt;br /&gt;
      parent = get_parent_and_check_if_exists(params[:id])&lt;br /&gt;
      @team = Object.const_get(session[:team_type] + 'Team').create(name: params[:team][:name], parent_id: parent.id)&lt;br /&gt;
      TeamNode.create(parent_id: parent.id, node_object_id: @team.id)&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully created.&amp;quot;)&lt;br /&gt;
      redirect_to action: 'list', id: parent.id&lt;br /&gt;
    rescue TeamExistsError&lt;br /&gt;
      flash_and_redirect_on_update_or_create_error('new', parent_id)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # called to fetch parent and check if team with same name and type already exists.&lt;br /&gt;
  def get_parent_and_check_if_exists(parent_id)&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(parent_id)&lt;br /&gt;
    Team.check_for_existing(parent, params[:team][:name], session[:team_type])&lt;br /&gt;
    return parent&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # to flash and redirect the user when there is any update or create error&lt;br /&gt;
  def flash_and_redirect_on_update_or_create_error(action, id)&lt;br /&gt;
    flash[:error] = $ERROR_INFO&lt;br /&gt;
    redirect_to action: action, id: id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===Refactoring update method===&lt;br /&gt;
&lt;br /&gt;
Description: It updates an existing team name&lt;br /&gt;
&lt;br /&gt;
Initially the update method was:&lt;br /&gt;
&lt;br /&gt;
  def update&lt;br /&gt;
    @team = Team.find(params[:id])&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(@team.parent_id)&lt;br /&gt;
    begin&lt;br /&gt;
      Team.check_for_existing(parent, params[:team][:name], session[:team_type])&lt;br /&gt;
      @team.name = params[:team][:name]&lt;br /&gt;
      @team.save&lt;br /&gt;
      flash[:success] = &amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
      undo_link(&amp;quot;&amp;quot;)&lt;br /&gt;
      redirect_to action: 'list', id: parent.id&lt;br /&gt;
    rescue TeamExistsError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
      redirect_to action: 'edit', id: @team.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Which changed to: &lt;br /&gt;
&lt;br /&gt;
  # It updates an existing team name&lt;br /&gt;
  def update&lt;br /&gt;
    @team = Team.find(params[:id])&lt;br /&gt;
    begin&lt;br /&gt;
      parent = get_parent_and_check_if_exists(@team.parent_id)&lt;br /&gt;
      @team.name = params[:team][:name]&lt;br /&gt;
      @team.save&lt;br /&gt;
      flash[:success] = &amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully updated.&amp;quot;&lt;br /&gt;
      undo_link(&amp;quot;&amp;quot;)&lt;br /&gt;
      redirect_to action: 'list', id: parent.id&lt;br /&gt;
    rescue TeamExistsError&lt;br /&gt;
      flash_and_redirect_on_update_or_create_error('edit', @team.id)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # called to fetch parent and check if team with same name and type already exists.&lt;br /&gt;
  def get_parent_and_check_if_exists(parent_id)&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(parent_id)&lt;br /&gt;
    Team.check_for_existing(parent, params[:team][:name], session[:team_type])&lt;br /&gt;
    return parent&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # to flash and redirect the user when there is any update or create error&lt;br /&gt;
  def flash_and_redirect_on_update_or_create_error(action, id)&lt;br /&gt;
    flash[:error] = $ERROR_INFO&lt;br /&gt;
    redirect_to action: action, id: id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Create Teams===&lt;br /&gt;
&lt;br /&gt;
The new method self.create_teams() is created in Team.rb model and placed the common of create_teams method.&lt;br /&gt;
  # This function is used to create teams with random names.&lt;br /&gt;
  # Instructors can call by clicking &amp;quot;Create temas&amp;quot; icon anc then click &amp;quot;Create teams&amp;quot; at the bottom.&lt;br /&gt;
  def self.create_teams(session,params)&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(params[:id])&lt;br /&gt;
    Team.randomize_all_by_parent(parent, session[:team_type], params[:team_size].to_i)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Exiting code of create_teams() method in teams_controller.rb&lt;br /&gt;
&lt;br /&gt;
  # This function is used to create teams with random names.	&lt;br /&gt;
  # Instructors can call by clicking &amp;quot;Create temas&amp;quot; icon anc then click &amp;quot;Create teams&amp;quot; at the bottom.	&lt;br /&gt;
  def create_teams	&lt;br /&gt;
    parent = Object.const_get(session[:team_type]).find(params[:id])	&lt;br /&gt;
    Team.randomize_all_by_parent(parent, session[:team_type], params[:team_size].to_i)	&lt;br /&gt;
    undo_link(&amp;quot;Random teams have been successfully created.&amp;quot;)	&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Random teams have been successfully created', request)	&lt;br /&gt;
    redirect_to action: 'list', id: parent.id	&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Modified the teams_controller.rb file and it is now using the Team.create_teams(session,params) present in Team.rb model to create teams.&lt;br /&gt;
&lt;br /&gt;
  # This function is used to create teams with random names.&lt;br /&gt;
  # Instructors can call by clicking &amp;quot;Create temas&amp;quot; icon anc then click &amp;quot;Create teams&amp;quot; at the bottom.&lt;br /&gt;
  def create_teams&lt;br /&gt;
    Team.create_teams(session,params)&lt;br /&gt;
    undo_link(&amp;quot;Random teams have been successfully created.&amp;quot;)&lt;br /&gt;
    ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Random teams have been successfully created', request)&lt;br /&gt;
    redirect_to action: 'list', id: parent.id&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===signUps should be signups===&lt;br /&gt;
Existing code for the signUps nouns are modified to signups.&lt;br /&gt;
&lt;br /&gt;
Existing code teams_controller.rb &lt;br /&gt;
&lt;br /&gt;
 def delete&lt;br /&gt;
    # delete records in team, teams_users, signed_up_teams table&lt;br /&gt;
    @team = Team.find_by(id: params[:id])&lt;br /&gt;
    unless @team.nil?&lt;br /&gt;
      course = Object.const_get(session[:team_type]).find(@team.parent_id)&lt;br /&gt;
      @signed_up_team = SignedUpTeam.where(team_id: @team.id)&lt;br /&gt;
      @teams_users = TeamsUser.where(team_id: @team.id)&lt;br /&gt;
&lt;br /&gt;
      SignedUpTeam.assign_topic_to_first_in_waitlist_post_team_deletion(@signed_up_team, @signUps)&lt;br /&gt;
&lt;br /&gt;
      @sign_up_team.destroy_all if @sign_up_team&lt;br /&gt;
      @teams_users.destroy_all if @teams_users&lt;br /&gt;
      @team.destroy if @team&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully deleted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to :back&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Modified code in teams_controller.rb &lt;br /&gt;
&lt;br /&gt;
 def delete&lt;br /&gt;
    # delete records in team, teams_users, signed_up_teams table&lt;br /&gt;
    @team = Team.find_by(id: params[:id])&lt;br /&gt;
    unless @team.nil?&lt;br /&gt;
      course = Object.const_get(session[:team_type]).find(@team.parent_id)&lt;br /&gt;
      @signed_up_team = SignedUpTeam.where(team_id: @team.id)&lt;br /&gt;
      @teams_users = TeamsUser.where(team_id: @team.id)&lt;br /&gt;
&lt;br /&gt;
      SignedUpTeam.assign_topic_to_first_in_waitlist_post_team_deletion(@signed_up_team, @signups)&lt;br /&gt;
&lt;br /&gt;
      @sign_up_team.destroy_all if @sign_up_team&lt;br /&gt;
      @teams_users.destroy_all if @teams_users&lt;br /&gt;
      @team.destroy if @team&lt;br /&gt;
      undo_link(&amp;quot;The team \&amp;quot;#{@team.name}\&amp;quot; has been successfully deleted.&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to :back&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Existing code signed_up_team.rb &lt;br /&gt;
&lt;br /&gt;
  def self.assign_topic_to_first_in_waitlist_post_team_deletion (signed_up_team, signUps)&lt;br /&gt;
    if signed_up_team == 1 &amp;amp;&amp;amp; !signups.first.is_waitlisted # this team hold a topic&lt;br /&gt;
      # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
      topic_id = signed_up_team.first.topic_id&lt;br /&gt;
      next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
      # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
      SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Modified code in signed_up_team.rb &lt;br /&gt;
&lt;br /&gt;
  def self.assign_topic_to_first_in_waitlist_post_team_deletion (signed_up_team, signups)&lt;br /&gt;
    if signed_up_team == 1 &amp;amp;&amp;amp; !signups.first.is_waitlisted # this team hold a topic&lt;br /&gt;
      # if there is another team in waitlist, make this team hold this topic&lt;br /&gt;
      topic_id = signed_up_team.first.topic_id&lt;br /&gt;
      next_wait_listed_team = SignedUpTeam.where(topic_id: topic_id, is_waitlisted: true).first&lt;br /&gt;
      # if slot exist, then confirm the topic for this team and delete all waitlists for this team&lt;br /&gt;
      SignUpTopic.assign_to_first_waiting_team(next_wait_listed_team) if next_wait_listed_team&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== Testing the Teams_Controller ==&lt;br /&gt;
&lt;br /&gt;
=== Instructions for testing Rspecs ===&lt;br /&gt;
&lt;br /&gt;
1. git clone https://github.com/bhaskarsinha1311/expertiza.git&lt;br /&gt;
&lt;br /&gt;
2. Change to the expertiza directory and then perform &amp;quot;bundle install&amp;quot; and rake db:migrate.&lt;br /&gt;
&lt;br /&gt;
3. Start the rails server&lt;br /&gt;
&lt;br /&gt;
4. In a new terminal and in the expertiza directory, perform the following commands:&lt;br /&gt;
    i.  rspec spec/controllers/teams_controller_spec.rb&lt;br /&gt;
    ii. rspec spec/features/inherit_teams_display_spec.rb&lt;br /&gt;
    iii. rspec spec/features/list_teams_spec.rb&lt;br /&gt;
&lt;br /&gt;
The results to the above commands can be found [https://www.youtube.com/watch?v=CcSruLHQoeU/ here].&lt;br /&gt;
&lt;br /&gt;
===Testing Inherit Method===&lt;br /&gt;
&lt;br /&gt;
To test that while creating an assignment team, the inherit teams section should be displayed, we log in as instructor got to list page and click on Create Team Link. On this page, we test that it should contain the string 'Inherit Teams From Course'. &lt;br /&gt;
To do this test manually, user need lo log in as an Instructor and navigate to assignments page for any course. There the user can click on 'Create Teams' icon and will be redirected to the Create teams page for an assignment, there the user can check for the 'inherit teams' button in the view, ideally, it should be there.&lt;br /&gt;
&lt;br /&gt;
  it 'should display inherit teams while creating an assignment team' do&lt;br /&gt;
    create(:assignment)&lt;br /&gt;
    create(:assignment_node)&lt;br /&gt;
    create(:assignment_team)&lt;br /&gt;
    login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/teams/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
    click_link 'Create Team'&lt;br /&gt;
    expect(page).to have_content('Inherit Teams From Course')&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
To test that while creating a course team, the inherit teams section should not be displayed, we do same steps in the previous case but finally, we test that the page does NOT contain 'Inherit Teams from Course'.&lt;br /&gt;
To do this test manually, user need lo log in as an Instructor and navigate to courses page. There the user can click on 'Create Teams' icon and will be redirected to 'create team' page, ideally, the 'Inherit Teams' button should not be displayed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  it 'should not display inherit teams while creating a course team' do&lt;br /&gt;
    create(:course)&lt;br /&gt;
    create(:course_node)&lt;br /&gt;
    create(:course_team)&lt;br /&gt;
    login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
    visit '/teams/list?id=1&amp;amp;type=Course'&lt;br /&gt;
    click_link 'Create Team'&lt;br /&gt;
    expect(page).to have_no_content('Inherit Teams From Course')&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Similarly, for creating a team for an assignment without a course, we test that the page does not contain 'Inherit Teams From Course'. For this particular test case, we added a new factory object defined as an assignment with the course set to nil.&lt;br /&gt;
This can not be tested manually because assignment cannot be created without a course parent.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  it 'should not display inherit teams while creating team for an assignment without a course' do&lt;br /&gt;
    create(:assignment_without_course)&lt;br /&gt;
    create(:assignment_without_course_node)&lt;br /&gt;
    create(:assignment_without_course_team)&lt;br /&gt;
    login_as(&amp;quot;instructor6&amp;quot;)    &lt;br /&gt;
    visit '/teams/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
    click_link 'Create Team'&lt;br /&gt;
    expect(page).to have_no_content('Inherit Teams From Course')&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
===Testing Create Method===&lt;br /&gt;
&lt;br /&gt;
This test checks that after creating an assignment team the count in the teams table increase by 1.&lt;br /&gt;
This test cannot be performed manually as it is testing the count of a database table.&lt;br /&gt;
But, the user can check this functionality online by logging in as an instructor, going to the assignment page of any course and clicking on 'create teams' icon. Following up with entering the required details and clicking on 'create team'.&lt;br /&gt;
&lt;br /&gt;
    describe &amp;quot;POST #create&amp;quot; do&lt;br /&gt;
    context &amp;quot;with an assignment team&amp;quot; do&lt;br /&gt;
      it &amp;quot;increases count by 1&amp;quot; do	&lt;br /&gt;
        expect{create :assignment_team, assignment: @assignment}.to change(Team,:count).by(1)&lt;br /&gt;
      end&lt;br /&gt;
     it &amp;quot;redirects to the list page&amp;quot; do&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
The same test an be applied to create a course team as well.&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;with a course team&amp;quot; do&lt;br /&gt;
      it &amp;quot;increases the count by 1&amp;quot; do&lt;br /&gt;
        expect{create :course_team, course: @course}.to change(Team,:count).by(1)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===Testing Delete Method===&lt;br /&gt;
    &lt;br /&gt;
The delete method should work for deleting both assignment and course teams. We check this functionality by deleting the respective team and then check if the count of Teams goes down by 1. &lt;br /&gt;
The user can check this test manually by logging in as an instructor navigating to the page of any team for an assignment and clicking on 'Delete Team' icon. &lt;br /&gt;
&lt;br /&gt;
   context &amp;quot;with an assignment team &amp;quot; do&lt;br /&gt;
      it &amp;quot;deletes an assignment team&amp;quot; do&lt;br /&gt;
        @assignment = create(:assignment)&lt;br /&gt;
        @a_team = create(:assignment_team)&lt;br /&gt;
        expect{ @a_team.delete }.to change(Team, :count).by(-1)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
Same Delete test has been applied to the course team&lt;br /&gt;
The manual check can also be performed in a similar way by logging in as an instructor navigating to the page of any team for an assignment and clicking on 'Delete Team' icon.&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    context &amp;quot;with a course team &amp;quot; do&lt;br /&gt;
      it &amp;quot;deletes a course team&amp;quot; do&lt;br /&gt;
        @course = create(:course)&lt;br /&gt;
        @c_team = create(:course_team)&lt;br /&gt;
        expect{ @c_team.delete }.to change(Team, :count).by(-1)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
===Testing List Method===&lt;br /&gt;
&lt;br /&gt;
The list method lists all the team nodes. This test that we have written, checks whether the instructor is able to view the team nodes in the list view.&lt;br /&gt;
To do this test manually user can log into the system as an instructor and click on any course, the course teams will be displayed. Also, the user can click on any team node to view information about that team.&lt;br /&gt;
&lt;br /&gt;
 describe 'List Team' do&lt;br /&gt;
 &lt;br /&gt;
   it 'should list all team nodes' do&lt;br /&gt;
     create(:assignment)&lt;br /&gt;
     create(:assignment_node)&lt;br /&gt;
     assignment_team = create(:assignment_team)&lt;br /&gt;
    team_user = create(:team_user)&lt;br /&gt;
     login_as(&amp;quot;instructor6&amp;quot;)&lt;br /&gt;
     visit '/teams/list?id=1&amp;amp;type=Assignment'&lt;br /&gt;
     page.all('#theTable tr').each do |tr|&lt;br /&gt;
       expect(tr).to have_content?(assignment_team.name)&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bhaskarsinha1311/expertiza/ Github] link to the project.&lt;br /&gt;
* [https://docs.google.com/document/d/1TFC0G3zW-xkJYuloh_BmvWnj3dGZB23GOIYuikNRf_I/edit Link] to the project description.&lt;br /&gt;
* [https://www.youtube.com/watch?v=CcSruLHQoeU/ Youtube video of tests]&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=139505</id>
		<title>CSC/ECE 517 Fall 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=139505"/>
		<updated>2021-10-20T20:28:41Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OSS Projects ==&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - {$num}. {$desc.title}]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2128. Refactor student_quizzes_controller.rb &amp;amp; late_policies_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2132. Add tests cases for review mapping helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2134. Write unit tests for admin_controller.rb and institution_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2138. Auto-generate submission directory names based on assignment]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2133. Write tests for popup_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2120. Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2139. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2131. Improve assessment360_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2121. Refactor suggestion_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2122. Refactor impersonate_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2126. Refactor account_request_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2124. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2125. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2127. Refactor teams_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2130. Refactor submitted_content_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2141. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2147. Role-based reviewing]]&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=139501</id>
		<title>CSC/ECE 517 Fall 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2021&amp;diff=139501"/>
		<updated>2021-10-20T20:25:07Z</updated>

		<summary type="html">&lt;p&gt;Akuchib: /* OSS Projects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== OSS Projects ==&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - {$num}. {$desc.title}]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2128. Refactor student_quizzes_controller.rb &amp;amp; late_policies_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2132. Add tests cases for review mapping helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2134. Write unit tests for admin_controller.rb and institution_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2138. Auto-generate submission directory names based on assignment]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2142. Improve e-mail notifications]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2133. Write tests for popup_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2120. Refactor reputation_web_service_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2139. Remove multiple topics at a time]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2131. Improve assessment360_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2121. Refactor suggestion_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2122. Refactor impersonate_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2126. Refactor account_request_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2124. Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2125. Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2127. Refactor teams_controller]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2127. Refactor submitted_content_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2141. OSS project Finklestein: Instructors &amp;amp; Institutions]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2021 - E2147. Role-based reviewing]]&lt;/div&gt;</summary>
		<author><name>Akuchib</name></author>
	</entry>
</feed>