<?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=Kvysyar</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=Kvysyar"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Kvysyar"/>
	<updated>2026-10-02T01:12:31Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1631_Team-based_reviewing&amp;diff=102239</id>
		<title>CSC/ECE 517 Spring 2016 E1631 Team-based reviewing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1631_Team-based_reviewing&amp;diff=102239"/>
		<updated>2016-04-12T02:57:11Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: /* RSpec */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Purpose ==&lt;br /&gt;
&lt;br /&gt;
When a participant of a team reviewed an assignment, his/her review is independent of his teammate’s reviews. To allow teammates to discuss and review together, allowing teams to submit reviews for the team as a whole should be allowed ideally. We intend to do this in our project. &lt;br /&gt;
&lt;br /&gt;
*Currently all reviews in Expertiza are done by individuals. This is true regardless of whether the assignment is done by individuals or teams . &lt;br /&gt;
*There are occasions when it's advantageous to review projects as a team . &lt;br /&gt;
*It helps foster discussion and thereby improves the process of learning.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
This project comprises of the following steps :&lt;br /&gt;
&lt;br /&gt;
# Objects of ResponseMap record the information of who reviews whom. The field reviewee_id refers to the team who is being reviewed. The field reviewer_id refers to the individual/team performing the review. We added a boolean field &amp;quot;reviewer_is_team&amp;quot; to identify if the review is performed by a team or an individual.&lt;br /&gt;
# If reviewer_is_team is true, the reviewer_id will be a reference to the Teams table.&lt;br /&gt;
# For an Instructor to specify whether the review is a Team/Individual based review, we will be providing a dropdown on the Review Strategy tab of assignment creation.&lt;br /&gt;
# Ensure that features such as &amp;quot;view my scores&amp;quot;, or the &amp;quot;alternate view/heat map&amp;quot; should continue working.&lt;br /&gt;
# Concurrency control: Shouldn't allow multiple teammates to edit the team's review at the same time. The scope of the project doesn't include concurrent editing to allow multiple teammates to edit a review simultaneously.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
==== Design Pattern ====&lt;br /&gt;
'''Model View Controller'''&lt;br /&gt;
&lt;br /&gt;
In an MVC model, a software application is divided into three major components: Model, View and Controller. &lt;br /&gt;
&lt;br /&gt;
'''Model''' - Keeps data, logic and relations between objects and the database. It also handles validations, associations and transactions.&lt;br /&gt;
&lt;br /&gt;
'''View''' - Displays the data received from the controller in the user interface.&lt;br /&gt;
&lt;br /&gt;
'''Controller''' - Accepts the client's input and converts it into action points for the model or view. Other responsibilities include querying models and organizing data in a structure that is displayed by the view.&lt;br /&gt;
&lt;br /&gt;
==== Use Case Diagram ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Name:''' Specify review type on Review Strategy tab.&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Instructor. &lt;br /&gt;
&lt;br /&gt;
'''Description:''' The instructor specifies whether this review is an individual review or a team based review on the Review Strategy tab.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Name:''' Perform Review.&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Individual Student/Team.&lt;br /&gt;
&lt;br /&gt;
'''Description:''' The individual/team will perform a review for the Assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:OODDUseCase.jpg]]&lt;br /&gt;
&lt;br /&gt;
=== Database Design ===&lt;br /&gt;
&lt;br /&gt;
ResponseMap in essence, records who reviews whom. Schema of ResponseMap:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Data type&lt;br /&gt;
|-&lt;br /&gt;
| id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| reviewed_object_id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| reviewer_id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| reviewee_id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| type&lt;br /&gt;
| varchar(255)&lt;br /&gt;
|-&lt;br /&gt;
| created_at&lt;br /&gt;
| datetime&lt;br /&gt;
|-&lt;br /&gt;
| updated_at&lt;br /&gt;
| datetime&lt;br /&gt;
|-&lt;br /&gt;
| caliberate_to&lt;br /&gt;
| boolean&lt;br /&gt;
|-&lt;br /&gt;
| reviewer_is_team &lt;br /&gt;
| boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The description of the fields of the database for ResponseMap:&lt;br /&gt;
&lt;br /&gt;
1. '''id:''' The unique record identifier.&lt;br /&gt;
&lt;br /&gt;
2. '''reviewed_object_id:''' The id of the object that is reviewed. Assignments or ReviewMaps could be reviewed.&lt;br /&gt;
&lt;br /&gt;
3. '''reviewer_id:''' The reviewer can either be an “AssignmentTeam” or “AssignmentParticipant”, which is indicated by the field reviwer_is_team.&lt;br /&gt;
&lt;br /&gt;
4. '''reviewee_id:''' The id “AssignmentTeam” who is getting the “Response” i.e., the one whose work is being reviewed. &lt;br /&gt;
&lt;br /&gt;
5. '''type :'''  Indicates the type of the ResponseMap.&lt;br /&gt;
&lt;br /&gt;
6. '''created_at:''' The timestamp when the Response was created.&lt;br /&gt;
&lt;br /&gt;
7. '''updated_at:''' The timestamp when the Response was updated.&lt;br /&gt;
&lt;br /&gt;
8. '''calibrate_to:''' A field of boolean data type.&lt;br /&gt;
&lt;br /&gt;
9. '''reviewer_is_team:''' If this field is ‘true’, the reviewer_id refers to the id of the “AssignmentTeam” to which the participant belongs. Else, it refers to the id of the “Participant” itself.&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
&lt;br /&gt;
Below are the key files to be modified:&lt;br /&gt;
====Models====&lt;br /&gt;
* '''review_response_map.rb:''' Add a field reviewer_is_team , which determines if the reviewer is doing an individual review or on behalf of the team. &lt;br /&gt;
* '''assignment.rb:''' Add a field review_type , that indicates if the assignment is a team based or an individual assignment decided by the instructor.&lt;br /&gt;
&lt;br /&gt;
====Views====&lt;br /&gt;
* '''assignments/edit/_review_report.html.erb:''' Add a dropdown for the instructors to select if the reviews are individual or team-based.&lt;br /&gt;
&lt;br /&gt;
====Controllers====&lt;br /&gt;
* review_mapping_controller.rb&lt;br /&gt;
* participants_controller.rb&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
&lt;br /&gt;
=== RSpec ===&lt;br /&gt;
RSpec is a testing framework for Rails, and is a Behavioral-Driven Development tool. It is a domain specific language(DSL). All the tests can be executed by rspec spec command, or can also be executed individually using the command &amp;quot;rspec spec/models/assignment_team_spec.rb&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
We intend to write unit tests using RSpec for all the methods which we modified/created.&lt;br /&gt;
&lt;br /&gt;
===Factory Girl===&lt;br /&gt;
Factory Girl is used for creating Assignment and Team objects to be used for testing. Factory Girl is a replacement for fixtures. Fixtures have to be updated whenever we change a data model whereas adding and removing fields is much easier in Factory Girl. Fixture definitions are global whereas Factories can be local, so isolated cases can be tested. Factories are defined to create objects for testing.&lt;br /&gt;
&lt;br /&gt;
===Running RSpec===&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  $ rspec spec/models/assignment_team_spec.rb&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1631_Team-based_reviewing&amp;diff=102171</id>
		<title>CSC/ECE 517 Spring 2016 E1631 Team-based reviewing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1631_Team-based_reviewing&amp;diff=102171"/>
		<updated>2016-04-11T23:09:12Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: /* Task Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Purpose ==&lt;br /&gt;
&lt;br /&gt;
When a participant of a team reviewed an assignment, his/her review is independent of his teammate’s reviews. To allow teammates to discuss and review together, allowing teams to submit reviews for the team as a whole should be allowed ideally. We intend to do this in our project. &lt;br /&gt;
&lt;br /&gt;
*Currently all reviews in Expertiza are done by individuals. This is true regardless of whether the assignment is done by individuals or teams . &lt;br /&gt;
*There are occasions when it's advantageous to review projects as a team . &lt;br /&gt;
*It helps foster discussion and thereby improves the process of learning.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
This project comprises of the following steps :&lt;br /&gt;
&lt;br /&gt;
# Objects of ResponseMap record the information of who reviews whom. The field reviewee_id refers to the team who is being reviewed. The field reviewer_id refers to the individual/team performing the review. We added a boolean field &amp;quot;reviewer_is_team&amp;quot; to identify if the review is performed by a team or an individual.&lt;br /&gt;
# If reviewer_is_team is true, the reviewer_id will be a reference to the Teams table. Else, it will be a reference to the Participants table.&lt;br /&gt;
# For an Instructor to specify whether the review is a Team/Individual based review, provide a checkbox on the Review Strategy tab of assignment creation.&lt;br /&gt;
# Using polymorphism wherever possible.&lt;br /&gt;
# Features such as &amp;quot;view my scores&amp;quot;, or the &amp;quot;alternate view/heat map&amp;quot; should continue working.&lt;br /&gt;
# Concurrency control: Shouldn't allow multiple teammates to edit the team's review at the same time. The scope of the project doesn't include concurrent editing to allow multiple teammates to edit a review simultaneously.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
==== Use Case Diagram ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Name:''' Specify review type on Review Strategy tab.&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Instructor. &lt;br /&gt;
&lt;br /&gt;
'''Description:''' The instructor specifies whether this review is an individual review or a team based review on the Review Strategy tab.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Name:''' Perform Review.&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Individual Student/Team.&lt;br /&gt;
&lt;br /&gt;
'''Description:''' The individual/team will perform a review for the Assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:OODDUseCase.jpg]]&lt;br /&gt;
&lt;br /&gt;
=== Database Design ===&lt;br /&gt;
&lt;br /&gt;
ResponseMap in essence, records who reviews whom. Schema of ResponseMap:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Data type&lt;br /&gt;
|-&lt;br /&gt;
| id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| reviewed_object_id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| reviewer_id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| reviewee_id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| type&lt;br /&gt;
| varchar(255)&lt;br /&gt;
|-&lt;br /&gt;
| created_at&lt;br /&gt;
| datetime&lt;br /&gt;
|-&lt;br /&gt;
| updated_at&lt;br /&gt;
| datetime&lt;br /&gt;
|-&lt;br /&gt;
| caliberate_to&lt;br /&gt;
| boolean&lt;br /&gt;
|-&lt;br /&gt;
| reviewer_is_team &lt;br /&gt;
| boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The description of the fields of the database for ResponseMap:&lt;br /&gt;
&lt;br /&gt;
1. '''id:''' The unique record identifier.&lt;br /&gt;
&lt;br /&gt;
2. '''reviewed_object_id:''' The id of the object that is reviewed. Assignments or ReviewMaps could be reviewed.&lt;br /&gt;
&lt;br /&gt;
3. '''reviewer_id:''' The reviewer can either be an “AssignmentTeam” or “AssignmentParticipant”, which is indicated by the field reviwer_is_team.&lt;br /&gt;
&lt;br /&gt;
4. '''reviewee_id:''' The id “AssignmentTeam” who is getting the “Response” i.e., the one whose work is being reviewed. &lt;br /&gt;
&lt;br /&gt;
5. '''type :'''  Indicates the type of the ResponseMap.&lt;br /&gt;
&lt;br /&gt;
6. '''created_at:''' The timestamp when the Response was created.&lt;br /&gt;
&lt;br /&gt;
7. '''updated_at:''' The timestamp when the Response was updated.&lt;br /&gt;
&lt;br /&gt;
8. '''calibrate_to:''' A field of boolean data type.&lt;br /&gt;
&lt;br /&gt;
9. '''reviewer_is_team:''' If this field is ‘true’, the reviewer_id refers to the id of the “AssignmentTeam” to which the participant belongs. Else, it refers to the id of the “Participant” itself.&lt;br /&gt;
&lt;br /&gt;
===Key files to be modified===&lt;br /&gt;
&lt;br /&gt;
====Models====&lt;br /&gt;
* review_response_map.rb&lt;br /&gt;
* participant.rb &lt;br /&gt;
* response_map.rb &lt;br /&gt;
* response.rb &lt;br /&gt;
* assignment_team.rb&lt;br /&gt;
* assignment_participant.rb &lt;br /&gt;
* assignment.rb&lt;br /&gt;
====Views====&lt;br /&gt;
* review_mapping/_review_report.html.erb &lt;br /&gt;
====Controllers====&lt;br /&gt;
* review_mapping_controller.rb&lt;br /&gt;
* participants_controller.rb&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1631_Team-based_reviewing&amp;diff=102170</id>
		<title>CSC/ECE 517 Spring 2016 E1631 Team-based reviewing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1631_Team-based_reviewing&amp;diff=102170"/>
		<updated>2016-04-11T23:08:42Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: /* Task Description update */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Purpose ==&lt;br /&gt;
