<?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=Nnagara2</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=Nnagara2"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Nnagara2"/>
	<updated>2026-05-10T15:41:35Z</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_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100247</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100247"/>
		<updated>2015-12-05T02:41:27Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
The project was divided into 4 categories:&lt;br /&gt;
# Database migrations&lt;br /&gt;
# Refactor ''submitted_hyperlink'' related methods&lt;br /&gt;
# Refactor ''directory_num'' related methods&lt;br /&gt;
# Testing&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We followed the steps listed below in the process of refactoring the submitted content controller:&lt;br /&gt;
&lt;br /&gt;
* Writing database migrations to move the ''submitted_hyperlinks'' and ''directory_num'' attributes from the Participants table to the Teams table.&lt;br /&gt;
* Rewriting ''submitted_hyperlinks'' related methods in the Participants model to read from and write to the Teams table.&lt;br /&gt;
* Modifying the corresponding views to read ''hyperlinks_array'' instead of ''hyperlinks''. ''hyperlinks_array'' stores the the submissions of all the team members of a team. &lt;br /&gt;
* Removing ''directory_num'' related methods from the participant model.&lt;br /&gt;
* Rewriting ''directory_num'' related methods in the team model.&lt;br /&gt;
* Rewriting the corresponding views to read ''directory_num'' from the teams table instead of the participants table.&lt;br /&gt;
* For testing, we first created fixtures for all required tables.&lt;br /&gt;
* We tested our changes by writing functional tests to test the SubmittedContentController.&lt;br /&gt;
* Our test suite included the following tests:&lt;br /&gt;
** Testing submission of a hyperlink by one student - Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of two hyperlinks by two students in a team -  Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of the same hyperlink by two students in a team - Check that the duplicate hyperlinks does not get stored.&lt;br /&gt;
** Testing deletion of a hyperlink - Check the count of submmited hyperlinks and the updated list is displayed correctly from the UI.&lt;br /&gt;
** Testing submission of one file by one student - Check the submission of a file and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of one file by one student - Check the deletion of a submitted file and check the updated count of submitted files.&lt;br /&gt;
** Testing submission of multiple files by multiple students - Check the submission of multiple files and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of multiple files by multiple students - Check the deletion of multiple submitted files and check the updated count of submitted files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We can conclusively say that, after refactoring the submitted content controller, the query time for retrieving submissions will improve significantly as they are stored together on a team-basis rather than for each participant.&lt;br /&gt;
&lt;br /&gt;
Video demo of our work can be found at https://www.youtube.com/watch?v=VHVWF_UKgOc&amp;amp;feature=youtu.be &amp;lt;br&amp;gt;&lt;br /&gt;
GitHub repository containing the refactoring changes can be found at https://github.com/nitinnagaraja/expertiza/ &amp;lt;br&amp;gt;&lt;br /&gt;
Link to the pull request to Expertiza is https://github.com/expertiza/expertiza/pull/629&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100245</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100245"/>
		<updated>2015-12-05T02:41:05Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
The project was divided into 4 categories:&lt;br /&gt;
# Database migrations&lt;br /&gt;
# Refactor ''submitted_hyperlink'' related methods&lt;br /&gt;
# Refactor ''directory_num'' related methods&lt;br /&gt;
# Testing&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We followed the steps listed below in the process of refactoring the submitted content controller:&lt;br /&gt;
&lt;br /&gt;
* Writing database migrations to move the ''submitted_hyperlinks'' and ''directory_num'' attributes from the Participants table to the Teams table.&lt;br /&gt;
* Rewriting ''submitted_hyperlinks'' related methods in the Participants model to read from and write to the Teams table.&lt;br /&gt;
* Modifying the corresponding views to read ''hyperlinks_array'' instead of ''hyperlinks''. ''hyperlinks_array'' stores the the submissions of all the team members of a team. &lt;br /&gt;
* Removing ''directory_num'' related methods from the participant model.&lt;br /&gt;
* Rewriting ''directory_num'' related methods in the team model.&lt;br /&gt;
* Rewriting the corresponding views to read ''directory_num'' from the teams table instead of the participants table.&lt;br /&gt;
* For testing, we first created fixtures for all required tables.&lt;br /&gt;
* We tested our changes by writing functional tests to test the SubmittedContentController.&lt;br /&gt;
* Our test suite included the following tests:&lt;br /&gt;
** Testing submission of a hyperlink by one student - Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of two hyperlinks by two students in a team -  Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of the same hyperlink by two students in a team - Check that the duplicate hyperlinks does not get stored.&lt;br /&gt;
** Testing deletion of a hyperlink - Check the count of submmited hyperlinks and the updated list is displayed correctly from the UI.&lt;br /&gt;
** Testing submission of one file by one student - Check the submission of a file and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of one file by one student - Check the deletion of a submitted file and check the updated count of submitted files.&lt;br /&gt;
** Testing submission of multiple files by multiple students - Check the submission of multiple files and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of multiple files by multiple students - Check the deletion of multiple submitted files and check the updated count of submitted files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We can conclusively say that, after refactoring the submitted content controller, the query time for retrieving submissions will improve significantly as they are stored together on a team-basis rather than for each participant.&lt;br /&gt;
&lt;br /&gt;
Video demo of our work can be found at https://www.youtube.com/watch?v=VHVWF_UKgOc&amp;amp;feature=youtu.be &amp;lt;br&amp;gt;&lt;br /&gt;
GitHub repository containing the refactoring changes can be found at https://github.com/nitinnagaraja/expertiza/ &amp;lt;br&amp;gt;&lt;br /&gt;
Link to the pull request to Expertiza is https://github.com/expertiza/expertiza/pull/629&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100244</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100244"/>
		<updated>2015-12-05T02:38:10Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
The project was divided into 4 categories:&lt;br /&gt;
# Database migrations&lt;br /&gt;
# Refactor ''submitted_hyperlink'' related methods&lt;br /&gt;
# Refactor ''directory_num'' related methods&lt;br /&gt;
# Testing&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We followed the steps listed below in the process of refactoring the submitted content controller:&lt;br /&gt;
&lt;br /&gt;
* Writing database migrations to move the ''submitted_hyperlinks'' and ''directory_num'' attributes from the Participants table to the Teams table.&lt;br /&gt;
* Rewriting ''submitted_hyperlinks'' related methods in the Participants model to read from and write to the Teams table.&lt;br /&gt;
* Modifying the corresponding views to read ''hyperlinks_array'' instead of ''hyperlinks''. ''hyperlinks_array'' stores the the submissions of all the team members of a team. &lt;br /&gt;
* Removing ''directory_num'' related methods from the participant model.&lt;br /&gt;
* Rewriting ''directory_num'' related methods in the team model.&lt;br /&gt;
* Rewriting the corresponding views to read ''directory_num'' from the teams table instead of the participants table.&lt;br /&gt;
* For testing, we first created fixtures for all required tables.&lt;br /&gt;
* We tested our changes by writing functional tests to test the SubmittedContentController.&lt;br /&gt;
* Our test suite included the following tests:&lt;br /&gt;
** Testing submission of a hyperlink by one student - Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of two hyperlinks by two students in a team -  Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of the same hyperlink by two students in a team - Check that the duplicate hyperlinks does not get stored.&lt;br /&gt;
** Testing deletion of a hyperlink - Check the count of submmited hyperlinks and the updated list is displayed correctly from the UI.&lt;br /&gt;
** Testing submission of one file by one student - Check the submission of a file and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of one file by one student - Check the deletion of a submitted file and check the updated count of submitted files.&lt;br /&gt;
** Testing submission of multiple files by multiple students - Check the submission of multiple files and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of multiple files by multiple students - Check the deletion of multiple submitted files and check the updated count of submitted files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We can conclusively say that, after refactoring the submitted content controller, the query time for retrieving submissions will improve significantly as they are stored together on a team-basis rather than for each participant.&lt;br /&gt;
&lt;br /&gt;
Video demo of our work can be found at https://www.youtube.com/watch?v=VHVWF_UKgOc&amp;amp;feature=youtu.be &amp;lt;br&amp;gt;&lt;br /&gt;
GitHub repository containing the refactoring changes can be found at https://github.com/nitinnagaraja/expertiza/ &amp;lt;br&amp;gt;&lt;br /&gt;
Link to the pull request to Expertiza is https://github.com/expertiza/expertiza/pull/629&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100243</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100243"/>
		<updated>2015-12-05T02:37:16Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
The project was divided into 4 categories:&lt;br /&gt;
# Database migrations&lt;br /&gt;
# Refactor ''submitted_hyperlink'' related methods&lt;br /&gt;
# Refactor ''directory_num'' related methods&lt;br /&gt;
# Testing&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We followed the steps listed below in the process of refactoring the submitted content controller:&lt;br /&gt;
&lt;br /&gt;
* Writing database migrations to move the ''submitted_hyperlinks'' and ''directory_num'' attributes from the Participants table to the Teams table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* Rewriting ''submitted_hyperlinks'' related methods in the Participants model to read from and write to the Teams table.&lt;br /&gt;
* Modifying the corresponding views to read ''hyperlinks_array'' instead of ''hyperlinks''. ''hyperlinks_array'' stores the the submissions of all the team members of a team. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* Removing ''directory_num'' related methods from the participant model.&lt;br /&gt;
* Rewriting ''directory_num'' related methods in the team model.&lt;br /&gt;
* Rewriting the corresponding views to read ''directory_num'' from the teams table instead of the participants table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* For testing, we first created fixtures for all required tables.&lt;br /&gt;
* We tested our changes by writing functional tests to test the SubmittedContentController.&lt;br /&gt;
* Our test suite included the following tests:&lt;br /&gt;
** Testing submission of a hyperlink by one student - Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of two hyperlinks by two students in a team -  Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of the same hyperlink by two students in a team - Check that the duplicate hyperlinks does not get stored.&lt;br /&gt;
** Testing deletion of a hyperlink - Check the count of submmited hyperlinks and the updated list is displayed correctly from the UI.&lt;br /&gt;
** Testing submission of one file by one student - Check the submission of a file and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of one file by one student - Check the deletion of a submitted file and check the updated count of submitted files.&lt;br /&gt;
** Testing submission of multiple files by multiple students - Check the submission of multiple files and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of multiple files by multiple students - Check the deletion of multiple submitted files and check the updated count of submitted files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We can conclusively say that, after refactoring the submitted content controller, the query time for retrieving submissions will improve significantly as they are stored together on a team-basis rather than for each participant.&lt;br /&gt;
&lt;br /&gt;
Video demo of our work can be found at https://www.youtube.com/watch?v=VHVWF_UKgOc&amp;amp;feature=youtu.be &amp;lt;br&amp;gt;&lt;br /&gt;
GitHub repository containing the refactoring changes can be found at https://github.com/nitinnagaraja/expertiza/ &amp;lt;br&amp;gt;&lt;br /&gt;
Link to the pull request to Expertiza is https://github.com/expertiza/expertiza/pull/629&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100239</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100239"/>
		<updated>2015-12-05T02:20:31Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Problem Description =&lt;br /&gt;