&lt;br /&gt;
When a participant of a team reviewed an assignment, his/her review is independent of his teammate’s reviews. To allow teammates to discuss and review together, allowing teams to submit reviews for the team as a whole should be allowed ideally. We intend to do this in our project. &lt;br /&gt;
&lt;br /&gt;
*Currently all reviews in Expertiza are done by individuals. This is true regardless of whether the assignment is done by individuals or teams . &lt;br /&gt;
*There are occasions when it's advantageous to review projects as a team . &lt;br /&gt;
*It helps foster discussion and thereby improves the process of learning.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
This project comprises of the following steps :&lt;br /&gt;
&lt;br /&gt;
# Objects of ResponseMap record who reviews whom. The field reviewee_id refers to the team who is being reviewed. The field reviewer_id refers to the individual/team performing the review. We added a boolean field &amp;quot;reviewer_is_team&amp;quot; to identify if the review is performed by a team or an individual.&lt;br /&gt;
# If reviewer_is_team is true, the reviewer_id will be a reference to the Teams table. Else, it will be a reference to the Participants table.&lt;br /&gt;
# For an Instructor to specify whether the review is a Team/Individual based review, provide a checkbox on the Review Strategy tab of assignment creation.&lt;br /&gt;
# Using polymorphism wherever possible.&lt;br /&gt;
# Features such as &amp;quot;view my scores&amp;quot;, or the &amp;quot;alternate view/heat map&amp;quot; should continue working.&lt;br /&gt;
# Concurrency control: Shouldn't allow multiple teammates to edit the team's review at the same time. The scope of the project doesn't include concurrent editing to allow multiple teammates to edit a review simultaneously.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
==== Use Case Diagram ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Name:''' Specify review type on Review Strategy tab.&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Instructor. &lt;br /&gt;
&lt;br /&gt;
'''Description:''' The instructor specifies whether this review is an individual review or a team based review on the Review Strategy tab.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Name:''' Perform Review.&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Individual Student/Team.&lt;br /&gt;
&lt;br /&gt;
'''Description:''' The individual/team will perform a review for the Assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:OODDUseCase.jpg]]&lt;br /&gt;
&lt;br /&gt;
=== Database Design ===&lt;br /&gt;
&lt;br /&gt;
ResponseMap in essence, records who reviews whom. Schema of ResponseMap:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Data type&lt;br /&gt;
|-&lt;br /&gt;
| id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| reviewed_object_id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| reviewer_id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| reviewee_id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| type&lt;br /&gt;
| varchar(255)&lt;br /&gt;
|-&lt;br /&gt;
| created_at&lt;br /&gt;
| datetime&lt;br /&gt;
|-&lt;br /&gt;
| updated_at&lt;br /&gt;
| datetime&lt;br /&gt;
|-&lt;br /&gt;
| caliberate_to&lt;br /&gt;
| boolean&lt;br /&gt;
|-&lt;br /&gt;
| reviewer_is_team &lt;br /&gt;
| boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The description of the fields of the database for ResponseMap:&lt;br /&gt;
&lt;br /&gt;
1. '''id:''' The unique record identifier.&lt;br /&gt;
&lt;br /&gt;
2. '''reviewed_object_id:''' The id of the object that is reviewed. Assignments or ReviewMaps could be reviewed.&lt;br /&gt;
&lt;br /&gt;
3. '''reviewer_id:''' The reviewer can either be an “AssignmentTeam” or “AssignmentParticipant”, which is indicated by the field reviwer_is_team.&lt;br /&gt;
&lt;br /&gt;
4. '''reviewee_id:''' The id “AssignmentTeam” who is getting the “Response” i.e., the one whose work is being reviewed. &lt;br /&gt;
&lt;br /&gt;
5. '''type :'''  Indicates the type of the ResponseMap.&lt;br /&gt;
&lt;br /&gt;
6. '''created_at:''' The timestamp when the Response was created.&lt;br /&gt;
&lt;br /&gt;
7. '''updated_at:''' The timestamp when the Response was updated.&lt;br /&gt;
&lt;br /&gt;
8. '''calibrate_to:''' A field of boolean data type.&lt;br /&gt;
&lt;br /&gt;
9. '''reviewer_is_team:''' If this field is ‘true’, the reviewer_id refers to the id of the “AssignmentTeam” to which the participant belongs. Else, it refers to the id of the “Participant” itself.&lt;br /&gt;
&lt;br /&gt;
===Key files to be modified===&lt;br /&gt;
&lt;br /&gt;
====Models====&lt;br /&gt;
* review_response_map.rb&lt;br /&gt;
* participant.rb &lt;br /&gt;
* response_map.rb &lt;br /&gt;
* response.rb &lt;br /&gt;
* assignment_team.rb&lt;br /&gt;
* assignment_participant.rb &lt;br /&gt;
* assignment.rb&lt;br /&gt;
====Views====&lt;br /&gt;
* review_mapping/_review_report.html.erb &lt;br /&gt;
====Controllers====&lt;br /&gt;
* review_mapping_controller.rb&lt;br /&gt;
* participants_controller.rb&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1631_Team-based_reviewing&amp;diff=101694</id>
		<title>CSC/ECE 517 Spring 2016 E1631 Team-based reviewing</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1631_Team-based_reviewing&amp;diff=101694"/>
		<updated>2016-04-03T00:18:48Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: /* Purpose */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Purpose ==&lt;br /&gt;
&lt;br /&gt;
When a participant of a team reviewed an assignment, his/her review is independent of his teammate’s reviews. To allow teammates to discuss and review together, allowing teams to submit reviews for the team as a whole should be allowed ideally. We intend to do this in our project. &lt;br /&gt;
&lt;br /&gt;
*Currently all reviews in Expertiza are done by individuals. This is true regardless of whether the assignment is done by individuals or teams . &lt;br /&gt;
*There are occasions when it's advantageous to review projects as a team . &lt;br /&gt;
*It helps foster discussion and thereby improves the process of learning.&lt;br /&gt;
&lt;br /&gt;
== Task Description ==&lt;br /&gt;
This project comprises of the following steps :&lt;br /&gt;
&lt;br /&gt;
# Add fields to the ResponseMap model to record who reviews whom. The field reviewee_id refers to the team who is being reviewed. The field reviewer_id refers to the individual/team performing the review.&lt;br /&gt;
# Add a boolean field reviewer_is_team to identify if the review is performed by a team or an individual.&lt;br /&gt;
# If reviewer_is_team is true, the reviewer_id will be a reference to the Teams table. Else, it will be a reference to the Participants table.&lt;br /&gt;
# For an Instructor to specify whether the review is a Team/Individual based review, provide a checkbox on the Review Strategy tab of assignment creation.&lt;br /&gt;
&lt;br /&gt;
== Design ==&lt;br /&gt;
&lt;br /&gt;
==== Use Case Diagram ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Name:''' Specify review type on Review Strategy tab.&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Instructor. &lt;br /&gt;
&lt;br /&gt;
'''Description:''' The instructor specifies whether this review is an individual review or a team based review on the Review Strategy tab.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Name:''' Perform Review.&lt;br /&gt;
&lt;br /&gt;
'''Actor:''' Individual Student/Team.&lt;br /&gt;
&lt;br /&gt;
'''Description:''' The individual/team will perform a review for the Assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:OODDUseCase.jpg]]&lt;br /&gt;
&lt;br /&gt;
=== Database Design ===&lt;br /&gt;
&lt;br /&gt;
ResponseMap in essence, records who reviews whom. Schema of ResponseMap:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Data type&lt;br /&gt;
|-&lt;br /&gt;
| id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| reviewed_object_id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| reviewer_id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| reviewee_id&lt;br /&gt;
| int(11)&lt;br /&gt;
|-&lt;br /&gt;
| type&lt;br /&gt;
| varchar(255)&lt;br /&gt;
|-&lt;br /&gt;
| created_at&lt;br /&gt;
| datetime&lt;br /&gt;
|-&lt;br /&gt;
| updated_at&lt;br /&gt;
| datetime&lt;br /&gt;
|-&lt;br /&gt;
| caliberate_to&lt;br /&gt;
| boolean&lt;br /&gt;
|-&lt;br /&gt;
| reviewer_is_team &lt;br /&gt;
| boolean&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The description of the fields of the database for ResponseMap:&lt;br /&gt;
&lt;br /&gt;
1. '''id:''' The unique record identifier.&lt;br /&gt;
&lt;br /&gt;
2. '''reviewed_object_id:''' The id of the object that is reviewed. Assignments or ReviewMaps could be reviewed.&lt;br /&gt;
&lt;br /&gt;
3. '''reviewer_id:''' The reviewer can either be an “AssignmentTeam” or “AssignmentParticipant”, which is indicated by the field reviwer_is_team.&lt;br /&gt;
&lt;br /&gt;
4. '''reviewee_id:''' The id “AssignmentTeam” who is getting the “Response” i.e., the one whose work is being reviewed. &lt;br /&gt;
&lt;br /&gt;
5. '''type :'''  Indicates the type of the ResponseMap.&lt;br /&gt;
&lt;br /&gt;
6. '''created_at:''' The timestamp when the Response was created.&lt;br /&gt;
&lt;br /&gt;
7. '''updated_at:''' The timestamp when the Response was updated.&lt;br /&gt;
&lt;br /&gt;
8. '''calibrate_to:''' A field of boolean data type.&lt;br /&gt;
&lt;br /&gt;
9. '''reviewer_is_team:''' If this field is ‘true’, the reviewer_id refers to the id of the “AssignmentTeam” to which the participant belongs. Else, it refers to the id of the “Participant” itself.&lt;br /&gt;
&lt;br /&gt;
===Key files to be modified===&lt;br /&gt;
&lt;br /&gt;
====Models====&lt;br /&gt;
* review_response_map.rb&lt;br /&gt;
* participant.rb &lt;br /&gt;
* response_map.rb &lt;br /&gt;
* response.rb &lt;br /&gt;
* assignment_team.rb&lt;br /&gt;
* assignment_participant.rb &lt;br /&gt;
* assignment.rb&lt;br /&gt;
====Views====&lt;br /&gt;
* review_mapping/_review_report.html.erb &lt;br /&gt;
====Controllers====&lt;br /&gt;
* review_mapping_controller.rb&lt;br /&gt;
* participants_controller.rb&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101663</id>
		<title>CSC/ECE 517 Spring 2016/OSS E1601</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101663"/>
		<updated>2016-04-02T04:06:11Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: /* Example RSpec */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== E1601: Refactor methods related to submitted_hyperlinks. ===&lt;br /&gt;
&lt;br /&gt;
This wiki is for the open source refactoring project E1601: Refactor methods related to submitted_hyperlinks for the course ECE/CSC 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
The reviewers may use the below student and instructor logins for the purpose of reviewing and testing the functionality. These students belong to the same team and work on an assignment created by the below instructor:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5884,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student6420,  password -&amp;gt; password&lt;br /&gt;
'''Please note''': Please do not delete the above users or their team. If you wish to do so, please add them back so as to aid other reviewers. Also note that the option to submit hyperlinks in the UI will be displayed to the enrolled students only if assignment deadline is in future and the assignment is not in &amp;quot;Finish&amp;quot; state.&lt;br /&gt;
&lt;br /&gt;
== Expertiza Introduction==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source web application which enhances the student's learning through peer reviews. The students can form teams and work on assignments given by course instructors. The peers can review the submissions and give feedback. The students also get to review the reviewers!&lt;br /&gt;
&lt;br /&gt;
== Problem statement ==&lt;br /&gt;
&lt;br /&gt;
'''Before''': When a student submitted files and hyperlinks for an assignment, that content was submitted on behalf of his team, and not individually (even if there is only one person in the team i.e a student working on an assignment cannot be without a team even if he is working alone). Some of the previous contributors had worked on a project which made this change and associated all the submitted content to teams instead of the individual participants: the submitted_hyperlinks and dirctory_num fields were moved to teams table. All the hyperlinks were now recorded in one submitted_hyperlinks field in the team model instead of being present in all the participants of the team. All the submitted files similarly were uploaded to the common file space and in the “course_folder/assignment_folder/team_folder” path.&lt;br /&gt;
&lt;br /&gt;
'''What was wrong with that''': There are multiple methods in assignment_participant.rb which still give the impression that the author is submitting the hyperlinks on behalf of himself and not the team even though the relevant fields have been moved to teams model. These methods are to be moved to assignment_teams.rb for improving the clarity and the efficiency of code.&lt;br /&gt;
&lt;br /&gt;
'''What refactoring we have done to improve the code''':&lt;br /&gt;
&lt;br /&gt;
''Task1::'' Removed “hyperlinks_array” method and “hyperlinks” method from assignment_participant.rb. Created “hyperlinks” method in assignment_team.rb.&lt;br /&gt;
&lt;br /&gt;
''Task2::'' Removed “submit_hyperlink” and “remove_hyperlink” from assignment_pariticpant.rb and created equivalent methods in assignment_team.rb.        &lt;br /&gt;
&lt;br /&gt;
''Task3::'' Removed “has_submissions?” from assginment_participant.rb and created the equivalent method in assignment_team.rb.          &lt;br /&gt;
&lt;br /&gt;
''Task4::'' All the calls to the above methods were refactored to call the appropriate method's functions.&lt;br /&gt;
&lt;br /&gt;
''Task5::'' Refactored some of the logic of controller methods.&lt;br /&gt;
&lt;br /&gt;
''Task6::'' Tests for submitting and removing submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
== List of files changed ==&lt;br /&gt;
&lt;br /&gt;
Model Files:&lt;br /&gt;
&lt;br /&gt;
#assignment_participant.rb&lt;br /&gt;
#assignment_team.rb&lt;br /&gt;
#student_task.rb&lt;br /&gt;
&lt;br /&gt;
View Files:&lt;br /&gt;
&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#assignments/edit/_calibration.html.erb&lt;br /&gt;
#assignments/list_submissions.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
&lt;br /&gt;
Controller Files:&lt;br /&gt;
&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
#submitted_content_controller.rb&lt;br /&gt;
&lt;br /&gt;
Files with major modifications:&lt;br /&gt;
&lt;br /&gt;
#The model: assignment_participant.rb&lt;br /&gt;
#The model: assignment_team.rb&lt;br /&gt;
#The controller: submitted_content_controller.rb&lt;br /&gt;
&lt;br /&gt;
== Key changes ==&lt;br /&gt;
&lt;br /&gt;
Four methods &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;submit_hyperlink&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; were moved from the assignment_participant.rb model to assignment_team.rb, and the &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; method was removed.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task1::''' The below methods &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; were removed from the assignment_participant.rb. The &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method which existed here seemed suspect as there was no &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method in the AssignmentTeam/Team models so the &amp;lt;code&amp;gt;try&amp;lt;/code&amp;gt; would always fail and return an empty array. Also the &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; method retrieved the hyperlinks from the &amp;lt;code&amp;gt;submitted_hyperlinks&amp;lt;/code&amp;gt; field of the team model so in moving to AssignmentTeam model we just had to remove the .team quantifier.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;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.team.submitted_hyperlinks.blank? ? [] : YAML::load(self.team.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They are both merged into a new single &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method in assignment_team.rb. All callers of both methods were refactored to use &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method of AssignmentTeam.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
        self.submitted_hyperlinks.blank? ? [] : YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task2::''' Earlier, the following method &amp;lt;code&amp;gt;submit_hyperlink&amp;lt;/code&amp;gt; was in assignment_participant.rb:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&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;
    team_object = self.team&lt;br /&gt;
    team_object.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    team_object.save&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It has been now moved to assignment_team.rb as below. Again, as the method was moved to AssignmentTeam model, it obviated the need to invoke the &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&amp;lt;code&amp;gt;&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&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;
&amp;lt;/code&amp;gt;&lt;br /&gt;
A similar refactoring was done for &amp;lt;code&amp;gt;remove_hyperlinks&amp;lt;/code&amp;gt; method in assignment_participant.rb. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task3::''' The methods &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; earlier existed both in AssignmentTeam model and AssignmentParticipant model.&lt;br /&gt;
&lt;br /&gt;
'' In assignment_team.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        list_of_users = participants;&lt;br /&gt;
        list_of_users.each { |participant| return true if participant.has_submissions? }&lt;br /&gt;
        false&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
''In assignment_participant.rb''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        return ((self.team.submitted_files.length &amp;gt; 0) or (hyperlinks_array.length &amp;gt; 0))&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What was happening earlier was that &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; (AssignmentTeam method) used to call &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; for each of the AssignmentParticipants in the team. This was redundant as  the &amp;lt;code&amp;gt;submitted_files&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;submitted_hyperlinks&amp;lt;/code&amp;gt; fields had been moved from the participant to the team model in earlier projects. So the participant objects again ended up again going to the team for retrieving these fields.&lt;br /&gt;
&lt;br /&gt;
So we removed &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; from the AssignmentParticipant and refactored the one already present in AssignmentTeam to the simple code below:&lt;br /&gt;
&lt;br /&gt;
''In assignment_team.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        return ((self.submitted_files.length &amp;gt; 0) or (hyperlinks.length &amp;gt; 0))&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task4::''' Most importantly, at all the places in the Expertiza code, where there were calls to the above mentioned methods in assignment_participant.rb, they were refactored appropriately to call the newly created methods in assignment_team.rb.&lt;br /&gt;
&lt;br /&gt;
''Sample example :''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
        if (participant.submitted_at.nil? &amp;amp;&amp;amp; participant.hyperlinks.empty?)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''This was refactored as''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
        if (participant.submitted_at.nil? &amp;amp;&amp;amp; participant.team.hyperlinks.empty?)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In refactoring the call points, we used the existing &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; method of AssignmentParticipant to get the AssignmentTeam object associated with the particular participant and then invoked the equivalent methods on the &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task5 ::''' Refactoring some of controller code.&lt;br /&gt;
&lt;br /&gt;
In submitted_content_controller, &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method used to cycle through all the participants belonging to the team of current participant, and for each participant call the &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method of the AssignmentParticipant Model to delete the instance of input hyperlink.&lt;br /&gt;
&lt;br /&gt;
Since all the required hyperlink methods and fields are now in AssignmentTeam this would be redundant and waste cycles. So we refactored it to directly call the AssignmentTeam &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
''Earlier in submitted_content_controller.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def remove_hyperlink&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:hyperlinks][:participant_id])&lt;br /&gt;
 &lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    hyperlink_to_delete = @participant.hyperlinks_array[params['chk_links'].to_i]&lt;br /&gt;
  &lt;br /&gt;
    team_id = TeamsUser.team_id(@participant.parent_id, @participant.user_id)&lt;br /&gt;
    team_participants = Array.new&lt;br /&gt;
    if Team.exists?(team_id)&lt;br /&gt;
      team_users = TeamsUser.where(team_id: team_id)&lt;br /&gt;
      team_users.each do |team_user|&lt;br /&gt;
        team_participants &amp;lt;&amp;lt; AssignmentParticipant.where(parent_id: @participant.parent_id, user_id: team_user.user_id).first&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      team_participants &amp;lt;&amp;lt; @participant&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    team_participants.each do |team_participant|&lt;br /&gt;
      team_participant.remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''Refactored:''&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def remove_hyperlink&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:hyperlinks][:participant_id])&lt;br /&gt;
 &lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
 &lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    hyperlink_to_delete = team.hyperlinks[params['chk_links'].to_i]&lt;br /&gt;
    team.remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
&lt;br /&gt;
=== RSpec ===&lt;br /&gt;
RSpec is a testing framework for Rails, and is a Behavioral-Driven Development tool. It is a domain specific language(DSL).  &lt;br /&gt;
&lt;br /&gt;
There were no existing tests for the hyperlinks related methods. We used RSpec to write test cases using TTD approach. The assignment_team_spec.rb in the spec folder will have these tests. All the tests can be executed by rspec spec command, or can also be executed individually using the command &amp;quot;rspec spec/models/assignment_team_spec.rb&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Factory Girl===&lt;br /&gt;
We have used Factory Girl for creating Assignment and Team objects to be used for testing. Factory Girl is a replacement for fixtures. Fixtures have to be updated whenever we change a data model whereas adding and removing fields is much easier in Factory Girl. Fixture definitions are global whereas Factories can be local, so isolated cases can be tested. Factories are defined to create objects for testing.&lt;br /&gt;
&lt;br /&gt;
===Setup===&lt;br /&gt;
Below code has to be added to the gemfile&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  gem 'rspec-rails'&lt;br /&gt;
  gem &amp;quot;factory_girl_rails&amp;quot;, &amp;quot;~&amp;gt; 4.0&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Building Factory===&lt;br /&gt;
Below is the code to create object of team class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 FactoryGirl.define do&lt;br /&gt;
  factory :team do&lt;br /&gt;
    name &amp;quot;Wikipedia contribution_Team2&amp;quot;&lt;br /&gt;
    parent_id 999&lt;br /&gt;
    #parent_id 741&lt;br /&gt;
    type &amp;quot;AssignmentTeam&amp;quot;&lt;br /&gt;
    submitted_hyperlinks &amp;quot;---\n- http://www.goo.gl.com/2122\n- http://www.goo.gl.com/8767&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example RSpec===&lt;br /&gt;
We have written unit tests for each of the methods we have re-factored in this project. Here's a unit test example contained in spec/model/assignment_team_spec.rb:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  describe &amp;quot;#has_submissions?&amp;quot; do&lt;br /&gt;
    it &amp;quot;checks if a team has submitted hyperlinks&amp;quot; do&lt;br /&gt;
      # assignment = build(:assignment)&lt;br /&gt;
      assign_team = build(:assignment_team)&lt;br /&gt;
      assign_team.submitted_hyperlinks &amp;lt;&amp;lt; &amp;quot;\n- https://www.csc.ncsu.edu/2341&amp;quot;&lt;br /&gt;
      expect(assign_team.has_submissions?).to be true&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Running RSpec===&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  $ rspec spec/models/assignment_team_spec.rb&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Following are some of the steps which we performed to test this code from the User interface.&lt;br /&gt;
&lt;br /&gt;
''Before the test::'' Have two students in an assignment team (say student1 and student2, you can also use the student logins listed in this wiki) for an active assignment. Active assignment simply means that the due date is in future and the assignment is not in &amp;quot;Finish&amp;quot; state. You can use an instructor login (example username: instructor6 password: password) to create a new assignment or update the due dates of some previous assignment and assign the team to it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test1:''  Login as student1. Submit a hyperlink (say : linkA) as student1.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Submit should go through. The hyperlink should be visible when you login as student2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test2:'' Now as student2, submit another hyperlink (say linkB).&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Submit should go through. Now both hyperlinks should be visible from both student1 and student2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test3:'' As student1, try submitting linkB.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' As linkB already exists in team's hyperlinks the submit should not go through.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test4:'' Remove a hyperlink (say linkA).&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Remove goes through. Now only linkB should be visible from both student accounts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test5:'' Remove all hyperlinks.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Hyperlinks list is empty for team and this can be seen from both student accounts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test6:'' Submit some hyperlink. Try dropping topic after submitting.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' You are not allowed to drop if you have submitted some work. Only if you remove the submitted work it is possible for you to drop.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test7:'' Submit some hyperlink. Do a review of the team after logging in as a student in another team. The assignment should be in review stage for this to be possible, you can move the due dates via instructor login to achieve this.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Peer review should show the links submitted by the other team. Review should be submitted successfully.&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101662</id>
		<title>CSC/ECE 517 Spring 2016/OSS E1601</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101662"/>
		<updated>2016-04-02T04:05:26Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: /* Building Factory */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== E1601: Refactor methods related to submitted_hyperlinks. ===&lt;br /&gt;
&lt;br /&gt;
This wiki is for the open source refactoring project E1601: Refactor methods related to submitted_hyperlinks for the course ECE/CSC 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
The reviewers may use the below student and instructor logins for the purpose of reviewing and testing the functionality. These students belong to the same team and work on an assignment created by the below instructor:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5884,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student6420,  password -&amp;gt; password&lt;br /&gt;
'''Please note''': Please do not delete the above users or their team. If you wish to do so, please add them back so as to aid other reviewers. Also note that the option to submit hyperlinks in the UI will be displayed to the enrolled students only if assignment deadline is in future and the assignment is not in &amp;quot;Finish&amp;quot; state.&lt;br /&gt;
&lt;br /&gt;
== Expertiza Introduction==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source web application which enhances the student's learning through peer reviews. The students can form teams and work on assignments given by course instructors. The peers can review the submissions and give feedback. The students also get to review the reviewers!&lt;br /&gt;
&lt;br /&gt;
== Problem statement ==&lt;br /&gt;
&lt;br /&gt;
'''Before''': When a student submitted files and hyperlinks for an assignment, that content was submitted on behalf of his team, and not individually (even if there is only one person in the team i.e a student working on an assignment cannot be without a team even if he is working alone). Some of the previous contributors had worked on a project which made this change and associated all the submitted content to teams instead of the individual participants: the submitted_hyperlinks and dirctory_num fields were moved to teams table. All the hyperlinks were now recorded in one submitted_hyperlinks field in the team model instead of being present in all the participants of the team. All the submitted files similarly were uploaded to the common file space and in the “course_folder/assignment_folder/team_folder” path.&lt;br /&gt;
&lt;br /&gt;
'''What was wrong with that''': There are multiple methods in assignment_participant.rb which still give the impression that the author is submitting the hyperlinks on behalf of himself and not the team even though the relevant fields have been moved to teams model. These methods are to be moved to assignment_teams.rb for improving the clarity and the efficiency of code.&lt;br /&gt;
&lt;br /&gt;
'''What refactoring we have done to improve the code''':&lt;br /&gt;
&lt;br /&gt;
''Task1::'' Removed “hyperlinks_array” method and “hyperlinks” method from assignment_participant.rb. Created “hyperlinks” method in assignment_team.rb.&lt;br /&gt;
&lt;br /&gt;
''Task2::'' Removed “submit_hyperlink” and “remove_hyperlink” from assignment_pariticpant.rb and created equivalent methods in assignment_team.rb.        &lt;br /&gt;
&lt;br /&gt;
''Task3::'' Removed “has_submissions?” from assginment_participant.rb and created the equivalent method in assignment_team.rb.          &lt;br /&gt;
&lt;br /&gt;
''Task4::'' All the calls to the above methods were refactored to call the appropriate method's functions.&lt;br /&gt;
&lt;br /&gt;
''Task5::'' Refactored some of the logic of controller methods.&lt;br /&gt;
&lt;br /&gt;
''Task6::'' Tests for submitting and removing submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
== List of files changed ==&lt;br /&gt;
&lt;br /&gt;
Model Files:&lt;br /&gt;
&lt;br /&gt;
#assignment_participant.rb&lt;br /&gt;
#assignment_team.rb&lt;br /&gt;
#student_task.rb&lt;br /&gt;
&lt;br /&gt;
View Files:&lt;br /&gt;
&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#assignments/edit/_calibration.html.erb&lt;br /&gt;
#assignments/list_submissions.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
&lt;br /&gt;
Controller Files:&lt;br /&gt;
&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
#submitted_content_controller.rb&lt;br /&gt;
&lt;br /&gt;
Files with major modifications:&lt;br /&gt;
&lt;br /&gt;
#The model: assignment_participant.rb&lt;br /&gt;
#The model: assignment_team.rb&lt;br /&gt;
#The controller: submitted_content_controller.rb&lt;br /&gt;
&lt;br /&gt;
== Key changes ==&lt;br /&gt;
&lt;br /&gt;
Four methods &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;submit_hyperlink&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; were moved from the assignment_participant.rb model to assignment_team.rb, and the &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; method was removed.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task1::''' The below methods &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; were removed from the assignment_participant.rb. The &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method which existed here seemed suspect as there was no &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method in the AssignmentTeam/Team models so the &amp;lt;code&amp;gt;try&amp;lt;/code&amp;gt; would always fail and return an empty array. Also the &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; method retrieved the hyperlinks from the &amp;lt;code&amp;gt;submitted_hyperlinks&amp;lt;/code&amp;gt; field of the team model so in moving to AssignmentTeam model we just had to remove the .team quantifier.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;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.team.submitted_hyperlinks.blank? ? [] : YAML::load(self.team.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They are both merged into a new single &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method in assignment_team.rb. All callers of both methods were refactored to use &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method of AssignmentTeam.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
        self.submitted_hyperlinks.blank? ? [] : YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task2::''' Earlier, the following method &amp;lt;code&amp;gt;submit_hyperlink&amp;lt;/code&amp;gt; was in assignment_participant.rb:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&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;
    team_object = self.team&lt;br /&gt;
    team_object.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    team_object.save&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It has been now moved to assignment_team.rb as below. Again, as the method was moved to AssignmentTeam model, it obviated the need to invoke the &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&amp;lt;code&amp;gt;&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&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;
&amp;lt;/code&amp;gt;&lt;br /&gt;
A similar refactoring was done for &amp;lt;code&amp;gt;remove_hyperlinks&amp;lt;/code&amp;gt; method in assignment_participant.rb. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task3::''' The methods &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; earlier existed both in AssignmentTeam model and AssignmentParticipant model.&lt;br /&gt;
&lt;br /&gt;
'' In assignment_team.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        list_of_users = participants;&lt;br /&gt;
        list_of_users.each { |participant| return true if participant.has_submissions? }&lt;br /&gt;
        false&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
''In assignment_participant.rb''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        return ((self.team.submitted_files.length &amp;gt; 0) or (hyperlinks_array.length &amp;gt; 0))&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What was happening earlier was that &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; (AssignmentTeam method) used to call &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; for each of the AssignmentParticipants in the team. This was redundant as  the &amp;lt;code&amp;gt;submitted_files&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;submitted_hyperlinks&amp;lt;/code&amp;gt; fields had been moved from the participant to the team model in earlier projects. So the participant objects again ended up again going to the team for retrieving these fields.&lt;br /&gt;
&lt;br /&gt;
So we removed &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; from the AssignmentParticipant and refactored the one already present in AssignmentTeam to the simple code below:&lt;br /&gt;
&lt;br /&gt;
''In assignment_team.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        return ((self.submitted_files.length &amp;gt; 0) or (hyperlinks.length &amp;gt; 0))&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task4::''' Most importantly, at all the places in the Expertiza code, where there were calls to the above mentioned methods in assignment_participant.rb, they were refactored appropriately to call the newly created methods in assignment_team.rb.&lt;br /&gt;
&lt;br /&gt;
''Sample example :''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
        if (participant.submitted_at.nil? &amp;amp;&amp;amp; participant.hyperlinks.empty?)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''This was refactored as''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
        if (participant.submitted_at.nil? &amp;amp;&amp;amp; participant.team.hyperlinks.empty?)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In refactoring the call points, we used the existing &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; method of AssignmentParticipant to get the AssignmentTeam object associated with the particular participant and then invoked the equivalent methods on the &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task5 ::''' Refactoring some of controller code.&lt;br /&gt;
&lt;br /&gt;
In submitted_content_controller, &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method used to cycle through all the participants belonging to the team of current participant, and for each participant call the &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method of the AssignmentParticipant Model to delete the instance of input hyperlink.&lt;br /&gt;
&lt;br /&gt;
Since all the required hyperlink methods and fields are now in AssignmentTeam this would be redundant and waste cycles. So we refactored it to directly call the AssignmentTeam &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
''Earlier in submitted_content_controller.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def remove_hyperlink&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:hyperlinks][:participant_id])&lt;br /&gt;
 &lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    hyperlink_to_delete = @participant.hyperlinks_array[params['chk_links'].to_i]&lt;br /&gt;
  &lt;br /&gt;
    team_id = TeamsUser.team_id(@participant.parent_id, @participant.user_id)&lt;br /&gt;
    team_participants = Array.new&lt;br /&gt;
    if Team.exists?(team_id)&lt;br /&gt;
      team_users = TeamsUser.where(team_id: team_id)&lt;br /&gt;
      team_users.each do |team_user|&lt;br /&gt;
        team_participants &amp;lt;&amp;lt; AssignmentParticipant.where(parent_id: @participant.parent_id, user_id: team_user.user_id).first&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      team_participants &amp;lt;&amp;lt; @participant&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    team_participants.each do |team_participant|&lt;br /&gt;
      team_participant.remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''Refactored:''&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def remove_hyperlink&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:hyperlinks][:participant_id])&lt;br /&gt;
 &lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
 &lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    hyperlink_to_delete = team.hyperlinks[params['chk_links'].to_i]&lt;br /&gt;
    team.remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