The main purpose of this project is to improve how submitted hyperlinks are recorded in Expertiza in the current scheme. As of now, the submitted hyperlinks are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments). This results in a lot of redundant data.&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. When a team member wants to remove one hyperlink, Expertiza needs to loop over all the participants, which makes the code complicated and results in unnecessary computations.&lt;br /&gt;
Another aspect of this project requires moving the field '''directory_num''' from the '''participants''' table to the '''teams''' table. The '''directory_num''' field signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''. In the current design, since this field is in the '''participants''' table, we are forced to guarantee that all the team members have the same '''directory_num''', which results in redundant code.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
The project was divided into 4 categories:&lt;br /&gt;
# Database migrations&lt;br /&gt;
# Refactor ''submitted_hyperlink'' related methods&lt;br /&gt;
# Refactor ''directory_num'' related methods&lt;br /&gt;
# Testing&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We followed the steps listed below in the process of refactoring the submitted content controller:&lt;br /&gt;
&lt;br /&gt;
* Writing database migrations to move the ''submitted_hyperlinks'' and ''directory_num'' attributes from the Participants table to the Teams table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* Rewriting ''submitted_hyperlinks'' related methods in the Participants model to read from and write to the Teams table.&lt;br /&gt;
* Modifying the corresponding views to read ''hyperlinks_array'' instead of ''hyperlinks''. ''hyperlinks_array'' stores the the submissions of all the team members of a team. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* Removing ''directory_num'' related methods from the participant model.&lt;br /&gt;
* Rewriting ''directory_num'' related methods in the team model.&lt;br /&gt;
* Rewriting the corresponding views to read ''directory_num'' from the teams table instead of the participants table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* For testing, we first created fixtures for all required tables.&lt;br /&gt;
* We tested our changes by writing functional tests to test the SubmittedContentController.&lt;br /&gt;
* Our test suite included the following tests:&lt;br /&gt;
** Testing submission of a hyperlink by one student - Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of two hyperlinks by two students in a team -  Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of the same hyperlink by two students in a team - Check that the duplicate hyperlinks does not get stored.&lt;br /&gt;
** Testing deletion of a hyperlink - Check the count of submmited hyperlinks and the updated list is displayed correctly from the UI.&lt;br /&gt;
** Testing submission of one file by one student - Check the submission of a file and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of one file by one student - Check the deletion of a submitted file and check the updated count of submitted files.&lt;br /&gt;
** Testing submission of multiple files by multiple students - Check the submission of multiple files and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of multiple files by multiple students - Check the deletion of multiple submitted files and check the updated count of submitted files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We can conclusively say that, after refactoring the submitted content controller, the query time for retrieving submissions will improve significantly as they are stored together on a team-basis rather than for each participant.&lt;br /&gt;
&lt;br /&gt;
Video demo of our work can be found at https://www.youtube.com/watch?v=VHVWF_UKgOc&amp;amp;feature=youtu.be &amp;lt;br&amp;gt;&lt;br /&gt;
GitHub repository containing the refactoring changes can be found at https://github.com/nitinnagaraja/expertiza/ &amp;lt;br&amp;gt;&lt;br /&gt;
Link to the pull request to Expertiza is https://github.com/expertiza/expertiza/pull/629&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100237</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100237"/>
		<updated>2015-12-05T02:19:53Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Problem Description =&lt;br /&gt;
The main purpose of this project is to improve how submitted hyperlinks are recorded in Expertiza in the current scheme. As of now, the submitted hyperlinks are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments). This results in a lot of redundant data.&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. When a team member wants to remove one hyperlink, Expertiza needs to loop over all the participants, which makes the code complicated and results in unnecessary computations.&lt;br /&gt;
Another aspect of this project requires moving the field '''directory_num''' from the '''participants''' table to the '''teams''' table. The '''directory_num''' field signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''. In the current design, since this field is in the '''participants''' table, we are forced to guarantee that all the team members have the same '''directory_num''', which results in redundant code.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
The project was divided into 4 categories:&lt;br /&gt;
# Database migrations&lt;br /&gt;
# Refactor ''submitted_hyperlink'' related methods&lt;br /&gt;
# Refactor ''directory_num'' related methods&lt;br /&gt;
# Testing&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We followed the steps listed below in the process of refactoring the submitted content controller:&lt;br /&gt;
&lt;br /&gt;
* Writing database migrations to move the ''submitted_hyperlinks'' and ''directory_num'' attributes from the Participants table to the Teams table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* Rewriting ''submitted_hyperlinks'' related methods in the Participants model to read from and write to the Teams table.&lt;br /&gt;
* Modifying the corresponding views to read ''hyperlinks_array'' instead of ''hyperlinks''. ''hyperlinks_array'' stores the the submissions of all the team members of a team. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* Removing ''directory_num'' related methods from the participant model.&lt;br /&gt;
* Rewriting ''directory_num'' related methods in the team model.&lt;br /&gt;
* Rewriting the corresponding views to read ''directory_num'' from the teams table instead of the participants table.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* For testing, we first created fixtures for all required tables.&lt;br /&gt;
* We tested our changes by writing functional tests to test the SubmittedContentController.&lt;br /&gt;
* Our test suite included the following tests:&lt;br /&gt;
** Testing submission of a hyperlink by one student - Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of two hyperlinks by two students in a team -  Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of the same hyperlink by two students in a team - Check that the duplicate hyperlinks does not get stored.&lt;br /&gt;
** Testing deletion of a hyperlink - Check the count of submmited hyperlinks and the updated list is displayed correctly from the UI.&lt;br /&gt;
** Testing submission of one file by one student - Check the submission of a file and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of one file by one student - Check the deletion of a submitted file and check the updated count of submitted files.&lt;br /&gt;
** Testing submission of multiple files by multiple students - Check the submission of multiple files and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of multiple files by multiple students - Check the deletion of multiple submitted files and check the updated count of submitted files.&lt;br /&gt;
&lt;br /&gt;
We can conclusively say that, after refactoring the submitted content controller, the query time for retrieving submissions will improve significantly as they are stored together on a team-basis rather than for each participant.&lt;br /&gt;
&lt;br /&gt;
Video demo of our work can be found at https://www.youtube.com/watch?v=VHVWF_UKgOc&amp;amp;feature=youtu.be &amp;lt;br&amp;gt;&lt;br /&gt;
GitHub repository containing the refactoring changes can be found at https://github.com/nitinnagaraja/expertiza/ &amp;lt;br&amp;gt;&lt;br /&gt;
Link to the pull request to Expertiza is https://github.com/expertiza/expertiza/pull/629&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100236</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100236"/>
		<updated>2015-12-05T02:18:39Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Problem Description =&lt;br /&gt;
The main purpose of this project is to improve how submitted hyperlinks are recorded in Expertiza in the current scheme. As of now, the submitted hyperlinks are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments). This results in a lot of redundant data.&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. When a team member wants to remove one hyperlink, Expertiza needs to loop over all the participants, which makes the code complicated and results in unnecessary computations.&lt;br /&gt;
Another aspect of this project requires moving the field '''directory_num''' from the '''participants''' table to the '''teams''' table. The '''directory_num''' field signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''. In the current design, since this field is in the '''participants''' table, we are forced to guarantee that all the team members have the same '''directory_num''', which results in redundant code.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
The project was divided into 4 categories:&lt;br /&gt;
# Database migrations&lt;br /&gt;
# Refactor ''submitted_hyperlink'' related methods&lt;br /&gt;
# Refactor ''directory_num'' related methods&lt;br /&gt;
# Testing&lt;br /&gt;
&lt;br /&gt;
We followed the steps listed below in the process of refactoring the submitted content controller:&lt;br /&gt;
&lt;br /&gt;
* Writing database migrations to move the ''submitted_hyperlinks'' and ''directory_num'' attributes from the Participants table to the Teams table.&lt;br /&gt;
&lt;br /&gt;
* Rewriting ''submitted_hyperlinks'' related methods in the Participants model to read from and write to the Teams table.&lt;br /&gt;
* Modifying the corresponding views to read ''hyperlinks_array'' instead of ''hyperlinks''. ''hyperlinks_array'' stores the the submissions of all the team members of a team. &lt;br /&gt;
&lt;br /&gt;
* Removing ''directory_num'' related methods from the participant model.&lt;br /&gt;
* Rewriting ''directory_num'' related methods in the team model.&lt;br /&gt;
* Rewriting the corresponding views to read ''directory_num'' from the teams table instead of the participants table.&lt;br /&gt;
* For testing, we first created fixtures for all required tables.&lt;br /&gt;
* We tested our changes by writing functional tests to test the SubmittedContentController.&lt;br /&gt;
&lt;br /&gt;
* Our test suite included the following tests:&lt;br /&gt;
** Testing submission of a hyperlink by one student - Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of two hyperlinks by two students in a team -  Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of the same hyperlink by two students in a team - Check that the duplicate hyperlinks does not get stored.&lt;br /&gt;
** Testing deletion of a hyperlink - Check the count of submmited hyperlinks and the updated list is displayed correctly from the UI.&lt;br /&gt;
** Testing submission of one file by one student - Check the submission of a file and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of one file by one student - Check the deletion of a submitted file and check the updated count of submitted files.&lt;br /&gt;
** Testing submission of multiple files by multiple students - Check the submission of multiple files and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of multiple files by multiple students - Check the deletion of multiple submitted files and check the updated count of submitted files.&lt;br /&gt;
&lt;br /&gt;
We can conclusively say that, after refactoring the submitted content controller, the query time for retrieving submissions will improve significantly as they are stored together on a team-basis rather than for each participant.&lt;br /&gt;
&lt;br /&gt;
Video demo of our work can be found at https://www.youtube.com/watch?v=VHVWF_UKgOc&amp;amp;feature=youtu.be&lt;br /&gt;
GitHub repository containing the refactoring changes can be found at https://github.com/nitinnagaraja/expertiza/&lt;br /&gt;
Link to the pull request to Expertiza is https://github.com/expertiza/expertiza/pull/629&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100235</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100235"/>
		<updated>2015-12-05T02:16:15Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Problem Description =&lt;br /&gt;