&lt;br /&gt;
=== RSpec ===&lt;br /&gt;
RSpec is a testing framework for Rails, and is a Behavioral-Driven Development tool. It is a domain specific language(DSL).  &lt;br /&gt;
&lt;br /&gt;
There were no existing tests for the hyperlinks related methods. We used RSpec to write test cases using TTD approach. The assignment_team_spec.rb in the spec folder will have these tests. All the tests can be executed by rspec spec command, or can also be executed individually using the command &amp;quot;rspec spec/models/assignment_team_spec.rb&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Factory Girl===&lt;br /&gt;
We have used Factory Girl for creating Assignment and Team objects to be used for testing. Factory Girl is a replacement for fixtures. Fixtures have to be updated whenever we change a data model whereas adding and removing fields is much easier in Factory Girl. Fixture definitions are global whereas Factories can be local, so isolated cases can be tested. Factories are defined to create objects for testing.&lt;br /&gt;
&lt;br /&gt;
===Setup===&lt;br /&gt;
Below code has to be added to the gemfile&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  gem 'rspec-rails'&lt;br /&gt;
  gem &amp;quot;factory_girl_rails&amp;quot;, &amp;quot;~&amp;gt; 4.0&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Building Factory===&lt;br /&gt;
Below is the code to create object of team class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 FactoryGirl.define do&lt;br /&gt;
  factory :team do&lt;br /&gt;
    name &amp;quot;Wikipedia contribution_Team2&amp;quot;&lt;br /&gt;
    parent_id 999&lt;br /&gt;
    #parent_id 741&lt;br /&gt;
    type &amp;quot;AssignmentTeam&amp;quot;&lt;br /&gt;
    submitted_hyperlinks &amp;quot;---\n- http://www.goo.gl.com/2122\n- http://www.goo.gl.com/8767&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example RSpec===&lt;br /&gt;
We have written unit tests for each of the methods we have re-factored in this project. Here's a unit test example contained in spec/model/assignment_team_spec.rb:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  describe &amp;quot;#has_submissions?&amp;quot; do&lt;br /&gt;
    it &amp;quot;checks if a team has submitted hyperlinks&amp;quot; do&lt;br /&gt;
      # assignment = build(:assignment)&lt;br /&gt;
      assign_team = build(:assignment_team)&lt;br /&gt;
      assign_team.submitted_hyperlinks &amp;lt;&amp;lt; &amp;quot;\n- https://www.harrypotter.ncsu.edu&amp;quot;&lt;br /&gt;
      expect(assign_team.has_submissions?).to be true&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Running RSpec===&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  $ rspec spec/models/assignment_team_spec.rb&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Following are some of the steps which we performed to test this code from the User interface.&lt;br /&gt;
&lt;br /&gt;
''Before the test::'' Have two students in an assignment team (say student1 and student2, you can also use the student logins listed in this wiki) for an active assignment. Active assignment simply means that the due date is in future and the assignment is not in &amp;quot;Finish&amp;quot; state. You can use an instructor login (example username: instructor6 password: password) to create a new assignment or update the due dates of some previous assignment and assign the team to it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test1:''  Login as student1. Submit a hyperlink (say : linkA) as student1.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Submit should go through. The hyperlink should be visible when you login as student2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test2:'' Now as student2, submit another hyperlink (say linkB).&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Submit should go through. Now both hyperlinks should be visible from both student1 and student2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test3:'' As student1, try submitting linkB.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' As linkB already exists in team's hyperlinks the submit should not go through.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test4:'' Remove a hyperlink (say linkA).&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Remove goes through. Now only linkB should be visible from both student accounts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test5:'' Remove all hyperlinks.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Hyperlinks list is empty for team and this can be seen from both student accounts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test6:'' Submit some hyperlink. Try dropping topic after submitting.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' You are not allowed to drop if you have submitted some work. Only if you remove the submitted work it is possible for you to drop.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test7:'' Submit some hyperlink. Do a review of the team after logging in as a student in another team. The assignment should be in review stage for this to be possible, you can move the due dates via instructor login to achieve this.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Peer review should show the links submitted by the other team. Review should be submitted successfully.&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101661</id>
		<title>CSC/ECE 517 Spring 2016/OSS E1601</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101661"/>
		<updated>2016-04-02T04:02:37Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: /* Factory Girl */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== E1601: Refactor methods related to submitted_hyperlinks. ===&lt;br /&gt;
&lt;br /&gt;
This wiki is for the open source refactoring project E1601: Refactor methods related to submitted_hyperlinks for the course ECE/CSC 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
The reviewers may use the below student and instructor logins for the purpose of reviewing and testing the functionality. These students belong to the same team and work on an assignment created by the below instructor:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5884,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student6420,  password -&amp;gt; password&lt;br /&gt;
'''Please note''': Please do not delete the above users or their team. If you wish to do so, please add them back so as to aid other reviewers. Also note that the option to submit hyperlinks in the UI will be displayed to the enrolled students only if assignment deadline is in future and the assignment is not in &amp;quot;Finish&amp;quot; state.&lt;br /&gt;
&lt;br /&gt;
== Expertiza Introduction==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source web application which enhances the student's learning through peer reviews. The students can form teams and work on assignments given by course instructors. The peers can review the submissions and give feedback. The students also get to review the reviewers!&lt;br /&gt;
&lt;br /&gt;
== Problem statement ==&lt;br /&gt;
&lt;br /&gt;
'''Before''': When a student submitted files and hyperlinks for an assignment, that content was submitted on behalf of his team, and not individually (even if there is only one person in the team i.e a student working on an assignment cannot be without a team even if he is working alone). Some of the previous contributors had worked on a project which made this change and associated all the submitted content to teams instead of the individual participants: the submitted_hyperlinks and dirctory_num fields were moved to teams table. All the hyperlinks were now recorded in one submitted_hyperlinks field in the team model instead of being present in all the participants of the team. All the submitted files similarly were uploaded to the common file space and in the “course_folder/assignment_folder/team_folder” path.&lt;br /&gt;
&lt;br /&gt;
'''What was wrong with that''': There are multiple methods in assignment_participant.rb which still give the impression that the author is submitting the hyperlinks on behalf of himself and not the team even though the relevant fields have been moved to teams model. These methods are to be moved to assignment_teams.rb for improving the clarity and the efficiency of code.&lt;br /&gt;
&lt;br /&gt;
'''What refactoring we have done to improve the code''':&lt;br /&gt;
&lt;br /&gt;
''Task1::'' Removed “hyperlinks_array” method and “hyperlinks” method from assignment_participant.rb. Created “hyperlinks” method in assignment_team.rb.&lt;br /&gt;
&lt;br /&gt;
''Task2::'' Removed “submit_hyperlink” and “remove_hyperlink” from assignment_pariticpant.rb and created equivalent methods in assignment_team.rb.        &lt;br /&gt;
&lt;br /&gt;
''Task3::'' Removed “has_submissions?” from assginment_participant.rb and created the equivalent method in assignment_team.rb.          &lt;br /&gt;
&lt;br /&gt;
''Task4::'' All the calls to the above methods were refactored to call the appropriate method's functions.&lt;br /&gt;
&lt;br /&gt;
''Task5::'' Refactored some of the logic of controller methods.&lt;br /&gt;
&lt;br /&gt;
''Task6::'' Tests for submitting and removing submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
== List of files changed ==&lt;br /&gt;
&lt;br /&gt;
Model Files:&lt;br /&gt;
&lt;br /&gt;
#assignment_participant.rb&lt;br /&gt;
#assignment_team.rb&lt;br /&gt;
#student_task.rb&lt;br /&gt;
&lt;br /&gt;
View Files:&lt;br /&gt;
&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#assignments/edit/_calibration.html.erb&lt;br /&gt;
#assignments/list_submissions.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
&lt;br /&gt;
Controller Files:&lt;br /&gt;
&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
#submitted_content_controller.rb&lt;br /&gt;
&lt;br /&gt;
Files with major modifications:&lt;br /&gt;
&lt;br /&gt;
#The model: assignment_participant.rb&lt;br /&gt;
#The model: assignment_team.rb&lt;br /&gt;
#The controller: submitted_content_controller.rb&lt;br /&gt;
&lt;br /&gt;
== Key changes ==&lt;br /&gt;
&lt;br /&gt;
Four methods &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;submit_hyperlink&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; were moved from the assignment_participant.rb model to assignment_team.rb, and the &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; method was removed.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task1::''' The below methods &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; were removed from the assignment_participant.rb. The &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method which existed here seemed suspect as there was no &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method in the AssignmentTeam/Team models so the &amp;lt;code&amp;gt;try&amp;lt;/code&amp;gt; would always fail and return an empty array. Also the &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; method retrieved the hyperlinks from the &amp;lt;code&amp;gt;submitted_hyperlinks&amp;lt;/code&amp;gt; field of the team model so in moving to AssignmentTeam model we just had to remove the .team quantifier.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;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.team.submitted_hyperlinks.blank? ? [] : YAML::load(self.team.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They are both merged into a new single &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method in assignment_team.rb. All callers of both methods were refactored to use &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method of AssignmentTeam.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
        self.submitted_hyperlinks.blank? ? [] : YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task2::''' Earlier, the following method &amp;lt;code&amp;gt;submit_hyperlink&amp;lt;/code&amp;gt; was in assignment_participant.rb:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&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;
    team_object = self.team&lt;br /&gt;
    team_object.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    team_object.save&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It has been now moved to assignment_team.rb as below. Again, as the method was moved to AssignmentTeam model, it obviated the need to invoke the &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&amp;lt;code&amp;gt;&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&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;
&amp;lt;/code&amp;gt;&lt;br /&gt;
A similar refactoring was done for &amp;lt;code&amp;gt;remove_hyperlinks&amp;lt;/code&amp;gt; method in assignment_participant.rb. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task3::''' The methods &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; earlier existed both in AssignmentTeam model and AssignmentParticipant model.&lt;br /&gt;
&lt;br /&gt;
'' In assignment_team.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        list_of_users = participants;&lt;br /&gt;
        list_of_users.each { |participant| return true if participant.has_submissions? }&lt;br /&gt;
        false&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
''In assignment_participant.rb''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        return ((self.team.submitted_files.length &amp;gt; 0) or (hyperlinks_array.length &amp;gt; 0))&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What was happening earlier was that &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; (AssignmentTeam method) used to call &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; for each of the AssignmentParticipants in the team. This was redundant as  the &amp;lt;code&amp;gt;submitted_files&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;submitted_hyperlinks&amp;lt;/code&amp;gt; fields had been moved from the participant to the team model in earlier projects. So the participant objects again ended up again going to the team for retrieving these fields.&lt;br /&gt;
&lt;br /&gt;
So we removed &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; from the AssignmentParticipant and refactored the one already present in AssignmentTeam to the simple code below:&lt;br /&gt;
&lt;br /&gt;
''In assignment_team.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        return ((self.submitted_files.length &amp;gt; 0) or (hyperlinks.length &amp;gt; 0))&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task4::''' Most importantly, at all the places in the Expertiza code, where there were calls to the above mentioned methods in assignment_participant.rb, they were refactored appropriately to call the newly created methods in assignment_team.rb.&lt;br /&gt;
&lt;br /&gt;
''Sample example :''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
        if (participant.submitted_at.nil? &amp;amp;&amp;amp; participant.hyperlinks.empty?)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''This was refactored as''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
        if (participant.submitted_at.nil? &amp;amp;&amp;amp; participant.team.hyperlinks.empty?)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In refactoring the call points, we used the existing &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; method of AssignmentParticipant to get the AssignmentTeam object associated with the particular participant and then invoked the equivalent methods on the &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task5 ::''' Refactoring some of controller code.&lt;br /&gt;
&lt;br /&gt;
In submitted_content_controller, &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method used to cycle through all the participants belonging to the team of current participant, and for each participant call the &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method of the AssignmentParticipant Model to delete the instance of input hyperlink.&lt;br /&gt;
&lt;br /&gt;
Since all the required hyperlink methods and fields are now in AssignmentTeam this would be redundant and waste cycles. So we refactored it to directly call the AssignmentTeam &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
''Earlier in submitted_content_controller.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def remove_hyperlink&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:hyperlinks][:participant_id])&lt;br /&gt;
 &lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    hyperlink_to_delete = @participant.hyperlinks_array[params['chk_links'].to_i]&lt;br /&gt;
  &lt;br /&gt;
    team_id = TeamsUser.team_id(@participant.parent_id, @participant.user_id)&lt;br /&gt;
    team_participants = Array.new&lt;br /&gt;
    if Team.exists?(team_id)&lt;br /&gt;
      team_users = TeamsUser.where(team_id: team_id)&lt;br /&gt;
      team_users.each do |team_user|&lt;br /&gt;
        team_participants &amp;lt;&amp;lt; AssignmentParticipant.where(parent_id: @participant.parent_id, user_id: team_user.user_id).first&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      team_participants &amp;lt;&amp;lt; @participant&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    team_participants.each do |team_participant|&lt;br /&gt;
      team_participant.remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''Refactored:''&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def remove_hyperlink&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:hyperlinks][:participant_id])&lt;br /&gt;
 &lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
 &lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    hyperlink_to_delete = team.hyperlinks[params['chk_links'].to_i]&lt;br /&gt;
    team.remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
&lt;br /&gt;
=== RSpec ===&lt;br /&gt;
RSpec is a testing framework for Rails, and is a Behavioral-Driven Development tool. It is a domain specific language(DSL).  &lt;br /&gt;
&lt;br /&gt;
There were no existing tests for the hyperlinks related methods. We used RSpec to write test cases using TTD approach. The assignment_team_spec.rb in the spec folder will have these tests. All the tests can be executed by rspec spec command, or can also be executed individually using the command &amp;quot;rspec spec/models/assignment_team_spec.rb&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Factory Girl===&lt;br /&gt;
We have used Factory Girl for creating Assignment and Team objects to be used for testing. Factory Girl is a replacement for fixtures. Fixtures have to be updated whenever we change a data model whereas adding and removing fields is much easier in Factory Girl. Fixture definitions are global whereas Factories can be local, so isolated cases can be tested. Factories are defined to create objects for testing.&lt;br /&gt;
&lt;br /&gt;
===Setup===&lt;br /&gt;
Below code has to be added to the gemfile&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  gem 'rspec-rails'&lt;br /&gt;
  gem &amp;quot;factory_girl_rails&amp;quot;, &amp;quot;~&amp;gt; 4.0&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Building Factory===&lt;br /&gt;
Below is the code to create object of team class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 FactoryGirl.define do&lt;br /&gt;
  factory :team do&lt;br /&gt;
    name &amp;quot;Wikipedia contribution_Team2&amp;quot;&lt;br /&gt;
    parent_id 999&lt;br /&gt;
    #parent_id 741&lt;br /&gt;
    type &amp;quot;AssignmentTeam&amp;quot;&lt;br /&gt;
    submitted_hyperlinks &amp;quot;---\n- http://water.com\n- http://shed.com&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example RSpec===&lt;br /&gt;
We have written unit tests for each of the methods we have re-factored in this project. Here's a unit test example contained in spec/model/assignment_team_spec.rb:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  describe &amp;quot;#has_submissions?&amp;quot; do&lt;br /&gt;
    it &amp;quot;checks if a team has submitted hyperlinks&amp;quot; do&lt;br /&gt;
      # assignment = build(:assignment)&lt;br /&gt;
      assign_team = build(:assignment_team)&lt;br /&gt;
      assign_team.submitted_hyperlinks &amp;lt;&amp;lt; &amp;quot;\n- https://www.harrypotter.ncsu.edu&amp;quot;&lt;br /&gt;
      expect(assign_team.has_submissions?).to be true&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Running RSpec===&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  $ rspec spec/models/assignment_team_spec.rb&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Following are some of the steps which we performed to test this code from the User interface.&lt;br /&gt;
&lt;br /&gt;
''Before the test::'' Have two students in an assignment team (say student1 and student2, you can also use the student logins listed in this wiki) for an active assignment. Active assignment simply means that the due date is in future and the assignment is not in &amp;quot;Finish&amp;quot; state. You can use an instructor login (example username: instructor6 password: password) to create a new assignment or update the due dates of some previous assignment and assign the team to it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test1:''  Login as student1. Submit a hyperlink (say : linkA) as student1.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Submit should go through. The hyperlink should be visible when you login as student2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test2:'' Now as student2, submit another hyperlink (say linkB).&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Submit should go through. Now both hyperlinks should be visible from both student1 and student2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test3:'' As student1, try submitting linkB.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' As linkB already exists in team's hyperlinks the submit should not go through.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test4:'' Remove a hyperlink (say linkA).&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Remove goes through. Now only linkB should be visible from both student accounts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test5:'' Remove all hyperlinks.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Hyperlinks list is empty for team and this can be seen from both student accounts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test6:'' Submit some hyperlink. Try dropping topic after submitting.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' You are not allowed to drop if you have submitted some work. Only if you remove the submitted work it is possible for you to drop.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test7:'' Submit some hyperlink. Do a review of the team after logging in as a student in another team. The assignment should be in review stage for this to be possible, you can move the due dates via instructor login to achieve this.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Peer review should show the links submitted by the other team. Review should be submitted successfully.&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101657</id>
		<title>CSC/ECE 517 Spring 2016/OSS E1601</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101657"/>
		<updated>2016-04-02T03:41:35Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: /* RSpec */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== E1601: Refactor methods related to submitted_hyperlinks. ===&lt;br /&gt;
&lt;br /&gt;
This wiki is for the open source refactoring project E1601: Refactor methods related to submitted_hyperlinks for the course ECE/CSC 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
The reviewers may use the below student and instructor logins for the purpose of reviewing and testing the functionality. These students belong to the same team and work on an assignment created by the below instructor:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5884,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student6420,  password -&amp;gt; password&lt;br /&gt;
'''Please note''': Please do not delete the above users or their team. If you wish to do so, please add them back so as to aid other reviewers. Also note that the option to submit hyperlinks in the UI will be displayed to the enrolled students only if assignment deadline is in future and the assignment is not in &amp;quot;Finish&amp;quot; state.&lt;br /&gt;
&lt;br /&gt;
== Expertiza Introduction==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source web application which enhances the student's learning through peer reviews. The students can form teams and work on assignments given by course instructors. The peers can review the submissions and give feedback. The students also get to review the reviewers!&lt;br /&gt;
&lt;br /&gt;
== Problem statement ==&lt;br /&gt;
&lt;br /&gt;
'''Before''': When a student submitted files and hyperlinks for an assignment, that content was submitted on behalf of his team, and not individually (even if there is only one person in the team i.e a student working on an assignment cannot be without a team even if he is working alone). Some of the previous contributors had worked on a project which made this change and associated all the submitted content to teams instead of the individual participants: the submitted_hyperlinks and dirctory_num fields were moved to teams table. All the hyperlinks were now recorded in one submitted_hyperlinks field in the team model instead of being present in all the participants of the team. All the submitted files similarly were uploaded to the common file space and in the “course_folder/assignment_folder/team_folder” path.&lt;br /&gt;
&lt;br /&gt;
'''What was wrong with that''': There are multiple methods in assignment_participant.rb which still give the impression that the author is submitting the hyperlinks on behalf of himself and not the team even though the relevant fields have been moved to teams model. These methods are to be moved to assignment_teams.rb for improving the clarity and the efficiency of code.&lt;br /&gt;
&lt;br /&gt;
'''What refactoring we have done to improve the code''':&lt;br /&gt;
&lt;br /&gt;
''Task1::'' Removed “hyperlinks_array” method and “hyperlinks” method from assignment_participant.rb. Created “hyperlinks” method in assignment_team.rb.&lt;br /&gt;
&lt;br /&gt;
''Task2::'' Removed “submit_hyperlink” and “remove_hyperlink” from assignment_pariticpant.rb and created equivalent methods in assignment_team.rb.        &lt;br /&gt;
&lt;br /&gt;
''Task3::'' Removed “has_submissions?” from assginment_participant.rb and created the equivalent method in assignment_team.rb.          &lt;br /&gt;
&lt;br /&gt;
''Task4::'' All the calls to the above methods were refactored to call the appropriate method's functions.&lt;br /&gt;
&lt;br /&gt;
''Task5::'' Refactored some of the logic of controller methods.&lt;br /&gt;
&lt;br /&gt;
''Task6::'' Tests for submitting and removing submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
== List of files changed ==&lt;br /&gt;
&lt;br /&gt;
Model Files:&lt;br /&gt;
&lt;br /&gt;
#assignment_participant.rb&lt;br /&gt;
#assignment_team.rb&lt;br /&gt;
#student_task.rb&lt;br /&gt;
&lt;br /&gt;
View Files:&lt;br /&gt;
&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#assignments/edit/_calibration.html.erb&lt;br /&gt;
#assignments/list_submissions.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
&lt;br /&gt;
Controller Files:&lt;br /&gt;
&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
#submitted_content_controller.rb&lt;br /&gt;
&lt;br /&gt;
Files with major modifications:&lt;br /&gt;
&lt;br /&gt;
#The model: assignment_participant.rb&lt;br /&gt;
#The model: assignment_team.rb&lt;br /&gt;
#The controller: submitted_content_controller.rb&lt;br /&gt;
&lt;br /&gt;
== Key changes ==&lt;br /&gt;
&lt;br /&gt;
Four methods &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;submit_hyperlink&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; were moved from the assignment_participant.rb model to assignment_team.rb, and the &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; method was removed.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task1::''' The below methods &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; were removed from the assignment_participant.rb. The &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method which existed here seemed suspect as there was no &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method in the AssignmentTeam/Team models so the &amp;lt;code&amp;gt;try&amp;lt;/code&amp;gt; would always fail and return an empty array. Also the &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; method retrieved the hyperlinks from the &amp;lt;code&amp;gt;submitted_hyperlinks&amp;lt;/code&amp;gt; field of the team model so in moving to AssignmentTeam model we just had to remove the .team quantifier.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;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.team.submitted_hyperlinks.blank? ? [] : YAML::load(self.team.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They are both merged into a new single &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method in assignment_team.rb. All callers of both methods were refactored to use &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method of AssignmentTeam.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
        self.submitted_hyperlinks.blank? ? [] : YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task2::''' Earlier, the following method &amp;lt;code&amp;gt;submit_hyperlink&amp;lt;/code&amp;gt; was in assignment_participant.rb:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&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;
    team_object = self.team&lt;br /&gt;
    team_object.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    team_object.save&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It has been now moved to assignment_team.rb as below. Again, as the method was moved to AssignmentTeam model, it obviated the need to invoke the &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&amp;lt;code&amp;gt;&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&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;
&amp;lt;/code&amp;gt;&lt;br /&gt;
A similar refactoring was done for &amp;lt;code&amp;gt;remove_hyperlinks&amp;lt;/code&amp;gt; method in assignment_participant.rb. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task3::''' The methods &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; earlier existed both in AssignmentTeam model and AssignmentParticipant model.&lt;br /&gt;
&lt;br /&gt;
'' In assignment_team.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        list_of_users = participants;&lt;br /&gt;
        list_of_users.each { |participant| return true if participant.has_submissions? }&lt;br /&gt;
        false&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
''In assignment_participant.rb''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        return ((self.team.submitted_files.length &amp;gt; 0) or (hyperlinks_array.length &amp;gt; 0))&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What was happening earlier was that &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; (AssignmentTeam method) used to call &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; for each of the AssignmentParticipants in the team. This was redundant as  the &amp;lt;code&amp;gt;submitted_files&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;submitted_hyperlinks&amp;lt;/code&amp;gt; fields had been moved from the participant to the team model in earlier projects. So the participant objects again ended up again going to the team for retrieving these fields.&lt;br /&gt;
&lt;br /&gt;
So we removed &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; from the AssignmentParticipant and refactored the one already present in AssignmentTeam to the simple code below:&lt;br /&gt;
&lt;br /&gt;
''In assignment_team.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        return ((self.submitted_files.length &amp;gt; 0) or (hyperlinks.length &amp;gt; 0))&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task4::''' Most importantly, at all the places in the Expertiza code, where there were calls to the above mentioned methods in assignment_participant.rb, they were refactored appropriately to call the newly created methods in assignment_team.rb.&lt;br /&gt;
&lt;br /&gt;
''Sample example :''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
        if (participant.submitted_at.nil? &amp;amp;&amp;amp; participant.hyperlinks.empty?)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''This was refactored as''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
        if (participant.submitted_at.nil? &amp;amp;&amp;amp; participant.team.hyperlinks.empty?)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In refactoring the call points, we used the existing &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; method of AssignmentParticipant to get the AssignmentTeam object associated with the particular participant and then invoked the equivalent methods on the &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Task5 ::''' Refactoring some of controller code.&lt;br /&gt;
&lt;br /&gt;
In submitted_content_controller, &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method used to cycle through all the participants belonging to the team of current participant, and for each participant call the &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method of the AssignmentParticipant Model to delete the instance of input hyperlink.&lt;br /&gt;
&lt;br /&gt;
Since all the required hyperlink methods and fields are now in AssignmentTeam this would be redundant and waste cycles. So we refactored it to directly call the AssignmentTeam &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
''Earlier in submitted_content_controller.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def remove_hyperlink&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:hyperlinks][:participant_id])&lt;br /&gt;
 &lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    hyperlink_to_delete = @participant.hyperlinks_array[params['chk_links'].to_i]&lt;br /&gt;
  &lt;br /&gt;
    team_id = TeamsUser.team_id(@participant.parent_id, @participant.user_id)&lt;br /&gt;
    team_participants = Array.new&lt;br /&gt;
    if Team.exists?(team_id)&lt;br /&gt;
      team_users = TeamsUser.where(team_id: team_id)&lt;br /&gt;
      team_users.each do |team_user|&lt;br /&gt;
        team_participants &amp;lt;&amp;lt; AssignmentParticipant.where(parent_id: @participant.parent_id, user_id: team_user.user_id).first&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      team_participants &amp;lt;&amp;lt; @participant&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    team_participants.each do |team_participant|&lt;br /&gt;
      team_participant.remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''Refactored:''&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def remove_hyperlink&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:hyperlinks][:participant_id])&lt;br /&gt;
 &lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
 &lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    hyperlink_to_delete = team.hyperlinks[params['chk_links'].to_i]&lt;br /&gt;
    team.remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
&lt;br /&gt;
=== RSpec ===&lt;br /&gt;
RSpec is a testing framework for Rails, and is a Behavioral-Driven Development tool. It is a domain specific language(DSL).  &lt;br /&gt;
&lt;br /&gt;
There were no existing tests for the hyperlinks related methods. We used RSpec to write test cases using TTD approach. The assignment_team_spec.rb in the spec folder will have these tests. All the tests can be executed by rspec spec command, or can also be executed individually using the command &amp;quot;rspec spec/models/assignment_team_spec.rb&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Factory Girl===&lt;br /&gt;
We have used Factory Girl for creating test Assignment and Team objects. Factory Girl is a replacement for fixtures. Fixtures have to be updated whenever we change a data model whereas adding and removing fields is much easier in Factory Girl. Fixture definitions are global whereas Factories can be local, so isolated cases can be tested. Factories are defined to create objects for testing.&lt;br /&gt;
&lt;br /&gt;
===Setup===&lt;br /&gt;
Below code has to be added to the gemfile&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  gem 'rspec-rails'&lt;br /&gt;
  gem &amp;quot;factory_girl_rails&amp;quot;, &amp;quot;~&amp;gt; 4.0&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Running RSpec===&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  $ rspec spec/models/assignment_team_spec.rb&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Following are some of the steps which we performed to test this code from the User interface.&lt;br /&gt;
&lt;br /&gt;
''Before the test::'' Have two students in an assignment team (say student1 and student2, you can also use the student logins listed in this wiki) for an active assignment. Active assignment simply means that the due date is in future and the assignment is not in &amp;quot;Finish&amp;quot; state. You can use an instructor login (example username: instructor6 password: password) to create a new assignment or update the due dates of some previous assignment and assign the team to it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test1:''  Login as student1. Submit a hyperlink (say : linkA) as student1.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Submit should go through. The hyperlink should be visible when you login as student2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test2:'' Now as student2, submit another hyperlink (say linkB).&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Submit should go through. Now both hyperlinks should be visible from both student1 and student2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test3:'' As student1, try submitting linkB.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' As linkB already exists in team's hyperlinks the submit should not go through.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test4:'' Remove a hyperlink (say linkA).&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Remove goes through. Now only linkB should be visible from both student accounts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test5:'' Remove all hyperlinks.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Hyperlinks list is empty for team and this can be seen from both student accounts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test6:'' Submit some hyperlink. Try dropping topic after submitting.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' You are not allowed to drop if you have submitted some work. Only if you remove the submitted work it is possible for you to drop.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test7:'' Submit some hyperlink. Do a review of the team after logging in as a student in another team. The assignment should be in review stage for this to be possible, you can move the due dates via instructor login to achieve this.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Peer review should show the links submitted by the other team. Review should be submitted successfully.&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016&amp;diff=101504</id>
		<title>CSC/ECE 517 Spring 2016</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016&amp;diff=101504"/>
		<updated>2016-03-30T16:34:36Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Writing Assignment 1==&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Active Job]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Calibration Assignment Submissions==&lt;br /&gt;
*[[Calibration Assignment Submission (OmniAuth)]]&lt;br /&gt;
*[[Calibration Assignment Submission (Patch_verb)]]&lt;br /&gt;
&lt;br /&gt;
==Writing Assignment 2==&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Mozilla Implement HTML5 form validation]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Functional Tests for Questionnaire Controller]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016 / Expertiza Self-Review Feature]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Refactor different question types from quiz feature]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Implement private browsing]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Write automated tests for WebDriver]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Refactor sign_up_sheet_controller.rb and sign_up_topic.rb]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Implement Common Parts of the CSSOM API]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Functional tests for assignment creation function]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/E1604. Functional tests for Calibration function]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Refactor and write unit tests for question type.rb]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Refactor response controller]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE_517_Spring_2016_OSS_M1606]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE_517_Spring_2016_OSS_E1601]]&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=E1601:_Refactor_methods_related_to_submitted_hyperlinks&amp;diff=101503</id>
		<title>E1601: Refactor methods related to submitted hyperlinks</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=E1601:_Refactor_methods_related_to_submitted_hyperlinks&amp;diff=101503"/>
		<updated>2016-03-30T16:33:23Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: moved E1601: Refactor methods related to submitted hyperlinks to CSC/ECE 517 Spring 2016 OSS E1601: Updated title&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[CSC/ECE 517 Spring 2016 OSS E1601]]&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101502</id>
		<title>CSC/ECE 517 Spring 2016/OSS E1601</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101502"/>
		<updated>2016-03-30T16:33:23Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: moved E1601: Refactor methods related to submitted hyperlinks to CSC/ECE 517 Spring 2016 OSS E1601: Updated title&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== E1601: Refactor methods related to submitted_hyperlinks. ===&lt;br /&gt;