The main purpose of this project is to improve how submitted hyperlinks are recorded in Expertiza in the current scheme. As of now, the submitted hyperlinks are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments). This results in a lot of redundant data.&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. When a team member wants to remove one hyperlink, Expertiza needs to loop over all the participants, which makes the code complicated and results in unnecessary computations.&lt;br /&gt;
Another aspect of this project requires moving the field '''directory_num''' from the '''participants''' table to the '''teams''' table. The '''directory_num''' field signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''. In the current design, since this field is in the '''participants''' table, we are forced to guarantee that all the team members have the same '''directory_num''', which results in redundant code.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
We followed the following steps in the process of refactoring the submitted content controller:&lt;br /&gt;
&lt;br /&gt;
* Writing database migrations to move the ''submitted_hyperlinks'' and ''directory_num'' attributes from the Participants table to the Teams table.&lt;br /&gt;
* Rewriting ''submitted_hyperlinks'' related methods in the Participants model to read from and write to the Teams table.&lt;br /&gt;
* Modifying the corresponding views to read ''hyperlinks_array'' instead of ''hyperlinks''. ''hyperlinks_array'' stores the the submissions of all the team members of a team. &lt;br /&gt;
* Removing ''directory_num'' related methods from the participant model.&lt;br /&gt;
* Rewriting ''directory_num'' related methods in the team model.&lt;br /&gt;
* Rewriting the corresponding views to read ''directory_num'' from the teams table instead of the participants table.&lt;br /&gt;
* For testing, we first created fixtures for all required tables.&lt;br /&gt;
* We tested our changes by writing functional tests to test the SubmittedContentController.&lt;br /&gt;
* Our test suite included the following tests:&lt;br /&gt;
** Testing submission of a hyperlink by one student - Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of two hyperlinks by two students in a team -  Check the count of submmited hyperlinks, verify that the hyperlink is stored properly in the database and displayed correctly from the UI.&lt;br /&gt;
** Testing submission of the same hyperlink by two students in a team - Check that the duplicate hyperlinks does not get stored.&lt;br /&gt;
** Testing deletion of a hyperlink - Check the count of submmited hyperlinks and the updated list is displayed correctly from the UI.&lt;br /&gt;
** Testing submission of one file by one student - Check the submission of a file and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of one file by one student - Check the deletion of a submitted file and check the updated count of submitted files.&lt;br /&gt;
** Testing submission of multiple files by multiple students - Check the submission of multiple files and check the updated count of submitted files.&lt;br /&gt;
** Testing deletion of multiple files by multiple students - Check the deletion of multiple submitted files and check the updated count of submitted files.&lt;br /&gt;
&lt;br /&gt;
We can conclusively say that, after refactoring the submitted content controller, the query time for retrieving submissions will improve significantly as they are stored together on a team-basis rather than for each participant.&lt;br /&gt;
&lt;br /&gt;
Video demo of our work can be found at https://www.youtube.com/watch?v=VHVWF_UKgOc&amp;amp;feature=youtu.be&lt;br /&gt;
GitHub repository containing the refactoring changes can be found at https://github.com/nitinnagaraja/expertiza/&lt;br /&gt;
Link to the pull request to Expertiza is https://github.com/expertiza/expertiza/pull/629&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100176</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100176"/>
		<updated>2015-12-05T01:02:11Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Problem Description =&lt;br /&gt;
The main purpose of this project is to improve how submitted hyperlinks are recorded in Expertiza in the current scheme. As of now, the submitted hyperlinks are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments). This results in a lot of redundant data.&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. When a team member wants to remove one hyperlink, Expertiza needs to loop over all the participants, which makes the code complicated and results in unnecessary computations.&lt;br /&gt;
Another aspect of this project requires moving the field '''directory_num''' from the '''participants''' table to the '''teams''' table. The '''directory_num''' field signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''. In the current design, since this field is in the '''participants''' table, we are forced to guarantee that all the team members have the same '''directory_num''', which results in redundant code.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
We followed the following steps in the process of refactoring the submitted content controller:&lt;br /&gt;
&lt;br /&gt;
# Writing database migrations to move the ''submitted_hyperlinks'' and ''directory_num'' attributes from the Participants table to the Teams table.&lt;br /&gt;
# Rewriting ''submitted_hyperlinks'' related methods in the Participants model to read from and write to the Teams table.&lt;br /&gt;
# Modifying the corresponding views to read ''hyperlinks_array'' instead of ''hyperlinks''. ''hyperlinks_array'' stores the the submissions of all the team members of a team. &lt;br /&gt;
# Removing ''directory_num'' related methods from the participant model.&lt;br /&gt;
# Rewriting ''directory_num'' related methods in the team model.&lt;br /&gt;
# Rewriting the corresponding views to read ''directory_num'' from the teams table instead of the participants table.&lt;br /&gt;
# For testing, we first created fixtures for all required tables.&lt;br /&gt;
# We tested our changes by writing functional tests to test the SubmittedContentController.&lt;br /&gt;
* Our test suite included the following tests:&lt;br /&gt;
** a&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100145</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100145"/>
		<updated>2015-12-05T00:15:40Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Problem Description =&lt;br /&gt;
The main purpose of this project is to improve how submitted hyperlinks are recorded in Expertiza in the current scheme. As of now, the submitted hyperlinks are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments). This results in a lot of redundant data.&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. When a team member wants to remove one hyperlink, Expertiza needs to loop over all the participants, which makes the code complicated and results in unnecessary computations.&lt;br /&gt;
Another aspect of this project requires moving the field '''directory_num''' from the '''participants''' table to the '''teams''' table. The '''directory_num''' field signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''. In the current design, since this field is in the '''participants''' table, we are forced to guarantee that all the team members have the same '''directory_num''', which results in redundant code.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
We made the following changes in the process of refactoring the submitted content controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang =&amp;quot;diff&amp;quot;&amp;gt;&lt;br /&gt;
 def participant_params&lt;br /&gt;
-  params.require(:participant).permit(:can_submit,:can_review,:user_id,:parent_id,:directory_num,:submitted_at,:permission_granted,:penalty_accumulated,:submitted_hypelinks,:grade,:type,:handle,:time_stamp,:digital_signature,:duty,:can_take_quiz)&lt;br /&gt;
+ params.require(:participant).permit(:can_submit,:can_review,:user_id,:parent_id,:submitted_at,:permission_granted,:penalty_accumulated,:grade,:type,:handle,:time_stamp,:digital_signature,:duty,:can_take_quiz)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100144</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100144"/>
		<updated>2015-12-05T00:13:04Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Problem Description =&lt;br /&gt;
The main purpose of this project is to improve how submitted hyperlinks are recorded in Expertiza in the current scheme. As of now, the submitted hyperlinks are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments). This results in a lot of redundant data.&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. When a team member wants to remove one hyperlink, Expertiza needs to loop over all the participants, which makes the code complicated and results in unnecessary computations.&lt;br /&gt;
Another aspect of this project requires moving the field '''directory_num''' from the '''participants''' table to the '''teams''' table. The '''directory_num''' field signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''. In the current design, since this field is in the '''participants''' table, we are forced to guarantee that all the team members have the same '''directory_num''', which results in redundant code.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
We made the following changes in the process of refactoring the submitted content controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang =&amp;quot;diff&amp;quot;&amp;gt;&lt;br /&gt;
 def participant_params&lt;br /&gt;
-  params.require(:participant).permit(:can_submit,:can_review,:user_id,:parent_id,:directory_num,:submitted_at,:permission_granted,:penalty_accumulated,:submitted_hypelinks,:grade,:type,:handle,:time_stamp,:digital_signature,:duty,:can_take_quiz) &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&lt;br /&gt;
+ params.require(:participant).permit(:can_submit,:can_review,:user_id,:parent_id,:submitted_at,:permission_granted,:penalty_accumulated,:grade,:type,:handle,:time_stamp,:digital_signature,:duty,:can_take_quiz)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100143</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100143"/>
		<updated>2015-12-05T00:12:11Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Problem Description =&lt;br /&gt;
The main purpose of this project is to improve how submitted hyperlinks are recorded in Expertiza in the current scheme. As of now, the submitted hyperlinks are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments). This results in a lot of redundant data.&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. When a team member wants to remove one hyperlink, Expertiza needs to loop over all the participants, which makes the code complicated and results in unnecessary computations.&lt;br /&gt;
Another aspect of this project requires moving the field '''directory_num''' from the '''participants''' table to the '''teams''' table. The '''directory_num''' field signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''. In the current design, since this field is in the '''participants''' table, we are forced to guarantee that all the team members have the same '''directory_num''', which results in redundant code.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
We made the following changes in the process of refactoring the submitted content controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang = diff&amp;gt;&lt;br /&gt;
 def participant_params&lt;br /&gt;
-  params.require(:participant).permit(:can_submit,:can_review,:user_id,:parent_id,:directory_num,:submitted_at,:permission_granted,:penalty_accumulated,:submitted_hypelinks,:grade,:type,:handle,:time_stamp,:digital_signature,:duty,:can_take_quiz) &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&lt;br /&gt;
+ params.require(:participant).permit(:can_submit,:can_review,:user_id,:parent_id,:submitted_at,:permission_granted,:penalty_accumulated,:grade,:type,:handle,:time_stamp,:digital_signature,:duty,:can_take_quiz)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100142</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100142"/>
		<updated>2015-12-05T00:08:41Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Problem Description =&lt;br /&gt;
The main purpose of this project is to improve how submitted hyperlinks are recorded in Expertiza in the current scheme. As of now, the submitted hyperlinks are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments). This results in a lot of redundant data.&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. When a team member wants to remove one hyperlink, Expertiza needs to loop over all the participants, which makes the code complicated and results in unnecessary computations.&lt;br /&gt;
Another aspect of this project requires moving the field '''directory_num''' from the '''participants''' table to the '''teams''' table. The '''directory_num''' field signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''. In the current design, since this field is in the '''participants''' table, we are forced to guarantee that all the team members have the same '''directory_num''', which results in redundant code.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
We made the following changes in the process of refactoring the submitted content controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def participant_params&lt;br /&gt;
- &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; params.require(:participant).permit(:can_submit,:can_review,:user_id,:parent_id,:directory_num,:submitted_at,:permission_granted,:penalty_accumulated,:submitted_hypelinks,:grade,:type,:handle,:time_stamp,:digital_signature,:duty,:can_take_quiz) &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&lt;br /&gt;
+ params.require(:participant).permit(:can_submit,:can_review,:user_id,:parent_id,:submitted_at,:permission_granted,:penalty_accumulated,:grade,:type,:handle,:time_stamp,:digital_signature,:duty,:can_take_quiz)&lt;br /&gt;
end &amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100141</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100141"/>
		<updated>2015-12-05T00:06:22Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Problem Description =&lt;br /&gt;
The main purpose of this project is to improve how submitted hyperlinks are recorded in Expertiza in the current scheme. As of now, the submitted hyperlinks are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments). This results in a lot of redundant data.&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. When a team member wants to remove one hyperlink, Expertiza needs to loop over all the participants, which makes the code complicated and results in unnecessary computations.&lt;br /&gt;
Another aspect of this project requires moving the field '''directory_num''' from the '''participants''' table to the '''teams''' table. The '''directory_num''' field signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''. In the current design, since this field is in the '''participants''' table, we are forced to guarantee that all the team members have the same '''directory_num''', which results in redundant code.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
We made the following changes in the process of refactoring the submitted content controller.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def participant_params&lt;br /&gt;
- params.require(:participant).permit(:can_submit,:can_review,:user_id,:parent_id,:directory_num,:submitted_at,:permission_granted,:penalty_accumulated,:submitted_hypelinks,:grade,:type,:handle,:time_stamp,:digital_signature,:duty,:can_take_quiz)&lt;br /&gt;
+ params.require(:participant).permit(:can_submit,:can_review,:user_id,:parent_id,:submitted_at,:permission_granted,:penalty_accumulated,:grade,:type,:handle,:time_stamp,:digital_signature,:duty,:can_take_quiz)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100140</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100140"/>
		<updated>2015-12-05T00:05:13Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Problem Description =&lt;br /&gt;
The main purpose of this project is to improve how submitted hyperlinks are recorded in Expertiza in the current scheme. As of now, the submitted hyperlinks are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments). This results in a lot of redundant data.&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. When a team member wants to remove one hyperlink, Expertiza needs to loop over all the participants, which makes the code complicated and results in unnecessary computations.&lt;br /&gt;
Another aspect of this project requires moving the field '''directory_num''' from the '''participants''' table to the '''teams''' table. The '''directory_num''' field signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''. In the current design, since this field is in the '''participants''' table, we are forced to guarantee that all the team members have the same '''directory_num''', which results in redundant code.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
We made the following changes in the process of refactoring the submitted content controller.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100116</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=100116"/>
		<updated>2015-12-04T22:39:44Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Problem Description =&lt;br /&gt;