&lt;br /&gt;
This wiki is for the open source refactoring project E1601: Refactor methods related to submitted_hyperlinks for the course ECE/CSC 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
We suggest the reviewers to use the below students and instructor for the purpose of reviewing. These students belong to the same team and work on an assignment given by the below instructor:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5884,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student6420,  password -&amp;gt; password&lt;br /&gt;
'''Please note''': Please do not delete the above users or their team. If you wish to do so, please add them back so as to aid other reviewers. Also note that the option to submit hyperlinks in the UI will only be displayed to the enrolled students only before the assignment deadline.&lt;br /&gt;
&lt;br /&gt;
== Expertiza Introduction==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source web application which enhances learning through peer reviews. The students can form teams and work on assignments given by course instructors. The peers can review the submissions and give feedback. The students also get to review the reviewers! &lt;br /&gt;
&lt;br /&gt;
== Problem statement ==&lt;br /&gt;
&lt;br /&gt;
'''Before''': When student submitted files and hyperlinks, that content was submitted on behalf of a team, not individuals (even there is only one person in the team). Some of the previous contributors worked on a project which associated all the submitted content to teams: there were submitted_hyperlinks and dirctory_num fields in teams table. All the hyperlinks should ideally be recorded in one submitted_hyperlinks field. All the submitted files were uploaded to the file space and in the “course_folder/assignment_folder/team_folder” path.&lt;br /&gt;
&lt;br /&gt;
'''What was wrong with that''': There are multiple methods in assignment_participant.rb which still look like the author submitted the hyperlinks on behalf of him/herself. They should be moved to assignment_teams.rb.&lt;br /&gt;
&lt;br /&gt;
'''What refactoring we have done to improve''':&lt;br /&gt;
* Removed “hyperlinks_array” method and “hyperlinks” method from assignment_participant.rb. Created “hyperlinks” method in assignment_team.rb.&lt;br /&gt;
* Removed “submit_hyperlink” and “remove_hyperlink” from assignment_pariticpant.rb and created equivalent methods in assignment_team.rb.        &lt;br /&gt;
&lt;br /&gt;
* Removed “has_submissions?” from assginment_participant.rb and created the equivalent method in assignment_team.rb.          &lt;br /&gt;
* All the calls to the above methods were refactored to call the appropriate method's functions.&lt;br /&gt;
* Wrote tests for submitting and removing submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
== List of files changed ==&lt;br /&gt;
&lt;br /&gt;
Model Files:&lt;br /&gt;
&lt;br /&gt;
#assignment_participant.rb&lt;br /&gt;
#assignment_team.rb&lt;br /&gt;
#student_task.rb&lt;br /&gt;
&lt;br /&gt;
View Files:&lt;br /&gt;
&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#assignments/edit/_calibration.html.erb&lt;br /&gt;
#assignments/list_submissions.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
&lt;br /&gt;
Controller Files:&lt;br /&gt;
&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
#submitted_content_controller.rb&lt;br /&gt;
&lt;br /&gt;
Files with major modifications:&lt;br /&gt;
&lt;br /&gt;
#The model: assignment_participant.rb&lt;br /&gt;
#The model: assignment_team.rb&lt;br /&gt;
#The controller: submitted_content_controller.rb&lt;br /&gt;
&lt;br /&gt;
== Key changes ==&lt;br /&gt;
&lt;br /&gt;
Four methods &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;submit_hyperlink&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; were moved from the assignment_participant.rb model to assignment_team.rb, and the &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; method was removed.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1) The below methods &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; were removed from the assignment_participant.rb. The &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method which existed here seemed suspect as there was no &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method in the AssignmentTeam/Team models so the &amp;lt;code&amp;gt;try&amp;lt;/code&amp;gt; would always fail and return an empty array. Also the &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; method retrieved the hyperlinks from the &amp;lt;code&amp;gt;submitted_hyperlinks&amp;lt;/code&amp;gt; field of the team model so in moving to AssignmentTeam model we just had to remove the .team quantifier.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;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.team.submitted_hyperlinks.blank? ? [] : YAML::load(self.team.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They are both merged into a new single &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method in assignment_team.rb. All callers of both methods were refactored to use &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method of AssignmentTeam.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
        self.submitted_hyperlinks.blank? ? [] : YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2) Earlier, the following method &amp;lt;code&amp;gt;submit_hyperlink&amp;lt;/code&amp;gt; was in assignment_participant.rb:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&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;
    team_object = self.team&lt;br /&gt;
    team_object.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    team_object.save&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It has been now moved to assignment_team.rb as below. Again, as the method was moved to AssignmentTeam model, it obviated the need to invoke the &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&amp;lt;code&amp;gt;&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&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;
&amp;lt;/code&amp;gt;&lt;br /&gt;
A similar refactoring was done for &amp;lt;code&amp;gt;remove_hyperlinks&amp;lt;/code&amp;gt; method in assignment_participant.rb. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3) The methods &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; earlier existed both in AssignmentTeam model and AssignmentParticipant model.&lt;br /&gt;
&lt;br /&gt;
'' In assignment_team.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        list_of_users = participants;&lt;br /&gt;
        list_of_users.each { |participant| return true if participant.has_submissions? }&lt;br /&gt;
        false&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
''In assignment_participant.rb''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        return ((self.team.submitted_files.length &amp;gt; 0) or (hyperlinks_array.length &amp;gt; 0))&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What was happening earlier was that &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; (AssignmentTeam method) used to call &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; for each of the AssignmentParticipants in the team. This was redundant as  the &amp;lt;code&amp;gt;submitted_files&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;submitted_hyperlinks&amp;lt;/code&amp;gt; fields had been moved from the participant to the team model in earlier projects. So the participant objects again ended up again going to the team for retrieving these fields.&lt;br /&gt;
&lt;br /&gt;
So we removed &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; from the AssignmentParticipant and refactored the one already present in AssignmentTeam to the simple code below:&lt;br /&gt;
&lt;br /&gt;
''In assignment_team.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        return ((self.submitted_files.length &amp;gt; 0) or (hyperlinks.length &amp;gt; 0))&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4) Most importantly, at all the places in the Expertiza code, where there were calls to the above mentioned methods in assignment_participant.rb, were refactored appropriately to call the newly created methods in assignment_team.rb.&lt;br /&gt;
&lt;br /&gt;
''Sample example :''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
        if (participant.submitted_at.nil? &amp;amp;&amp;amp; participant.hyperlinks.empty?)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''This was refactored as''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
        if (participant.submitted_at.nil? &amp;amp;&amp;amp; participant.team.hyperlinks.empty?)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In refactoring the call points, we used the existing &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; method of AssignmentParticipant to get the AssignmentTeam object associated with the particular participant and then invoked the equivalent methods on the &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5) Refactoring some of controller code.&lt;br /&gt;
&lt;br /&gt;
In submitted_content_controller, &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method used to cycle through all the participants belonging to the team of current participant, and for each participant call the &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method of the AssignmentParticipant Model to delete the instance of input hyperlink.&lt;br /&gt;
&lt;br /&gt;
Since all the required hyperlink methods and fields are now in AssignmentTeam this would be redundant and waste cycles. So we refactored it to directly call the AssignmentTeam &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
''Earlier in submitted_content_controller.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def remove_hyperlink&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:hyperlinks][:participant_id])&lt;br /&gt;
 &lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    hyperlink_to_delete = @participant.hyperlinks_array[params['chk_links'].to_i]&lt;br /&gt;
  &lt;br /&gt;
    team_id = TeamsUser.team_id(@participant.parent_id, @participant.user_id)&lt;br /&gt;
    team_participants = Array.new&lt;br /&gt;
    if Team.exists?(team_id)&lt;br /&gt;
      team_users = TeamsUser.where(team_id: team_id)&lt;br /&gt;
      team_users.each do |team_user|&lt;br /&gt;
        team_participants &amp;lt;&amp;lt; AssignmentParticipant.where(parent_id: @participant.parent_id, user_id: team_user.user_id).first&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      team_participants &amp;lt;&amp;lt; @participant&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    team_participants.each do |team_participant|&lt;br /&gt;
      team_participant.remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''Refactored:''&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def remove_hyperlink&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:hyperlinks][:participant_id])&lt;br /&gt;
 &lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
 &lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    hyperlink_to_delete = team.hyperlinks[params['chk_links'].to_i]&lt;br /&gt;
    team.remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
&lt;br /&gt;
=== RSpec ===&lt;br /&gt;
There were no existing tests for the hyperlinks related methods. We used RSpec to write test cases using TTD approach. The assignment_team_spec.rb in the spec folder will have these tests. All the tests can be executed by rspec spec command, or can also be executed individually using the command &amp;quot;rspec spec/models/assignment_team_spec.rb&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Following are some of the steps which we performed to test this code from the User interface.&lt;br /&gt;
&lt;br /&gt;
''Before the test::'' Have two students in an assignment team (say student1 and student2) for an active assignment. Active assignment simply means that the due date is in future and the assignment is not in &amp;quot;Finish&amp;quot; state. You can use an instructor login (example username: instructor6 password: password) to create a new assignment or update the due dates of some previous assignment and assign the team to it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test1::''  Login as student1. Submit a hyperlink (say : linkA) as student1.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Submit should go through. The hyperlink should be visible when you login as student2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test2:'' Now as student2, submit another hyperlink (say linkB).&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Submit should go through. Now both hyperlinks should be visible from both student1 and student2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test3:'' As student1, try submitting linkB.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' As linkB already exists in team's hyperlinks the submit should not go through.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test4:'' Remove a hyperlink (say linkA).&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Remove goes through. Now only linkB should be visible from both student accounts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test5:'' Remove all hyperlinks.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Hyperlinks list is empty for team and this can be seen from both student accounts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test6:'' Submit some hyperlink. Try dropping topic after submitting.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' You are not allowed to drop if you have submitted some work. Only if you remove the submitted work it is possible for you to drop.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test7:'' Submit some hyperlink. Do a review of the team after logging in as a student in another team. The assignment should be in review stage for this to be possible, you can move the due dates via instructor login to achieve this.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Peer review should show the links submitted by the other team. Review should be submitted successfully.&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=User:Kvysyar&amp;diff=101500</id>
		<title>User:Kvysyar</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=User:Kvysyar&amp;diff=101500"/>
		<updated>2016-03-30T16:26:30Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: moved User:Kvysyar to E1601: Refactor methods related to submitted hyperlinks: Moved the page and added a new title.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[E1601: Refactor methods related to submitted hyperlinks]]&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101499</id>
		<title>CSC/ECE 517 Spring 2016/OSS E1601</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101499"/>
		<updated>2016-03-30T16:26:30Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: moved User:Kvysyar to E1601: Refactor methods related to submitted hyperlinks: Moved the page and added a new title.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== E1601: Refactor methods related to submitted_hyperlinks. ===&lt;br /&gt;
&lt;br /&gt;
This wiki is for the open source refactoring project E1601: Refactor methods related to submitted_hyperlinks for the course ECE/CSC 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
We suggest the reviewers to use the below students and instructor for the purpose of reviewing. These students belong to the same team and work on an assignment given by the below instructor:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5884,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student6420,  password -&amp;gt; password&lt;br /&gt;
'''Please note''': Please do not delete the above users or their team. If you wish to do so, please add them back so as to aid other reviewers. Also note that the option to submit hyperlinks in the UI will only be displayed to the enrolled students only before the assignment deadline.&lt;br /&gt;
&lt;br /&gt;
== Expertiza Introduction==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source web application which enhances learning through peer reviews. The students can form teams and work on assignments given by course instructors. The peers can review the submissions and give feedback. The students also get to review the reviewers! &lt;br /&gt;
&lt;br /&gt;
== Problem statement ==&lt;br /&gt;
&lt;br /&gt;
'''Before''': When student submitted files and hyperlinks, that content was submitted on behalf of a team, not individuals (even there is only one person in the team). Some of the previous contributors worked on a project which associated all the submitted content to teams: there were submitted_hyperlinks and dirctory_num fields in teams table. All the hyperlinks should ideally be recorded in one submitted_hyperlinks field. All the submitted files were uploaded to the file space and in the “course_folder/assignment_folder/team_folder” path.&lt;br /&gt;
&lt;br /&gt;
'''What was wrong with that''': There are multiple methods in assignment_participant.rb which still look like the author submitted the hyperlinks on behalf of him/herself. They should be moved to assignment_teams.rb.&lt;br /&gt;
&lt;br /&gt;
'''What refactoring we have done to improve''':&lt;br /&gt;
* Removed “hyperlinks_array” method and “hyperlinks” method from assignment_participant.rb. Created “hyperlinks” method in assignment_team.rb.&lt;br /&gt;
* Removed “submit_hyperlink” and “remove_hyperlink” from assignment_pariticpant.rb and created equivalent methods in assignment_team.rb.        &lt;br /&gt;
&lt;br /&gt;
* Removed “has_submissions?” from assginment_participant.rb and created the equivalent method in assignment_team.rb.          &lt;br /&gt;
* All the calls to the above methods were refactored to call the appropriate method's functions.&lt;br /&gt;
* Wrote tests for submitting and removing submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
== List of files changed ==&lt;br /&gt;
&lt;br /&gt;
Model Files:&lt;br /&gt;
&lt;br /&gt;
#assignment_participant.rb&lt;br /&gt;
#assignment_team.rb&lt;br /&gt;
#student_task.rb&lt;br /&gt;
&lt;br /&gt;
View Files:&lt;br /&gt;
&lt;br /&gt;
#submitted_content/_hyperlink.html.erb&lt;br /&gt;
#assignments/edit/_calibration.html.erb&lt;br /&gt;
#assignments/list_submissions.html.erb&lt;br /&gt;
#submitted_content/_main.html.erb&lt;br /&gt;
&lt;br /&gt;
Controller Files:&lt;br /&gt;
&lt;br /&gt;
#sign_up_sheet_controller.rb&lt;br /&gt;
#submitted_content_controller.rb&lt;br /&gt;
&lt;br /&gt;
Files with major modifications:&lt;br /&gt;
&lt;br /&gt;
#The model: assignment_participant.rb&lt;br /&gt;
#The model: assignment_team.rb&lt;br /&gt;
#The controller: submitted_content_controller.rb&lt;br /&gt;
&lt;br /&gt;
== Key changes ==&lt;br /&gt;
&lt;br /&gt;
Four methods &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;submit_hyperlink&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; were moved from the assignment_participant.rb model to assignment_team.rb, and the &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; method was removed.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1) The below methods &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; were removed from the assignment_participant.rb. The &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method which existed here seemed suspect as there was no &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method in the AssignmentTeam/Team models so the &amp;lt;code&amp;gt;try&amp;lt;/code&amp;gt; would always fail and return an empty array. Also the &amp;lt;code&amp;gt;hyperlinks_array&amp;lt;/code&amp;gt; method retrieved the hyperlinks from the &amp;lt;code&amp;gt;submitted_hyperlinks&amp;lt;/code&amp;gt; field of the team model so in moving to AssignmentTeam model we just had to remove the .team quantifier.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;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.team.submitted_hyperlinks.blank? ? [] : YAML::load(self.team.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They are both merged into a new single &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method in assignment_team.rb. All callers of both methods were refactored to use &amp;lt;code&amp;gt;hyperlinks&amp;lt;/code&amp;gt; method of AssignmentTeam.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
        self.submitted_hyperlinks.blank? ? [] : YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2) Earlier, the following method &amp;lt;code&amp;gt;submit_hyperlink&amp;lt;/code&amp;gt; was in assignment_participant.rb:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&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;
    team_object = self.team&lt;br /&gt;
    team_object.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    team_object.save&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It has been now moved to assignment_team.rb as below. Again, as the method was moved to AssignmentTeam model, it obviated the need to invoke the &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&amp;lt;code&amp;gt;&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&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;
&amp;lt;/code&amp;gt;&lt;br /&gt;
A similar refactoring was done for &amp;lt;code&amp;gt;remove_hyperlinks&amp;lt;/code&amp;gt; method in assignment_participant.rb. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3) The methods &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; earlier existed both in AssignmentTeam model and AssignmentParticipant model.&lt;br /&gt;
&lt;br /&gt;
'' In assignment_team.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        list_of_users = participants;&lt;br /&gt;
        list_of_users.each { |participant| return true if participant.has_submissions? }&lt;br /&gt;
        false&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
''In assignment_participant.rb''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        return ((self.team.submitted_files.length &amp;gt; 0) or (hyperlinks_array.length &amp;gt; 0))&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What was happening earlier was that &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; (AssignmentTeam method) used to call &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; for each of the AssignmentParticipants in the team. This was redundant as  the &amp;lt;code&amp;gt;submitted_files&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;submitted_hyperlinks&amp;lt;/code&amp;gt; fields had been moved from the participant to the team model in earlier projects. So the participant objects again ended up again going to the team for retrieving these fields.&lt;br /&gt;
&lt;br /&gt;
So we removed &amp;lt;code&amp;gt;has_submissions?&amp;lt;/code&amp;gt; from the AssignmentParticipant and refactored the one already present in AssignmentTeam to the simple code below:&lt;br /&gt;
&lt;br /&gt;
''In assignment_team.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
  def has_submissions?&lt;br /&gt;
        return ((self.submitted_files.length &amp;gt; 0) or (hyperlinks.length &amp;gt; 0))&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4) Most importantly, at all the places in the Expertiza code, where there were calls to the above mentioned methods in assignment_participant.rb, were refactored appropriately to call the newly created methods in assignment_team.rb.&lt;br /&gt;
&lt;br /&gt;
''Sample example :''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
        if (participant.submitted_at.nil? &amp;amp;&amp;amp; participant.hyperlinks.empty?)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''This was refactored as''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
        if (participant.submitted_at.nil? &amp;amp;&amp;amp; participant.team.hyperlinks.empty?)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In refactoring the call points, we used the existing &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; method of AssignmentParticipant to get the AssignmentTeam object associated with the particular participant and then invoked the equivalent methods on the &amp;lt;code&amp;gt;team&amp;lt;/code&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5) Refactoring some of controller code.&lt;br /&gt;
&lt;br /&gt;
In submitted_content_controller, &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method used to cycle through all the participants belonging to the team of current participant, and for each participant call the &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method of the AssignmentParticipant Model to delete the instance of input hyperlink.&lt;br /&gt;
&lt;br /&gt;
Since all the required hyperlink methods and fields are now in AssignmentTeam this would be redundant and waste cycles. So we refactored it to directly call the AssignmentTeam &amp;lt;code&amp;gt;remove_hyperlink&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
''Earlier in submitted_content_controller.rb''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def remove_hyperlink&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:hyperlinks][:participant_id])&lt;br /&gt;
 &lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
    hyperlink_to_delete = @participant.hyperlinks_array[params['chk_links'].to_i]&lt;br /&gt;
  &lt;br /&gt;
    team_id = TeamsUser.team_id(@participant.parent_id, @participant.user_id)&lt;br /&gt;
    team_participants = Array.new&lt;br /&gt;
    if Team.exists?(team_id)&lt;br /&gt;
      team_users = TeamsUser.where(team_id: team_id)&lt;br /&gt;
      team_users.each do |team_user|&lt;br /&gt;
        team_participants &amp;lt;&amp;lt; AssignmentParticipant.where(parent_id: @participant.parent_id, user_id: team_user.user_id).first&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      team_participants &amp;lt;&amp;lt; @participant&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
    team_participants.each do |team_participant|&lt;br /&gt;
      team_participant.remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''Refactored:''&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  def remove_hyperlink&lt;br /&gt;
    @participant = AssignmentParticipant.find(params[:hyperlinks][:participant_id])&lt;br /&gt;
 &lt;br /&gt;
    return unless current_user_id?(@participant.user_id)&lt;br /&gt;
 &lt;br /&gt;
    team = @participant.team&lt;br /&gt;
    hyperlink_to_delete = team.hyperlinks[params['chk_links'].to_i]&lt;br /&gt;
    team.remove_hyperlink(hyperlink_to_delete)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