The main purpose of this project is to improve how submitted hyperlinks are recorded in Expertiza in the current scheme. As of now, the submitted hyperlinks are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments). This results in a lot of redundant data.&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. When a team member wants to remove one hyperlink, Expertiza needs to loop over all the participants, which makes the code complicated and results in unnecessary computations.&lt;br /&gt;
Another aspect of this project requires moving the field '''directory_num''' from the '''participants''' table to the '''teams''' table. The '''directory_num''' field signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''. In the current design, since this field is in the '''participants''' table, we are forced to guarantee that all the team members have the same '''directory_num''', which results in redundant code.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
= Accomplishments =&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=99066</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=99066"/>
		<updated>2015-11-09T06:34:14Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Problem Description =&lt;br /&gt;
The main purpose of this project is to improve how submitted hyperlinks are recorded in Expertiza in the current scheme. As of now, the submitted hyperlinks are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments). This results in a lot of redundant data.&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. When a team member wants to remove one hyperlink, Expertiza needs to loop over all the participants, which makes the code complicated and results in unnecessary computations.&lt;br /&gt;
Another aspect of this project requires moving the field '''directory_num''' from the '''participants''' table to the '''teams''' table. The '''directory_num''' field signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''. In the current design, since this field is in the '''participants''' table, we are forced to guarantee that all the team members have the same '''directory_num''', which results in redundant code.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Future Work =&lt;br /&gt;
A proposal for further improvement would be to possibly create a new '''submitted_content''' table in the database. This table could include attributes like '''user_id''', '''team_id''', '''can_submit''', '''hyperlink''', '''directory_num''', '''uploaded_at''', '''updated_at'''. This approach would resolve the existing hyperlinks issue and more importantly, aid in recording a history of the submitted hyperlinks. There could be a “Show previous submissions” view for a team. So, if ever there’s a scenario where a student or an instructor needs to revert or go back and check a previous submission, he/she can easily access it from this table.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=99060</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=99060"/>
		<updated>2015-11-09T06:25:07Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an [https://en.wikipedia.org/wiki/Open_source open source] application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Problem Description =&lt;br /&gt;
The main purpose of this project is to improve how submitted hyperlinks are recorded in Expertiza in the current scheme. As of now, the submitted hyperlinks are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments). This results in a lot of redundant data.&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. When a team member wants to remove one hyperlink, Expertiza needs to loop over all the participants, which makes the code complicated and results in unnecessary computations.&lt;br /&gt;
Another aspect of this project requires moving the field '''directory_num''' from the '''participants''' table to the '''teams''' table. The '''directory_num''' field signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''. In the current design, since this field is in the '''participants''' table, we are forced to guarantee that all the team members have the same '''directory_num''', which results in redundant code.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=99059</id>
		<title>CSC/ECE 517 Fall 2015 E1576 Refactoring submitted content (hyperlinks and files)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015_E1576_Refactoring_submitted_content_(hyperlinks_and_files)&amp;diff=99059"/>
		<updated>2015-11-09T06:24:29Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction to Expertiza =&lt;br /&gt;
Expertiza&amp;lt;ref&amp;gt;https://github.com/expertiza/expertiza&amp;lt;/ref&amp;gt; is a project developed using Ruby on Rails&amp;lt;ref&amp;gt;http://guides.rubyonrails.org/getting_started.html&amp;lt;/ref&amp;gt;. It provides features like peer review, team assignments and submission of projects. This can be achieved by submitting code base, URL of hosted code on remote server and Wiki submissions. It is an open source application and the code can be cloned from [https://github.com/expertiza/expertiza GitHub]. This application provides an efficient way to manage assignments, grades and reviews. This makes the process easier and faster when the class strength is large.&lt;br /&gt;
&lt;br /&gt;
= Problem Statement =&lt;br /&gt;
&lt;br /&gt;
== Files involved ==&lt;br /&gt;
*'''assignment_participant.rb'''&lt;br /&gt;
*'''assignment_team.rb''' and &lt;br /&gt;
*views related to submitted hyperlinks and files ('''submitted_content/_hyperlink.html.erb''', '''submitted_content/_submitted_files.html.erb''')&lt;br /&gt;
&lt;br /&gt;
== What it does ==&lt;br /&gt;
It handles the display, submission, deletion of hyperlinks and files by the teams.&lt;br /&gt;
&lt;br /&gt;
== What is wrong with it ==&lt;br /&gt;
The submitted hyperlinks and files are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments).&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. Similar overhead happens when a team member wants to delete a submitted hyperlink. Also, the '''directory_num''' field needs to be moved from the '''participants''' table to the '''teams''' table. It signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''.&lt;br /&gt;
&lt;br /&gt;
== What needs to be done ==&lt;br /&gt;
*Create a new column '''hyperlinks''' in the '''teams''' table.&lt;br /&gt;
*Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. Duplicate hyperlinks need to be removed.&lt;br /&gt;
*Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&lt;br /&gt;
*Rewrite the hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' to make sure the new code works with the new db design.&lt;br /&gt;
*Make sure when doing the peer-review, the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*Make sure when instructor see the peer-review records, they can see the submitted content from the reviewees.&lt;br /&gt;
*Write db migration, move the '''directory_num''' field (also the content, of course) to the '''teams''' table.&lt;br /&gt;
*Move the '''set_student_directory_num''' method from '''participants_controller''' to '''teams_controller''', then refactor this method into smaller methods.&lt;br /&gt;
**This method no longer needs to test all the participants.&lt;br /&gt;
**Check if any of them have '''directory_num'''. If so, instead, it should just check the '''directory_num''' from '''teams''' table.&lt;br /&gt;
*Make change to the submitted-file-related code to make it work with the new design.&lt;br /&gt;
*Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Problem Description =&lt;br /&gt;
The main purpose of this project is to improve how submitted hyperlinks are recorded in Expertiza in the current scheme. As of now, the submitted hyperlinks are stored in '''participants''' table, which means they are associated with individuals instead of team. This is not a good design because in Expertiza, students are always grouped in teams, even when there is only one person in each team (individual assignments). This results in a lot of redundant data.&lt;br /&gt;
Currently, when a team member wants to see all the submitted hyperlinks of his team, Expertiza needs to load all the submitted hyperlinks from each participant in this team and merge them all before display. When a team member wants to remove one hyperlink, Expertiza needs to loop over all the participants, which makes the code complicated and results in unnecessary computations.&lt;br /&gt;
Another aspect of this project requires moving the field '''directory_num''' from the '''participants''' table to the '''teams''' table. The '''directory_num''' field signifies the sub-directory which stores all the files submitted by this team. Intuitively it is clear that each team should ideally have only one common copy of '''directory_num'''. In the current design, since this field is in the '''participants''' table, we are forced to guarantee that all the team members have the same '''directory_num''', which results in redundant code.&lt;br /&gt;
&lt;br /&gt;
= Scope =&lt;br /&gt;
This project can be divided into four major work items:&lt;br /&gt;
#Moving the '''hyperlinks''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''directory_num''' field from the '''participants''' table to the '''teams''' table. After this change, relevant changes are needed in the code to support this database change.&lt;br /&gt;
#Moving the '''set_student_directory_num''' method from the '''participants_controller''' to the '''teams_controller'''. It just needs to check '''directory_num''' from the '''team''' table.&lt;br /&gt;
#Write test cases to verify student-submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
= Implementation =&lt;br /&gt;
Expertiza files that will be modified for each work item along with the description:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 50px;&amp;quot; | Work Item #&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 225px;&amp;quot; | Files to be modified&lt;br /&gt;
! scope=&amp;quot;col&amp;quot; style=&amp;quot;width: 500px;&amp;quot; | Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || assignment_participant.rb&amp;lt;br&amp;gt;assignment_team.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Create a new column '''hyperlinks''' in '''teams''' table&amp;lt;br&amp;gt;- Write db migration, move all the participants’ submitted hyperlinks from '''participants''' table into '''teams''' table. All duplicated hyperlinks have to be removed.&amp;lt;br&amp;gt;- Write db migration, remove the '''hyperlinks''' field from '''participants''' table.&amp;lt;br&amp;gt;- hyperlink-related methods in both '''assignment_participant.rb''' and '''assignment_team.rb''' have to be rewritten to make sure the new code works with the new db design.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || participants_controller.rb&amp;lt;br&amp;gt;teams_controller.rb&amp;lt;br&amp;gt;db:participants table&amp;lt;br&amp;gt;db:teams table || - Write db migration, move the '''directory_num''' field (also the content) to '''teams''' table.&amp;lt;br&amp;gt;- Move the '''set_student_directory_num''' from '''participant_controller''' to '''team_controller''', then refactor this method into smaller methods.&amp;lt;br&amp;gt;- This method no longer needs to test all the participants and see if any of them have '''directory_num''', instead, it just check the '''directory_num''' from '''teams''' table.&amp;lt;br&amp;gt;- Make change to the submitted-file-related code to make sure it works with the new design.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || New files to be added || - Write test cases to test student-submitted hyperlinks and files.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
Consider a simple use case where we need to retrieve the submitted hyperlinks and files corresponding to '''team_id''', say, '''23841'''. Since there is no existing correlation between teams and submitted content, we will first need to look up the '''participants''' in the team using the '''teams_users''' table. And then, using those user_id values one at a time, we need to look up the '''participants''' table.&lt;br /&gt;
&lt;br /&gt;
[[File:db.jpg]]&lt;br /&gt;
&lt;br /&gt;
Finally, we need to merge the results before displaying it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
  links = Array.new&lt;br /&gt;
  self.participants.each { |team_member|&lt;br /&gt;
    links.concat(team_member.hyperlinks_array) if team_member.hyperlinks_array}&lt;br /&gt;
  links&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, it becomes a tedious 3-step process. It is evident from this example that the current design is inefficient.&lt;br /&gt;
&lt;br /&gt;
Instead, if the hyperlinks data were available in '''teams''' table, we could directly access all the submitted content for a team in one shot, making it much more streamlined.&lt;br /&gt;
&lt;br /&gt;
As a part of this change, we’ll have to move the following routines in '''assignment_participants.rb''', which deal hyperlink handling to '''assignment_team.rb'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  # Appends the hyperlink to a list that is stored in YAML format in the DB&lt;br /&gt;
  # @exception  If is hyperlink was already there&lt;br /&gt;
  #             If it is an invalid URL&lt;br /&gt;
  def submit_hyperlink(hyperlink)&lt;br /&gt;
    hyperlink.strip!&lt;br /&gt;
    raise &amp;quot;The hyperlink cannot be empty&amp;quot; if hyperlink.empty?&lt;br /&gt;
    url = URI.parse(hyperlink)&lt;br /&gt;
    # If not a valid URL, it will throw an exception&lt;br /&gt;
    Net::HTTP.start(url.host, url.port)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks &amp;lt;&amp;lt; hyperlink&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  # Note: This method is not used yet. It is here in the case it will be&lt;br /&gt;
    needed.&lt;br /&gt;
  # @exception  If the index does not exist in the array&lt;br /&gt;
  def remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    hyperlinks = self.hyperlinks_array&lt;br /&gt;
    hyperlinks.delete(hyperlink_to_delete)&lt;br /&gt;
    self.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    self.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
    team.try(:hyperlinks) || []&lt;br /&gt;
  end&lt;br /&gt;
 &lt;br /&gt;
  def hyperlinks_array&lt;br /&gt;
    self.submitted_hyperlinks.blank? ? [] :YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similar refactoring work needs to be done for the '''directory_num''' field as well.&lt;br /&gt;
Finally, the refactoring needs to be thoroughly tested by writing test cases for student-submitted hyperlinks and files by making sure that:&lt;br /&gt;
*the submitted hyperlinks and files are correctly displayed on the submitted content page.&lt;br /&gt;
*the reviewer can see the submitted content from the reviewees.&lt;br /&gt;
*the instructor can see the submitted content from the reviewees.&lt;br /&gt;
&lt;br /&gt;
== Use Cases ==&lt;br /&gt;
'''Use Case 1:''' Submit hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The submitted hyperlink should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted hyperlink is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted hyperlink.&lt;br /&gt;
#A reviewer should be able to see the submitted hyperlink.&lt;br /&gt;
#An instructor should be able to see the submitted hyperlink.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
'''Use Case 2:''' Submit file for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to submit a file on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to submit the file.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The directory_num field which stores the directory number of the directory storing all the submitted files for a team should be stored in the teams table of the database.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The submitted file is visible every time the student views the “Your work” section for the Assignment.&lt;br /&gt;
#All other team members should be able to view the submitted file.&lt;br /&gt;
#A reviewer should be able to see the submitted file.&lt;br /&gt;
#An instructor should be able to see the submitted file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case 3:''' Delete hyperlink for an assignment by student.&lt;br /&gt;
 &lt;br /&gt;
'''Description:''' A student who is an assignment participant should be able to delete submitted hyperlink on the “Your work” section of an assignment.&lt;br /&gt;
 &lt;br /&gt;
'''Preconditions:''' Student should be a participant for the assignment he is trying to delete the hyperlink.&lt;br /&gt;
 &lt;br /&gt;
'''Postconditions:''' The deleted hyperlink should be removed from the teams table in DB.&lt;br /&gt;
 &lt;br /&gt;
'''Success Scenario:'''&lt;br /&gt;
#The deleted hyperlink should not be visible the next time the student clicks on “Your work” section.&lt;br /&gt;
#All other team members should not see the deleted hyperlink.&lt;br /&gt;
#A reviewer should not be able to see the deleted hyperlink.&lt;br /&gt;
#An instructor should not be able to see the deleted hyperlink.&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98963</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98963"/>
		<updated>2015-11-08T02:55:58Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ''ReviewMappingController''.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&lt;br /&gt;
Ensure that MySQL is already setup on your system. If you are using an Ubuntu system, the following commands can be used to install MySQL:&lt;br /&gt;
    sudo apt-get install mysql-server&lt;br /&gt;
    sudo apt-get install mysql-client&lt;br /&gt;
&lt;br /&gt;
===Clone the reopsitory===&lt;br /&gt;
In your local directory, clone the updated GitHub repository.&lt;br /&gt;
      &lt;br /&gt;
    git clone https://github.com/rrpod/expertiza.git&lt;br /&gt;
&lt;br /&gt;
Visit https://help.github.com for getting more information on setting up git.&lt;br /&gt;
&lt;br /&gt;
===Installing Gems===&lt;br /&gt;
&lt;br /&gt;
Go to the local expertiza directory:&lt;br /&gt;
&lt;br /&gt;
    bundle install&lt;br /&gt;
&lt;br /&gt;
===Running the test cases===&lt;br /&gt;
&lt;br /&gt;
From the expertiza directory, run the following command:&lt;br /&gt;
&lt;br /&gt;
    rspec spec/controllers/review_mapping_spec_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ''ReviewMappingController'' file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ''ReviewMappingController'':&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