&lt;br /&gt;
=== RSpec ===&lt;br /&gt;
There were no existing tests for the hyperlinks related methods. We used RSpec to write test cases using TTD approach. The assignment_team_spec.rb in the spec folder will have these tests. All the tests can be executed by rspec spec command, or can also be executed individually using the command &amp;quot;rspec spec/models/assignment_team_spec.rb&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Following are some of the steps which we performed to test this code from the User interface.&lt;br /&gt;
&lt;br /&gt;
''Before the test::'' Have two students in an assignment team (say student1 and student2) for an active assignment. Active assignment simply means that the due date is in future and the assignment is not in &amp;quot;Finish&amp;quot; state. You can use an instructor login (example username: instructor6 password: password) to create a new assignment or update the due dates of some previous assignment and assign the team to it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test1::''  Login as student1. Submit a hyperlink (say : linkA) as student1.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Submit should go through. The hyperlink should be visible when you login as student2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test2:'' Now as student2, submit another hyperlink (say linkB).&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Submit should go through. Now both hyperlinks should be visible from both student1 and student2.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test3:'' As student1, try submitting linkB.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' As linkB already exists in team's hyperlinks the submit should not go through.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test4:'' Remove a hyperlink (say linkA).&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Remove goes through. Now only linkB should be visible from both student accounts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test5:'' Remove all hyperlinks.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Hyperlinks list is empty for team and this can be seen from both student accounts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test6:'' Submit some hyperlink. Try dropping topic after submitting.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' You are not allowed to drop if you have submitted some work. Only if you remove the submitted work it is possible for you to drop.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Test7:'' Submit some hyperlink. Do a review of the team after logging in as a student in another team. The assignment should be in review stage for this to be possible, you can move the due dates via instructor login to achieve this.&lt;br /&gt;
&lt;br /&gt;
''Expected:'' Peer review should show the links submitted by the other team. Review should be submitted successfully.&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101200</id>
		<title>CSC/ECE 517 Spring 2016/OSS E1601</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101200"/>
		<updated>2016-03-24T00:42:45Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: /* Key changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki documentation is for the open source refactoring project E1601: Refactor methods related to submitted_hyperlinks for the course ECE/CSC 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
We suggest the reviewers to use the below students and instructor for the purpose of reviewing. These students belong to the same team and work on an assignment given by the below instructor:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5884,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student6420,  password -&amp;gt; password&lt;br /&gt;
'''Please note''': Please do not delete the above users or their team. If you wish to do so, please add them back so as to aid other reviewers. Also note that the option to submit hyperlinks in the UI will only be displayed to the enrolled students only before the assignment deadline.&lt;br /&gt;
&lt;br /&gt;
== Expertiza Introduction==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source web application which enhances learning through peer reviews. The students can form teams and work on assignments given by course instructors. The peers can review the submissions and give feedback. The students also get to review the reviewers! &lt;br /&gt;
&lt;br /&gt;
== Problem statement ==&lt;br /&gt;
&lt;br /&gt;
'''Before''': When student submitted files and hyperlinks, that content was submitted on behalf of a team, not individuals (even there is only one person in the team). Some of the previous contributors worked on a project which associated all the submitted content to teams: there were submitted_hyperlinks and dirctory_num fields in teams table. All the hyperlinks should ideally be recorded in one submitted_hyperlinks field. All the submitted files were uploaded to the file space and in the “course_folder/assignment_folder/team_folder” path.&lt;br /&gt;
&lt;br /&gt;
'''What was wrong with that''': There are multiple methods in assignment_participant.rb which still look like the author submit the hyperlinks on behalf of him/herself. They should be moved to assignment_teams.rb.&lt;br /&gt;
&lt;br /&gt;
'''What refactoring we have done to improve''':&lt;br /&gt;
* Removed “hyperlinks_array” method and “hyperlinks” method from assignment_participant.rb. Created “hyperlinks” method in assignment_team.rb.&lt;br /&gt;
* Removed “submit_hyperlink” and “remove_hyperlink” from assignment_pariticpant.rb and created equivalent methods in assignment_team.rb.        &lt;br /&gt;
&lt;br /&gt;
* Removed “has_submissions?” from assginment_participant.rb and created equivalent method in assignment_team.rb.          &lt;br /&gt;
* All the calls to the above methods were refactored to call the appropriate method's functions.&lt;br /&gt;
* Wrote tests for submitting and removing submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
== Key changes ==&lt;br /&gt;
Files with major modifications:&lt;br /&gt;
# The model: assignment_participant.rb&lt;br /&gt;
# The model: assignment_team.rb&lt;br /&gt;
Four methods &amp;quot;hyperlinks”, “has_submissions?”, “submit_hyperlink” and “remove_hyperlink” were moved from the assignment_participant.rb model to assignment_team.rb, and the &amp;quot;hyperlinks_array&amp;quot; method removed.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1.a) The below hyperlinks_array and hyperlinks method are removed from the assignment_participant.rb:&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.team.submitted_hyperlinks.blank? ? [] : YAML::load(self.team.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
b) They are both merged into a single method in assignment_team.rb under the hyperlinks method:&lt;br /&gt;
&lt;br /&gt;
  def hyperlinks&lt;br /&gt;
        self.submitted_hyperlinks.blank? ? [] : YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. a) Earlier, the following method submit_hyperlink was in assignment_participant.rb:&lt;br /&gt;
 &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;
    team_object = self.team&lt;br /&gt;
    team_object.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    team_object.save&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
b) It is now moved to assignment_team.rb:&lt;br /&gt;
&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&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;
&lt;br /&gt;
&lt;br /&gt;
3) Similarly the methods &amp;quot;has_submissions?&amp;quot;, &amp;quot;remove_hyperlink&amp;quot; were moved.&lt;br /&gt;
&lt;br /&gt;
4) Most importantly, at all the places in the Expertiza code, where there were calls to the above methods in assignment_participant.rb, which are now moved to assignment_team.rb, were refactored accordingly to call them appropriately.&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
=== RSpec ===&lt;br /&gt;
There were no existing tests for the hyperlinks related methods. We used RSpec to write test cases using TTD approach. The assignment_team_spec.rb in the spec folder will have these tests. All the tests can be executed by rspec spec command, or can also be executed individually using the command &amp;quot;rspec spec/models/assignment_team_spec.rb&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Following steps needs to be performed to test this code from UI:&lt;br /&gt;
# Login as a student.&lt;br /&gt;
# In an assignment, that is still due, add one or more hyperlinks.&lt;br /&gt;
# Login as another student who is a teammate of the first student working on the same assignment.&lt;br /&gt;
# You should be able to see the newly uploaded link(s) by the other team member.&lt;br /&gt;
# Try adding a link that is not a valid http or https link. It will give an error message.&lt;br /&gt;
# Try submitting the same link once again. This will give an error message too.&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101196</id>
		<title>CSC/ECE 517 Spring 2016/OSS E1601</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101196"/>
		<updated>2016-03-24T00:39:01Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: /* Key changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki documentation is for the open source refactoring project E1601: Refactor methods related to submitted_hyperlinks for the course ECE/CSC 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
We suggest the reviewers to use the below students and instructor for the purpose of reviewing. These students belong to the same team and work on an assignment given by the below instructor:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5884,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student6420,  password -&amp;gt; password&lt;br /&gt;
'''Please note''': Please do not delete the above users or their team. If you wish to do so, please add them back so as to aid other reviewers. Also note that the option to submit hyperlinks in the UI will only be displayed to the enrolled students only before the assignment deadline.&lt;br /&gt;
&lt;br /&gt;
== Expertiza Introduction==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source web application which enhances learning through peer reviews. The students can form teams and work on assignments given by course instructors. The peers can review the submissions and give feedback. The students also get to review the reviewers! &lt;br /&gt;
&lt;br /&gt;
== Problem statement ==&lt;br /&gt;
&lt;br /&gt;
'''Before''': When student submitted files and hyperlinks, that content was submitted on behalf of a team, not individuals (even there is only one person in the team). Some of the previous contributors worked on a project which associated all the submitted content to teams: there were submitted_hyperlinks and dirctory_num fields in teams table. All the hyperlinks should ideally be recorded in one submitted_hyperlinks field. All the submitted files were uploaded to the file space and in the “course_folder/assignment_folder/team_folder” path.&lt;br /&gt;
&lt;br /&gt;
'''What was wrong with that''': There are multiple methods in assignment_participant.rb which still look like the author submit the hyperlinks on behalf of him/herself. They should be moved to assignment_teams.rb.&lt;br /&gt;
&lt;br /&gt;
'''What refactoring we have done to improve''':&lt;br /&gt;
* Removed “hyperlinks_array” method and “hyperlinks” method from assignment_participant.rb. Created “hyperlinks” method in assignment_team.rb.&lt;br /&gt;
* Removed “submit_hyperlink” and “remove_hyperlink” from assignment_pariticpant.rb and created equivalent methods in assignment_team.rb.        &lt;br /&gt;
&lt;br /&gt;
* Removed “has_submissions?” from assginment_participant.rb and created equivalent method in assignment_team.rb.          &lt;br /&gt;
* All the calls to the above methods were refactored to call the appropriate method's functions.&lt;br /&gt;
* Wrote tests for submitting and removing submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
== Key changes ==&lt;br /&gt;
Files with major modifications:&lt;br /&gt;
# The model: assignment_participant.rb&lt;br /&gt;
# The model: assignment_team.rb&lt;br /&gt;
Four methods &amp;quot;hyperlinks”, “has_submissions?”, “submit_hyperlink” and “remove_hyperlink” were moved from the assignment_participant.rb model to assignment_team.rb, and the &amp;quot;hyperlinks_array&amp;quot; method removed.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1.a) The below hyperlinks_array and hyperlinks method are removed from the assignment_participant.rb:&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.team.submitted_hyperlinks.blank? ? [] : YAML::load(self.team.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
b) They are both merged into a single method in assignment_team.rb under the hyperlinks mehtod:&lt;br /&gt;
def hyperlinks&lt;br /&gt;
        self.submitted_hyperlinks.blank? ? [] : YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. a) Earlier, the following method submit_hyperlink was in assignment_participant.rb:&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;
    team_object = self.team&lt;br /&gt;
    team_object.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    team_object.save&lt;br /&gt;
  end&lt;br /&gt;
b) It is now moved to assignment_team.rb:&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&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3) Similarly the methods &amp;quot;has_submissions?&amp;quot;, &amp;quot;remove_hyperlink&amp;quot; were moved.&lt;br /&gt;
&lt;br /&gt;
4) Most importantly, at all the places in the Expertiza code, where there were calls to the above methods in assignment_participant.rb, which are now moved to assignment_team.rb, were refactored accordingly to call them appropriately.&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
=== RSpec ===&lt;br /&gt;
There were no existing tests for the hyperlinks related methods. We used RSpec to write test cases using TTD approach. The assignment_team_spec.rb in the spec folder will have these tests. All the tests can be executed by rspec spec command, or can also be executed individually using the command &amp;quot;rspec spec/models/assignment_team_spec.rb&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Following steps needs to be performed to test this code from UI:&lt;br /&gt;
# Login as a student.&lt;br /&gt;
# In an assignment, that is still due, add one or more hyperlinks.&lt;br /&gt;
# Login as another student who is a teammate of the first student working on the same assignment.&lt;br /&gt;
# You should be able to see the newly uploaded link(s) by the other team member.&lt;br /&gt;
# Try adding a link that is not a valid http or https link. It will give an error message.&lt;br /&gt;
# Try submitting the same link once again. This will give an error message too.&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101194</id>
		<title>CSC/ECE 517 Spring 2016/OSS E1601</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101194"/>
		<updated>2016-03-24T00:36:53Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: Moved the entire content from sandbox to ncsu wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki documentation is for the open source refactoring project E1601: Refactor methods related to submitted_hyperlinks for the course ECE/CSC 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
We suggest the reviewers to use the below students and instructor for the purpose of reviewing. These students belong to the same team and work on an assignment given by the below instructor:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student5884,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student6420,  password -&amp;gt; password&lt;br /&gt;
'''Please note''': Please do not delete the above users or their team. If you wish to do so, please add them back so as to aid other reviewers. Also note that the option to submit hyperlinks in the UI will only be displayed to the enrolled students only before the assignment deadline.&lt;br /&gt;
&lt;br /&gt;
== Expertiza Introduction==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source web application which enhances learning through peer reviews. The students can form teams and work on assignments given by course instructors. The peers can review the submissions and give feedback. The students also get to review the reviewers! &lt;br /&gt;
&lt;br /&gt;
== Problem statement ==&lt;br /&gt;
&lt;br /&gt;
'''Before''': When student submitted files and hyperlinks, that content was submitted on behalf of a team, not individuals (even there is only one person in the team). Some of the previous contributors worked on a project which associated all the submitted content to teams: there were submitted_hyperlinks and dirctory_num fields in teams table. All the hyperlinks should ideally be recorded in one submitted_hyperlinks field. All the submitted files were uploaded to the file space and in the “course_folder/assignment_folder/team_folder” path.&lt;br /&gt;
&lt;br /&gt;
'''What was wrong with that''': There are multiple methods in assignment_participant.rb which still look like the author submit the hyperlinks on behalf of him/herself. They should be moved to assignment_teams.rb.&lt;br /&gt;
&lt;br /&gt;
'''What refactoring we have done to improve''':&lt;br /&gt;
* Removed “hyperlinks_array” method and “hyperlinks” method from assignment_participant.rb. Created “hyperlinks” method in assignment_team.rb.&lt;br /&gt;
* Removed “submit_hyperlink” and “remove_hyperlink” from assignment_pariticpant.rb and created equivalent methods in assignment_team.rb.        &lt;br /&gt;
&lt;br /&gt;
* Removed “has_submissions?” from assginment_participant.rb and created equivalent method in assignment_team.rb.          &lt;br /&gt;
* All the calls to the above methods were refactored to call the appropriate method's functions.&lt;br /&gt;
* Wrote tests for submitting and removing submitted hyperlinks and files.&lt;br /&gt;
&lt;br /&gt;
== Key changes ==&lt;br /&gt;
Files with major modifications:&lt;br /&gt;
# The model: assignment_participant.rb&lt;br /&gt;
# The model: assignment_team.rb&lt;br /&gt;
Four methods &amp;quot;hyperlinks”, “has_submissions?”, “submit_hyperlink” and “remove_hyperlink” were moved from the assignment_participant.rb model to assignment_team.rb, and the &amp;quot;hyperlinks_array&amp;quot; method removed.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1.a) The below hyperlinks_array and hyperlinks method are removed from the assignment_participant.rb:&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;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.team.submitted_hyperlinks.blank? ? [] : YAML::load(self.team.submitted_hyperlinks)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;b) They are both merged into a single method in assignment_team.rb under the hyperlinks mehtod:&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
def hyperlinks&lt;br /&gt;
        self.submitted_hyperlinks.blank? ? [] : YAML::load(self.submitted_hyperlinks)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. a) Earlier, the following method submit_hyperlink was in assignment_participant.rb:&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&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;
    team_object = self.team&lt;br /&gt;
    team_object.submitted_hyperlinks = YAML::dump(hyperlinks)&lt;br /&gt;
    team_object.save&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;b) It is now moved to assignment_team.rb:&amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&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&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;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3) Similarly the methods &amp;quot;has_submissions?&amp;quot;, &amp;quot;remove_hyperlink&amp;quot; were moved.&lt;br /&gt;
&lt;br /&gt;
4) Most importantly, at all the places in the Expertiza code, where there were calls to the above methods in assignment_participant.rb, which are now moved to assignment_team.rb, were refactored accordingly to call them appropriately.&lt;br /&gt;
&lt;br /&gt;
== Testing Details ==&lt;br /&gt;
=== RSpec ===&lt;br /&gt;
There were no existing tests for the hyperlinks related methods. We used RSpec to write test cases using TTD approach. The assignment_team_spec.rb in the spec folder will have these tests. All the tests can be executed by rspec spec command, or can also be executed individually using the command &amp;quot;rspec spec/models/assignment_team_spec.rb&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Following steps needs to be performed to test this code from UI:&lt;br /&gt;
# Login as a student.&lt;br /&gt;
# In an assignment, that is still due, add one or more hyperlinks.&lt;br /&gt;
# Login as another student who is a teammate of the first student working on the same assignment.&lt;br /&gt;
# You should be able to see the newly uploaded link(s) by the other team member.&lt;br /&gt;
# Try adding a link that is not a valid http or https link. It will give an error message.&lt;br /&gt;
# Try submitting the same link once again. This will give an error message too.&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101149</id>
		<title>CSC/ECE 517 Spring 2016/OSS E1601</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101149"/>
		<updated>2016-03-23T18:07:38Z</updated>

		<summary type="html">&lt;p&gt;Kvysyar: testing a template&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Testing a template. This wiki page is for the description of changes made under E1555 OSS assignment for Fall 2015, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Peer Review Information ==&lt;br /&gt;
&lt;br /&gt;
For users intending to view the deployed Expertiza associated with this assignment, the credentials are below:&lt;br /&gt;
* Instructor login: username -&amp;gt; instructor6,  password -&amp;gt; password&lt;br /&gt;
* Student  login: username -&amp;gt; student4340,  password -&amp;gt; password &lt;br /&gt;
* Student login: username -&amp;gt; student4405,  password -&amp;gt; password&lt;br /&gt;
&lt;br /&gt;
== Expertiza Background==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an educational web application created and maintained by the joint efforts of the students and  the faculty at NCSU. It’s an open source project developed on Ruby on Rails platform and it’s code is available on Github. It allows students to review each other’s work and improve their work upon this feedback.&lt;br /&gt;
&lt;br /&gt;
== Description of the current project ==&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals primarily with the GradesController and GradesHelper. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
== Files modified in current project ==&lt;br /&gt;
&lt;br /&gt;
A controller and a helper file were modified for this project namely:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. GradesController &amp;lt;br/&amp;gt;&lt;br /&gt;
2. GradesHelper &amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== GradesController ===&lt;br /&gt;
 &lt;br /&gt;
This is a controller that helps students and instructors view grades and reviews, update scores, check for grading conflicts and calculate penalties. A couple of long and complex methods were refactored from this controller along with removal of some non-functional code and a few language changes to make it Ruby style.&lt;br /&gt;
Three methods in particular, namely conflict_notification ,calculate_all_penalties and edit were found to be too long and were in need of refactoring into smaller, easier to manage methods. Few more  compact methods were created for this purpose.&lt;br /&gt;
&lt;br /&gt;
There were no existing test cases for the controller. We have added a spec file named 'grades_spec.rb' under the spec folder. As no changes were done for the model, no tests for the model were included.&lt;br /&gt;
&lt;br /&gt;
=== GradesHelper ===&lt;br /&gt;
&lt;br /&gt;
This is a helper class which contains methods for constructing a table(construct_table) and to check whether an assignment has a team and metareveiw(has_team_and_metareview)&lt;br /&gt;
&lt;br /&gt;
== List of changes ==&lt;br /&gt;
We worked on the following work items(WIs)&amp;lt;br/&amp;gt;&lt;br /&gt;
WI1 : Refactor calculate_all_penalties method into smaller methods&amp;lt;br/&amp;gt;&lt;br /&gt;
WI2 : Move the repeated code in conflict_notification &amp;amp; edit methods to a separate method list_questions.&amp;lt;br/&amp;gt;&lt;br /&gt;
WI3 : Refactor the code as per the Ruby style guidelines and incorporate the good practices&amp;lt;br/&amp;gt;&lt;br /&gt;
WI4 : Test the conflict_notification method to test the changes made.&amp;lt;br/&amp;gt;&lt;br /&gt;
WI5 : Move the repeated code in view and view_my_scores methods to a separate method retrieve_questions&lt;br /&gt;
&lt;br /&gt;
=== Solutions Implemented and Delivered ===&lt;br /&gt;
&lt;br /&gt;
*Refactoring calculate_all_penalties method&lt;br /&gt;
&lt;br /&gt;
This is used to calculate various penalty values for each assignment if penalty is applicable.&lt;br /&gt;
&lt;br /&gt;
The following changes were made:&lt;br /&gt;
&lt;br /&gt;
1. This method was very complex, performing too many functions within a single method and had to be broken into 3 smaller methods each having a more well defined function.&lt;br /&gt;
2. The following 3 methods were created after splitting the first method&amp;lt;br&amp;gt;&lt;br /&gt;
   i.  calculate_all_penalties&amp;lt;br&amp;gt;&lt;br /&gt;
   ii. calculate_penatly_attributes&amp;lt;br&amp;gt;&lt;br /&gt;
   iii. assign_all_penalties&amp;lt;br&amp;gt;&lt;br /&gt;
3. Changes were also made to make the code follow ruby style.The language was made more ruby friendly.&lt;br /&gt;
4. Finally some redundant code was commented out as it was non-functional.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
Refactoring into smaller more specific methods:&lt;br /&gt;
&lt;br /&gt;
[[File:Change6_new.png]]&lt;br /&gt;
&lt;br /&gt;
Removal of non-functional code :&lt;br /&gt;
&lt;br /&gt;
[[File:Change5_new.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change of language to make it more Ruby friendly:&lt;br /&gt;
&lt;br /&gt;
[[File:Change1_new.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Move the redundant piece of code from conflict_notification &amp;amp; edit methods to a new method list_questions &lt;br /&gt;
&lt;br /&gt;
The conflict_notification method is used to help the instructors decide if one of the reviews are unfair or inaccurate.&lt;br /&gt;
This was again split into 2 methods with some part of the code which is repeated in another method  refactored into a new method.&lt;br /&gt;
&lt;br /&gt;
[[File:Change3_new.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Refactored #Created a method which was a duplicate in conflict_notification and edit methods&lt;br /&gt;
  &lt;br /&gt;
[[File:Change4_new.png]]&lt;br /&gt;
&lt;br /&gt;
edit method:&lt;br /&gt;
&lt;br /&gt;
This method is used to edit the questionnaires. This method again has code which is repeated in the conflict_notification method and thus the repeated section was split into a new method.&lt;br /&gt;
&lt;br /&gt;
[[File:Change2_new.png]]&lt;br /&gt;
&lt;br /&gt;
New method:&lt;br /&gt;
Refactored #Created a method which was a duplicate in conflict_notification and edit methods&lt;br /&gt;
&lt;br /&gt;
[[File:Change4_new.png]]&lt;br /&gt;
&lt;br /&gt;
Similar refactoring was performed to obtain the retrieve_questions method:&lt;br /&gt;
&lt;br /&gt;
[[File:Latest1.png]]&lt;br /&gt;
&lt;br /&gt;
This is the new method created after the above refactoring:&lt;br /&gt;
&lt;br /&gt;
[[File:Latest2.png]]&lt;br /&gt;
&lt;br /&gt;
== Testing Details==&lt;br /&gt;
&lt;br /&gt;
=== RSpec ===&lt;br /&gt;
There were no existing test cases for the GradesController. We have added a new spec file 'grades_spec.rb' which covers testing scenario for the newly added method. The specs were run on the previous and current files and they return the same results implying that the refactored code does not break anything.&lt;br /&gt;
As the model was not changed, no test cases were added for the model.&lt;br /&gt;
&lt;br /&gt;
=== UI Testing ===&lt;br /&gt;
&lt;br /&gt;
Following steps needs to be performed to test this code from UI:&amp;lt;br/&amp;gt;&lt;br /&gt;
1. Login as instructor. Create a course and an assignment under that course.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. Keep the has team checkbox checked while creating the assignment. Add a grading rubric to it. Add at least two students as participants to the assignment.&amp;lt;br/&amp;gt;&lt;br /&gt;
3. Create topics for the assignment.&amp;lt;br/&amp;gt;&lt;br /&gt;
4. Sign in as one of the students who were added to the assignment.&amp;lt;br/&amp;gt;&lt;br /&gt;
5. Go to the assignment and sign up for a topic.&amp;lt;br/&amp;gt;&lt;br /&gt;
6. Submit student's work by clicking 'Your work' under that assignment.&amp;lt;br/&amp;gt;&lt;br /&gt;
7. Sign in as a different student which is participant of the assignment.&amp;lt;br/&amp;gt;&lt;br /&gt;
8. Go to Assignments--&amp;gt;&amp;lt;assignment name&amp;gt;--&amp;gt;Others' work (If the link is disabled, login as instructor and change the due date of the assignment to current time).&amp;lt;br/&amp;gt;&lt;br /&gt;
9. Give reviews on first student's work.&amp;lt;br/&amp;gt;&lt;br /&gt;
10. Login as instructor or first student to look at the review grades.&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Scope for future improvement ==&lt;br /&gt;
1. The construct_table method in GradesHelper is not used anywhere. It has no reference in the project. So we feel it can be safely removed.&amp;lt;br/&amp;gt;&lt;br /&gt;
2. The has_team_and_metareview? method in GradesHelper can be broken down into separate methods, one each for team and metareview. This will provide improved flexibility. It needs some analysis though, as both the entities(team &amp;amp; metareview) are currently checked in conjuction from all the views they are referenced from.&lt;/div&gt;</summary>
		<author><name>Kvysyar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101148</id>
		<title>CSC/ECE 517 Spring 2016/OSS E1601</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/OSS_E1601&amp;diff=101148"/>
		<updated>2016-03-23T18:02:31Z</updated>

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