In the process of refactoring, we have actively followed the Ruby coding guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;. We have also followed some design pattern rules like Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;, which state that every class should have responsibility over a single part of functionality provided by software and that responsibility should be entirely encapsulated by the class. All the services and operations within the class should be aligned with that responsibility.&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other function is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
==About rspec==&lt;br /&gt;
[http://rspec.info/ Rspec] is a Behavior-driven development for Ruby programming language widely used for Test Driven Development. It has its own mocking framework based upon JMock. &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/RSpec&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
====Test Case 1: Check if on getting release mapping it redirects to student review controller====&lt;br /&gt;
    it &amp;quot;should use release_mapping to redirect to student_review controller&amp;quot; do&lt;br /&gt;
        get :release_mapping, id: @assignment.id&lt;br /&gt;
        expect(response).should redirect_to(:controller =&amp;gt; 'student_review', :action =&amp;gt; 'list', :id=&amp;gt; '828')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Test Case 2: Check if on delete outstanding reviewers it redirects to list mapping====&lt;br /&gt;
    it &amp;quot;should delete outstanding reviewers to redirect to list_mappings&amp;quot; do&lt;br /&gt;
        get :delete_outstanding_reviewers, id: @assignment.id, contributor_id: 200&lt;br /&gt;
        expect(response).should redirect_to(:action =&amp;gt; 'list_mappings', :id =&amp;gt; 200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 3: Check if rendered report matches the required template====&lt;br /&gt;
    it &amp;quot;should render appropritate response report&amp;quot; do&lt;br /&gt;
        get :response_report, id: 723&lt;br /&gt;
        response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 4: Check if rendered report matches the required template for a specific user====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :user =&amp;gt; {:fullname=&amp;gt; '523, student'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 5: Check if rendered report matches the required template for a specific user with type FeedbackResponseMap====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user with type FeedbackResponseMap&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :report =&amp;gt; {:type=&amp;gt; 'FeedbackResponseMap'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
'''View Response Report'''&lt;br /&gt;
[[File:View_assignment_response_report.png]]&lt;br /&gt;
&lt;br /&gt;
'''View Response Report by name'''&amp;lt;br&amp;gt;&lt;br /&gt;
Search for Reviewer's name &amp;quot;523, student&amp;quot;&lt;br /&gt;
[[File:Copy_view_response_report_by_name_-_Copy.png]]&lt;br /&gt;
&lt;br /&gt;
'''View Feedback Response Map'''&lt;br /&gt;
[[File:Copy_view_feedback_response_map_report_-_Copy.png]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ''ReviewMappingController'', extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98092</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98092"/>
		<updated>2015-11-01T04:59:54Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ''ReviewMappingController''.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&lt;br /&gt;
Ensure that MySQL is already setup on your system. If you are using an Ubuntu system, the following commands can be used to install MySQL:&lt;br /&gt;
    sudo apt-get install mysql-server&lt;br /&gt;
    sudo apt-get install mysql-client&lt;br /&gt;
&lt;br /&gt;
===Clone the reopsitory===&lt;br /&gt;
In your local directory, clone the Github repository.&lt;br /&gt;
      &lt;br /&gt;
    git clone https://github.com/rrpod/expertiza.git&lt;br /&gt;
&lt;br /&gt;
Visit https://help.github.com for getting more information on setting up git.&lt;br /&gt;
&lt;br /&gt;
===Installing Gems===&lt;br /&gt;
&lt;br /&gt;
Go to the local expertiza directory:&lt;br /&gt;
&lt;br /&gt;
    bundle install&lt;br /&gt;
&lt;br /&gt;
===Running the test cases===&lt;br /&gt;
&lt;br /&gt;
From the expertiza directory, run the following command:&lt;br /&gt;
&lt;br /&gt;
    rspec spec/controllers/review_mapping_spec_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ''ReviewMappingController'' file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ''ReviewMappingController'':&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
In the process of refactoring, we have actively followed the Ruby coding guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;. We have also followed some design pattern rules like Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;, which state that every class should have responsibility over a single part of functionality provided by software and that responsibility should be entirely encapsulated by the class. All the services and operations within the class should be aligned with that responsibility.&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other function is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
==About rspec==&lt;br /&gt;
[http://rspec.info/ Rspec] is a Behavior-driven development for Ruby programming language widely used for Test Driven Development. It has its own mocking framework based upon JMock. &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/RSpec&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
====Test Case 1: Check if on getting release mapping it redirects to student review controller====&lt;br /&gt;
    it &amp;quot;should use release_mapping to redirect to student_review controller&amp;quot; do&lt;br /&gt;
        get :release_mapping, id: @assignment.id&lt;br /&gt;
        expect(response).should redirect_to(:controller =&amp;gt; 'student_review', :action =&amp;gt; 'list', :id=&amp;gt; '828')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Test Case 2: Check if on delete outstanding reviewers it redirects to list mapping====&lt;br /&gt;
    it &amp;quot;should delete outstanding reviewers to redirect to list_mappings&amp;quot; do&lt;br /&gt;
        get :delete_outstanding_reviewers, id: @assignment.id, contributor_id: 200&lt;br /&gt;
        expect(response).should redirect_to(:action =&amp;gt; 'list_mappings', :id =&amp;gt; 200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 3: Check if rendered report matches the required template====&lt;br /&gt;
    it &amp;quot;should render appropritate response report&amp;quot; do&lt;br /&gt;
        get :response_report, id: 723&lt;br /&gt;
        response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 4: Check if rendered report matches the required template for a specific user====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :user =&amp;gt; {:fullname=&amp;gt; '523, student'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 5: Check if rendered report matches the required template for a specific user with type FeedbackResponseMap====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user with type FeedbackResponseMap&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :report =&amp;gt; {:type=&amp;gt; 'FeedbackResponseMap'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
'''View Response Report'''&lt;br /&gt;
[[File:View_assignment_response_report.png]]&lt;br /&gt;
&lt;br /&gt;
'''View Response Report by name'''&amp;lt;br&amp;gt;&lt;br /&gt;
Search for Reviewer's name &amp;quot;523, student&amp;quot;&lt;br /&gt;
[[File:Copy_view_response_report_by_name_-_Copy.png]]&lt;br /&gt;
&lt;br /&gt;
'''View Feedback Response Map'''&lt;br /&gt;
[[File:Copy_view_feedback_response_map_report_-_Copy.png]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ''ReviewMappingController'', extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98091</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98091"/>
		<updated>2015-11-01T04:57:54Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ''ReviewMappingController''.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&lt;br /&gt;
Ensure that MySQL is already setup on your system. If you are using an Ubuntu system, the following commands can be used to install MySQL:&lt;br /&gt;
    sudo apt-get install mysql-server&lt;br /&gt;
    sudo apt-get install mysql-client&lt;br /&gt;
&lt;br /&gt;
===Clone the reopsitory===&lt;br /&gt;
In your local directory, clone the Github repository.&lt;br /&gt;
      &lt;br /&gt;
    git clone https://github.com/rrpod/expertiza.git&lt;br /&gt;
&lt;br /&gt;
Visit https://help.github.com for getting more information on setting up git.&lt;br /&gt;
&lt;br /&gt;
===Installing Gems===&lt;br /&gt;
&lt;br /&gt;
Go to the local expertiza directory:&lt;br /&gt;
&lt;br /&gt;
    bundle install&lt;br /&gt;
&lt;br /&gt;
===Running the test cases===&lt;br /&gt;
&lt;br /&gt;
From the expertiza directory, run the following command:&lt;br /&gt;
&lt;br /&gt;
    rspec spec/controllers/review_mapping_spec_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ''ReviewMappingController'' file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ''ReviewMappingController'':&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
In the process of refactoring, we have actively followed the Ruby coding guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;. We have also followed some design pattern rules like Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;, which state that every class should have responsibility over a single part of functionality provided by software and that responsibility should be entirely encapsulated by the class. All the services and operations within the class should be aligned with that responsibility.&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other function is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
==About rspec==&lt;br /&gt;
[http://rspec.info/ Rspec] is a Behavior-driven development for Ruby programming language widely used for Test Driven Development. It has its own mocking framework based upon JMock. &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/RSpec&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
====Test Case 1: Check if on getting release mapping it redirects to student review controller====&lt;br /&gt;
    it &amp;quot;should use release_mapping to redirect to student_review controller&amp;quot; do&lt;br /&gt;
        get :release_mapping, id: @assignment.id&lt;br /&gt;
        expect(response).should redirect_to(:controller =&amp;gt; 'student_review', :action =&amp;gt; 'list', :id=&amp;gt; '828')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Test Case 2: Check if on delete outstanding reviewers it redirects to list mapping====&lt;br /&gt;
    it &amp;quot;should delete outstanding reviewers to redirect to list_mappings&amp;quot; do&lt;br /&gt;
        get :delete_outstanding_reviewers, id: @assignment.id, contributor_id: 200&lt;br /&gt;
        expect(response).should redirect_to(:action =&amp;gt; 'list_mappings', :id =&amp;gt; 200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 3: Check if rendered report matches the required template====&lt;br /&gt;
    it &amp;quot;should render appropritate response report&amp;quot; do&lt;br /&gt;
        get :response_report, id: 723&lt;br /&gt;
        response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 4: Check if rendered report matches the required template for a specific user====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :user =&amp;gt; {:fullname=&amp;gt; '523, student'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 5: Check if rendered report matches the required template for a specific user with type FeedbackResponseMap====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user with type FeedbackResponseMap&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :report =&amp;gt; {:type=&amp;gt; 'FeedbackResponseMap'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
'''View Response Report'''&lt;br /&gt;
[[File:View_assignment_response_report.png]]&lt;br /&gt;
&lt;br /&gt;
'''View Response Report by name'''&lt;br /&gt;
Search for Reviewer's name &amp;quot;523, student&amp;quot;&lt;br /&gt;
[[File:Copy_view_response_report_by_name_-_Copy.png]]&lt;br /&gt;
&lt;br /&gt;
'''View Feedback Response Map'''&lt;br /&gt;
[[File:Copy_view_feedback_response_map_report_-_Copy.png]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ''ReviewMappingController'', extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98090</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98090"/>
		<updated>2015-11-01T04:47:24Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ''ReviewMappingController''.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&lt;br /&gt;
Ensure that MySQL is already setup on your system. If you are using an Ubuntu system, the following commands can be used to install MySQL:&lt;br /&gt;
    sudo apt-get install mysql-server&lt;br /&gt;
    sudo apt-get install mysql-client&lt;br /&gt;
&lt;br /&gt;
===Clone the reopsitory===&lt;br /&gt;
In your local directory, clone the Github repository.&lt;br /&gt;
      &lt;br /&gt;
    git clone https://github.com/rrpod/expertiza.git&lt;br /&gt;
&lt;br /&gt;
Visit https://help.github.com for getting more information on setting up git.&lt;br /&gt;
&lt;br /&gt;
===Installing Gems===&lt;br /&gt;
&lt;br /&gt;
Go to the local expertiza directory:&lt;br /&gt;
&lt;br /&gt;
    bundle install&lt;br /&gt;
&lt;br /&gt;
===Running the test cases===&lt;br /&gt;
&lt;br /&gt;
From the expertiza directory, run the following command:&lt;br /&gt;
&lt;br /&gt;
    rspec spec/controllers/review_mapping_spec_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ''ReviewMappingController'' file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ''ReviewMappingController'':&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
In the process of refactoring, we have actively followed the Ruby coding guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;. We have also followed some design pattern rules like Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;, which state that every class should have responsibility over a single part of functionality provided by software and that responsibility should be entirely encapsulated by the class. All the services and operations within the class should be aligned with that responsibility.&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other function is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
==About rspec==&lt;br /&gt;
[http://rspec.info/ Rspec] is a Behavior-driven development for Ruby programming language widely used for Test Driven Development. It has its own mocking framework based upon JMock. &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/RSpec&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
====Test Case 1: Check if on getting release mapping it redirects to student review controller====&lt;br /&gt;
    it &amp;quot;should use release_mapping to redirect to student_review controller&amp;quot; do&lt;br /&gt;
        get :release_mapping, id: @assignment.id&lt;br /&gt;
        expect(response).should redirect_to(:controller =&amp;gt; 'student_review', :action =&amp;gt; 'list', :id=&amp;gt; '828')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Test Case 2: Check if on delete outstanding reviewers it redirects to list mapping====&lt;br /&gt;
    it &amp;quot;should delete outstanding reviewers to redirect to list_mappings&amp;quot; do&lt;br /&gt;
        get :delete_outstanding_reviewers, id: @assignment.id, contributor_id: 200&lt;br /&gt;
        expect(response).should redirect_to(:action =&amp;gt; 'list_mappings', :id =&amp;gt; 200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 3: Check if rendered report matches the required template====&lt;br /&gt;
    it &amp;quot;should render appropritate response report&amp;quot; do&lt;br /&gt;
        get :response_report, id: 723&lt;br /&gt;
        response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 4: Check if rendered report matches the required template for a specific user====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :user =&amp;gt; {:fullname=&amp;gt; '523, student'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 5: Check if rendered report matches the required template for a specific user with type FeedbackResponseMap====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user with type FeedbackResponseMap&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :report =&amp;gt; {:type=&amp;gt; 'FeedbackResponseMap'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
View Response Report&lt;br /&gt;
[[File:View_assignment_response_report.png]]&lt;br /&gt;
&lt;br /&gt;
View Response Report by name&lt;br /&gt;
[[File:Copy_view_response_report_by_name_-_Copy.png]]&lt;br /&gt;
&lt;br /&gt;
View Feedback Response Map&lt;br /&gt;
[[File:Copy_view_feedback_response_map_report_-_Copy.png]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ''ReviewMappingController'', extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98089</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98089"/>
		<updated>2015-11-01T04:46:48Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ''ReviewMappingController''.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&lt;br /&gt;
Ensure that MySQL is already setup on your system. If you are using an Ubuntu system, the following commands can be used to install MySQL:&lt;br /&gt;
    sudo apt-get install mysql-server&lt;br /&gt;
    sudo apt-get install mysql-client&lt;br /&gt;
&lt;br /&gt;
===Clone the reopsitory===&lt;br /&gt;
In your local directory, clone the Github repository.&lt;br /&gt;
      &lt;br /&gt;
    git clone https://github.com/rrpod/expertiza.git&lt;br /&gt;
&lt;br /&gt;
Visit https://help.github.com for getting more information on setting up git.&lt;br /&gt;
&lt;br /&gt;
===Installing Gems===&lt;br /&gt;
&lt;br /&gt;
Go to the local expertiza directory:&lt;br /&gt;
&lt;br /&gt;
    bundle install&lt;br /&gt;
&lt;br /&gt;
===Running the test cases===&lt;br /&gt;
&lt;br /&gt;
From the expertiza directory, run the following command:&lt;br /&gt;
&lt;br /&gt;
    rspec spec/controllers/review_mapping_spec_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ''ReviewMappingController'' file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ''ReviewMappingController'':&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
In the process of refactoring, we have actively followed the Ruby coding guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;. We have also followed some design pattern rules like Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;, which state that every class should have responsibility over a single part of functionality provided by software and that responsibility should be entirely encapsulated by the class. All the services and operations within the class should be aligned with that responsibility.&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other function is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
==About rspec==&lt;br /&gt;
[http://rspec.info/ Rspec] is a Behavior-driven development for Ruby programming language widely used for Test Driven Development. It has its own mocking framework based upon JMock. &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/RSpec&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
====Test Case 1: Check if on getting release mapping it redirects to student review controller====&lt;br /&gt;
    it &amp;quot;should use release_mapping to redirect to student_review controller&amp;quot; do&lt;br /&gt;
        get :release_mapping, id: @assignment.id&lt;br /&gt;
        expect(response).should redirect_to(:controller =&amp;gt; 'student_review', :action =&amp;gt; 'list', :id=&amp;gt; '828')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Test Case 2: Check if on delete outstanding reviewers it redirects to list mapping====&lt;br /&gt;
    it &amp;quot;should delete outstanding reviewers to redirect to list_mappings&amp;quot; do&lt;br /&gt;
        get :delete_outstanding_reviewers, id: @assignment.id, contributor_id: 200&lt;br /&gt;
        expect(response).should redirect_to(:action =&amp;gt; 'list_mappings', :id =&amp;gt; 200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 3: Check if rendered report matches the required template====&lt;br /&gt;
    it &amp;quot;should render appropritate response report&amp;quot; do&lt;br /&gt;
        get :response_report, id: 723&lt;br /&gt;
        response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 4: Check if rendered report matches the required template for a specific user====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :user =&amp;gt; {:fullname=&amp;gt; '523, student'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 5: Check if rendered report matches the required template for a specific user with type FeedbackResponseMap====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user with type FeedbackResponseMap&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :report =&amp;gt; {:type=&amp;gt; 'FeedbackResponseMap'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
View Response Report&lt;br /&gt;
[[File:View_assignment_response_report.png]]&lt;br /&gt;
&lt;br /&gt;
View Response Report by name&lt;br /&gt;
[[File:Copy_view_response_report_by_name_-_Copy.png]]&lt;br /&gt;
&lt;br /&gt;
View Feedback Response Map&lt;br /&gt;
[[File:Copy_view_feedback_response_map_report_-_Copy.png]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ''ReviewMappingController'', extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98088</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98088"/>
		<updated>2015-11-01T04:44:40Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ''ReviewMappingController''.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&lt;br /&gt;
Ensure that MySQL is already setup on your system. If you are using an Ubuntu system, the following commands can be used to install MySQL:&lt;br /&gt;
    sudo apt-get install mysql-server&lt;br /&gt;
    sudo apt-get install mysql-client&lt;br /&gt;
&lt;br /&gt;
===Clone the reopsitory===&lt;br /&gt;
In your local directory, clone the Github repository.&lt;br /&gt;
      &lt;br /&gt;
    git clone https://github.com/rrpod/expertiza.git&lt;br /&gt;
&lt;br /&gt;
Visit https://help.github.com for getting more information on setting up git.&lt;br /&gt;
&lt;br /&gt;
===Installing Gems===&lt;br /&gt;
&lt;br /&gt;
Go to the local expertiza directory:&lt;br /&gt;
&lt;br /&gt;
    bundle install&lt;br /&gt;
&lt;br /&gt;
===Running the test cases===&lt;br /&gt;
&lt;br /&gt;
From the expertiza directory, run the following command:&lt;br /&gt;
&lt;br /&gt;
    rspec spec/controllers/review_mapping_spec_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ''ReviewMappingController'' file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ''ReviewMappingController'':&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other function is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
==About rspec==&lt;br /&gt;
[http://rspec.info/ Rspec] is a Behavior-driven development for Ruby programming language widely used for Test Driven Development. It has its own mocking framework based upon JMock. &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/RSpec&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
====Test Case 1: Check if on getting release mapping it redirects to student review controller====&lt;br /&gt;
    it &amp;quot;should use release_mapping to redirect to student_review controller&amp;quot; do&lt;br /&gt;
        get :release_mapping, id: @assignment.id&lt;br /&gt;
        expect(response).should redirect_to(:controller =&amp;gt; 'student_review', :action =&amp;gt; 'list', :id=&amp;gt; '828')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Test Case 2: Check if on delete outstanding reviewers it redirects to list mapping====&lt;br /&gt;
    it &amp;quot;should delete outstanding reviewers to redirect to list_mappings&amp;quot; do&lt;br /&gt;
        get :delete_outstanding_reviewers, id: @assignment.id, contributor_id: 200&lt;br /&gt;
        expect(response).should redirect_to(:action =&amp;gt; 'list_mappings', :id =&amp;gt; 200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 3: Check if rendered report matches the required template====&lt;br /&gt;
    it &amp;quot;should render appropritate response report&amp;quot; do&lt;br /&gt;
        get :response_report, id: 723&lt;br /&gt;
        response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 4: Check if rendered report matches the required template for a specific user====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :user =&amp;gt; {:fullname=&amp;gt; '523, student'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 5: Check if rendered report matches the required template for a specific user with type FeedbackResponseMap====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user with type FeedbackResponseMap&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :report =&amp;gt; {:type=&amp;gt; 'FeedbackResponseMap'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
View Response Report&lt;br /&gt;
[[File:View_assignment_response_report.png]]&lt;br /&gt;
&lt;br /&gt;
View Response Report by name&lt;br /&gt;
[[File:Copy_view_response_report_by_name_-_Copy.png]]&lt;br /&gt;
&lt;br /&gt;
View Feedback Response Map&lt;br /&gt;
[[File:Copy_view_feedback_response_map_report_-_Copy.png]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ''ReviewMappingController'', extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Copy_view_feedback_response_map_report_-_Copy.png&amp;diff=98087</id>
		<title>File:Copy view feedback response map report - Copy.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Copy_view_feedback_response_map_report_-_Copy.png&amp;diff=98087"/>
		<updated>2015-11-01T04:44:27Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98086</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98086"/>
		<updated>2015-11-01T04:37:59Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ''ReviewMappingController''.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&lt;br /&gt;
Ensure that MySQL is already setup on your system. If you are using an Ubuntu system, the following commands can be used to install MySQL:&lt;br /&gt;
    sudo apt-get install mysql-server&lt;br /&gt;
    sudo apt-get install mysql-client&lt;br /&gt;
&lt;br /&gt;
===Clone the reopsitory===&lt;br /&gt;
In your local directory, clone the Github repository.&lt;br /&gt;
      &lt;br /&gt;
    git clone https://github.com/rrpod/expertiza.git&lt;br /&gt;
&lt;br /&gt;
Visit https://help.github.com for getting more information on setting up git.&lt;br /&gt;
&lt;br /&gt;
===Installing Gems===&lt;br /&gt;
&lt;br /&gt;
Go to the local expertiza directory:&lt;br /&gt;
&lt;br /&gt;
    bundle install&lt;br /&gt;
&lt;br /&gt;
===Running the test cases===&lt;br /&gt;
&lt;br /&gt;
From the expertiza directory, run the following command:&lt;br /&gt;
&lt;br /&gt;
    rspec spec/controllers/review_mapping_spec_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ''ReviewMappingController'' file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ''ReviewMappingController'':&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other function is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
==About rspec==&lt;br /&gt;
[http://rspec.info/ Rspec] is a Behavior-driven development for Ruby programming language widely used for Test Driven Development. It has its own mocking framework based upon JMock. &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/RSpec&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
====Test Case 1: Check if on getting release mapping it redirects to student review controller====&lt;br /&gt;
    it &amp;quot;should use release_mapping to redirect to student_review controller&amp;quot; do&lt;br /&gt;
        get :release_mapping, id: @assignment.id&lt;br /&gt;
        expect(response).should redirect_to(:controller =&amp;gt; 'student_review', :action =&amp;gt; 'list', :id=&amp;gt; '828')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Test Case 2: Check if on delete outstanding reviewers it redirects to list mapping====&lt;br /&gt;
    it &amp;quot;should delete outstanding reviewers to redirect to list_mappings&amp;quot; do&lt;br /&gt;
        get :delete_outstanding_reviewers, id: @assignment.id, contributor_id: 200&lt;br /&gt;
        expect(response).should redirect_to(:action =&amp;gt; 'list_mappings', :id =&amp;gt; 200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 3: Check if rendered report matches the required template====&lt;br /&gt;
    it &amp;quot;should render appropritate response report&amp;quot; do&lt;br /&gt;
        get :response_report, id: 723&lt;br /&gt;
        response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 4: Check if rendered report matches the required template for a specific user====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :user =&amp;gt; {:fullname=&amp;gt; '523, student'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 5: Check if rendered report matches the required template for a specific user with type FeedbackResponseMap====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user with type FeedbackResponseMap&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :report =&amp;gt; {:type=&amp;gt; 'FeedbackResponseMap'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
View Response Report&lt;br /&gt;
[[File:View_assignment_response_report.png]]&lt;br /&gt;
&lt;br /&gt;
View Response Report by name&lt;br /&gt;
[[File:Copy_view_response_report_by_name_-_Copy.png]]&lt;br /&gt;
&lt;br /&gt;
View Feedback Response Map&lt;br /&gt;
[[File:Feeback_response_map.png|800px]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ''ReviewMappingController'', extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Copy_view_response_report_by_name_-_Copy.png&amp;diff=98085</id>
		<title>File:Copy view response report by name - Copy.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Copy_view_response_report_by_name_-_Copy.png&amp;diff=98085"/>
		<updated>2015-11-01T04:37:35Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98084</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=98084"/>
		<updated>2015-11-01T04:37:04Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ''ReviewMappingController''.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&lt;br /&gt;
Ensure that MySQL is already setup on your system. If you are using an Ubuntu system, the following commands can be used to install MySQL:&lt;br /&gt;
    sudo apt-get install mysql-server&lt;br /&gt;
    sudo apt-get install mysql-client&lt;br /&gt;
&lt;br /&gt;
===Clone the reopsitory===&lt;br /&gt;
In your local directory, clone the Github repository.&lt;br /&gt;
      &lt;br /&gt;
    git clone https://github.com/rrpod/expertiza.git&lt;br /&gt;
&lt;br /&gt;
Visit https://help.github.com for getting more information on setting up git.&lt;br /&gt;
&lt;br /&gt;
===Installing Gems===&lt;br /&gt;
&lt;br /&gt;
Go to the local expertiza directory:&lt;br /&gt;
&lt;br /&gt;
    bundle install&lt;br /&gt;
&lt;br /&gt;
===Running the test cases===&lt;br /&gt;
&lt;br /&gt;
From the expertiza directory, run the following command:&lt;br /&gt;
&lt;br /&gt;
    rspec spec/controllers/review_mapping_spec_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ''ReviewMappingController'' file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ''ReviewMappingController'':&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other function is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not being used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
==About rspec==&lt;br /&gt;
[http://rspec.info/ Rspec] is a Behavior-driven development for Ruby programming language widely used for Test Driven Development. It has its own mocking framework based upon JMock. &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/RSpec&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
====Test Case 1: Check if on getting release mapping it redirects to student review controller====&lt;br /&gt;
    it &amp;quot;should use release_mapping to redirect to student_review controller&amp;quot; do&lt;br /&gt;
        get :release_mapping, id: @assignment.id&lt;br /&gt;
        expect(response).should redirect_to(:controller =&amp;gt; 'student_review', :action =&amp;gt; 'list', :id=&amp;gt; '828')&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Test Case 2: Check if on delete outstanding reviewers it redirects to list mapping====&lt;br /&gt;
    it &amp;quot;should delete outstanding reviewers to redirect to list_mappings&amp;quot; do&lt;br /&gt;
        get :delete_outstanding_reviewers, id: @assignment.id, contributor_id: 200&lt;br /&gt;
        expect(response).should redirect_to(:action =&amp;gt; 'list_mappings', :id =&amp;gt; 200)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 3: Check if rendered report matches the required template====&lt;br /&gt;
    it &amp;quot;should render appropritate response report&amp;quot; do&lt;br /&gt;
        get :response_report, id: 723&lt;br /&gt;
        response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 4: Check if rendered report matches the required template for a specific user====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :user =&amp;gt; {:fullname=&amp;gt; '523, student'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
====Test Case 5: Check if rendered report matches the required template for a specific user with type FeedbackResponseMap====&lt;br /&gt;
    it &amp;quot;should render appropriate response report for the specific user with type FeedbackResponseMap&amp;quot; do&lt;br /&gt;
       get :response_report,  id: 723, :report =&amp;gt; {:type=&amp;gt; 'FeedbackResponseMap'}&lt;br /&gt;
       response.should render_template(:response_report)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
View Response Report&lt;br /&gt;
[[File:View_assignment_response_report.png]]&lt;br /&gt;
&lt;br /&gt;
View Response Report by name&lt;br /&gt;
[[File:Response_report_by_name.png|800px]]&lt;br /&gt;
&lt;br /&gt;
View Feedback Response Map&lt;br /&gt;
[[File:Feeback_response_map.png|800px]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ''ReviewMappingController'', extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:View_assignment_response_report.png&amp;diff=98083</id>
		<title>File:View assignment response report.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:View_assignment_response_report.png&amp;diff=98083"/>
		<updated>2015-11-01T04:36:08Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:View_Response_Report.png&amp;diff=98082</id>
		<title>File:View Response Report.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:View_Response_Report.png&amp;diff=98082"/>
		<updated>2015-11-01T04:27:09Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97516</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97516"/>
		<updated>2015-10-31T16:00:56Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ''ReviewMappingController''.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/Main_Page&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ''ReviewMappingController'' file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ''ReviewMappingController'':&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other functional is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
View Response Report&lt;br /&gt;
[[File:Response_report.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
View Response Report by name&lt;br /&gt;
[[File:Response_report_by_name.png|800px]]&lt;br /&gt;
&lt;br /&gt;
View Feedback Response Map&lt;br /&gt;
[[File:Feeback_response_map.png|800px]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ''ReviewMappingController'', extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97492</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97492"/>
		<updated>2015-10-31T06:20:55Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ReviewMappingController.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/Main_Page&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ReviewMappingController file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ReviewMappingController:&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other functional is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
View Response Report&lt;br /&gt;
[[File:Response_report.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
View Response Report by name&lt;br /&gt;
[[File:Response_report_by_name.png|800px]]&lt;br /&gt;
&lt;br /&gt;
View Feedback Response Map&lt;br /&gt;
[[File:Feeback_response_map.png|800px]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ReviewMappingController, extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97490</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97490"/>
		<updated>2015-10-31T06:18:04Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ReviewMappingController.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/Main_Page&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ReviewMappingController file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ReviewMappingController:&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other functional is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
View Response Report&lt;br /&gt;
[[File:Response_report.png|800px]]&lt;br /&gt;
&lt;br /&gt;
View Response Report by name&lt;br /&gt;
[[File:Response_report_by_name.png|800px]]&lt;br /&gt;
&lt;br /&gt;
View Feedback Response Map&lt;br /&gt;
[[File:Feeback_response_map.png|800px]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ReviewMappingController, extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97489</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97489"/>
		<updated>2015-10-31T06:17:42Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ReviewMappingController.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/Main_Page&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ReviewMappingController file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ReviewMappingController:&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other functional is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
View Response Report&lt;br /&gt;
[[File:Response_report.png|500px]]&lt;br /&gt;
&lt;br /&gt;
View Response Report by name&lt;br /&gt;
[[File:Response_report_by_name.png|500px]]&lt;br /&gt;
&lt;br /&gt;
View Feedback Response Map&lt;br /&gt;
[[File:Feeback_response_map.png|500px]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ReviewMappingController, extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97488</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97488"/>
		<updated>2015-10-31T06:17:12Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ReviewMappingController.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/Main_Page&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ReviewMappingController file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ReviewMappingController:&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other functional is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
View Response Report&lt;br /&gt;
[[File:Response_report.png|thumb|left]]&lt;br /&gt;
&lt;br /&gt;
View Response Report by name&lt;br /&gt;
[[File:Response_report_by_name.png|thumb|left]]&lt;br /&gt;
&lt;br /&gt;
View Feedback Response Map&lt;br /&gt;
[[File:Feeback_response_map.png|thumb|left]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ReviewMappingController, extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97486</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97486"/>
		<updated>2015-10-31T06:15:50Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ReviewMappingController.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/Main_Page&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ReviewMappingController file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ReviewMappingController:&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other functional is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
View Response Report&lt;br /&gt;
[[File:Response_report.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
View Response Report by name&lt;br /&gt;
[[File:Response_report_by_name.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
View Feedback Response Map&lt;br /&gt;
[[File:Feeback_response_map.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ReviewMappingController, extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Feeback_response_map.png&amp;diff=97485</id>
		<title>File:Feeback response map.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Feeback_response_map.png&amp;diff=97485"/>
		<updated>2015-10-31T06:15:19Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Response_report_by_name.png&amp;diff=97484</id>
		<title>File:Response report by name.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Response_report_by_name.png&amp;diff=97484"/>
		<updated>2015-10-31T06:15:01Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Response_report.png&amp;diff=97482</id>
		<title>File:Response report.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Response_report.png&amp;diff=97482"/>
		<updated>2015-10-31T06:14:21Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: uploaded a new version of &amp;amp;quot;File:Response report.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Response_report.png&amp;diff=97481</id>
		<title>File:Response report.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Response_report.png&amp;diff=97481"/>
		<updated>2015-10-31T06:13:53Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97479</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97479"/>
		<updated>2015-10-31T06:11:08Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ReviewMappingController.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/Main_Page&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ReviewMappingController file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ReviewMappingController:&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other functional is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
View Response Report&lt;br /&gt;
[[File:Response_report.png]]&lt;br /&gt;
&lt;br /&gt;
View Response Report by name&lt;br /&gt;
[[File:Response_report_by_name.png]]&lt;br /&gt;
&lt;br /&gt;
View Feedback Response Map&lt;br /&gt;
[[File:Feeback_response_map.png]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ReviewMappingController, extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97478</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97478"/>
		<updated>2015-10-31T06:09:04Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ReviewMappingController.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/Main_Page&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ReviewMappingController file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ReviewMappingController:&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other functional is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
=== Test Case Development using RSpec ===&lt;br /&gt;
&lt;br /&gt;
=== Testing from the UI ===&lt;br /&gt;
&lt;br /&gt;
[[File:Response_report.png]]&lt;br /&gt;
[[File:Response_report_by_name.png]]&lt;br /&gt;
[[File:Feeback_response_map.png]]&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ReviewMappingController, extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97475</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97475"/>
		<updated>2015-10-31T06:04:08Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza-based OSS project, which aimed at refactoring the ReviewMappingController.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/Main_Page&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ReviewMappingController file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ReviewMappingController:&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other functional is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
== Test Case Development ==&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ReviewMappingController, extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97474</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97474"/>
		<updated>2015-10-31T06:02:59Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza based OSS project, which aimed at refactoring the ReviewMappingController.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/Main_Page&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ReviewMappingController file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the ReviewMappingController:&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other functional is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
== Test Case Development ==&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring ReviewMappingController, extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97473</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97473"/>
		<updated>2015-10-31T06:02:24Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza based OSS project, which aimed at refactoring the ReviewMappingController.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/Main_Page&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ReviewMappingController file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the review_mapping_controller:&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other functional is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
== Test Case Development ==&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring review_mapping_controller, extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository used for development]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97472</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97472"/>
		<updated>2015-10-31T06:01:25Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza based OSS project, which aimed at refactoring the ReviewMappingController.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/Main_Page&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ReviewMappingController file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the review_mapping_controller:&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping_strategy'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other functional is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping_strategy ===&lt;br /&gt;
This function was originally too long. Hence, we modularised it by moving the part of the code that loops over all teams and creates the ReviewResponseMap into a new function.&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
This method is responsible for returning the team given an assignment submission. It did not have any direct correlation with the reviewer/reviewee. Hence, it was moved to the AssignmentTeam model (assignment_team.rb) file as suggested.&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
== Test Case Development ==&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring review_mapping_controller, extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97470</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97470"/>
		<updated>2015-10-31T05:53:46Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza based OSS project, which aimed at refactoring the ReviewMappingController.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/Main_Page&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ReviewMappingController file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the review_mapping_controller:&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other functional is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping ===&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
== Test Case Development ==&lt;br /&gt;
&lt;br /&gt;
= Conclusion =&lt;br /&gt;
By refactoring review_mapping_controller, extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97469</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97469"/>
		<updated>2015-10-31T05:53:33Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza based OSS project, which aimed at refactoring the ReviewMappingController.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/Main_Page&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ReviewMappingController file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the review_mapping_controller:&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other functional is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping ===&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
== Test Case Development ==&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
By refactoring review_mapping_controller, extraneous and unused code was removed, readability was increased, and tests confirm that its functionality remained intact. Users will experience incrementally better performance, and developers will have an easier time getting up to speed on the software, resulting in heightened developer efficiency and faster turnaround times for new features.&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97467</id>
		<title>CSC/ECE 517 Fall 2015/oss E1569 JNR</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2015/oss_E1569_JNR&amp;diff=97467"/>
		<updated>2015-10-31T05:50:14Z</updated>

		<summary type="html">&lt;p&gt;Nnagara2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E1569: Refactoring ReviewMappingController&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This page provides a description of our Expertiza based OSS project, which aimed at refactoring the ReviewMappingController.&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an [http://en.wikipedia.org/wiki/Open-source_software Open Source] software tool developed at NC State University. It is used to facilitate assignment and course management. It is primarily intended to facilitate assignments being peer reviewed. It is written as a [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails] application, thus functioning natively in a web environment. It can be cloned from [https://github.com/expertiza/expertiza/ GitHub].&lt;br /&gt;
&lt;br /&gt;
=Refactoring=&lt;br /&gt;
[https://en.wikipedia.org/wiki/Code_refactoring Refactoring] is a process designed to change code without modifying the functionality. Refactoring can improve the readability and the logical design of the software, making sure everything is in the right place and has the right name. This allows code to be understood more quickly by a developer, which shortens the time it takes to develop new features.&lt;br /&gt;
&lt;br /&gt;
=Development environment setup=&lt;br /&gt;
&amp;lt;ref&amp;gt;http://wiki.expertiza.ncsu.edu/index.php/Main_Page&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Problem statement=&lt;br /&gt;
The ReviewMappingController file in this application (review_mapping_controller.rb) is responsible for setting up mappings between reviewers and reviewees. It essentially connects a reviewer to an assignment. However, it is a fairly bloated file since it has to handle functionality for five different kinds of maps (review response, author feedback, teammate review, meta-review, and quiz response). It is a prime choice for refactoring because the refactoring can clarify the intent of the different methods in the file.&lt;br /&gt;
&lt;br /&gt;
According to the problem statement&amp;lt;ref&amp;gt;https://docs.google.com/document/d/1uWs3zyrupTmrOFuv5IbVWCF4NRvCXqJmg8dZ0wCqgus/edit&amp;lt;/ref&amp;gt;, there were 11 tasks involved in refactoring the review_mapping_controller:&lt;br /&gt;
&lt;br /&gt;
* Method ''delete_rofreviewer'' should do the same thing as delete_metareviewer&lt;br /&gt;
* Method ''delete_participant'' is not used&lt;br /&gt;
* Method ''list_sortable'' is not used&lt;br /&gt;
* Method ''automatic_review_mapping'' is too long&lt;br /&gt;
* Method ''review_report'' has SQL-like code&lt;br /&gt;
* Method ''add_user_to_assignment'' should not be in this controller&lt;br /&gt;
* Method ''get_team_from_submission'' should not be in this controller&lt;br /&gt;
* Method ''delete_all_reviewers'' doesn’t actually delete all the reviewers, but just the outstanding review response maps. We want to keep this functionality&lt;br /&gt;
* Method ''delete_participant'' should not be in this controller&lt;br /&gt;
* Method ''name release_reservation'' doesn’t describe the functionality well&lt;br /&gt;
* Method ''delete_review'' is not used&lt;br /&gt;
&lt;br /&gt;
= Design Approach =&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
guidelines &amp;lt;ref&amp;gt;https://docs.google.com/document/d/1qQD7fcypFk77nq7Jx7ZNyCNpLyt1oXKaq5G-W7zkV3k/edit#&amp;lt;/ref&amp;gt;&lt;br /&gt;
Single Responsibility Principle &amp;lt;ref&amp;gt;https://en.wikipedia.org/wiki/Single_responsibility_principle&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== delete_rofreviewer ===&lt;br /&gt;
This function has duplicate functionality to another function, delete_metareviewer, and the other functional is named much better. The method delete_rofreviewer was removed.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== list_sortable ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== automatic_review_mapping ===&lt;br /&gt;
&lt;br /&gt;
=== response_report ===&lt;br /&gt;
To make this code easier to read for a pure Ruby developer, the SQL-like code was rewritten with ActiveRecord.&lt;br /&gt;
&lt;br /&gt;
=== add_user_to_assignment ===&lt;br /&gt;
This method does not belong in this controller, and it is only ever called by participants_helper. Therefore, the method should go into participants_controller, which is where it was moved.&lt;br /&gt;
&lt;br /&gt;
=== get_team_from_submission ===&lt;br /&gt;
&lt;br /&gt;
=== delete_all_reviewers ===&lt;br /&gt;
Since the only problem with this method is that the name does not describe the actual or intended functionality, we replaced all instances of “delete_all_reviewers” with “delete_outstanding_reviewers”.&lt;br /&gt;
&lt;br /&gt;
=== delete_participant ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
=== release_reservation ===&lt;br /&gt;
Since the method name does not accurately describe the functionality within, all instances of “release_reservation” were replaced with “release_mapping”.&lt;br /&gt;
&lt;br /&gt;
=== delete_review ===&lt;br /&gt;
This function was confirmed to not be used, since there is no other function in the application that calls it. Therefore, it was removed.&lt;br /&gt;
&lt;br /&gt;
== Test Case Development ==&lt;br /&gt;
&lt;br /&gt;
= Project Links =&lt;br /&gt;
&lt;br /&gt;
* [http://152.46.19.84:3000/ Run Expertiza hosted on VCL]&lt;br /&gt;
* [https://github.com/rrpod/expertiza GitHub repository]&lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/591 GitHub pull request to merge to expertiza/master]&lt;br /&gt;
&lt;br /&gt;
= References=&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nnagara2</name></author>
	</entry>
</feed>